UNPKG

@extra-array/find-right

Version:

Finds last value passing a test.

52 lines (38 loc) 1.61 kB
Finds last value passing a test. [:package:](https://www.npmjs.com/package/@extra-array/find-right) [:smiley_cat:](https://github.com/orgs/nodef/packages?repo_name=extra-array) [:running:](https://npm.runkit.com/@extra-array/find-right) [:vhs:](https://asciinema.org/a/332050) [:moon:](https://www.npmjs.com/package/@extra-array/find-right.min) [:scroll:](https://unpkg.com/@extra-array/find-right/) [: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.findRight(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.findRight(x, v => v % 2 == 0); // 4 ^ array.findRight(x, v => v % 2 == 1); // 5 ^ ``` <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) - [_.findLastIndex: lodash](https://lodash.com/docs/4.17.15#findLastIndex) [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