2015-05-19 13:00:06 +02:00
|
|
|
'use strict';
|
2017-05-04 15:33:14 +02:00
|
|
|
const common = require('../common');
|
2015-02-03 01:12:41 +00:00
|
|
|
|
2020-02-22 12:28:26 +01:00
|
|
|
const assert = require('assert');
|
2018-02-16 15:46:48 +01:00
|
|
|
const { Transform } = require('stream');
|
2015-02-03 01:12:41 +00:00
|
|
|
|
2018-02-16 12:53:34 +01:00
|
|
|
const t = new Transform();
|
|
|
|
|
2020-02-22 12:28:26 +01:00
|
|
|
assert.throws(
|
|
|
|
() => {
|
|
|
|
t.end(Buffer.from('blerg'));
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Error',
|
|
|
|
code: 'ERR_METHOD_NOT_IMPLEMENTED',
|
|
|
|
message: 'The _transform() method is not implemented'
|
|
|
|
}
|
|
|
|
);
|
2018-02-16 12:53:34 +01:00
|
|
|
|
2018-02-16 15:46:48 +01:00
|
|
|
const _transform = common.mustCall((chunk, _, next) => {
|
|
|
|
next();
|
2017-05-04 15:33:14 +02:00
|
|
|
});
|
2015-02-03 01:12:41 +00:00
|
|
|
|
2018-02-16 15:46:48 +01:00
|
|
|
const _final = common.mustCall((next) => {
|
|
|
|
next();
|
2017-05-04 15:33:14 +02:00
|
|
|
});
|
|
|
|
|
2018-02-16 15:46:48 +01:00
|
|
|
const _flush = common.mustCall((next) => {
|
|
|
|
next();
|
2017-05-04 15:33:14 +02:00
|
|
|
});
|
2015-02-03 01:12:41 +00:00
|
|
|
|
2018-02-16 12:53:34 +01:00
|
|
|
const t2 = new Transform({
|
2015-02-03 01:12:41 +00:00
|
|
|
transform: _transform,
|
2017-05-04 15:33:14 +02:00
|
|
|
flush: _flush,
|
|
|
|
final: _final
|
2015-02-03 01:12:41 +00:00
|
|
|
});
|
|
|
|
|
2020-02-22 12:28:26 +01:00
|
|
|
assert.strictEqual(t2._transform, _transform);
|
|
|
|
assert.strictEqual(t2._flush, _flush);
|
|
|
|
assert.strictEqual(t2._final, _final);
|
2017-01-08 22:36:59 -05:00
|
|
|
|
2018-02-16 12:53:34 +01:00
|
|
|
t2.end(Buffer.from('blerg'));
|
|
|
|
t2.resume();
|