Nodeify is a compact utility designed to convert Promise/A+-compliant promises into Node.js-style callback invocations. It allows developers to seamlessly integrate promise-based asynchronous operations into existing callback-driven codebases. The package offers several usage patterns: a direct functional approach, a `nodeify.Promise` constructor that returns promises with a `.nodeify` method, and various `extend` methods to add the `.nodeify` method to existing promise constructors or instances. The current stable version is 1.0.1. Due to its last publish date over seven years ago and no recent activity, the package is considered abandoned. For modern Node.js development, built-in features like `util.promisify` or native `async/await` are the preferred and more robust solutions for handling asynchronous operations and bridging between promises and callbacks.
npm install nodeifyVerified import paths — ran on the pinned version, not inferred.
Demonstrates `nodeify` converting a promise-based function to one that supports a Node.js-style callback, returning the promise if no callback is provided.
For new projects, prefer native `async/await` syntax for promise management or `util.promisify` for converting callback-based APIs to promises. For existing promise-callback bridging, consider modern alternatives or maintaining the current version with caution.
Use `const nodeify = require('nodeify');` for CommonJS projects. In ESM projects, consider a modern alternative or ensure proper build tool configuration to handle CommonJS modules.Always ensure that promises are handled either by providing a callback to `nodeify` or by explicitly chaining `.catch()` to the returned promise if no callback is supplied. For uncaught rejections, consider setting up a global `unhandledRejection` handler in Node.js.
Use the functional `nodeify(promise, callback)` approach or the `nodeify.Promise` constructor to avoid modifying global or shared Promise prototypes. If extending is necessary, ensure careful testing and isolation to prevent conflicts.
Ensure the second argument to `nodeify` (or the first to the `.nodeify()` method) is a valid function with the signature `(err, result) => {...}`.Either provide a callback function to `nodeify` to handle errors, or explicitly add a `.catch()` block to the promise returned by `nodeify` when no callback is used: `nodeify(myPromise(), null).catch(err => console.error(err));`
No dependency data recorded yet.