UNPKG

@extra-array/find-indices

Version:

Finds indices of values passing a test.

39 lines (30 loc) 1.39 kB
Finds indices of values passing a test. [:running:] [:vhs:] [:package:] [:moon:] [:ledger:] > Alternatives: [findIndex], [findIndices].<br> > Similar: [find], [findIndex].<br> > This is part of package [extra-array]. [extra-array]: https://www.npmjs.com/package/extra-array ```javascript array.findIndices(x, fn); // x: an array // fn: test function (v, i, x) ``` ```javascript const array = require('extra-array'); var x = [1, 2, 3, 4, 5]; array.findIndices(x, v => v % 2 == 0); // [ 1, 3 ] ^ ^ array.findIndices(x, v => v % 2 == 1); // [ 0, 2, 4 ] ^ ^ ``` ### references - [Data.List.findIndices: Haskell](http://hackage.haskell.org/package/base-4.12.0.0/docs/Data-List.html#v:findIndices) - [List-Extra.findIndices: elm](https://package.elm-lang.org/packages/elm-community/list-extra/7.1.0/List-Extra#findIndices) - [find-array: @hdkhoa162](https://www.npmjs.com/package/find-array) [:running:]: https://npm.runkit.com/@extra-array/find-indices [:package:]: https://www.npmjs.com/package/@extra-array/find-indices [:moon:]: https://www.npmjs.com/package/@extra-array/find-indices.min [:ledger:]: https://unpkg.com/@extra-array/find-indices/ [findIndex]: https://github.com/nodef/extra-array/wiki/findIndex [findIndices]: https://github.com/nodef/extra-array/wiki/findIndices [find]: https://github.com/nodef/extra-array/wiki/find [:vhs:]: https://asciinema.org/a/332049