3.1.2 • Published 6 years ago

find-last-index-x v3.1.2

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

find-last-index-x

Search an array from the end and return the matched index.

module.exports(array, callback, [thisArg])number

Like findIndex, this method returns an index in the array, if an element in the array satisfies the provided testing function, except it is peformed in reverse. Otherwise -1 is returned.

Kind: Exported function
Returns: number - Returns index of positively tested element, otherwise -1.
Throws:

  • TypeError If array is null or undefined-
  • TypeError If callback is not a function.
ParamTypeDescription
arrayArrayThe array to search.
callbackfunctionFunction to execute on each value in the array, taking three arguments: element, index and array.
thisArg*Object to use as this when executing callback.

Example

import findLastIndex from 'find-index-x';

function isPrime(element, index, array) {
  var start = 2;
  while (start <= Math.sqrt(element)) {
    if (element % start++ < 1) {
      return false;
    }
  }
  return element > 1;
}

console.log(findLastIndex([4, 6, 8, 12, 14], isPrime)); // -1, not found
console.log(findLastIndex([4, 6, 7, 12, 13], isPrime)); // 4
3.1.2

6 years ago

3.1.1

6 years ago

3.1.0

6 years ago

3.0.10

6 years ago

3.0.9

6 years ago

3.0.8

6 years ago

3.0.7

6 years ago

3.0.6

6 years ago

3.0.5

6 years ago

3.0.4

6 years ago

3.0.3

6 years ago

3.0.2

6 years ago

3.0.1

6 years ago

3.0.0

6 years ago

2.1.0

8 years ago

2.0.0

8 years ago

1.7.0

8 years ago

1.6.0

8 years ago

1.5.0

8 years ago

1.4.0

8 years ago

1.3.1

8 years ago

1.3.0

8 years ago

1.2.0

8 years ago

1.1.0

8 years ago

1.0.14

9 years ago

1.0.13

9 years ago

1.0.12

10 years ago

1.0.11

10 years ago

1.0.10

10 years ago

1.0.8

10 years ago

1.0.7

10 years ago

1.0.6

10 years ago

1.0.5

10 years ago

1.0.4

10 years ago

1.0.3

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago