UNPKG

@extra-array/search-value-right

Version:
60 lines (45 loc) 1.98 kB
Finds last index of a value. [:package:](https://www.npmjs.com/package/@extra-array/search-value-right) [:smiley_cat:](https://github.com/orgs/nodef/packages?repo_name=extra-array) [:running:](https://npm.runkit.com/@extra-array/search-value-right) [:vhs:](https://asciinema.org/a/339822) [:moon:](https://www.npmjs.com/package/@extra-array/search-value-right.min) [:scroll:](https://unpkg.com/@extra-array/search-value-right/) [:newspaper:](https://nodef.github.io/extra-array/) [:blue_book:](https://github.com/nodef/extra-array/wiki/) > Alternatives: [searchValue], [searchValueRight], [searchValueAll].<br> > Similar: [search], [scan], [find]. > This is part of package [extra-array]. [extra-array]: https://www.npmjs.com/package/extra-array <br> ```javascript array.searchValueRight(x, v, [fc], [fm]); // x: an array // v: search value // fc: compare function (a, b) // fm: map function (v, i, x) // → index of value, -1 if not found ``` ```javascript const array = require("extra-array"); var x = [1, 2, 3, 2, 5]; array.searchValueRight(x, 2); // 3 ^ var x = [1, 2, 3, -2, 5]; array.searchValueRight(x, 2, (a, b) => Math.abs(a) - Math.abs(b)); // 3 ^ array.searchValueRight(x, 2, null, v => Math.abs(v)); // 3 ^ ``` <br> <br> ## References - [List-Extra.elemIndex: elm](https://package.elm-lang.org/packages/elm-community/list-extra/7.1.0/List-Extra#elemIndex) - [iterable-binsearch: @krisselden](https://www.npmjs.com/package/iterable-binsearch) - [binarysearch: @soldair](https://www.npmjs.com/package/binarysearch) [searchValue]: https://github.com/nodef/extra-array/wiki/searchValue [searchValueRight]: https://github.com/nodef/extra-array/wiki/searchValueRight [searchValueAll]: https://github.com/nodef/extra-array/wiki/searchValueAll [search]: https://github.com/nodef/extra-array/wiki/search [scan]: https://github.com/nodef/extra-array/wiki/scan [find]: https://github.com/nodef/extra-array/wiki/find