
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
node-callback-adapter
Advanced tools
Adapt Promise returning functions to optionally accept Node-style callbacks as last argument
This is a function/method decorator which is when applied to a function which returns a promise makes it to handle optionally passed Node-style callback as last argument.
As decorators are a part of future ES7 standard they can only be used with transpilers such as Babel.
Installation:
% npm install node-callback-adapter
Example usage as a method decorator:
import adapt from 'node-callback-adapter'
class Component {
@adapt
add(x, y) {
return Promise.resolve(x + y)
}
}
let component = new Component()
// call without callback and get a promise back
component.add(2, 2).then(four => console.log(four))
// call with a callback
component.add(2, 2, function(err, four) {
console.log(four)
})
Example usage as a function decorator:
import {adaptFunction} from 'node-callback-adapter'
let add = adaptFunction(function add(x, y) {
return Promise.resolve(x + y)
})
// call without callback and get a promise back
add(2, 2).then(four => console.log(four))
// call with a callback
add(2, 2, function(err, four) {
console.log(four)
})
FAQs
Adapt Promise returning functions to optionally accept Node-style callbacks as last argument
We found that node-callback-adapter 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.