0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-25 08:19:38 +01:00
nodejs/test/parallel/test-stream-transform-constructor-set-methods.js
Sam Newman 50daee7243 stream: simpler stream constructon
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>
2015-02-04 20:19:39 -08:00

32 lines
568 B
JavaScript

var common = require('../common');
var assert = require('assert');
var Transform = require('stream').Transform;
var _transformCalled = false;
function _transform(d, e, n) {
_transformCalled = true;
n();
}
var _flushCalled = false;
function _flush(n) {
_flushCalled = true;
n();
}
var t = new Transform({
transform: _transform,
flush: _flush
});
t.end(new Buffer('blerg'));
t.resume();
process.on('exit', function () {
assert.equal(t._transform, _transform);
assert.equal(t._flush, _flush);
assert(_transformCalled);
assert(_flushCalled);
});