Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

array.prototype.findindex

paulmillr572.4kMIT2.2.4

Array.prototype.findIndex ES2015 polyfill.

Array.prototype.findIndex, findIndex, es6, es2015

readme

ES6 Array.prototype.findIndex polyfill

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

For browsers and node.js.

Installation

  • Just include repo before your scripts.
  • npm install array.prototype.findindex if you’re using node.js.
  • component install paulmillr/Array.prototype.findIndex if you’re using component(1).
  • bower install Array.prototype.findIndex if you’re using Twitter Bower.

Usage

  • Array.prototype.findIndex(predicate[, thisArg]) returns first item index that matches predicate function.
  • predicate(value, index, collection): takes three arguments
    • value: current collection element
    • index: current collection element index
    • collection: the collection
var findIndex = require('array.prototype.findindex');

findIndex.shim(); // if you want to install it on the global environment

Code example:

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

License

The MIT License (MIT)

Copyright (c) 2013 Paul Miller http://paulmillr.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.

changelog

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog and this project adheres to Semantic Versioning.

v2.2.4 - 2024-12-17

Commits

  • [actions] split out node 10-20, and 20+ 22ec19f
  • [Dev Deps] update @es-shims/api, auto-changelog, tape 60c8f4a
  • [Deps] update call-bind, es-abstract 31f714f
  • [Dev Deps] update @es-shims/api, @ljharb/eslint-config 763157c
  • [meta] add missing engines.node 1f5d651
  • [Refactor] use call-bound directly ebc05aa
  • [Tests] replace aud with npm audit 1f6d4de
  • [meta] add SECURITY.md 2cf450e
  • [Deps] update es-abstract 33ede20
  • [Dev Deps] add missing peer dep 906ece2

v2.2.3 - 2024-03-16

Commits

  • [Refactor] use es-object-atoms, update es-abstract 7747551
  • [Deps] update call-bind, define-properties, es-shim-unscopables d0f9882
  • [Dev Deps] update aud, npmignore, tape f6a1abf

v2.2.2 - 2023-08-27

Commits

  • [meta] add auto-changelog d653e4c
  • [Deps] update define-properties, es-abstract 6afe819
  • [Dev Deps] update @es-shims/api, @ljharb/eslint-config, aud, tape c65fb5f

2.2.1

  • [Deps] update define-properties, es-abstract
  • [meta] use npmignore to autogenerate an npmignore file
  • [actions] update rebase action to use reusable workflow
  • [Dev Deps] update aud, functions-have-names, tape

2.2.0

  • [New] shim/auto: add findIndex to Symbol.unscopables
  • [Tests] migrate to tape
  • [Deps] update es-abstract
  • [Dev Deps] update @ljharb/eslint-config

2.1.1

  • [Refactor] update implementation to match spec text
  • [meta] add safe-publish-latest
  • [Dev Deps] update eslint, @ljharb/eslint-config, aud, @es-shims/api
  • [Tests] migrate tests to Github Actions

2.1.0

  • [New] add auto entry point
  • [Fix] remove detect file, broken/unused in v2
  • [Refactor] use split-up es-abstract (77% bundle size decrease)
  • [Performance] avoid checking arguments indexes beyond arguments.length
  • [Performance] inline ES.Call since IsCallable is already checked prior to the loop.
  • [Deps] update define-properties
  • [meta] Only apps should have lockfiles
  • [meta] add missing LICENSE file
  • [Tests] add npm run lint
  • [Tests] use shared travis-ci configs
  • [Tests] use aud in posttest

2.0.2

  • [Performance] the entry point should use the native function when compliant

2.0.1

  • [Fix] use call instead of apply in bound entry point function (#17)
  • [Refactor] Remove unnecessary double ToLength call (#16)
  • [Tests] run tests on travis-ci

2.0.0

  • [Breaking] use es-shim API (#13)
  • [Docs] fix example in README (#9)
  • [Docs] Fix npm install command in README (#7)

1.0.0

  • [Fix] do not skip holes, per ES6 change (#4)
  • [Fix] Older browsers report the typeof some host objects and regexes as "function" (#5)

0.1.1

  • [Fix] Support IE8 by wrapping Object.defineProperty with a try catch (#3)
  • [Refactor] remove redundant enumerable: false (#1)

0.1.0

  • Initial release.