Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
buffered-async-iterator
Advanced tools
`buffer` wraps an async iterator into another async iterator, buffering items from the wrapped async iterator. This buffering allows the inner iterator to produce items concurrently with consumption of the items from the outer iterator. An example will
buffer
wraps an async iterator into another async iterator, buffering items
from the wrapped async iterator. This buffering allows the inner iterator to
produce items concurrently with consumption of the items from the outer
iterator. An example will help:
const buffer = require('buffered-async-iterator');
const someSlowIterator = ..;
for await (let item of buffer(someSlowIterator, 20)) {
await someSlowOperation(item);
}
Here, someSlowIterator
can slowly produce items (perhaps it is querying them
from a database) and we can perform someSlowOperation
on those items (perhaps
calling some HTTP API). Both the DB queries and the HTTP calls will happen
concurrently.
Without this functionality (that is, with for await (let item of someSlowIterator)
), the DB queries and the HTTP calls would alternate, each
unnecessarily waiting for the other.
The buffer has a length
property which gives the current number of buffered
items.
const buf = buffer(someSlowIterator, 20);
for await (let item of buffer) {
await someSlowOperation(item);
console.log(`${buf.length} items currently buffered`);
}
Inspired by https://github.com/mirkokiefer/async-iterators but updated for modern async iterators
FAQs
`buffer` wraps an async iterator into another async iterator, buffering items from the wrapped async iterator. This buffering allows the inner iterator to produce items concurrently with consumption of the items from the outer iterator. An example will
The npm package buffered-async-iterator receives a total of 3 weekly downloads. As such, buffered-async-iterator popularity was classified as not popular.
We found that buffered-async-iterator 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 researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.