array.find

1.0.9 • Public • Published

Lightweight Array.prototype.find polyfill

Build Status Coverage Status Maintainability Size npm version

The find() method returns the value of the first element in the array that satisfies the provided testing function. Otherwise undefined is returned.

How It Works

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

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

3. Use as native method

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

Performance

Testing in Chrome 61.0.3163 / Mac OS X 10.13.0
Native 400,642 Ops/sec
Polyfill 2,240,624 Ops/sec

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

Links

Specification on "Ecma International"
MDN examples

Copyright and license

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

Package Sidebar

Install

npm i array.find

Weekly Downloads

264

Version

1.0.9

License

MIT

Unpacked Size

5.64 kB

Total Files

6

Last publish

Collaborators

  • vovkabelov