drop internal predicate
Vladimir Bauer
4 years ago
| 4 | 4 |
"io"
|
| 5 | 5 |
|
| 6 | 6 |
"github.com/vbauerster/mpb/v7/decor"
|
| 7 | |
"github.com/vbauerster/mpb/v7/internal"
|
| 8 | 7 |
)
|
| 9 | 8 |
|
| 10 | 9 |
// BarOption is a func option to alter default behavior of a bar.
|
|
| 148 | 147 |
|
| 149 | 148 |
// BarOptional will invoke provided option only when pick is true.
|
| 150 | 149 |
func BarOptional(option BarOption, pick bool) BarOption {
|
| 151 | |
return BarOptOn(option, internal.Predicate(pick))
|
|
150 |
if pick {
|
|
151 |
return option
|
|
152 |
}
|
|
153 |
return nil
|
| 152 | 154 |
}
|
| 153 | 155 |
|
| 154 | 156 |
// BarOptOn will invoke provided option only when higher order predicate
|
| 4 | 4 |
"io/ioutil"
|
| 5 | 5 |
"sync"
|
| 6 | 6 |
"time"
|
| 7 | |
|
| 8 | |
"github.com/vbauerster/mpb/v7/internal"
|
| 9 | 7 |
)
|
| 10 | 8 |
|
| 11 | 9 |
// ContainerOption is a func option to alter default behavior of a bar
|
|
| 102 | 100 |
|
| 103 | 101 |
// ContainerOptional will invoke provided option only when pick is true.
|
| 104 | 102 |
func ContainerOptional(option ContainerOption, pick bool) ContainerOption {
|
| 105 | |
return ContainerOptOn(option, internal.Predicate(pick))
|
|
103 |
if pick {
|
|
104 |
return option
|
|
105 |
}
|
|
106 |
return nil
|
| 106 | 107 |
}
|
| 107 | 108 |
|
| 108 | 109 |
// ContainerOptOn will invoke provided option only when higher order
|
| 0 | |
package internal
|
| 1 | |
|
| 2 | |
// Predicate helper for internal use.
|
| 3 | |
func Predicate(pick bool) func() bool {
|
| 4 | |
return func() bool { return pick }
|
| 5 | |
}
|