Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report
Generated on Jun 16, 2024 via pnpm

from2 2.3.0

Convenience wrapper for ReadableStream, with an API lifted from "from" and "through2"
Package summary
Share
0
issues
2
licenses
8
MIT
1
ISC
Package created
10 Feb 2014
Version published
15 Aug 2016
Maintainers
2
Total deps
9
Direct deps
2
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
8 Packages, Including:
core-util-is@1.0.3
from2@2.3.0
isarray@1.0.0
process-nextick-args@2.0.1
readable-stream@2.3.8
safe-buffer@5.1.2
string_decoder@1.1.1
util-deprecate@1.0.2

ISC License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
Cannot
hold-liable
Must
include-copyright
include-license
1 Packages, Including:
inherits@2.0.4
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

2
All Dependencies CSV
β“˜ This is a list of from2 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities
inherits2.0.41.98 kBISC
prod
readable-stream2.3.825.14 kBMIT
prod

Visualizations

Frequently Asked Questions

What does from2 do?

From2 is a high-level JavaScript module that aids in creating readable streams with an excellent ability to handle backpressure. Taking its API from 'from' and 'through2', it acts as a convenient wrapper for 'ReadableStream's base class from 'readable-stream'. The primary use of from2 is to generate data on request, effectively managing memory and data flow by adhering to backpressure rules.

How do you use from2?

From2 is easy to use, requiring just a few steps to set up. Once the package is installed, it can be used by importing into a JavaScript file, invoking the from2 function and defining the read(size, next) function which will be called when data is requested from the stream. An example of its usage in code is given below:

var from = require('from2');

function fromString(string) {
  return from(function(size, next) {
    if (string.length <= 0) return next(null, null) // close the stream if there's no more content left

    var chunk = string.slice(0, size) // retrieve a new chunk of text
    string = string.slice(size) // remove it from the string

    next(null, chunk) // emit "chunk" from the stream
  })
}

fromString('hello world').pipe(process.stdout) // pipe "hello world" to stdout

This shows how you can create a readable stream from a string. You can easily modify the fromString function for different uses.

Besides this, from2 also provides shorthand for object mode streams and a way to create a stream constructor for creating similar streams repeatedly, which improves performance.

Where are the from2 docs?

The documentation for the from2 module is present within the README.md file of the module's Git repository (http://github.com/hughsk/from2). The documentation provides essential details about the library, the API, and ways to utilize it, along with code examples. The README.md also includes important notes about the usage of the library and links to related projects. If you are starting with the from2 module, this should be your start point.