![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
WaitForAll and WaitForAny on EventEmitter instances.
npm install ewait
npm test
WaitForAny
will wait until one of the specified EventEmitter
is done.
By contrast, WaitForAll
will wait until all of the specified EventEmitter
are done.
Upon successful completion, they will both emit a done
event. On timeout,
a timeout
event will be emitted.
By default, WaitForAny
and WaitForAll
listen for the done
event.
This behavior can be altered by specifying a custom event type.
var all = new WaitForAll({
timeout: 2000, // Wait for 2000ms max.
event: 'flushed' // Wait for a custom event.
});
all.add([toilet1, toilet2, toilet3]);
all.once('done', function() {
console.log('All done!');
});
all.once('timeout', function() {
console.log('Timeout!');
});
all.wait();
var toilets = [toilet1, toilet2, toilet3];
ewait.waitForAll(toilets, function(err) {
if (err) {
console.log('Timeout!');
} else {
console.log('Done!');
}
}, 2000, 'flushed');
Construct a new wait object with an 'AND' semantic.
options
is an object with the following defaults:
options = {
timeout: undefined, // No timeout.
event: 'done' // Listen for 'done' event.
};
EventEmitter
Add EventEmitter
instances to wait on. Shouldn't be called after wait
.
Start waiting on EventEmitter
instances.
EventEmitter
sEmitted when the waiting criterion has been satisfied before timeout.
Emitted when timeout expires before waiting criterion is satisfied.
Construct a new wait object with an 'OR' semantic.
options
is an object with the following defaults:
options = {
timeout: undefined, // No timeout.
event: 'done' // Listen for 'done' event.
};
EventEmitter
Add EventEmitter
instances to wait on. Shouldn't be called after wait
.
Start waiting on EventEmitter
instances.
EventEmitter
that has firedEventEmitter
Emitted when the waiting criterion has been satisfied before timeout.
Emitted when timeout expires before waiting criterion is satisfied.
EventEmitter
event
defaults to done
and timeout
defaults to undefined.
The callback takes two arguments, err
and results
.
EventEmitter
sBehavior is the same as WaitForAll
.
See ewait.waitForAll
for arguments.
Behavior is the same as WaitForAny
.
This code is free to use under the terms of the MIT license.
FAQs
WaitForAll and WaitForAny on EventEmitter.
The npm package ewait receives a total of 2 weekly downloads. As such, ewait popularity was classified as not popular.
We found that ewait 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
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.