JSPM

array.findindex

v1.0.4
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 16
  • Score
    100M100P100Q45730F
  • License MIT

Lightweight Array.prototype.findIndex Polyfill. ES5. IE9+

Package Exports

  • array.findindex

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (array.findindex) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Lightweight Array.prototype.findIndex polyfill

Build Status Coverage Status Maintainability Size

The findIndex() method returns the index of the first element in the array that satisfies the provided testing function. Otherwise -1 is returned.

How It Works

1. Download Latest version or install with bower bower install array.findindex
2. Include polyfill on your web-page

<script src="dist/array-find-index-polyfill.min.js"></script>

3. Use as native method

["apple", "banana", "peach"].findIndex(function(item) {
    return item === "banana";
});
// 1

Performance

Testing in Chrome 61.0.3163 / Mac OS X 10.13.0
Native 431,077 Ops/sec
Polyfill 2,289,661 Ops/sec

See https://jsperf.com/array-prototype-find-index-polyfill

Specification on "Ecma International"
MDN examples

Code and documentation copyright 2017 Vladimir Belov. Code released under the MIT license.