Socket
Socket
Sign inDemoInstall

find-index

Package Overview
Dependencies
0
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

find-index

finds an item in an array matching a predicate function, and returns its index


Version published
Maintainers
1
Weekly downloads
646,790
decreased by-9.77%

Weekly downloads

Readme

Source

find-index

An implementation of the ES6 method Array.prototype.findIndex as a standalone module and a ponyfill.

Finds an item in an array matching a predicate function, and returns its index.

Fast both when thisArg is used and also when it isn't.

usage

npm install find-index
var findIndex = require('find-index/findIndex')
var findIndex = require('find-index/ponyfill') // will use native Array#findIndex if available.
var findLastIndex = require('find-index/findLastIndex') // search backwards from end
findIndex(array, callback[, thisArg])
findLastIndex(array, callback[, thisArg])
Parameters:
  array
    The array to operate on.
  callback
    Function to execute on each value in the array, taking three arguments:
      element
        The current element being processed in the array.
      index
        The index of the current element being processed in the array.
      array
        The array findIndex was called upon.
  thisArg
    Object to use as this when executing callback.

Based on array-findindex

performance

$ iojs --harmony_arrays perf/benchmark.js

native Array.prototype.findIndex: 6347ms
findIndex: 1633ms
findIndex ponyfill: 6384ms
findLastIndex: 1508ms
npm lodash.findindex: 2900ms
npm array-findindex: 3512ms

Keywords

FAQs

Last updated on 12 Feb 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc