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.
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
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’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.