pax_global_header00006660000000000000000000000064127734223200014514gustar00rootroot0000000000000052 comment=983f4c827ad22fa0353182b1ddcbfaecd4412859 array-find-index-1.0.2/000077500000000000000000000000001277342232000146555ustar00rootroot00000000000000array-find-index-1.0.2/.editorconfig000066400000000000000000000002761277342232000173370ustar00rootroot00000000000000root = true [*] indent_style = tab end_of_line = lf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true [{package.json,*.yml}] indent_style = space indent_size = 2 array-find-index-1.0.2/.gitattributes000066400000000000000000000000141277342232000175430ustar00rootroot00000000000000* text=auto array-find-index-1.0.2/.gitignore000066400000000000000000000000151277342232000166410ustar00rootroot00000000000000node_modules array-find-index-1.0.2/.travis.yml000066400000000000000000000001011277342232000167560ustar00rootroot00000000000000language: node_js node_js: - '6' - '4' - '0.12' - '0.10' array-find-index-1.0.2/index.js000066400000000000000000000007201277342232000163210ustar00rootroot00000000000000'use strict'; module.exports = function (arr, predicate, ctx) { if (typeof Array.prototype.findIndex === 'function') { return arr.findIndex(predicate, ctx); } if (typeof predicate !== 'function') { throw new TypeError('predicate must be a function'); } var list = Object(arr); var len = list.length; if (len === 0) { return -1; } for (var i = 0; i < len; i++) { if (predicate.call(ctx, list[i], i, list)) { return i; } } return -1; }; array-find-index-1.0.2/license000066400000000000000000000021371277342232000162250ustar00rootroot00000000000000The MIT License (MIT) Copyright (c) Sindre Sorhus (sindresorhus.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. array-find-index-1.0.2/package.json000066400000000000000000000011401277342232000171370ustar00rootroot00000000000000{ "name": "array-find-index", "version": "1.0.2", "description": "ES2015 `Array#findIndex()` ponyfill", "license": "MIT", "repository": "sindresorhus/array-find-index", "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", "url": "sindresorhus.com" }, "engines": { "node": ">=0.10.0" }, "scripts": { "test": "xo && ava" }, "files": [ "index.js" ], "keywords": [ "es2015", "ponyfill", "polyfill", "shim", "find", "index", "findindex", "array" ], "devDependencies": { "ava": "*", "xo": "*" } } array-find-index-1.0.2/readme.md000066400000000000000000000012561277342232000164400ustar00rootroot00000000000000# array-find-index [![Build Status](https://travis-ci.org/sindresorhus/array-find-index.svg?branch=master)](https://travis-ci.org/sindresorhus/array-find-index) > ES2015 [`Array#findIndex()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex) [ponyfill](https://ponyfill.com) ## Install ``` $ npm install --save array-find-index ``` ## Usage ```js const arrayFindIndex = require('array-find-index'); arrayFindIndex(['rainbow', 'unicorn', 'pony'], x => x === 'unicorn'); //=> 1 ``` ## API Same as `Array#findIndex()`, but with the input array as the first argument. ## License MIT © [Sindre Sorhus](https://sindresorhus.com) array-find-index-1.0.2/test.js000066400000000000000000000003601277342232000161710ustar00rootroot00000000000000/* eslint-disable no-extend-native */ import test from 'ava'; Array.prototype.findIndex = undefined; const m = require('./'); const f = [10, 20, 30, 40]; test(t => { t.is(m(f, x => x === 30), 2); t.is(m(f, x => x === 'noop'), -1); });