Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
A collection of utilities for working with Node.js streams.
Install via npm:
npm install noria
encoding
String (optional) - alias for options.encoding
.objectMode
Boolean (optional) - alias for options.objectMode
.callback
Function - Called after all data has been collected. Takes one
data
parameter.options
Object (optional) - Options passed to the stream.Returns a new Transform
stream that buffers all incoming data and then calls callback(data)
. Or, if
objectMode
is true, data
will be an array containing each object that has
passed through. If encoding
is defined, data
will be converted to a string
before it is passed to callback
.
The options
parameter is identical to that of Node's
Transform stream constructor.
The following will print the contents of a file to the console before writing it to a new location.
fs.createReadStream('liftoff-file.txt')
.pipe(noria.collect('utf8', function(data) {
console.log(data);
}))
.pipe(fs.createWriteStrem('landing-file.txt'));
data
- The data to pass to the stream.options
Object (optional) - Options to pass to the stream.Returns a new
Readable
stream initialized with some arbitrary data. If data
is an array, each
element in the array will be treated as a chunk of data. options.objectMode is
true by default. The options
parameter is identical that of Node's
Readable stream constructor.
// Initializes with one chunk of type String.
noria.init('Colorless green ideas sleep furiously.');
// Initializes with three chunks of various types.
noria.init([42, 'than', {name: 'adams'}]);
// Initializes with one chunk of type Array.
noria.init([['the', 'universe']]);
prefix
Buffer | String (optional) - Data to prepend to the beginning of
the stream.suffix
Buffer | String (optional) - Data to append to the end of
the stream.options
Object (optional) - Options to pass to the stream.Returns a new Transform
stream that wraps the contents of a stream with an arbitrary prefix and suffix.
Either can be omitted by passing null
or by leaving the argument undefined.
The options
parameter is identical to that of Node's
Transform stream constructor.
const fs = require('fs');
fs.createReadStream('elfish-ge.txt')
// Contents: ' are the master programmers, and they '
.pipe(noria.wrap(
'The genes',
'are programming for their lives.'
)).pipe(process.stdout);
// Prints: 'The genes are the master programmers,
// and they are programming for their lives.'
Copyright © 2015 Akim McMath. Licensed under the MIT License.
FAQs
A collection of utilities and Classes for working with Node.js streams
We found that noria demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.