You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

array-find-index

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

array-find-index

ES2015 `Array#findIndex()` ponyfill


Version published
Weekly downloads
4.8M
decreased by-3.44%
Maintainers
1
Install size
3.77 kB
Created
Weekly downloads
 

Package description

What is array-find-index?

The array-find-index npm package provides a simple utility to find the index of the first element in an array that satisfies a provided testing function. It is a lightweight and straightforward alternative to the native Array.prototype.findIndex method, particularly useful in environments where polyfills are not available or desired.

What are array-find-index's main functionalities?

Find Index of First Matching Element

This feature allows you to find the index of the first element in an array that satisfies the provided testing function. In this example, the function isLargeNumber checks if an element is greater than 13, and findIndex returns the index of the first element that meets this condition.

const findIndex = require('array-find-index');
const array = [5, 12, 8, 130, 44];
const isLargeNumber = (element) => element > 13;
const index = findIndex(array, isLargeNumber);
console.log(index); // Output: 3

Other packages similar to array-find-index

Readme

Source

array-find-index Build Status

ES2015 Array#findIndex() ponyfill

Install

$ npm install --save array-find-index

Usage

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

Keywords

FAQs

Package last updated on 30 Sep 2016

Did you know?

Socket

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
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc