
Security News
MCP Community Begins Work on Official MCP Metaregistry
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
array-find-index
Advanced tools
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.
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
Lodash is a popular utility library that provides a wide range of functions for common programming tasks. The lodash.findindex method is similar to array-find-index, offering the ability to find the index of the first element in an array that matches a given predicate. Lodash is more feature-rich and includes many other utilities, making it a heavier dependency compared to array-find-index.
This package is a polyfill for the native Array.prototype.findIndex method, which is available in modern JavaScript environments. It provides the same functionality as array-find-index but is intended for use in environments where the native method is not available. It is a direct drop-in replacement for the native method.
ES2015
Array#findIndex()
ponyfill
$ npm install --save array-find-index
const arrayFindIndex = require('array-find-index');
arrayFindIndex(['rainbow', 'unicorn', 'pony'], x => x === 'unicorn');
//=> 1
Same as Array#findIndex()
, but with the input array as the first argument.
MIT © Sindre Sorhus
FAQs
ES2015 `Array#findIndex()` ponyfill
The npm package array-find-index receives a total of 0 weekly downloads. As such, array-find-index popularity was classified as not popular.
We found that array-find-index demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
Research
Security News
Socket uncovers an npm Trojan stealing crypto wallets and BullX credentials via obfuscated code and Telegram exfiltration.
Research
Security News
Malicious npm packages posing as developer tools target macOS Cursor IDE users, stealing credentials and modifying files to gain persistent backdoor access.