
Research
Security News
Malicious npm Packages Target BSC and Ethereum to Drain Crypto Wallets
Socket uncovered four malicious npm packages that exfiltrate up to 85% of a victim’s Ethereum or BSC wallet using obfuscated JavaScript.
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.
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 3,456,505 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.
Research
Security News
Socket uncovered four malicious npm packages that exfiltrate up to 85% of a victim’s Ethereum or BSC wallet using obfuscated JavaScript.
Security News
TC39 advances 9 JavaScript proposals, including Array.fromAsync, Error.isError, and Explicit Resource Management, which are now headed into the ECMAScript spec.
Security News
Vite releases Rolldown-Vite, a Rust-based bundler preview offering faster builds and lower memory usage as a drop-in replacement for Vite.