{"id":17846,"library":"nodeify","title":"Nodeify: Promise to Node Callback Converter","description":"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.","status":"abandoned","version":"1.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/then/nodeify","tags":["javascript","promise","then","nodeify","callback"],"install":[{"cmd":"npm install nodeify","lang":"bash","label":"npm"},{"cmd":"yarn add nodeify","lang":"bash","label":"yarn"},{"cmd":"pnpm add nodeify","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Primary functional export. This package is CJS-first, so direct ESM import might require a transpiler or Node.js loader configuration for older versions. CommonJS `require('nodeify')` is the standard approach.","wrong":"const nodeify = require('nodeify').nodeify","symbol":"nodeify","correct":"import nodeify from 'nodeify'"},{"note":"Accesses a specific constructor exposed by the package for creating promises with a built-in `.nodeify` method. Not the global Promise object.","wrong":"import Promise from 'nodeify'","symbol":"Promise (via nodeify.Promise)","correct":"import { Promise } from 'nodeify'; // For ESM\nconst Promise = require('nodeify').Promise; // For CJS"},{"note":"Used to extend existing promise instances or constructors with the `.nodeify` method, allowing for a more fluent API when integrated with other promise libraries.","wrong":"import { nodeifyExtend } from 'nodeify'","symbol":"extend (via nodeify.extend)","correct":"import { extend } from 'nodeify'; // For ESM\nconst extend = require('nodeify').extend; // For CJS"}],"quickstart":{"code":"import nodeify from 'nodeify';\n\n// Simulate an async operation that returns a Promise\nfunction myPromiseMethod(arg) {\n  return new Promise((resolve, reject) => {\n    setTimeout(() => {\n      if (arg > 0) {\n        resolve(`Processed: ${arg}`);\n      } else {\n        reject(new Error('Argument must be positive'));\n      }\n    }, 100);\n  });\n}\n\n// Example 1: Using nodeify with a callback\nfunction myAsyncMethodWithCallback(arg, callback) {\n  return nodeify(myPromiseMethod(arg), callback);\n}\n\nmyAsyncMethodWithCallback(5, (err, result) => {\n  if (err) {\n    console.error('Callback Error:', err.message);\n  } else {\n    console.log('Callback Result:', result);\n  }\n});\n\nmyAsyncMethodWithCallback(-1, (err, result) => {\n  if (err) {\n    console.error('Callback Error (negative arg):', err.message);\n  } else {\n    console.log('Callback Result (negative arg):', result);\n  }\n});\n\n// Example 2: Using nodeify without a callback returns the original promise\nconst promiseOnly = myAsyncMethodWithCallback(10);\npromiseOnly.then(res => console.log('Promise-only Result:', res)).catch(err => console.error('Promise-only Error:', err.message));\n","lang":"javascript","description":"Demonstrates `nodeify` converting a promise-based function to one that supports a Node.js-style callback, returning the promise if no callback is provided."},"warnings":[{"fix":"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.","message":"This package is effectively abandoned. The last publish was over seven years ago, and there is no ongoing maintenance. While it may still function for its intended purpose, it is not recommended for new projects or for critical systems due to potential unaddressed issues or lack of compatibility with future Node.js versions.","severity":"breaking","affected_versions":">=1.0.1"},{"fix":"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.","message":"Nodeify predates native ESM support in Node.js. It is primarily a CommonJS module. Direct `import` statements might require a transpiler (e.g., Babel) or specific Node.js loader configurations for older Node.js versions.","severity":"gotcha","affected_versions":">=1.0.1"},{"fix":"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.","message":"If no callback function is provided to `nodeify`, it will simply return the original promise. If that promise rejects, and there are no `.catch()` handlers attached, an unhandled promise rejection might occur, potentially crashing the application in Node.js.","severity":"gotcha","affected_versions":">=1.0.1"},{"fix":"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.","message":"The `nodeify.extend()` methods modify the prototype of a `PromiseConstructor` or a `Promise` instance. This global modification can lead to unexpected side effects or conflicts if multiple libraries attempt similar modifications or if the promise constructor is not the one `nodeify` expects.","severity":"gotcha","affected_versions":">=1.0.1"}],"env_vars":null,"last_verified":"2026-04-23T00:00:00.000Z","next_check":"2026-07-22T00:00:00.000Z","problems":[{"fix":"Ensure the second argument to `nodeify` (or the first to the `.nodeify()` method) is a valid function with the signature `(err, result) => {...}`.","cause":"The second argument passed to `nodeify` was not a function, or the `this` context for `.nodeify()` method was incorrect.","error":"TypeError: callback is not a function"},{"fix":"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));`","cause":"A promise being 'nodeified' rejected, but no callback was provided, and no `.catch()` handler was attached to the returned promise.","error":"UnhandledPromiseRejectionWarning: (in some promise message) / Uncaught (in promise) (Error: ...)"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}