JSPM

right-indexof

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3
  • Score
    100M100P100Q27891F
  • License MIT

indexof starting from the right side of an array

Package Exports

  • right-indexof

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (right-indexof) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

right-indexof

return the index of an item in an array starting from the right side

testling badge

build status

example

var rindex = require('right-indexof');
var xs = [ 'a', 'y', 'b', 'x', 'a', 'y' ];
console.log('rindex("a") = ', rindex(xs, 'a'));
console.log('rindex("b") = ', rindex(xs, 'b'));
console.log('rindex("x") = ', rindex(xs, 'x'));
console.log('rindex("y") = ', rindex(xs, 'y'));
console.log('rindex("z") = ', rindex(xs, 'z'));

output:

rindex("a") =  4
rindex("b") =  2
rindex("x") =  3
rindex("y") =  5
rindex("z") =  -1

methods

var rindex = require('right-indexof')

var ix = rindex(xs, x)

Return the index ix of the element x in the array xs starting from the right-hand side (starting at xs.length-1), returning the first element that is strictly equal (===) to the item x.

If x is not found in xs, return -1.

install

With npm do:

npm install right-indexof

license

MIT