codeql-action/node_modules/array.prototype.findlastindex
github-actions[bot] 9c3b394d7f Update checked-in dependencies 2023-10-23 18:03:04 +00:00
..
.github Bump the npm group with 2 updates (#1819) 2023-08-01 03:35:02 -07:00
test Update checked-in dependencies 2023-10-23 18:03:04 +00:00
.eslintrc Bump the npm group with 2 updates (#1819) 2023-08-01 03:35:02 -07:00
.nycrc Bump the npm group with 2 updates (#1819) 2023-08-01 03:35:02 -07:00
CHANGELOG.md Update checked-in dependencies 2023-10-23 18:03:04 +00:00
LICENSE Bump the npm group with 2 updates (#1819) 2023-08-01 03:35:02 -07:00
README.md Bump the npm group with 2 updates (#1819) 2023-08-01 03:35:02 -07:00
auto.js Bump the npm group with 2 updates (#1819) 2023-08-01 03:35:02 -07:00
implementation.js Update checked-in dependencies 2023-10-23 18:03:04 +00:00
index.js Update checked-in dependencies 2023-10-23 18:03:04 +00:00
index.mjs Update checked-in dependencies 2023-10-23 18:03:04 +00:00
package.json Update checked-in dependencies 2023-10-23 18:03:04 +00:00
polyfill.js Bump the npm group with 2 updates (#1819) 2023-08-01 03:35:02 -07:00
shim.js Bump the npm group with 2 updates (#1819) 2023-08-01 03:35:02 -07:00

README.md

array.prototype.findlastindex Version Badge

github actions coverage dependency status dev dependency status License Downloads

npm badge

An ESnext spec-compliant Array.prototype.findLastIndex shim/polyfill/replacement that works as far down as ES3.

This package implements the es-shim API interface. It works in an ES3-supported environment and complies with the proposed spec.

Because Array.prototype.findLastIndex depends on a receiver (the this value), the main export takes the array to operate on as the first argument.

Getting started

npm install --save array.prototype.findlastindex

Usage/Examples

var findLastIndex = require('array.prototype.findlastindex');
var assert = require('assert');

var arr = [1, [2], [], 3, [[4]]];
var isNumber = function (x) { return typeof x === 'number' };

assert.deepEqual(findLastIndex(arr, isNumber), 3);
var findLastIndex = require('array.prototype.findlastindex');
var assert = require('assert');
/* when Array#findLastIndex is not present */
delete Array.prototype.findLastIndex;
var shimmed = findLastIndex.shim();

assert.equal(shimmed, findLastIndex.getPolyfill());
assert.deepEqual(arr.findLastIndex(isNumber), findLastIndex(arr, isNumber));
var findLastIndex = require('array.prototype.findlastindex');
var assert = require('assert');
/* when Array#findLastIndex is present */
var shimmed = findLastIndex.shim();

assert.equal(shimmed, Array.prototype.findLastIndex);
assert.deepEqual(arr.findLastIndex(isNumber), findLastIndex(arr, isNumber));

Tests

Simply clone the repo, npm install, and run npm test