mirror of
https://github.com/nodejs/node.git
synced 2024-11-25 08:19:38 +01:00
50daee7243
Adds simplified constructor pattern, allowing users to provide "read", "write", "transform", "flush", and "writev" functions as stream options in lieu of subclassing. Semver: minor PR-URL: https://github.com/iojs/io.js/pull/697 Fixes: https://github.com/iojs/readable-stream/issues/102 Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
19 lines
345 B
JavaScript
19 lines
345 B
JavaScript
var common = require('../common');
|
|
var assert = require('assert');
|
|
|
|
var Readable = require('stream').Readable;
|
|
|
|
var _readCalled = false;
|
|
function _read(n) {
|
|
_readCalled = true;
|
|
this.push(null);
|
|
}
|
|
|
|
var r = new Readable({ read: _read });
|
|
r.resume();
|
|
|
|
process.on('exit', function () {
|
|
assert.equal(r._read, _read);
|
|
assert(_readCalled);
|
|
});
|