{"id":16098,"library":"kew","title":"kew: Lightweight Promise Library","description":"kew is a lightweight promise/deferred library specifically designed for Node.js environments. Developed by Medium, its primary goal was to offer a high-performance alternative to the Q library, particularly for server-side applications experiencing CPU bottlenecks in chained database callbacks. Currently at version 0.7.0, the package appears to be unmaintained, with its last commit dating back several years, indicating an abandoned status and no active release cadence. It provides a subset of promise functionality, including methods like `Q.resolve()`, `Q.reject()`, `Q.defer()`, and promise chaining with `.then()` and `.fail()`. Unlike more comprehensive promise libraries, kew intentionally implements only the features necessary for the common server-side use cases identified by its original developers, prioritizing minimal footprint and speed.","status":"abandoned","version":"0.7.0","language":"javascript","source_language":"en","source_url":"https://github.com/Medium/kew","tags":["javascript","kew","promises"],"install":[{"cmd":"npm install kew","lang":"bash","label":"npm"},{"cmd":"yarn add kew","lang":"bash","label":"yarn"},{"cmd":"pnpm add kew","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"kew is a CommonJS-only library. Attempting to use ESM `import` syntax will result in a `SyntaxError` in Node.js environments unless a transpilation step is used, which is generally not recommended for this abandoned library.","wrong":"import Q from 'kew'","symbol":"Q","correct":"const Q = require('kew')"},{"note":"All core functionality, including the `defer` method, is exposed as properties on the main `Q` object exported by the module. There are no named exports for individual methods.","wrong":"import { defer } from 'kew'","symbol":"defer","correct":"const Q = require('kew'); const deferred = Q.defer();"},{"note":"kew provides its own promise constructor via the `Q` object. It does not export a `Promise` class directly. Modern applications should generally use the native global `Promise` constructor.","wrong":"import { Promise } from 'kew'","symbol":"PromiseConstructor","correct":"const Q = require('kew'); const promise = Q.resolve('value');"}],"quickstart":{"code":"const Q = require('kew');\n\n// 1. Create a promise from a literal value\nconst successPromise = Q.resolve('Hello from kew!');\n\nsuccessPromise.then(function(message) {\n  console.log('Resolved with:', message);\n});\n\n// 2. Create a deferred promise and resolve it later\nconst myDeferred = Q.defer();\n\nsetTimeout(function() {\n  myDeferred.resolve('Delayed success!');\n}, 500);\n\nmyDeferred.promise.then(function(result) {\n  console.log('Deferred resolved with:', result);\n});\n\n// 3. Handle node-style callbacks with makeNodeResolver\nfunction getNodeStyleData(id, callback) {\n  setTimeout(() => {\n    if (id === 1) {\n      callback(null, { id: 1, name: 'Item 1' });\n    } else {\n      callback(new Error('Item not found!'));\n    }\n  }, 200);\n}\n\nconst dataDefer = Q.defer();\ngetNodeStyleData(1, dataDefer.makeNodeResolver());\n\ndataDefer.promise\n  .then(function(obj) {\n    console.log('Node-style callback success:', obj);\n  })\n  .fail(function(e) {\n    console.error('Node-style callback error:', e.message);\n  });\n\nconst errorDefer = Q.defer();\ngetNodeStyleData(2, errorDefer.makeNodeResolver());\n\nerrorDefer.promise\n  .then(function(obj) {\n    console.log('Node-style callback success (should not happen):', obj);\n  })\n  .fail(function(e) {\n    console.error('Node-style callback error (expected):', e.message);\n  });\n","lang":"javascript","description":"Demonstrates `Q.resolve()`, `Q.defer()`, handling deferred promises, and using `makeNodeResolver()` to integrate with Node.js-style callbacks, including error handling."},"warnings":[{"fix":"Thoroughly review kew's documentation and source code to confirm feature availability. For modern applications, consider using native ES6 Promises or actively maintained alternatives.","message":"kew implements only a subset of features found in other promise libraries like Q. Developers migrating from other promise libraries or expecting full Promise A+ compliance may encounter missing functionalities or different behaviors.","severity":"breaking","affected_versions":">=0.5.0"},{"fix":"Migrate to a currently maintained promise library or utilize native ES6 Promises (supported in Node.js v6+).","message":"The kew library is abandoned, with its last release (v0.7.0) several years ago. This means it receives no further updates, bug fixes, or security patches, making it unsuitable for new projects or critical production environments.","severity":"gotcha","affected_versions":">=0.5.0"},{"fix":"For CommonJS projects, use `const Q = require('kew')`. For ESM projects, consider using a different, actively maintained promise library that supports ESM, or native `Promise`.","message":"kew is a CommonJS-only module and does not natively support ES Modules (ESM) `import`/`export` syntax. Attempting to use `import Q from 'kew'` directly in an ESM context will fail.","severity":"gotcha","affected_versions":">=0.5.0"},{"fix":"Wrap kew promise-returning functions with `util.promisify` if necessary, or refactor to use native ES6 Promises for direct `async/await` compatibility.","message":"kew predates modern JavaScript features like `async/await`. While its promises can interoperate with `async/await` if 'promisified' using utility functions (e.g., Node.js `util.promisify`), it does not offer direct support for these constructs, leading to less ergonomic code compared to native promises.","severity":"gotcha","affected_versions":">=0.5.0"},{"fix":"Consider creating a custom `kew.d.ts` file or migrating to a promise library that provides TypeScript support out-of-the-box.","message":"The package does not ship with TypeScript declaration files (.d.ts). This makes it challenging to use in TypeScript projects without manually creating declaration files or resorting to `any` types.","severity":"gotcha","affected_versions":">=0.5.0"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"fix":"Ensure `const Q = require('kew');` is present and correctly scoped before `Q` is used.","cause":"The `kew` library was not correctly imported or its export was not assigned to the `Q` variable.","error":"ReferenceError: Q is not defined"},{"fix":"Access the `Q` object after requiring the module: `const Q = require('kew'); const promise = Q.resolve('value');`","cause":"Attempting to invoke the `kew` module directly as a function (e.g., `new kew()`) instead of accessing its exported `Q` object.","error":"TypeError: kew is not a function"},{"fix":"Use the CommonJS `require` syntax: `const Q = require('kew');`","cause":"Attempting to use ES module `import` syntax (e.g., `import Q from 'kew'`) in a Node.js CommonJS environment.","error":"SyntaxError: Cannot use import statement outside a module"}],"ecosystem":"npm"}