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
|
|
|
|
2018-02-16 15:46:48 +01:00
|
|
|
const { strictEqual } = require('assert');
|
|
|
|
const { Transform } = require('stream');
|
2015-02-03 01:12:41 +00: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
|
|
|
|
2017-01-08 13:19:00 +00:00
|
|
|
const t = 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
|
|
|
});
|
|
|
|
|
2018-02-16 15:46:48 +01:00
|
|
|
strictEqual(t._transform, _transform);
|
|
|
|
strictEqual(t._flush, _flush);
|
|
|
|
strictEqual(t._final, _final);
|
2017-01-08 22:36:59 -05:00
|
|
|
|
2016-01-25 15:00:06 -08:00
|
|
|
t.end(Buffer.from('blerg'));
|
2015-02-03 01:12:41 +00:00
|
|
|
t.resume();
|
|
|
|
|
2018-02-16 15:46:48 +01:00
|
|
|
const t2 = new Transform({});
|
|
|
|
|
2017-09-28 17:48:12 -03:00
|
|
|
common.expectsError(() => {
|
2017-01-08 22:36:59 -05:00
|
|
|
t2.end(Buffer.from('blerg'));
|
2017-09-28 17:48:12 -03:00
|
|
|
}, {
|
|
|
|
type: Error,
|
|
|
|
code: 'ERR_METHOD_NOT_IMPLEMENTED',
|
|
|
|
message: 'The _transform method is not implemented'
|
|
|
|
});
|