UNPKG

@extra-array/filter-at

Version:

Keeps values at given indices only.

53 lines (39 loc) 1.55 kB
Keeps values at given indices only. [:package:](https://www.npmjs.com/package/@extra-array/filter-at) [:smiley_cat:](https://github.com/orgs/nodef/packages?repo_name=extra-array) [:running:](https://npm.runkit.com/@extra-array/filter-at) [:vhs:](https://asciinema.org/a/339744) [:moon:](https://www.npmjs.com/package/@extra-array/filter-at.min) [:scroll:](https://unpkg.com/@extra-array/filter-at/) [:newspaper:](https://nodef.github.io/extra-array/) [:blue_book:](https://github.com/nodef/extra-array/wiki/) > Alternatives: [filter], [filter$], [filterAt].<br> > Similar: [map], [filter], [reject], [reduce], [accumulate]. > This is part of package [extra-array]. [extra-array]: https://www.npmjs.com/package/extra-array <br> ```javascript array.filterAt(x, is); // x: an array (updated) // is: indices (sorted) // → x ``` ```javascript const array = require("extra-array"); var x = [2, 4, 6, 8]; array.filterAt(x, [1, 2]); // [ 4, 6 ] array.filterAt(x, [1, 3]); // [ 4, 8 ] ``` <br> <br> ## References - [iterableList.get: Java](https://docs.oracle.com/javase/7/docs/api/java/util/iterableList.html#get(int)) [filter]: https://github.com/nodef/extra-array/wiki/filter [filter$]: https://github.com/nodef/extra-array/wiki/filter$ [filterAt]: https://github.com/nodef/extra-array/wiki/filterAt [map]: https://github.com/nodef/extra-array/wiki/map [reject]: https://github.com/nodef/extra-array/wiki/reject [reduce]: https://github.com/nodef/extra-array/wiki/reduce [accumulate]: https://github.com/nodef/extra-array/wiki/accumulate