prc b6c02717e6 Upload complete no-internet building environment. | před 1 rokem | |
---|---|---|
.. | ||
.github | před 1 rokem | |
test | před 1 rokem | |
.eslintrc | před 1 rokem | |
.nycrc | před 1 rokem | |
CHANGELOG.md | před 1 rokem | |
LICENSE | před 1 rokem | |
README.md | před 1 rokem | |
auto.js | před 1 rokem | |
implementation.js | před 1 rokem | |
index.js | před 1 rokem | |
index.mjs | před 1 rokem | |
package.json | před 1 rokem | |
polyfill.js | před 1 rokem | |
shim.js | před 1 rokem |
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.
npm install --save array.prototype.findlastindex
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));
Simply clone the repo, npm install
, and run npm test