UNPKG

1.98 kBMarkdownView Raw
1Finds last index of a value.
2[:package:](https://www.npmjs.com/package/@extra-array/search-value-right)
3[:smiley_cat:](https://github.com/orgs/nodef/packages?repo_name=extra-array)
4[:running:](https://npm.runkit.com/@extra-array/search-value-right)
5[:vhs:](https://asciinema.org/a/339822)
6[:moon:](https://www.npmjs.com/package/@extra-array/search-value-right.min)
7[:scroll:](https://unpkg.com/@extra-array/search-value-right/)
8[:newspaper:](https://nodef.github.io/extra-array/)
9[:blue_book:](https://github.com/nodef/extra-array/wiki/)
10
11> Alternatives: [searchValue], [searchValueRight], [searchValueAll].<br>
12> Similar: [search], [scan], [find].
13
14> This is part of package [extra-array].
15
16[extra-array]: https://www.npmjs.com/package/extra-array
17
18<br>
19
20```javascript
21array.searchValueRight(x, v, [fc], [fm]);
22// x: an array
23// v: search value
24// fc: compare function (a, b)
25// fm: map function (v, i, x)
26// → index of value, -1 if not found
27```
28
29```javascript
30const array = require("extra-array");
31
32var x = [1, 2, 3, 2, 5];
33array.searchValueRight(x, 2);
34// 3 ^
35
36var x = [1, 2, 3, -2, 5];
37array.searchValueRight(x, 2, (a, b) => Math.abs(a) - Math.abs(b));
38// 3 ^
39
40array.searchValueRight(x, 2, null, v => Math.abs(v));
41// 3 ^
42```
43
44<br>
45<br>
46
47
48## References
49
50- [List-Extra.elemIndex: elm](https://package.elm-lang.org/packages/elm-community/list-extra/7.1.0/List-Extra#elemIndex)
51- [iterable-binsearch: @krisselden](https://www.npmjs.com/package/iterable-binsearch)
52- [binarysearch: @soldair](https://www.npmjs.com/package/binarysearch)
53
54[searchValue]: https://github.com/nodef/extra-array/wiki/searchValue
55[searchValueRight]: https://github.com/nodef/extra-array/wiki/searchValueRight
56[searchValueAll]: https://github.com/nodef/extra-array/wiki/searchValueAll
57[search]: https://github.com/nodef/extra-array/wiki/search
58[scan]: https://github.com/nodef/extra-array/wiki/scan
59[find]: https://github.com/nodef/extra-array/wiki/find