UNPKG

1.66 kBMarkdownView Raw
1Breaks iterable when test passes.
2[:package:](https://www.npmjs.com/package/@extra-iterable/cut)
3[:smiley_cat:](https://github.com/orgs/nodef/packages?repo_name=extra-iterable)
4[:running:](https://npm.runkit.com/@extra-iterable/cut)
5[:vhs:](https://asciinema.org/a/339730)
6[:moon:](https://www.npmjs.com/package/@extra-iterable/cut.min)
7[:scroll:](https://unpkg.com/@extra-iterable/cut/)
8[:newspaper:](https://nodef.github.io/extra-iterable/)
9[:blue_book:](https://github.com/nodef/extra-iterable/wiki/)
10
11> Alternatives: [cut], [cutRight], [cutAt], [cutAtRight].<br>
12> Similar: [cut], [split], [group].
13
14> This is part of package [extra-iterable].
15
16[extra-iterable]: https://www.npmjs.com/package/extra-iterable
17
18<br>
19
20```javascript
21iterable.cut(x, ft);
22// x: an iterable
23// ft: test function (v, i, x)
24```
25
26```javascript
27const iterable = require("extra-iterable");
28
29var x = [1, 2, 3, 4, 5];
30[...iterable.cut(x, v => v % 2 === 0)];
31// [ [ 1 ], [ 2, 3 ], [ 4, 5 ] ]
32
33[...iterable.cut(x, v => v % 2 === 1)];
34// [ [], [ 1, 2 ], [ 3, 4 ], [ 5 ] ]
35```
36
37<br>
38<br>
39
40
41## References
42
43- [Data.List.splitAt: Haskell](https://hackage.haskell.org/package/base-4.12.0.0/docs/Data-List.html#v:splitAt)
44- [numpy.split: Python](https://docs.scipy.org/doc/numpy/reference/generated/numpy.split.html)
45
46[cut]: https://github.com/nodef/extra-iterable/wiki/cut
47[cutRight]: https://github.com/nodef/extra-iterable/wiki/cutRight
48[split]: https://github.com/nodef/extra-iterable/wiki/split
49[cutAt]: https://github.com/nodef/extra-iterable/wiki/cutAt
50[cutAtRight]: https://github.com/nodef/extra-iterable/wiki/cutAtRight
51[group]: https://github.com/nodef/extra-iterable/wiki/group