Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bendingbender/mdn-array.prototype.findindex
MDN version of Array.prototype.findIndex shim
https://github.com/bendingbender/mdn-array.prototype.findindex
Last synced: 25 days ago
JSON representation
MDN version of Array.prototype.findIndex shim
- Host: GitHub
- URL: https://github.com/bendingbender/mdn-array.prototype.findindex
- Owner: BendingBender
- License: cc0-1.0
- Created: 2016-08-03T08:17:10.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-05-11T19:42:41.000Z (over 7 years ago)
- Last Synced: 2024-11-20T18:11:55.458Z (about 1 month ago)
- Language: JavaScript
- Size: 7.81 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![browser support](https://ci.testling.com/BendingBender/MDN-Array.prototype.findIndex.png)](https://ci.testling.com/BendingBender/MDN-Array.prototype.findIndex)
[![Build Status](https://travis-ci.org/BendingBender/MDN-Array.prototype.findIndex.svg?branch=master)](https://travis-ci.org/BendingBender/MDN-Array.prototype.findIndex)
# ES6 `Array.prototype.findIndex` shim
Simple ES6 [Array.prototype.findIndex](https://tc39.github.io/ecma262/#sec-array.prototype.findindex) polyfill for older environments taken from [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex#Polyfill).
For browsers only, bower-friendly. Explicitly not meant to be used with node, use [Array.prototype.findIndex](https://github.com/paulmillr/Array.prototype.findIndex) if you wish a shim for node.
## Installation
* Just include repo before your scripts.
* `bower install mdn-array.prototype.findindex`## Usage
* `Array.prototype.findindex(predicate[, thisArg])` returns first item index that matches `predicate` function.
#### Parameters
* `predicate(value, index, collection)`: takes three arguments
* `value`: current collection element
* `index`: current collection element index
* `collection`: the collection
* `thisArg`: Optional. Object to use as `this` when executing `predicate`.#### Code example
```javascript
[1, 5, 10, 15].findIndex(function(a) {return a > 9;}) // 2
```## Acknowledgements
Tests, readme and travis support gratefully taken from [Array.prototype.findIndex](https://github.com/paulmillr/Array.prototype.findIndex)
## License
CC0 1.0