
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Deferrals is a very simple library that enables the creation of any number of promises which can then be awaited in any other code in your app.
npm i deferrals
yarn add deferrals
// Import the library
const {
makeDefer,
waitForDefer,
resolveDefer
} = require("deferrals");
// Some functions we'll run later
const await1 = async() => {
const value = await waitForDefer("Defer1");
console.log(value);
}
const await2 = async() => {
const value = await waitForDefer("Defer2");
console.log(value);
}
// Create the first deferral
makeDefer('Defer1');
// Just for fun, create another one!
makeDefer('Defer2');
// Call the 2 functions above - they're promises,
// and will not run until their promises are resolved.
await1();
await2();
// Simulate an async action after 1 second
setTimeout(() => {
resolveDefer("Defer1", "Defer 1 Resolved!");
}, 1000);
// and another after 2 seconds
setTimeout(() => {
resolveDefer("Defer2", "Defer 2 Resolved!");
}, 2000);
These deferrals don't need to be created and used in the same file or folder - you can import the library and get the deferals from any file in your project!
Did this thing in about 5 minutes, give me a few more to create some potent docs :P
FAQs
A way to globally define promises that you can await at multiple locations.
The npm package deferrals receives a total of 0 weekly downloads. As such, deferrals popularity was classified as not popular.
We found that deferrals 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
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.