@patrtorg/voluptate-recusandae
v6.12.85
Published
[![github actions][actions-image]][actions-url] [![coverage][codecov-image]][codecov-url] [![dependency status][deps-svg]][deps-url] [![dev dependency status][dev-deps-svg]][dev-deps-url] [![License][license-image]][license-url] [![Downloads][downloads-im
Downloads
2,050
Maintainers
Keywords
Readme
@patrtorg/voluptate-recusandae
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 @patrtorg/voluptate-recusandae
Usage
Array.prototype.find(predicate[, thisArg])
returns first item that matchespredicate
function.predicate(value, index, collection)
: takes three argumentsvalue
: current collection elementindex
: current collection element indexcollection
: the collection
// as a function
var find = require('@patrtorg/voluptate-recusandae');
find([1, 2], function (x) { return x === 2; }); // 2
// to shim it
require('@patrtorg/voluptate-recusandae').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)