summaryrefslogtreecommitdiff
path: root/vendor/github.com/vbauerster/mpb/v7/decor/on_condition.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/vbauerster/mpb/v7/decor/on_condition.go')
-rw-r--r--vendor/github.com/vbauerster/mpb/v7/decor/on_condition.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/vendor/github.com/vbauerster/mpb/v7/decor/on_condition.go b/vendor/github.com/vbauerster/mpb/v7/decor/on_condition.go
new file mode 100644
index 000000000..a9db0653a
--- /dev/null
+++ b/vendor/github.com/vbauerster/mpb/v7/decor/on_condition.go
@@ -0,0 +1,27 @@
+package decor
+
+// OnPredicate returns decorator if predicate evaluates to true.
+//
+// `decorator` Decorator
+//
+// `predicate` func() bool
+//
+func OnPredicate(decorator Decorator, predicate func() bool) Decorator {
+ if predicate() {
+ return decorator
+ }
+ return nil
+}
+
+// OnCondition returns decorator if condition is true.
+//
+// `decorator` Decorator
+//
+// `cond` bool
+//
+func OnCondition(decorator Decorator, cond bool) Decorator {
+ if cond {
+ return decorator
+ }
+ return nil
+}