
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.
Utility function that returns a promise that resolves after x ms
Can be used as a yieldable with co or in koa.
Basic example:
var wait = require('wait-then'),
timeout = wait.timeout;
wait(2000).then(function() {
console.log('This is logged after 2 seconds');
});
timeout(2000).catch(e) {
console.log('This is logged after 2 seconds');
}
Example with co
:
var wait = require('wait-then'),
timeout = wait.timeout,
co = require('co');
co(function *() {
yield wait(1000);
console.log('This is logged after 1 second');
});
co(function *() {
try {
yield timeout(1000);
} catch (e) {
console.log('This is logged after 1 second');
}
});
The generator function passed into co
can be yielded in a middleware in koa
.
Note: This relies on the existence of a global Promise
object as defined in the ECMAScript 6 (Harmony) proposal.
How this differs from co-sleep
and co-wait
is that both of them use thunks, support for which is set to be deprecated. wait-then
instead uses Promises, which are also yieldable.
FAQs
Utility function that returns a promise that resolves after x ms
The npm package wait-then receives a total of 2 weekly downloads. As such, wait-then popularity was classified as not popular.
We found that wait-then 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.