Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including array.prototype.find with all npm packages installed. Try it out:

var arrayPrototypeFind = require("array.prototype.find")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

array.prototype.find v2.1.1

Array.prototype.find ES6 polyfill.

Build Status

ES6 Array.prototype.find polyfill

Simple ES6 Array.prototype.find polyfill for older environments taken from es6-shim.

For browsers and node.js.

Installation

  • Just include repo before your scripts.
  • npm install array.prototype.find

Usage

  • Array.prototype.find(predicate[, thisArg]) returns first item that matches predicate function.
  • predicate(value, index, collection): takes three arguments
    • value: current collection element
    • index: current collection element index
    • collection: the collection
// as a function
var find = require('array.prototype.find');
find([1, 2], function (x) { return x === 2; }); // 2

// to shim it
require('array.prototype.find').shim();

Code example:

// Default:
[1, 5, 10, 15].find(function (a) { return a > 9; }) // 10

Acknowledgements

Tests, fixes and travis support added by _duncanhall

License

The MIT License (c) 2016 Paul Miller (http://paulmillr.com)

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free