
Security News
Crates.io Implements Trusted Publishing Support
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
promise-spin-wait
Advanced tools
An ES6-Promise based spin wait
$ npm install --save promise-spin-wait
Imagine you'd want to test a script that sends emails. Sadly the infrastructure that actually sends them is out of your controll, so emails are not delivered instantly. This is when a spin wait can be useful, it allows you to check regularly for a certain criteria until it's fulfilled.
const spinner = require('promise-spin-wait');
return sendEmail() // Asyncronous, but it will return before the email has actually been delivered
.then(() => {
return spinner(
() => {
return getEmailInboxCount().then(n => n > 0);
},
{
message: "Timeout: No Email received",
timeout: 5000,
interval: 500
}
);
})
Returns a promise for a the first truish response of fn()
or the first rejected promise of fn()
;
A function returning a value or a promise. If a promise is returned fn()
will not be called again until it is resolved. Any errors thrown or promise rejections will lead to the spinner rejecting as well.
Only a truish return value will lead to the spinner stopping.
Type: string
Default: Timeout
Message thrown when timeout occurs
Type: number
Default: 5000
Milliseconds since start when instead of calling fn
again an timeout error will be returned
Type: number
Default: 100
Duration between the last time fn()
has been fulfilled and the next fn()
is being called
MIT © marekventur
FAQs
An ES6-Promise based spin wait
The npm package promise-spin-wait receives a total of 4 weekly downloads. As such, promise-spin-wait popularity was classified as not popular.
We found that promise-spin-wait 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
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.