Security News
Research
Supply Chain Attack on Rspack npm Packages Injects Cryptojacking Malware
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
promisize takes your function's callback argument and returns a new callback with a promise
property. When the new callback is called, it either calls the original callback or if no callback was given it fulfills the promise. promisize is lightweight and does not include any promise shims or dependencies but instead uses the globally defined Promise
. If Promise
is not defined (i.e. no native promise support) then callbacks still work as they would without promisize.
var promisize = require('promisize')
function someAsyncFunction (cb) {
cb = promisize(cb)
// Do some async stuff then
setTimeout(function () {
cb(null, 'foobar')
})
// Undefined if there is no Promise support
// or if the original callback was defined
return cb.promise
}
var cb = promisize(function callback (err, result) {})
promisize
takes a nodejs style callback and returns another nodejs style callback. When the returned callback is called it either calls the original callback or fulfills the promise but never both.
cb.promise
The returned cb
has a promise
property that is only defined if the environment has Promise support (i.e. Promise
is defined) and the original callback was undefined. When the returned callback is called it fulfills this promise if it is defined or calls the original callback if the promise is undefined.
MIT. Copyright (c) Austin Middleton.
FAQs
Easily support both callbacks and promises in your js lib
The npm package promisize receives a total of 339 weekly downloads. As such, promisize popularity was classified as not popular.
We found that promisize 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
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.
Security News
Sonar’s acquisition of Tidelift highlights a growing industry shift toward sustainable open source funding, addressing maintainer burnout and critical software dependencies.