UNPKG

@extra-array/cut-at

Version:

Breaks array at given indices.

52 lines (38 loc) 1.57 kB
Breaks array at given indices. [:package:](https://www.npmjs.com/package/@extra-array/cut-at) [:smiley_cat:](https://github.com/orgs/nodef/packages?repo_name=extra-array) [:running:](https://npm.runkit.com/@extra-array/cut-at) [:vhs:](https://asciinema.org/a/339731) [:moon:](https://www.npmjs.com/package/@extra-array/cut-at.min) [:scroll:](https://unpkg.com/@extra-array/cut-at/) [:newspaper:](https://nodef.github.io/extra-array/) [:blue_book:](https://github.com/nodef/extra-array/wiki/) > Alternatives: [cut], [cutRight], [cutAt], [cutAtRight].<br> > Similar: [cut], [split], [group]. > This is part of package [extra-array]. [extra-array]: https://www.npmjs.com/package/extra-array <br> ```javascript array.cutAt(x, is); // x: an array // is: split indices (sorted) ``` ```javascript const array = require("extra-array"); var x = [1, 2, 3, 4, 5]; array.cutAt(x, [1, 3]); // [ [ 1 ], [ 2, 3 ], [ 4, 5 ] ] array.cutAt(x, [0, 4]); // [ [], [ 1, 2, 3, 4 ], [ 5 ] ] ``` <br> <br> ## References - [Data.List.splitAt: Haskell](https://hackage.haskell.org/package/base-4.12.0.0/docs/Data-List.html#v:splitAt) - [numpy.split: Python](https://docs.scipy.org/doc/numpy/reference/generated/numpy.split.html) [cut]: https://github.com/nodef/extra-array/wiki/cut [cutRight]: https://github.com/nodef/extra-array/wiki/cutRight [cutAt]: https://github.com/nodef/extra-array/wiki/cutAt [cutAtRight]: https://github.com/nodef/extra-array/wiki/cutAtRight [split]: https://github.com/nodef/extra-array/wiki/split [group]: https://github.com/nodef/extra-array/wiki/group