
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
@shutterstock/chunker
Advanced tools
Calls a callback before size would be exceeded or when count limit is reached
@shutterstock/chunker
calls a blocking async callback before adding an item that would exceed a user-defined size limit OR when the count of items limit is reached.
A common use case for @shutterstock/chunker
is as a "batch accumulator" that gathers up items to be processed in a batch where the batch has specific count and size constraints that must be followed. For example, sending batches to an AWS Kinesis Data Stream requires that there be 500 or less records totalling 5 MB or less in size (see AWS Kinesis PutRecords) . The record count part is easy, but the record size check and handling both is more difficult.
The package is available on npm as @shutterstock/chunker
npm i @shutterstock/chunker
import { Chunker } from '@shutterstock/chunker';
After installing the package, you might want to look at our API Documentation to learn about all the features available.
Chunker
Chunker
has a BlockingQueue
that it uses to store items until the size or count limits are reached. When the limits are reached, the Chunker
calls the user-provided callback with the items in the queue. The callback is expected to return a Promise
that resolves when the items have been processed. The Chunker
will wait for the Promise
to resolve before continuing.
See below for an example of using Chunker
to write batches of records to an AWS Kinesis Data Stream.
nvm use
npm i
npm run build
npm run lint
npm run test
aws kinesis create-stream --stream-name chunker-test-stream --shard-count 1
chunker-test-stream
npm run example:aws-kinesis-writer
KINESIS_STREAM_NAME=my-stream-name npm run example:aws-kinesis-writer
enqueue
method intermittently blocks when the count or size constraints would be breached. During the block the records are written to the Kinesis Data Stream, after which the block is released and the new item is added to the next batch.FAQs
Calls a callback before size would be exceeded or when count limit is reached
The npm package @shutterstock/chunker receives a total of 8 weekly downloads. As such, @shutterstock/chunker popularity was classified as not popular.
We found that @shutterstock/chunker demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.