Security News
New Python Packaging Proposal Aims to Solve Phantom Dependency Problem with SBOMs
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
use-async-queue
Advanced tools
A React Hook implementing a queue for sync or async tasks, with optional concurrency limit.
Inspired by @caolan/async.queue.
Infinity
or less than 1 for no concurrency limit.id
(some unique primitive
value that makes sense for your use case -- a number, a url, etc.) and a
task
(a function that returns a Promise).
add
is called with a task that has an id
equal to the id
of a
pending or in-flight tasks, it will not be added to the queue.import useAsyncQueue from 'use-async-queue';
// Example shows a task fetching a url, but a task can be any operation.
const url = 'some url';
const inflight = task => {
console.log(`starting ${task.id}`);
console.dir(stats); // { numPending: 0, numInFlight: 1, numDone: 0}
};
const done = async task => {
const result = await task.result;
console.log(`finished ${task.id}: ${result}`);
console.dir(stats); // { numPending: 0, numInFlight: 0, numDone: 1}
};
const drain = () => {
console.log('all done');
console.dir(stats); // { numPending: 0, numInFlight: 0, numDone: 1}
};
const { add, stats } = useAsyncQueue({
concurrency: 1,
inflight,
done,
drain,
});
add({
id: url,
task: () => {
return fetch(url).then(res => res.text());
},
});
console.dir(stats); // { numPending: 1, numInFlight: 0, numDone: 0}
FAQs
Unknown package
The npm package use-async-queue receives a total of 3,176 weekly downloads. As such, use-async-queue popularity was classified as popular.
We found that use-async-queue 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.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
Security News
Socket CEO Feross Aboukhadijeh discusses open source security challenges, including zero-day attacks and supply chain risks, on the Cyber Security Council podcast.
Security News
Research
Socket researchers uncover how threat actors weaponize Out-of-Band Application Security Testing (OAST) techniques across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.