Security News
Highlights from the 2024 Rails Community Survey
A record 2,709 developers participated in the 2024 Ruby on Rails Community Survey, revealing key tools, practices, and trends shaping the Rails ecosystem.
@bucuo/async-control
Advanced tools
Help control parallel executions of async tasks/functions.
npm i @bucuo/async-control
Wrappers are composable high order functions which provide various async control options.
const {
returnError,
retry,
limitRate,
limitParallel,
expoBackoff
} = require("@bucuo/async-control");
const wrappers = [
returnError(), // returning error instead of throwing
retry({
maxRetries: 3,
backoff: expoBackoff({
factor: 1000, // milliseconds
base: 3, // defaults to 2
min: 100, // milliseconds, defaults to 0
max: 1000 // milliseconds, defaults to Infinity
})
// backoff: constBackoff(...)
// backoff: linearBackoff(...)
}),
limitRate({
count: 100,
interval: 1000 // milliseconds
}),
limitParallel(500)
];
You can build a run
function to run many tasks (async functions without arg) with controls.
const { buildRun } = require("@bucuo/async-control");
const wrappers = ...
const tasks = ... // async function without arg
const run = buildRun(wrappers);
// const run = buildRun(...wrappers); // another api format
const results = await run(tasks);
// const results = await run(...tasks); // another api format
You can wrap an existing async function to get a controlled version of it.
const { buildWrap } = require("@bucuo/async-control");
const wrappers = ...
const wrap = buildWrap(wrappers);
// const wrap = buildWrap(...wrappers);
const myFetch = wrap(fetch);
const response = await fetch("https://github.com/bucuo-js");
Function Builders:
Wrappers:
Retry Backoffs:
Errors:
buildWrap
If you use the same wrap
functions to wrap multiple target functions, the wrapped functions will share the same suite
of wrappers (so the invocations of them would be controlled in the same limit queue, etc).
This logic is correct and intended, but should be put emphasis on to avoid misunderstandings.
If you need the wrapped function to be controlled separately, make sure build separate a suit of wrappers for each of them.
MIT
FAQs
Help control parallel executions of async tasks.
The npm package @bucuo/async-control receives a total of 1 weekly downloads. As such, @bucuo/async-control popularity was classified as not popular.
We found that @bucuo/async-control 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.
Security News
A record 2,709 developers participated in the 2024 Ruby on Rails Community Survey, revealing key tools, practices, and trends shaping the Rails ecosystem.
Security News
In 2023, data breaches surged 78% from zero-day and supply chain attacks, but developers are still buried under alerts that are unable to prevent these threats.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.