This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const {Success, Failure} = require('folktale/validation'); | |
| const create = (predicate, failure = _ => _) => { | |
| return function (value) { | |
| if (predicate(value)) { | |
| return Success(value) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function debouncePromise(inner, ms) { | |
| ms = ms || 0; | |
| var timer = null; | |
| var resolves = []; | |
| return function () { | |
| var args = [].slice.call(arguments, 0); | |
| // Run the function after a certain amount of time | |
| clearTimeout(timer); | |
| timer = setTimeout(function () { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var data = [1, 2, 3, 13, 5, 6, 7, 8, 9, 10, 11]; | |
| var predicate = element => element % 2 === 0; | |
| function chunk(predicate, data) { | |
| return data.map(predicate).reduce((prev, curr, i, arr) => { | |
| if (curr) { | |
| if (prev.length) { | |
| let first = prev[prev.length - 1][1]; | |
| prev.push([first, i + 1]); | |
| } else { |