blob: 0b71b3d9a50569438ab21d117b64e50cc2772084 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
'use strict';
require('../common');
const assert = require('assert');
const Duplex = require('stream').Transform;
const stream = new Duplex({ objectMode: true });
assert(Duplex() instanceof Duplex);
assert(stream._readableState.objectMode);
assert(stream._writableState.objectMode);
let written;
let read;
stream._write = (obj, _, cb) => {
written = obj;
cb();
};
stream._read = () => {};
stream.on('data', (obj) => {
read = obj;
});
stream.push({ val: 1 });
stream.end({ val: 2 });
process.on('exit', () => {
assert.strictEqual(read.val, 1);
assert.strictEqual(written.val, 2);
});
|