UNPKG

@extra-array/find-all

Version:

Finds all values passing a test.

63 lines (49 loc) 2.34 kB
Finds all values passing a test. [:package:](https://www.npmjs.com/package/@extra-array/find-all) [:smiley_cat:](https://github.com/orgs/nodef/packages?repo_name=extra-array) [:running:](https://npm.runkit.com/@extra-array/find-all) [:vhs:](https://asciinema.org/a/332046) [:moon:](https://www.npmjs.com/package/@extra-array/find-all.min) [:scroll:](https://unpkg.com/@extra-array/find-all/) [:newspaper:](https://nodef.github.io/extra-array/) [:blue_book:](https://github.com/nodef/extra-array/wiki/) > Alternatives: [find], [findRight], [findAll].<br> > Similar: [search], [scan], [find]. > This is part of package [extra-array]. [extra-array]: https://www.npmjs.com/package/extra-array <br> ```javascript array.findAll(x, ft); // x: an array // ft: test function (v, i, x) ``` ```javascript const array = require("extra-array"); var x = [1, 2, 3, 4, 5]; array.findAll(x, v => v % 2 === 1); // [ 1, 3, 5 ] array.findAll(x, v => v % 2 === 0); // [ 2, 4 ] ``` <br> <br> ## References - [Data.List.filter: Haskell](https://hackage.haskell.org/package/base-4.12.0.0/docs/Data-List.html#v:filter) - [Array.prototype.filter: MDN web docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter) - [array_filter: PHP](https://www.php.net/manual/en/function.array-filter.php) - [_.remove: lodash](https://lodash.com/docs/4.17.15#remove) - [_.without: lodash](https://lodash.com/docs/4.17.15#without) - [_.compact: lodash](https://lodash.com/docs/4.17.15#compact) - [_.pull: lodash](https://lodash.com/docs/4.17.15#pull) - [_.pullAll: lodash](https://lodash.com/docs/4.17.15#pullAll) - [_.pullAllBy: lodash](https://lodash.com/docs/4.17.15#pullAllBy) - [_.pullAllWith: lodash](https://lodash.com/docs/4.17.15#pullAllWith) - [Array.filter: sugarjs](https://sugarjs.com/docs/#/Array/filter) - [Array.exclude: sugarjs](https://sugarjs.com/docs/#/Array/exclude) - [Array.compact: sugarjs](https://sugarjs.com/docs/#/Array/compact) - [array-tools.where: @75lb](https://www.npmjs.com/package/array-tools) [find]: https://github.com/nodef/extra-array/wiki/find [findRight]: https://github.com/nodef/extra-array/wiki/findRight [findAll]: https://github.com/nodef/extra-array/wiki/findAll [search]: https://github.com/nodef/extra-array/wiki/search [scan]: https://github.com/nodef/extra-array/wiki/scan