Security News
UK Officials Consider Banning Ransomware Payments from Public Entities
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.
Alternative converter between promises and callbacks
npm install deferinfer
# -- or --
yarn add deferinfer
const { defer, infer } = require('promise-util')
// -- or --
const defer = require('promise-util').defer
defer(callback)
-> Promise
Convert callback function into to promise
const result = await defer(done => someCallbackFunction(done))
Properly forwards error
defer(done => {
done(new Error()) // forwarded to .catch()
throw new Error() // forwarded to .catch()
done(null, 42) // forwarded to .then()
})
.then(console.log)
.catch(console.error)
Async method support
defer(async done => {
const result = await anotherPromise()
done(null, result)promise-util
})
infer(promise, callback)
-> Promise
Convert promise to callback
const p = infer(Promise.resolve(42), (err, res) => {
if (err) console.error(err)
else console.log(res)
})
Define promise/callback agnostic functions
function add(a, b, callback) {
const promise = defer(done => {
done(null, a + b)
})
return infer(promise, callback)
}
add(5, 7, (err, sum) => {
console.log(sum) // => 12
})
const sum = await add(6, 4)
console.log(sum) // => 10
FAQs
Alternative converter between promises and callbacks
The npm package deferinfer receives a total of 1 weekly downloads. As such, deferinfer popularity was classified as not popular.
We found that deferinfer 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
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.