diff --git a/docs/Fuse.html b/docs/Fuse.html index 56e66f0..69bdd33 100644 --- a/docs/Fuse.html +++ b/docs/Fuse.html @@ -158,6 +158,164 @@ +

else(consequent) → {Fuse}

+ + + + + + +
+ Accepts a consequent function which automatically becomes resolve. +Does not return a Fuse instance as .on after .else would be useless. +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
consequent + + +callback + + + + Consequent callback function
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ Returns new FuseItem instance +
+ + + +
+
+ Type +
+
+ +Fuse + + +
+
+ + + + + + + + + + + + +

is(value, consequent) → {Fuse}

@@ -283,7 +441,7 @@ equality with this.value.
Source:
@@ -464,7 +622,7 @@ inequality with this.value.
Source:
@@ -831,7 +989,7 @@ Used in case a resolve is never found.
diff --git a/docs/FuseItem.html b/docs/FuseItem.html index c41b9c6..2f403f8 100644 --- a/docs/FuseItem.html +++ b/docs/FuseItem.html @@ -584,7 +584,7 @@ Used in case a resolve is never found.
diff --git a/docs/FuseIterable.html b/docs/FuseIterable.html index b905ca3..95f20d3 100644 --- a/docs/FuseIterable.html +++ b/docs/FuseIterable.html @@ -835,7 +835,7 @@ each value into the winning consequent function.
diff --git a/docs/global.html b/docs/global.html index 3f21817..adb7b8b 100644 --- a/docs/global.html +++ b/docs/global.html @@ -465,7 +465,7 @@
diff --git a/docs/index.html b/docs/index.html index 8f67fba..bb4d259 100644 --- a/docs/index.html +++ b/docs/index.html @@ -45,8 +45,7 @@

Fuse

FunctionSelect

Fuse selects a function that passes a condition.

-

Usage

const Fuse = require('@codefeathers/fuse');
-const { FuseIterable } = require('@codefeathers/fuse');
+

Usage

Fuse

const Fuse = require('@codefeathers/fuse');
 
 const a = 100;
 
@@ -58,7 +57,19 @@ const result = new Fuse(a)
     .on(x => x===10,
         a => `${a} is 10.`)
 
-console.log(result.resolve()); // -> "100 is greater than 10."

Docs

Docs exist in /docs directory. Will be served soon.

+console.log(result.resolve()); // -> "100 is greater than 10."

FuseIterable

const { FuseIterable } = require('@codefeathers/fuse');
+
+const temperatures = [ 0, 20, 30 ];
+
+const result = new FuseIterable(temperatures)
+    .on(temp => temp<10,
+        () => `Too cold!`)
+    .on(temp => temp>=10 && temp <25,
+        () => `Just right.`)
+    .on(temp => temp>=25,
+        () => `Too warm!`)
+
+console.log(result.resolve()); // -> [ "Too cold!", "Just right.", "Too warm!" ]

Docs

Docs exist in /docs directory. Will be served soon.

Development

If you find any mistakes in code/documentation, or if you feel something could be done better, do PR :) I appreciate it.

@@ -87,7 +98,7 @@ console.log(result.resolve()); // -> "100 is greater than 10."<
- Documentation generated by JSDoc 3.5.5 on Wed Apr 11 2018 11:02:55 GMT+0530 (IST) + Documentation generated by JSDoc 3.5.5 on Fri Apr 20 2018 02:24:29 GMT+0530 (IST)
diff --git a/docs/index.js.html b/docs/index.js.html index c47cbdd..77dbf64 100644 --- a/docs/index.js.html +++ b/docs/index.js.html @@ -183,6 +183,16 @@ class Fuse extends FuseItem { } /** + * Accepts a consequent function which automatically becomes resolve. + * Does not return a Fuse instance as .on after .else would be useless. + * @param {callback} consequent Consequent callback function + * @returns {Fuse} Returns new FuseItem instance + */ + else(consequent) { + return new FuseItem(this.value, consequent); + } + + /** * Accepts a value instead of a test function, and checks for strict * equality with this.value. * @param {any} value Any value to check against this.value @@ -224,7 +234,7 @@ module.exports.FuseIterable = FuseIterable;
- Documentation generated by JSDoc 3.5.5 on Wed Apr 11 2018 11:02:55 GMT+0530 (IST) + Documentation generated by JSDoc 3.5.5 on Fri Apr 20 2018 02:24:29 GMT+0530 (IST)