Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

first run at 6.4.0 #225

Merged
merged 4 commits into from
Sep 6, 2016
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# readable-stream

***Node-core v6.3.1 streams for userland*** [![Build Status](https://travis-ci.org/nodejs/readable-stream.svg?branch=master)](https://travis-ci.org/nodejs/readable-stream)
***Node-core v6.4.0 streams for userland*** [![Build Status](https://travis-ci.org/nodejs/readable-stream.svg?branch=master)](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/)
Expand Down
3 changes: 2 additions & 1 deletion build/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ function processFile (inputLoc, out, replacements) {
if (inputLoc.slice(-3) === '.js') {
const transformed = babel.transform(data, {
plugins: [
'transform-es2015-parameters',
'transform-es2015-arrow-functions',
'transform-es2015-block-scoping',
'transform-es2015-template-literals',
Expand Down Expand Up @@ -103,7 +104,7 @@ hyperquest(testlisturl).pipe(bl(function (err, data) {

$('table.files .js-navigation-open').each(function () {
var file = $(this).text()
if (/^test-stream/.test(file) && !/-wrap(?:-encoding)?\.js$/.test(file) && file !== 'test-stream2-httpclient-response-end.js' && file !== 'test-stream-base-no-abort.js')
if (/^test-stream/.test(file) && !/-wrap(?:-encoding)?\.js$/.test(file) && file !== 'test-stream2-httpclient-response-end.js' && file !== 'test-stream-base-no-abort.js' && file !== 'test-stream-preprocess.js')
processTestFile(file)
})
}))
Expand Down
1 change: 1 addition & 0 deletions build/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"babel-plugin-transform-es2015-arrow-functions": "^6.5.2",
"babel-plugin-transform-es2015-block-scoping": "^6.5.0",
"babel-plugin-transform-es2015-for-of": "^6.8.0",
"babel-plugin-transform-es2015-parameters": "^6.11.4",
"babel-plugin-transform-es2015-shorthand-properties": "^6.8.0",
"babel-plugin-transform-es2015-template-literals": "^6.8.0",
"bl": "~0.6.0",
Expand Down
10 changes: 10 additions & 0 deletions build/test-replacements.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ module.exports['test-stream2-transform.js'] = [
module.exports['test-stream2-writable.js'] = [
altForEachImplReplacement
, altForEachUseReplacement
, [
/'latin1',/g,
'\'binary\','
]
]

module.exports['test-stream-big-packet.js'] = [
Expand Down Expand Up @@ -274,3 +278,9 @@ module.exports['test-stream2-readable-from-list.js'] = [
'require(\'../../lib/internal/streams/BufferList\')'
]
]
module.exports['test-stream-writev.js'] = [
[
/'latin1'/g,
`'binary'`
]
]
52 changes: 24 additions & 28 deletions doc/stream.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Stream

Stability: 2 - Stable
> Stability: 2 - Stable

A stream is an abstract interface for working with streaming data in Node.js.
The `stream` module provides a base API that makes it easy to build objects
Expand All @@ -20,7 +20,7 @@ const stream = require('stream');
```

While it is important for all Node.js users to understand how streams works,
the `stream` module itself is most useful for developer's that are creating new
the `stream` module itself is most useful for developers that are creating new
types of stream instances. Developer's who are primarily *consuming* stream
objects will rarely (if ever) have need to use the `stream` module directly.

Expand Down Expand Up @@ -343,7 +343,7 @@ The buffered data will be flushed when either the [`stream.uncork()`][] or
[`stream.end()`][stream-end] methods are called.

The primary intent of `writable.cork()` is to avoid a situation where writing
many small chunks of data to a stream do not cause an backup in the internal
many small chunks of data to a stream do not cause a backup in the internal
buffer that would have an adverse impact on performance. In such situations,
implementations that implement the `writable._writev()` method can perform
buffered writes in a more optimized manner.
Expand Down Expand Up @@ -411,7 +411,7 @@ If the `writable.cork()` method is called multiple times on a stream, the same
number of calls to `writable.uncork()` must be called to flush the buffered
data.

```
```js
stream.cork();
stream.write('some ');
stream.cork();
Expand Down Expand Up @@ -444,7 +444,7 @@ first argument. To reliably detect write errors, add a listener for the
The return value indicates whether the written `chunk` was buffered internally
and the buffer has exceeded the `highWaterMark` configured when the stream was
created. If `false` is returned, further attempts to write data to the stream
should be paused until the `'drain'` event is emitted.
should be paused until the [`'drain'`][] event is emitted.

A Writable stream in object mode will always ignore the `encoding` argument.

Expand Down Expand Up @@ -676,7 +676,7 @@ rr.on('end', () => {

The output of running this script is:

```
```txt
$ node test.js
readable: null
end
Expand Down Expand Up @@ -1262,7 +1262,7 @@ write succeeded.
It is important to note that all calls to `writable.write()` that occur between
the time `writable._write()` is called and the `callback` is called will cause
the written data to be buffered. Once the `callback` is invoked, the stream will
emit a `'drain'` event. If a stream implementation is capable of processing
emit a [`'drain'`][] event. If a stream implementation is capable of processing
multiple chunks of data at once, the `writable._writev()` method should be
implemented.

Expand Down Expand Up @@ -1554,7 +1554,7 @@ class Counter extends Readable {
A [Duplex][] stream is one that implements both [Readable][] and [Writable][],
such as a TCP socket connection.

Because Javascript does not have support for multiple inheritance, the
Because JavaScript does not have support for multiple inheritance, the
`stream.Duplex` class is extended to implement a [Duplex][] stream (as opposed
to extending the `stream.Readable` *and* `stream.Writable` classes).

Expand Down Expand Up @@ -1968,36 +1968,32 @@ readable buffer so there is nothing for a user to consume.
[`'end'`]: #stream_event_end
[`'finish'`]: #stream_event_finish
[`'readable'`]: #stream_event_readable
[`buf.toString(encoding)`]: https://nodejs.org/docs/v6.3.1/api/buffer.html#buffer_buf_tostring_encoding_start_end
[`EventEmitter`]: https://nodejs.org/docs/v6.3.1/api/events.html#events_class_eventemitter
[`process.stderr`]: https://nodejs.org/docs/v6.3.1/api/process.html#process_process_stderr
[`process.stdin`]: https://nodejs.org/docs/v6.3.1/api/process.html#process_process_stdin
[`process.stdout`]: https://nodejs.org/docs/v6.3.1/api/process.html#process_process_stdout
[`EventEmitter`]: https://nodejs.org/docs/v6.4.0/api/events.html#events_class_eventemitter
[`process.stderr`]: https://nodejs.org/docs/v6.4.0/api/process.html#process_process_stderr
[`process.stdin`]: https://nodejs.org/docs/v6.4.0/api/process.html#process_process_stdin
[`process.stdout`]: https://nodejs.org/docs/v6.4.0/api/process.html#process_process_stdout
[`stream.cork()`]: #stream_writable_cork
[`stream.pipe()`]: #stream_readable_pipe_destination_options
[`stream.uncork()`]: #stream_writable_uncork
[`stream.unpipe()`]: #stream_readable_unpipe_destination
[`stream.wrap()`]: #stream_readable_wrap_stream
[`tls.CryptoStream`]: https://nodejs.org/docs/v6.3.1/api/tls.html#tls_class_cryptostream
[API for Stream Consumers]: #stream_api_for_stream_consumers
[API for Stream Implementers]: #stream_api_for_stream_implementers
[child process stdin]: https://nodejs.org/docs/v6.3.1/api/child_process.html#child_process_child_stdin
[child process stdout and stderr]: https://nodejs.org/docs/v6.3.1/api/child_process.html#child_process_child_stdout
[child process stdin]: https://nodejs.org/docs/v6.4.0/api/child_process.html#child_process_child_stdin
[child process stdout and stderr]: https://nodejs.org/docs/v6.4.0/api/child_process.html#child_process_child_stdout
[Compatibility]: #stream_compatibility_with_older_node_js_versions
[crypto]: crypto.html
[Duplex]: #stream_class_stream_duplex
[fs read streams]: https://nodejs.org/docs/v6.3.1/api/fs.html#fs_class_fs_readstream
[fs write streams]: https://nodejs.org/docs/v6.3.1/api/fs.html#fs_class_fs_writestream
[`fs.createReadStream()`]: https://nodejs.org/docs/v6.3.1/api/fs.html#fs_fs_createreadstream_path_options
[`fs.createWriteStream()`]: https://nodejs.org/docs/v6.3.1/api/fs.html#fs_fs_createwritestream_path_options
[`net.Socket`]: https://nodejs.org/docs/v6.3.1/api/net.html#net_class_net_socket
[`zlib.createDeflate()`]: https://nodejs.org/docs/v6.3.1/api/zlib.html#zlib_zlib_createdeflate_options
[HTTP requests, on the client]: https://nodejs.org/docs/v6.3.1/api/http.html#http_class_http_clientrequest
[HTTP responses, on the server]: https://nodejs.org/docs/v6.3.1/api/http.html#http_class_http_serverresponse
[http-incoming-message]: https://nodejs.org/docs/v6.3.1/api/http.html#http_class_http_incomingmessage
[Object mode]: #stream_object_mode
[fs read streams]: https://nodejs.org/docs/v6.4.0/api/fs.html#fs_class_fs_readstream
[fs write streams]: https://nodejs.org/docs/v6.4.0/api/fs.html#fs_class_fs_writestream
[`fs.createReadStream()`]: https://nodejs.org/docs/v6.4.0/api/fs.html#fs_fs_createreadstream_path_options
[`fs.createWriteStream()`]: https://nodejs.org/docs/v6.4.0/api/fs.html#fs_fs_createwritestream_path_options
[`net.Socket`]: https://nodejs.org/docs/v6.4.0/api/net.html#net_class_net_socket
[`zlib.createDeflate()`]: https://nodejs.org/docs/v6.4.0/api/zlib.html#zlib_zlib_createdeflate_options
[HTTP requests, on the client]: https://nodejs.org/docs/v6.4.0/api/http.html#http_class_http_clientrequest
[HTTP responses, on the server]: https://nodejs.org/docs/v6.4.0/api/http.html#http_class_http_serverresponse
[http-incoming-message]: https://nodejs.org/docs/v6.4.0/api/http.html#http_class_http_incomingmessage
[Readable]: #stream_class_stream_readable
[SimpleProtocol v2]: #stream_example_simpleprotocol_parser_v2
[stream-_flush]: #stream_transform_flush_callback
[stream-_read]: #stream_readable_read_size_1
[stream-_transform]: #stream_transform_transform_chunk_encoding_callback
Expand All @@ -2009,7 +2005,7 @@ readable buffer so there is nothing for a user to consume.
[stream-read]: #stream_readable_read_size
[stream-resume]: #stream_readable_resume
[stream-write]: #stream_writable_write_chunk_encoding_callback
[TCP sockets]: https://nodejs.org/docs/v6.3.1/api/net.html#net_class_net_socket
[TCP sockets]: https://nodejs.org/docs/v6.4.0/api/net.html#net_class_net_socket
[Transform]: #stream_class_stream_transform
[Writable]: #stream_class_stream_writable
[zlib]: zlib.html
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"devDependencies": {
"assert": "~1.4.0",
"babel-polyfill": "^6.9.1",
"buffer": "^4.9.0",
"nyc": "^6.4.0",
"tap": "~0.7.1",
"tape": "~4.5.1",
Expand Down
25 changes: 18 additions & 7 deletions test/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,21 @@ util.inherits = require('inherits');

var Timer = { now: function () {} };

var testRoot = path.resolve(process.env.NODE_TEST_DIR || path.dirname(__filename));
var testRoot = process.env.NODE_TEST_DIR ? path.resolve(process.env.NODE_TEST_DIR) : __dirname;

exports.testDir = path.dirname(__filename);
exports.testDir = __dirname;
exports.fixturesDir = path.join(exports.testDir, 'fixtures');
exports.libDir = path.join(exports.testDir, '../lib');
exports.tmpDirName = 'tmp';
exports.PORT = +process.env.NODE_COMMON_PORT || 12346;
exports.isWindows = process.platform === 'win32';
exports.isWOW64 = exports.isWindows && process.env['PROCESSOR_ARCHITEW6432'] !== undefined;
exports.isWOW64 = exports.isWindows && process.env.PROCESSOR_ARCHITEW6432 !== undefined;
exports.isAix = process.platform === 'aix';
exports.isLinuxPPCBE = process.platform === 'linux' && process.arch === 'ppc64' && os.endianness() === 'BE';
exports.isSunOS = process.platform === 'sunos';
exports.isFreeBSD = process.platform === 'freebsd';
exports.isLinux = process.platform === 'linux';
exports.isOSX = process.platform === 'darwin';

exports.enoughTestMem = os.totalmem() > 0x40000000; /* 1 Gb */
exports.rootDir = exports.isWindows ? 'c:\\' : '/';
Expand Down Expand Up @@ -81,7 +83,7 @@ function rmdirSync(p, originalEr) {
} catch (e) {
if (e.code === 'ENOTDIR') throw originalEr;
if (e.code === 'ENOTEMPTY' || e.code === 'EEXIST' || e.code === 'EPERM') {
var enc = process.platform === 'linux' ? 'buffer' : 'utf8';
var enc = exports.isLinux ? 'buffer' : 'utf8';
fs.readdirSync(p, forEach(enc), function (f) {
if (f instanceof Buffer) {
var buf = Buffer.concat([Buffer.from(p), Buffer.from(path.sep), f]);
Expand Down Expand Up @@ -111,7 +113,7 @@ var inFreeBSDJail = null;
var localhostIPv4 = null;

exports.localIPv6Hosts = ['localhost'];
if (process.platform === 'linux') {
if (exports.isLinux) {
exports.localIPv6Hosts = [
// Debian/Ubuntu
'ip6-localhost', 'ip6-loopback',
Expand All @@ -128,7 +130,7 @@ if (process.platform === 'linux') {
get: function () {
if (inFreeBSDJail !== null) return inFreeBSDJail;

if (process.platform === 'freebsd' && child_process.execSync('sysctl -n security.jail.jailed').toString() === '1\n') {
if (exports.isFreeBSD && child_process.execSync('sysctl -n security.jail.jailed').toString() === '1\n') {
inFreeBSDJail = true;
} else {
inFreeBSDJail = false;
Expand Down Expand Up @@ -348,6 +350,15 @@ if (global.Symbol) {
knownGlobals.push(Symbol);
}

function allowGlobals() {
for (var _len = arguments.length, whitelist = Array(_len), _key = 0; _key < _len; _key++) {
whitelist[_key] = arguments[_key];
}

knownGlobals = knownGlobals.concat(whitelist);
}
exports.allowGlobals = allowGlobals;

/*<replacement>*/
if (typeof constructor == 'function') knownGlobals.push(constructor);
if (typeof DTRACE_NET_SOCKET_READ == 'function') knownGlobals.push(DTRACE_NET_SOCKET_READ);
Expand Down Expand Up @@ -479,7 +490,7 @@ exports.nodeProcessAborted = function nodeProcessAborted(exitCode, signal) {

// On Windows, v8's base::OS::Abort triggers an access violation,
// which corresponds to exit code 3221225477 (0xC0000005)
if (process.platform === 'win32') expectedExitCodes = [3221225477];
if (exports.isWindows) expectedExitCodes = [3221225477];

// When using --abort-on-uncaught-exception, V8 will use
// base::OS::Abort to terminate the process.
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-stream-push-order.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ s.read(0);
process.on('exit', function () {
assert.deepStrictEqual(s._readableState.buffer.join(','), '1,2,3,4,5,6');
console.log('ok');
});
});
6 changes: 3 additions & 3 deletions test/parallel/test-stream2-writable.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ test('write bufferize', function (t) {
highWaterMark: 100
});

var encodings = ['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', undefined];
var encodings = ['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', undefined];

tw.on('finish', function () {
t.same(tw.buffer, chunks, 'got the expected chunks');
Expand All @@ -159,7 +159,7 @@ test('write no bufferize', function (t) {
return TestWriter.prototype._write.call(this, chunk, encoding, cb);
};

var encodings = ['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', undefined];
var encodings = ['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', undefined];

tw.on('finish', function () {
t.same(tw.buffer, chunks, 'got the expected chunks');
Expand Down Expand Up @@ -251,7 +251,7 @@ test('encoding should be ignored for buffers', function (t) {
t.end();
};
var buf = bufferShim.from(hex, 'hex');
tw.write(buf, 'binary');
tw.write(buf, 'latin1');
});

test('writables are not pipable', function (t) {
Expand Down