readable-wrap
upgrade streams1 to streams2 streams as a standalone module
Last updated 12 years ago by substack .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install readable-wrap 
SYNC missed versions from official npm registry.

readable-wrap

upgrade streams1 to streams2 streams as a standalone module

This module provides a wrap function based on Readable().wrap() from node core but as a standalone module.

Use this module if you don't want to wait for a patch in node core to land that fixes falsey objectMode values in wrapped readable streams.

build status

testling badge

example

var split = require('split');
var wrap = require('readable-wrap');
var through = require('through2');

process.stdin.pipe(wrap.obj(split())).pipe(through.obj(write));

function write (buf, enc, next) {
    console.log(buf.length + ': ' + buf);
    next();
}

output:

$ echo -e 'one\ntwo\n\nthree' | node example/split.js 
3: one
3: two
0: 
5: three
0: 

In object mode you get the empty lines, which is handy if you need to perform a special action on empty lines such as to partition an HTTP request header from a body in a streaming fashion.

In non-object mode the empty lines get ignored because that is how node core streams work.

methods

var wrap = require('readable-wrap')

var stream = wrap(oldStream, opts)

Return a new streams2 stream based on the streams1 stream oldStream.

The opts will be passed to the underlying readable stream instance.

var stream = wrap.obj(oldStream, opts)

Return a new streams2 stream based on the streams1 stream oldStream with opts.objectMode set to true.

install

With npm do:

npm install readable-wrap

license

MIT

Current Tags

  • 1.0.0                                ...           latest (12 years ago)

1 Versions

  • 1.0.0                                ...           12 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (1)
Dev Dependencies (2)

Copyright 2013 - present © cnpmjs.org | Home |