
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.
promise-assist
Advanced tools
Several helper functions when working with native promises.
Useful for waiting a specific amount of time before continuing an operation.
import { sleep } from 'promise-assist'
async function myOperation() {
const startTime = Date.now()
await sleep(500)
console.log(`${Date.now() - startTime}ms passed!`)
}
Useful for limiting the amount of time an async Promise-based operation can take.
import { timeout } from 'promise-assist'
async function myOperation() {
try {
const data = await timeout(
fetchDataFromServer(), // pass a Promise to the timeout function
10000, // request will be limited to 10 seconds
`failed loading required data from backend`
)
// do something with the data
} catch (e) {
// handle errors
}
}
Creates a deferred Promise, where resolve
/reject
are exposed to the place that holds the promise.
Generally bad practice, but there are use-cases where one mixes callback-based API with Promise API and this is helpful.
import { deferred } from 'promise-assist'
const { promise, resolve, reject } = deferred<string>()
// `resolve` or `reject` calls are reflected on `promise`
promise.then(value => console.log(value))
resolve('some text')
// 'some text' is printed to console
MIT
FAQs
Several helper functions when working with native promises
The npm package promise-assist receives a total of 8,830 weekly downloads. As such, promise-assist popularity was classified as popular.
We found that promise-assist 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.