array.prototype.findlast
An ESnext spec-compliant `Array.prototype.findLast` shim/polyfill/replacement that works as far down as ES3.
Last updated 8 months ago by ljharb .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install array.prototype.findlast 
SYNC missed versions from official npm registry.

array.prototype.findlast Version Badge

github actions coverage dependency status dev dependency status License Downloads

npm badge

An ESnext spec-compliant Array.prototype.findLast 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.findLast 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.findlast

Usage/Examples

var findLast = require('array.prototype.findlast');
var assert = require('assert');

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

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

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

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

Tests

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

Current Tags

  • 1.2.5                                ...           latest (8 months ago)

9 Versions

  • 1.2.5                                ...           8 months ago
  • 1.2.4                                ...           9 months ago
  • 1.2.3                                ...           a year ago
  • 1.2.2                                ...           2 years ago
  • 1.2.1                                ...           3 years ago
  • 1.2.0                                ...           3 years ago
  • 1.1.1                                ...           3 years ago
  • 1.1.0                                ...           3 years ago
  • 1.0.0                                ...           3 years ago
Maintainers (1)
Downloads
Total 0
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (6)
Dev Dependencies (17)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE