Registry / http-networking / from2
library2.3.0jsnpmunverified

from2 is a convenience wrapper for Node.js `ReadableStream` (specifically, the `readable-stream` base class), designed to simplify the creation of readable streams while correctly handling backpressure. The current stable version is 2.3.0, published in 2016, indicating the project is likely abandoned or in long-term maintenance with no active development or planned release cadence. It differentiates itself by offering an API inspired by `from` and `through2`, providing `from2.obj` for object mode streams and `from2.ctor` for creating reusable stream constructors, which can improve performance for multiple similar streams. It aims to make stream creation more approachable than direct `ReadableStream` implementation.

npm install from2
INSTALL
IMPORT
SIG · FROM2
F
from2
http-networkingjavascriptv2.3.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

from
const from = require('from2')
import from from 'from2'
from2 is a CommonJS module. Direct ES module `import` syntax will not work without a transpiler or Node.js's experimental CommonJS-to-ESM interop features, which may lead to unexpected behavior or require dynamic `import()`.
from.obj
const from = require('from2'); const objStream = from.obj(...)
import { obj } from 'from2'
`obj` is a property of the default export, not a named export. Attempting to destructure it as a named import will fail.
from.ctor
const from = require('from2'); const StreamConstructor = from.ctor(...)
import { ctor } from 'from2'
Similar to `obj`, `ctor` is a property of the CommonJS default export, not a named export.

This example demonstrates how to create a basic readable stream using `from2` that emits chunks of a given string, handling backpressure appropriately, and then pipes it to standard output.

const from = require('from2'); function fromString(string) { return from(function(size, next) { // if there's no more content // left in the string, close the stream. if (string.length <= 0) return next(null, null); // Pull in a new chunk of text, // removing it from the string. var chunk = string.slice(0, size); string = string.slice(size); // Emit "chunk" from the stream. next(null, chunk); }); } // pipe "hello world" out // to stdout. fromString('hello world').pipe(process.stdout);
Debug
Known issues
gotchaThe package displays an 'experimental' stability badge in its README. While functional, this historically implied that its API or behavior might not be fully stable or guaranteed for long-term production use without potential changes. Given its age, no further stabilization is expected.
fix
Be aware that the API, while stable in its current form, was once considered experimental. Thorough testing is recommended if relying on specific undocumented behaviors.
affects: <=2.3.0
breakingThis package is no longer actively maintained. The last release was over 7 years ago (as of 2026). This means it will not receive updates for new Node.js features, critical bug fixes, or security patches, potentially exposing applications to vulnerabilities or compatibility issues with newer environments.
fix
Evaluate modern stream implementations like Node.js's native `stream.Readable` or newer libraries that are actively maintained. Consider forking the project or implementing custom stream logic if specific `from2` behavior is critical and security/maintenance concerns are addressed internally.
affects: >=2.3.0
gotcha`from2` is built on CommonJS module syntax (`require`). Attempting to use ES module `import` syntax directly in an ESM context will likely fail or require complex interoperability solutions (e.g., dynamic `import()`), as named exports from CJS modules are not directly supported by `import { Name } from 'cjs-module'`.
fix
Always use `const from = require('from2')` for Node.js applications. If you must use `from2` in an ESM context, consider a bundler like Webpack or Rollup, or use `import from2 from 'from2'` (for default export) followed by `from2.obj` or `from2.ctor`. However, the direct `import { obj } from 'from2'` will not work.
affects: >=2.0.0
Errors
Common errors & fixes
TypeError: from2.obj is not a function
Attempting to import `obj` or `ctor` as a named ES module import, e.g., `import { obj } from 'from2'` in an ESM file.
fix
Use CommonJS `require` for `from2` and access properties directly: `const from = require('from2'); const myStream = from.obj(...)`.
Error [ERR_REQUIRE_ESM]: require() of ES Module ... from2.js not supported.
Trying to `require('from2')` from an ES module file (`.mjs` or `type: module` in `package.json`) if a hypothetical future version of from2 were ESM-only, or if a build process incorrectly targets ESM for `from2`. This specific error is unlikely for `from2` itself given its age and CJS nature, but represents a common interop issue.
fix
Ensure your project or build system correctly handles `from2` as a CommonJS module. If you are in an ESM context and cannot avoid `from2`, use dynamic `import('from2')` and then access the default export's properties, e.g., `(await import('from2')).default.obj(...)`. Note that `from2` itself is CJS, so `require` should generally work.
Upgrade
Version history
2.3.0latest on npm
Audit
Dependencies
readable-streamrequiredProvides the underlying ReadableStream base class that from2 wraps. This is a core runtime dependency.
Agent activity
2 hits · last 30 days
node
2
Resources
from2 — npm install from2 · libregistry