3.1.2 • Published 5 years ago

find-last-index-x v3.1.2

Weekly downloads
2
License
MIT
Repository
github
Last release
5 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

5 years ago

3.1.1

5 years ago

3.1.0

5 years ago

3.0.10

5 years ago

3.0.9

5 years ago

3.0.8

5 years ago

3.0.7

5 years ago

3.0.6

5 years ago

3.0.5

5 years ago

3.0.4

5 years ago

3.0.3

5 years ago

3.0.2

5 years ago

3.0.1

5 years ago

3.0.0

5 years ago

2.1.0

7 years ago

2.0.0

7 years ago

1.7.0

7 years ago

1.6.0

7 years ago

1.5.0

7 years ago

1.4.0

7 years ago

1.3.1

7 years ago

1.3.0

7 years ago

1.2.0

7 years ago

1.1.0

7 years ago

1.0.14

8 years ago

1.0.13

8 years ago

1.0.12

8 years ago

1.0.11

8 years ago

1.0.10

8 years ago

1.0.8

8 years ago

1.0.7

8 years ago

1.0.6

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago