« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data/composite/control-flow/withResultOfAvailabilityCheck.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/data/composite/control-flow/withResultOfAvailabilityCheck.js')
-rw-r--r--src/data/composite/control-flow/withResultOfAvailabilityCheck.js5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/data/composite/control-flow/withResultOfAvailabilityCheck.js b/src/data/composite/control-flow/withResultOfAvailabilityCheck.js
index bcbd0b37..a6942014 100644
--- a/src/data/composite/control-flow/withResultOfAvailabilityCheck.js
+++ b/src/data/composite/control-flow/withResultOfAvailabilityCheck.js
@@ -10,6 +10,7 @@
 // * 'falsy': Check that the value isn't false when treated as a boolean
 //            (nor an empty array). Keep in mind this will also be false
 //            for values like zero and the empty string!
+// * 'index': Check that the value is a number, and is at least zero.
 //
 // See also:
 //  - exitWithoutDependency
@@ -57,6 +58,10 @@ export default templateCompositeFrom({
           case 'falsy':
             availability = !!value && (!Array.isArray(value) || !empty(value));
             break;
+
+          case 'index':
+            availability = typeof value === 'number' && value >= 0;
+            break;
         }
 
         return continuation({'#availability': availability});