Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
language: node_js
node_js:
- "0.8"
- "0.10"
- "0.11"
- "0.12"
- "iojs"
27 changes: 23 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,33 @@

***Node-core streams for userland***


[![Build Status](https://travis-ci.org/nodejs/readable-stream.svg)](https://travis-ci.org/nodejs/readable-stream)
[![NPM](https://nodei.co/npm/readable-stream.png?downloads=true&downloadRank=true)](https://nodei.co/npm/readable-stream/)
[![NPM](https://nodei.co/npm-dl/readable-stream.png?&months=6&height=3)](https://nodei.co/npm/readable-stream/)

This package is a mirror of the Streams2 and Streams3 implementations in Node-core.
```bash
npm install --save readable-stream
```

***Node-core streams for userland***

This package is a mirror of the Streams2 and Streams3 implementations in
Node-core.

If you want to guarantee a stable streams base, regardless of what version of Node you, or the users of your libraries are using, use **readable-stream** *only* and avoid the *"stream"* module in Node-core.
If you want to guarantee a stable streams base, regardless of what version of
Node you, or the users of your libraries are using, use **readable-stream** *only* and avoid the *"stream"* module in Node-core.

**readable-stream** comes in two major versions, v1.0.x and v1.1.x. The former tracks the Streams2 implementation in Node 0.10, including bug-fixes and minor improvements as they are added. The latter tracks Streams3 as it develops in Node 0.11; we will likely see a v1.2.x branch for Node 0.12.
As of version 2.0.0 **readable-stream** uses semantic versioning.

**readable-stream** uses proper patch-level versioning so if you pin to `"~1.0.0"` you’ll get the latest Node 0.10 Streams2 implementation, including any fixes and minor non-breaking improvements. The patch-level versions of 1.0.x and 1.1.x should mirror the patch-level versions of Node-core releases. You should prefer the **1.0.x** releases for now and when you’re ready to start using Streams3, pin to `"~1.1.0"`
# Streams WG Team Members

* **Chris Dickinson** ([@chrisdickinson](https://github.com/chrisdickinson)) <christopher.s.dickinson@gmail.com>
- Release GPG key: 9554F04D7259F04124DE6B476D5A82AC7E37093B
* **Calvin Metcalf** ([@calvinmetcalf](https://github.com/calvinmetcalf)) $lt;calvin.metcalf@gmail.com@gt;
- Release GPG key: F3EF5F62A87FC27A22E643F714CE4FF5015AA242
* **Rod Vagg** ([@rvagg](https://github.com/rvagg)) <rod@vagg.org>
- Release GPG key: DD8F2338BAE7501E3DD5AC78C273792F7D83545D
* **Sam Newman** ([@sonewman](https://github.com/sonewman)) <newmansam@outlook.com>
* **Mathias Buus** ([@mafintosh](https://github.com/mafintosh)) <mathiasbuus@gmail.com>
* **Domenic Denicola** ([@domenic](https://github.com/domenic)) <d@domenic.me>
4 changes: 2 additions & 2 deletions build/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ const hyperquest = require('hyperzip')(require('hyperdirect'))
, files = require('./files')
, testReplace = require('./test-replacements')

, srcurlpfx = 'https://raw.githubusercontent.com/iojs/io.js/v' + process.argv[2] + '-release/'
, srcurlpfx = 'https://raw.githubusercontent.com/nodejs/io.js/v' + process.argv[2] + '/'
, libsrcurl = srcurlpfx + 'lib/'
, testsrcurl = srcurlpfx + 'test/parallel/'
, testlisturl = 'https://github.com/iojs/io.js/tree/v' + process.argv[2] + '-release/test/parallel'
, testlisturl = 'https://github.com/nodejs/io.js/tree/v' + process.argv[2] + '/test/parallel'
, libourroot = path.join(__dirname, '../lib/')
, testourroot = path.join(__dirname, '../test/parallel/')

Expand Down
63 changes: 57 additions & 6 deletions build/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,28 +98,69 @@ const headRegexp = /(^module.exports = \w+;?)/m
+ 'if (!EE.listenerCount) EE.listenerCount = function(emitter, type) {\n'
+ ' return emitter.listeners(type).length;\n'
+ '};\n/*</replacement>*/\n'
]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dcousens the changes to this file is the meat of the update, most of the other changes are consequences of this


, constReplacement = [
/const/g
, 'var'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this replaces all the uses of const with var for compatibility reasons

]

, bufferIsEncodingReplacement = [
/Buffer.isEncoding\((\w+)\)/
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replaces a single instance of Buffer.isEncoding with a manual check due to older versions of node not having the method

, '([\'hex\', \'utf8\', \'utf-8\', \'ascii\', \'binary\', \'base64\',\n'
+ '\'ucs2\', \'ucs-2\',\'utf16le\', \'utf-16le\', \'raw\']\n'
+ '.indexOf(($1 + \'\').toLowerCase()) > -1)'
]

, requireStreamReplacement = [
/var Stream = require\('stream'\);/
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great pains are made to make sure readableStream instanceof nativeStream is true, this avoids bundling the streams module unless it's already included.

In other words since you can't readableStream instanceof nativeStream without first doing var nativeStream = require('stream'); we only need to inherit from native streams if it's already bundled.

, '\n\n/*<replacement>*/\n'
+ 'var Stream;\n (function (){try{\n'
+ 'Stream = require(\'st\' + \'ream\');\n'
+ '}catch(_){Stream = require(\'events\').EventEmitter;}}())'
+ '\n/*</replacement>*/\n'
]

, isBufferReplacement = [
/(\w+) instanceof Buffer/
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

buffer instanceof Buffer doesn't work in the browser, so replaced with Buffer.isBuffer

, 'Buffer.isBuffer($1)'
]

, processNextTickImport = [
headRegexp
, '$1\n\n/*<replacement>*/\nvar processNextTick = require(\'process-nextick-args\');\n/*</replacement>*/\n'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these next 2 changes deal with process.nextTick which was updated to accept arguments

]

, processNextTickReplacement = [
/process.nextTick\(/g
, 'processNextTick('
]

module.exports['_stream_duplex.js'] = [
requireReplacement
constReplacement
, requireReplacement
, instanceofReplacement
, utilReplacement
, stringDecoderReplacement
, altForEachImplReplacement
, altForEachUseReplacement
, objectKeysReplacement
, objectKeysDefine
, processNextTickImport
, processNextTickReplacement
]

module.exports['_stream_passthrough.js'] = [
requireReplacement
constReplacement
, requireReplacement
, instanceofReplacement
, utilReplacement
, stringDecoderReplacement
]

module.exports['_stream_readable.js'] = [
addDuplexRequire
constReplacement
, addDuplexRequire
, requireReplacement
, instanceofReplacement
, bufferReplacement
Expand All @@ -134,20 +175,25 @@ module.exports['_stream_readable.js'] = [
, debugLogReplacement
, utilReplacement
, stringDecoderReplacement
, debugLogReplacement
, eventEmittterReplacement
, requireStreamReplacement
, isBufferReplacement
, processNextTickImport
, processNextTickReplacement

]

module.exports['_stream_transform.js'] = [
requireReplacement
constReplacement
, requireReplacement
, instanceofReplacement
, utilReplacement
, stringDecoderReplacement
]

module.exports['_stream_writable.js'] = [
addDuplexRequire
constReplacement
, addDuplexRequire
, requireReplacement
, instanceofReplacement
, bufferReplacement
Expand All @@ -156,5 +202,10 @@ module.exports['_stream_writable.js'] = [
, debugLogReplacement
, deprecateReplacement
, objectDefinePropertyReplacement
, bufferIsEncodingReplacement
, [ /^var assert = require\('assert'\);$/m, '' ]
, requireStreamReplacement
, isBufferReplacement
, processNextTickImport
, processNextTickReplacement
]
17 changes: 15 additions & 2 deletions build/test-replacements.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,21 +76,27 @@ module.exports['common.js'] = [
]

// for streams2 on node 0.11
// and dtrace in 0.10
, [
/^( for \(var x in global\) \{|function leakedGlobals\(\) \{)$/m
, ' /*<replacement>*/\n'
+ ' if (typeof constructor == \'function\')\n'
+ ' knownGlobals.push(constructor);\n'
+ ' if (typeof DTRACE_NET_SOCKET_READ == \'function\')\n'
+ ' knownGlobals.push(DTRACE_NET_SOCKET_READ);\n'
+ ' if (typeof DTRACE_NET_SOCKET_WRITE == \'function\')\n'
+ ' knownGlobals.push(DTRACE_NET_SOCKET_WRITE);\n'
+ ' /*</replacement>*/\n\n$1'
]

// for node 0.8
, [
/$/
/^/
, '/*<replacement>*/'
+ '\nif (!global.setImmediate) {\n'
+ ' global.setImmediate = function setImmediate(fn) {\n'
+ ' return setTimeout(fn, 0);\n'

+ ' return setTimeout(fn.bind.apply(fn, arguments), 0);\n'
+ ' };\n'
+ '}\n'
+ 'if (!global.clearImmediate) {\n'
Expand Down Expand Up @@ -144,3 +150,10 @@ module.exports['test-stream2-stderr-sync.js'] = [
+ ' return console.error(\'child 0\\nfoo\\nbar\\nbaz\');\n'
]
]

module.exports['test-stream-unshift-read-race.js'] = [
[
/data\.slice\(pos, pos \+ n\)/g,
'data.slice(pos, Math.min(pos + n, data.length))'
]
]
15 changes: 0 additions & 15 deletions examples/typer-fsr.js

This file was deleted.

Loading