Security News
The Dark Side of Open Source
At Node Congress, Socket CEO Feross Aboukhadijeh uncovers the darker aspects of open source, where applications that rely heavily on third-party dependencies can be exploited in supply chain attacks.
indexes-of
Advanced tools
Package description
The npm package 'indexes-of' is a utility that allows you to find all the indexes of a value within an array. It is a simple and focused package that provides a straightforward method for this specific task.
Find indexes of a value in an array
This feature allows you to find all occurrences of a specific value within an array and returns an array of their indexes. In the code sample, it finds all indexes of the value '2' in the array.
const indexesOf = require('indexes-of');
const arr = [1, 2, 3, 2, 4];
const indexes = indexesOf(arr, 2); // returns [1, 3]
This package provides a method similar to the ES6 Array.prototype.findIndex. It returns the index of the first element in the array that satisfies the provided testing function. Unlike 'indexes-of', it does not return all indexes, just the first one.
Lodash is a well-known utility library that includes a findIndex function. This function is similar to 'array-find-index' and returns the index of the first element that passes a test. Lodash offers a wide range of utilities, whereas 'indexes-of' is more specialized.
This package extends the capabilities of matching patterns against strings or arrays. While it can be used to find indexes of matches in an array, it is more complex and feature-rich than 'indexes-of', which focuses solely on finding indexes of a value.
Readme
like Array/String#indexOf but return all the indexes in an array.
var indexesOf = require('indexes-of')
var twosIndexes = indexesOf([1, 2, 3, 4, 5, 4, 3, 2, 1], 2)
console.log(twosIndexes)
// [1, 7]
MIT
FAQs
line String/Array#indexOf but return all the indexes in an array
The npm package indexes-of receives a total of 4,539,957 weekly downloads. As such, indexes-of popularity was classified as popular.
We found that indexes-of 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
At Node Congress, Socket CEO Feross Aboukhadijeh uncovers the darker aspects of open source, where applications that rely heavily on third-party dependencies can be exploited in supply chain attacks.
Research
Security News
The Socket Research team found this npm package includes code for collecting sensitive developer information, including your operating system username, Git username, and Git email.
Security News
OpenJS is warning of social engineering takeovers targeting open source projects after receiving a credible attempt on the foundation.