UNPKG
take-until
Version:
latest (0.1.0)
0.1.0
0.0.1
0.0.0
Take elements from an array or string until a condition is met
github.com/jb55/take-until
take-until
/
index.js
9 lines
(7 loc)
•
168 B
JavaScript
View Raw
1
2
3
4
5
6
7
8
9
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; };