{"id":14758,"library":"node-stream","title":"Node-Stream Utilities","description":"Node-Stream is a utility library designed to simplify working with Node.js stream APIs by exposing a collection of array-like methods for consuming, creating, and manipulating streams. Originally aiming to resolve common misunderstandings and misuse of Node's core stream interface, it provides methods like `where`, `sort`, `take`, `stringify`, and `intersperse` that return Streams3 instances. The library was built to work with Node.js versions 0.12 and newer, supporting the Streams3 implementation. However, the package, currently at version 1.7.0, was last published approximately 9 years ago (as of April 2026), indicating it is no longer actively maintained and has been effectively abandoned. While it aimed to offer a more accessible API for Node.js streams, its age means it does not support modern Node.js stream features like `stream.promises` or async iterators, nor does it provide ESM compatibility.","status":"abandoned","version":"1.7.0","language":"javascript","source_language":"en","source_url":"https://github.com/stezu/node-stream","tags":["javascript","streams","consume","create","manipulate","forEach","map","reduce","filter"],"install":[{"cmd":"npm install node-stream","lang":"bash","label":"npm"},{"cmd":"yarn add node-stream","lang":"bash","label":"yarn"},{"cmd":"pnpm add node-stream","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package is CommonJS only and does not support ESM import syntax. Attempting to use `import` will result in an error.","wrong":"import nodeStream from 'node-stream';","symbol":"nodeStream","correct":"const nodeStream = require('node-stream');"},{"note":"Individual utility functions are exposed as properties on the main module export. This package is CommonJS only.","wrong":"import { where } from 'node-stream';","symbol":"where","correct":"const { where } = require('node-stream');"},{"note":"Access specific methods by destructuring the `require` call or as properties on the `nodeStream` object. ESM imports are not supported.","wrong":"import { take } from 'node-stream';","symbol":"take","correct":"const { take } = require('node-stream');"}],"quickstart":{"code":"const nodeStream = require('node-stream');\nconst { Readable } = require('stream');\n\n// Mock a database read stream for demonstration purposes\nconst mockData = [\n  { id: 1, type: 'post', author: 'stezu', content: 'First post' },\n  { id: 2, type: 'comment', author: 'guest', content: 'Nice one!' },\n  { id: 3, type: 'post', author: 'stezu', content: 'Second post' },\n  { id: 4, type: 'post', author: 'other', content: 'Another post' },\n  { id: 5, type: 'post', author: 'stezu', content: 'Third post' },\n  { id: 6, type: 'post', author: 'stezu', content: 'Fourth post' },\n  { id: 7, type: 'post', author: 'stezu', content: 'Fifth post' }\n];\n\nconst db = {\n  createReadStream: () => {\n    let index = 0;\n    return new Readable({\n      objectMode: true,\n      read() {\n        if (index < mockData.length) {\n          this.push(mockData[index++]);\n        } else {\n          this.push(null);\n        }\n      }\n    });\n  }\n};\n\n// Get the 5 most recent posts by stezu\ndb.createReadStream()\n  .pipe(nodeStream.where({ type: 'post', author: 'stezu' }))\n  .pipe(nodeStream.sort((a, b) => a.id < b.id ? 1 : -1)) // Sort descending by ID for 'most recent'\n  .pipe(nodeStream.take(5))\n  .pipe(nodeStream.stringify()) // Convert objects to JSON strings\n  .pipe(nodeStream.intersperse('\\n')) // Add newlines between items\n  .pipe(process.stdout);","lang":"javascript","description":"This quickstart demonstrates piping a mock readable stream through several `node-stream` utility functions to filter, sort, limit, and format data, finally writing it to standard output. It simulates fetching the 5 most recent posts by a specific author."},"warnings":[{"fix":"Use `const nodeStream = require('node-stream');` for all imports. For projects requiring ESM, consider alternative stream utility libraries that are actively maintained.","message":"This package is CommonJS-only and does not natively support ECMAScript Modules (ESM) `import` syntax. Attempting to use `import` will cause `ERR_REQUIRE_ESM` or similar errors in modern Node.js environments configured for ESM.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Migrate to actively maintained stream utility libraries or leverage native Node.js stream capabilities, especially the `stream.promises` API and async iterators for modern asynchronous control flow.","message":"The `node-stream` package is effectively abandoned, with its last update occurring approximately 9 years ago. This means it receives no further bug fixes, security patches, or feature enhancements. Using it in production applications poses significant risks, including potential security vulnerabilities and incompatibility with future Node.js versions or modern stream patterns (e.g., `async/await` with streams).","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Review Node.js's native `node:stream` module documentation for current best practices, especially the `stream.pipeline` and `stream.promises` APIs for modern asynchronous stream composition and error management.","message":"Designed for Node.js 0.12+ and Streams3, this library predates many significant advancements in Node.js stream handling, such as `stream.pipeline` for robust error handling, `stream.finished`, and built-in support for `async iterators`. Its API may feel less ergonomic compared to modern approaches, and it lacks direct compatibility with newer stream features, potentially leading to increased boilerplate or inefficient patterns.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Change your import statement to `const nodeStream = require('node-stream');` or ensure your project's `package.json` specifies `\"type\": \"module\"` and handle CJS interop carefully.","cause":"Attempting to use `import` syntax in a CommonJS module context or a Node.js project not configured for ESM.","error":"SyntaxError: Cannot use import statement outside a module"},{"fix":"Use CommonJS `require` to import the module and access its properties: `const nodeStream = require('node-stream');` then `nodeStream.where(...)` or `const { where } = require('node-stream');`.","cause":"This error often occurs when a CommonJS module, which exports an object, is incorrectly imported using an ESM named import syntax (e.g., `import { where } from 'node-stream';`). The bundler or runtime tries to destructure a non-existent export.","error":"TypeError: (0 , node_stream_1.where) is not a function"},{"fix":"Ensure that `db` is defined and has a `createReadStream` method that returns a readable stream, or replace it with a standard `fs.createReadStream` or a mock as shown in the quickstart example.","cause":"The quickstart example assumes the existence of a `db` object with a `createReadStream` method. If you run the code without a proper mock or an actual database connection, this error will occur.","error":"TypeError: db.createReadStream is not a function"}],"ecosystem":"npm"}