UNPKG

@extra-array/find

Version:

Finds first value passing a test.

52 lines (38 loc) 1.54 kB
Finds first value passing a test. [:package:](https://www.npmjs.com/package/@extra-array/find) [:smiley_cat:](https://github.com/orgs/nodef/packages?repo_name=extra-array) [:running:](https://npm.runkit.com/@extra-array/find) [:vhs:](https://asciinema.org/a/332047) [:moon:](https://www.npmjs.com/package/@extra-array/find.min) [:scroll:](https://unpkg.com/@extra-array/find/) [: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.find(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.find(x, v => v % 2 == 0); // 2 ^ array.find(x, v => v % 2 == 1); // 1 ^ ``` <br> <br> ## References - [Data.List.find: Haskell](http://hackage.haskell.org/package/base-4.12.0.0/docs/Data-List.html#v:find) - [List-Extra.find: elm](https://package.elm-lang.org/packages/elm-community/list-extra/7.1.0/List-Extra#find) - [Array.find: sugarjs](https://sugarjs.com/docs/#/Array/find) [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