UNPKG

take-until

Version:

Take elements from an array or string until a condition is met

9 lines (7 loc) 168 B
module.exports = function takeUntil(xs, pred) { for (var i = 0; i < xs.length; ++i) { var x = xs[i]; if (pred(x)) return xs.slice(0, i); } return xs; };