Skip to content

Commit 90bf802

Browse files
committed
fist run at 6.4.0
1 parent 7ca6e8e commit 90bf802

File tree

9 files changed

+109
-42
lines changed

9 files changed

+109
-42
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# readable-stream
22

3-
***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)
3+
***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)
44

55

66
[![NPM](https://nodei.co/npm/readable-stream.png?downloads=true&downloadRank=true)](https://nodei.co/npm/readable-stream/)

build/build.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ function processFile (inputLoc, out, replacements) {
5050
if (inputLoc.slice(-3) === '.js') {
5151
const transformed = babel.transform(data, {
5252
plugins: [
53+
'transform-es2015-parameters',
5354
'transform-es2015-arrow-functions',
5455
'transform-es2015-block-scoping',
5556
'transform-es2015-template-literals',

build/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"babel-plugin-transform-es2015-arrow-functions": "^6.5.2",
99
"babel-plugin-transform-es2015-block-scoping": "^6.5.0",
1010
"babel-plugin-transform-es2015-for-of": "^6.8.0",
11+
"babel-plugin-transform-es2015-parameters": "^6.11.4",
1112
"babel-plugin-transform-es2015-shorthand-properties": "^6.8.0",
1213
"babel-plugin-transform-es2015-template-literals": "^6.8.0",
1314
"bl": "~0.6.0",

doc/stream.md

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Stream
22

3-
Stability: 2 - Stable
3+
> Stability: 2 - Stable
44
55
A stream is an abstract interface for working with streaming data in Node.js.
66
The `stream` module provides a base API that makes it easy to build objects
@@ -20,7 +20,7 @@ const stream = require('stream');
2020
```
2121

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

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

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

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

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

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

677677
The output of running this script is:
678678

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

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

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

@@ -1968,36 +1968,32 @@ readable buffer so there is nothing for a user to consume.
19681968
[`'end'`]: #stream_event_end
19691969
[`'finish'`]: #stream_event_finish
19701970
[`'readable'`]: #stream_event_readable
1971-
[`buf.toString(encoding)`]: https://nodejs.org/docs/v6.3.1/api/buffer.html#buffer_buf_tostring_encoding_start_end
1972-
[`EventEmitter`]: https://nodejs.org/docs/v6.3.1/api/events.html#events_class_eventemitter
1973-
[`process.stderr`]: https://nodejs.org/docs/v6.3.1/api/process.html#process_process_stderr
1974-
[`process.stdin`]: https://nodejs.org/docs/v6.3.1/api/process.html#process_process_stdin
1975-
[`process.stdout`]: https://nodejs.org/docs/v6.3.1/api/process.html#process_process_stdout
1971+
[`EventEmitter`]: https://nodejs.org/docs/v6.4.0/api/events.html#events_class_eventemitter
1972+
[`process.stderr`]: https://nodejs.org/docs/v6.4.0/api/process.html#process_process_stderr
1973+
[`process.stdin`]: https://nodejs.org/docs/v6.4.0/api/process.html#process_process_stdin
1974+
[`process.stdout`]: https://nodejs.org/docs/v6.4.0/api/process.html#process_process_stdout
19761975
[`stream.cork()`]: #stream_writable_cork
19771976
[`stream.pipe()`]: #stream_readable_pipe_destination_options
19781977
[`stream.uncork()`]: #stream_writable_uncork
19791978
[`stream.unpipe()`]: #stream_readable_unpipe_destination
19801979
[`stream.wrap()`]: #stream_readable_wrap_stream
1981-
[`tls.CryptoStream`]: https://nodejs.org/docs/v6.3.1/api/tls.html#tls_class_cryptostream
19821980
[API for Stream Consumers]: #stream_api_for_stream_consumers
19831981
[API for Stream Implementers]: #stream_api_for_stream_implementers
1984-
[child process stdin]: https://nodejs.org/docs/v6.3.1/api/child_process.html#child_process_child_stdin
1985-
[child process stdout and stderr]: https://nodejs.org/docs/v6.3.1/api/child_process.html#child_process_child_stdout
1982+
[child process stdin]: https://nodejs.org/docs/v6.4.0/api/child_process.html#child_process_child_stdin
1983+
[child process stdout and stderr]: https://nodejs.org/docs/v6.4.0/api/child_process.html#child_process_child_stdout
19861984
[Compatibility]: #stream_compatibility_with_older_node_js_versions
19871985
[crypto]: crypto.html
19881986
[Duplex]: #stream_class_stream_duplex
1989-
[fs read streams]: https://nodejs.org/docs/v6.3.1/api/fs.html#fs_class_fs_readstream
1990-
[fs write streams]: https://nodejs.org/docs/v6.3.1/api/fs.html#fs_class_fs_writestream
1991-
[`fs.createReadStream()`]: https://nodejs.org/docs/v6.3.1/api/fs.html#fs_fs_createreadstream_path_options
1992-
[`fs.createWriteStream()`]: https://nodejs.org/docs/v6.3.1/api/fs.html#fs_fs_createwritestream_path_options
1993-
[`net.Socket`]: https://nodejs.org/docs/v6.3.1/api/net.html#net_class_net_socket
1994-
[`zlib.createDeflate()`]: https://nodejs.org/docs/v6.3.1/api/zlib.html#zlib_zlib_createdeflate_options
1995-
[HTTP requests, on the client]: https://nodejs.org/docs/v6.3.1/api/http.html#http_class_http_clientrequest
1996-
[HTTP responses, on the server]: https://nodejs.org/docs/v6.3.1/api/http.html#http_class_http_serverresponse
1997-
[http-incoming-message]: https://nodejs.org/docs/v6.3.1/api/http.html#http_class_http_incomingmessage
1998-
[Object mode]: #stream_object_mode
1987+
[fs read streams]: https://nodejs.org/docs/v6.4.0/api/fs.html#fs_class_fs_readstream
1988+
[fs write streams]: https://nodejs.org/docs/v6.4.0/api/fs.html#fs_class_fs_writestream
1989+
[`fs.createReadStream()`]: https://nodejs.org/docs/v6.4.0/api/fs.html#fs_fs_createreadstream_path_options
1990+
[`fs.createWriteStream()`]: https://nodejs.org/docs/v6.4.0/api/fs.html#fs_fs_createwritestream_path_options
1991+
[`net.Socket`]: https://nodejs.org/docs/v6.4.0/api/net.html#net_class_net_socket
1992+
[`zlib.createDeflate()`]: https://nodejs.org/docs/v6.4.0/api/zlib.html#zlib_zlib_createdeflate_options
1993+
[HTTP requests, on the client]: https://nodejs.org/docs/v6.4.0/api/http.html#http_class_http_clientrequest
1994+
[HTTP responses, on the server]: https://nodejs.org/docs/v6.4.0/api/http.html#http_class_http_serverresponse
1995+
[http-incoming-message]: https://nodejs.org/docs/v6.4.0/api/http.html#http_class_http_incomingmessage
19991996
[Readable]: #stream_class_stream_readable
2000-
[SimpleProtocol v2]: #stream_example_simpleprotocol_parser_v2
20011997
[stream-_flush]: #stream_transform_flush_callback
20021998
[stream-_read]: #stream_readable_read_size_1
20031999
[stream-_transform]: #stream_transform_transform_chunk_encoding_callback
@@ -2009,7 +2005,7 @@ readable buffer so there is nothing for a user to consume.
20092005
[stream-read]: #stream_readable_read_size
20102006
[stream-resume]: #stream_readable_resume
20112007
[stream-write]: #stream_writable_write_chunk_encoding_callback
2012-
[TCP sockets]: https://nodejs.org/docs/v6.3.1/api/net.html#net_class_net_socket
2008+
[TCP sockets]: https://nodejs.org/docs/v6.4.0/api/net.html#net_class_net_socket
20132009
[Transform]: #stream_class_stream_transform
20142010
[Writable]: #stream_class_stream_writable
20152011
[zlib]: zlib.html

test/common.js

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,21 @@ util.inherits = require('inherits');
4141

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

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

46-
exports.testDir = path.dirname(__filename);
46+
exports.testDir = __dirname;
4747
exports.fixturesDir = path.join(exports.testDir, 'fixtures');
4848
exports.libDir = path.join(exports.testDir, '../lib');
4949
exports.tmpDirName = 'tmp';
5050
exports.PORT = +process.env.NODE_COMMON_PORT || 12346;
5151
exports.isWindows = process.platform === 'win32';
52-
exports.isWOW64 = exports.isWindows && process.env['PROCESSOR_ARCHITEW6432'] !== undefined;
52+
exports.isWOW64 = exports.isWindows && process.env.PROCESSOR_ARCHITEW6432 !== undefined;
5353
exports.isAix = process.platform === 'aix';
5454
exports.isLinuxPPCBE = process.platform === 'linux' && process.arch === 'ppc64' && os.endianness() === 'BE';
5555
exports.isSunOS = process.platform === 'sunos';
5656
exports.isFreeBSD = process.platform === 'freebsd';
57+
exports.isLinux = process.platform === 'linux';
58+
exports.isOSX = process.platform === 'darwin';
5759

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

113115
exports.localIPv6Hosts = ['localhost'];
114-
if (process.platform === 'linux') {
116+
if (exports.isLinux) {
115117
exports.localIPv6Hosts = [
116118
// Debian/Ubuntu
117119
'ip6-localhost', 'ip6-loopback',
@@ -128,7 +130,7 @@ if (process.platform === 'linux') {
128130
get: function () {
129131
if (inFreeBSDJail !== null) return inFreeBSDJail;
130132

131-
if (process.platform === 'freebsd' && child_process.execSync('sysctl -n security.jail.jailed').toString() === '1\n') {
133+
if (exports.isFreeBSD && child_process.execSync('sysctl -n security.jail.jailed').toString() === '1\n') {
132134
inFreeBSDJail = true;
133135
} else {
134136
inFreeBSDJail = false;
@@ -348,6 +350,15 @@ if (global.Symbol) {
348350
knownGlobals.push(Symbol);
349351
}
350352

353+
function allowGlobals() {
354+
for (var _len = arguments.length, whitelist = Array(_len), _key = 0; _key < _len; _key++) {
355+
whitelist[_key] = arguments[_key];
356+
}
357+
358+
knownGlobals = knownGlobals.concat(whitelist);
359+
}
360+
exports.allowGlobals = allowGlobals;
361+
351362
/*<replacement>*/
352363
if (typeof constructor == 'function') knownGlobals.push(constructor);
353364
if (typeof DTRACE_NET_SOCKET_READ == 'function') knownGlobals.push(DTRACE_NET_SOCKET_READ);
@@ -479,7 +490,7 @@ exports.nodeProcessAborted = function nodeProcessAborted(exitCode, signal) {
479490

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

484495
// When using --abort-on-uncaught-exception, V8 will use
485496
// base::OS::Abort to terminate the process.
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*<replacement>*/
2+
var bufferShim = require('buffer-shims');
3+
/*</replacement>*/
4+
var common = require('../common');
5+
var assert = require('assert/');
6+
7+
var fs = require('fs');
8+
var path = require('path');
9+
var rl = require('readline');
10+
11+
var BOM = '\uFEFF';
12+
13+
// Get the data using a non-stream way to compare with the streamed data.
14+
var modelData = fs.readFileSync(path.join(common.fixturesDir, 'file-to-read-without-bom.txt'), 'utf8');
15+
var modelDataFirstCharacter = modelData[0];
16+
17+
// Detect the number of forthcoming 'line' events for mustCall() 'expected' arg.
18+
var lineCount = modelData.match(/\n/g).length;
19+
20+
// Ensure both without-bom and with-bom test files are textwise equal.
21+
assert.strictEqual(fs.readFileSync(path.join(common.fixturesDir, 'file-to-read-with-bom.txt'), 'utf8'), '' + BOM + modelData);
22+
23+
// An unjustified BOM stripping with a non-BOM character unshifted to a stream.
24+
var inputWithoutBOM = fs.createReadStream(path.join(common.fixturesDir, 'file-to-read-without-bom.txt'), 'utf8');
25+
26+
inputWithoutBOM.once('readable', common.mustCall(function () {
27+
var maybeBOM = inputWithoutBOM.read(1);
28+
assert.strictEqual(maybeBOM, modelDataFirstCharacter);
29+
assert.notStrictEqual(maybeBOM, BOM);
30+
31+
inputWithoutBOM.unshift(maybeBOM);
32+
33+
var streamedData = '';
34+
rl.createInterface({
35+
input: inputWithoutBOM
36+
}).on('line', common.mustCall(function (line) {
37+
streamedData += line + '\n';
38+
}, lineCount)).on('close', common.mustCall(function () {
39+
assert.strictEqual(streamedData, modelData);
40+
}));
41+
}));
42+
43+
// A justified BOM stripping.
44+
var inputWithBOM = fs.createReadStream(path.join(common.fixturesDir, 'file-to-read-with-bom.txt'), 'utf8');
45+
46+
inputWithBOM.once('readable', common.mustCall(function () {
47+
var maybeBOM = inputWithBOM.read(1);
48+
assert.strictEqual(maybeBOM, BOM);
49+
50+
var streamedData = '';
51+
rl.createInterface({
52+
input: inputWithBOM
53+
}).on('line', common.mustCall(function (line) {
54+
streamedData += line + '\n';
55+
}, lineCount)).on('close', common.mustCall(function () {
56+
assert.strictEqual(streamedData, modelData);
57+
}));
58+
}));

test/parallel/test-stream-push-order.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ s.read(0);
3030
process.on('exit', function () {
3131
assert.deepStrictEqual(s._readableState.buffer.join(','), '1,2,3,4,5,6');
3232
console.log('ok');
33-
});
33+
});

test/parallel/test-stream-writev.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ function test(decode, uncork, multi, next) {
4646
chunk: [119, 111, 114, 108, 100] }, { encoding: 'buffer',
4747
chunk: [33] }, { encoding: 'buffer',
4848
chunk: [10, 97, 110, 100, 32, 116, 104, 101, 110, 46, 46, 46] }, { encoding: 'buffer',
49-
chunk: [250, 206, 190, 167, 222, 173, 190, 239, 222, 202, 251, 173] }] : [{ encoding: 'ascii', chunk: 'hello, ' }, { encoding: 'utf8', chunk: 'world' }, { encoding: 'buffer', chunk: [33] }, { encoding: 'binary', chunk: '\nand then...' }, { encoding: 'hex', chunk: 'facebea7deadbeefdecafbad' }];
49+
chunk: [250, 206, 190, 167, 222, 173, 190, 239, 222, 202, 251, 173] }] : [{ encoding: 'ascii', chunk: 'hello, ' }, { encoding: 'utf8', chunk: 'world' }, { encoding: 'buffer', chunk: [33] }, { encoding: 'latin1', chunk: '\nand then...' }, { encoding: 'hex', chunk: 'facebea7deadbeefdecafbad' }];
5050

5151
var actualChunks;
5252
w._writev = function (chunks, cb) {
@@ -66,7 +66,7 @@ function test(decode, uncork, multi, next) {
6666
if (multi) w.cork();
6767

6868
w.write(bufferShim.from('!'), 'buffer', cnt('!'));
69-
w.write('\nand then...', 'binary', cnt('and then'));
69+
w.write('\nand then...', 'latin1', cnt('and then'));
7070

7171
if (multi) w.uncork();
7272

test/parallel/test-stream2-writable.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ test('write bufferize', function (t) {
133133
highWaterMark: 100
134134
});
135135

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

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

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

164164
tw.on('finish', function () {
165165
t.same(tw.buffer, chunks, 'got the expected chunks');
@@ -251,7 +251,7 @@ test('encoding should be ignored for buffers', function (t) {
251251
t.end();
252252
};
253253
var buf = bufferShim.from(hex, 'hex');
254-
tw.write(buf, 'binary');
254+
tw.write(buf, 'latin1');
255255
});
256256

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

0 commit comments

Comments
 (0)