Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
array-batcher2
Advanced tools
A method for batching items in an array, returning a new Array containing smaller Arrays of batched items.
Items are batched in order, with the first batch containing the first items in the original Array.
A batchSize
parameter needs to be provided to specify the max size of the batches to be created.
Batches will be created to this max size, up until the final batch which will be filled partially if there are not enough items to fill it.
The batch()
method can be added as an extension of the native JS Array
interface.
const result1 = batch(
[1,2,3,4,5,6,7,8,9],
2
)
// returns [
// [1,2],
// [3,4],
// [5,6],
// [7,8],
// [9]
// ]
const result2 = [1,2,3,4,5,6,7,8,9].dedupe(2)
// returns [
// [1,2],
// [3,4],
// [5,6],
// [7,8],
// [9]
// ]
npm install --save array-batcher
Array
with batch()
To add the batch()
method to JS's base Array
interface, you can import the extension by including:
import "array-batcher/extend-array-with-batch"
into your codebase at some point before attempting to call [].batch()
// somewhere in your initialization logic
import "array-batcher/extend-array-with-batch"
// ...
// Array now has a batch() method
const result = [1,2,3].batch(2) // returns [[1,2], [3]]
FAQs
Batches items in an array
The npm package array-batcher2 receives a total of 0 weekly downloads. As such, array-batcher2 popularity was classified as not popular.
We found that array-batcher2 demonstrated a healthy version release cadence and project activity because the last version was released less than 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’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.