
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.
with-callback
Advanced tools
A small helper function to bridge the gap when returning a promise from a function that takes a callback
A small helper function to bridge the gap when returning a promise from a function that takes a callback
Note that this module will not introduce any custom Promise implementation.
It will use the global Promise
(requires node >= v4).
import withCallback from 'with-callback';
// or const withCallback = require('with-callback');
// withCallback returns a promise and invokes the function with a callback
// used to fulfill the promise
function readFile(name) {
return withCallback(callback => fs.readFile(name, callback));
}
// arguments can also be passed as an array
function readFile(name) {
return withCallback([name], fs.readFile);
}
// A second function can be passed to withCallback to map all arguments
// passed to the callback to a single value used to resolve the promise.
function example(callback) {
callback(null, 'a', 'b');
}
const promise = withCallback(example, (a, b) => [a, b]);
// promise resolves with ['a', 'b']
FAQs
A small helper function to bridge the gap when returning a promise from a function that takes a callback
We found that with-callback 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.