blob: 8efc9d4b5f416095d9b97be958933c93874be8fc (
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
|
var common = require('../common');
var assert = require('assert');
var Duplex = require('stream').Transform;
var stream = new Duplex({ objectMode: true });
assert(stream._readableState.objectMode);
assert(stream._writableState.objectMode);
var written;
var read;
stream._write = function (obj, _, cb) {
written = obj;
cb();
};
stream._read = function () {};
stream.on('data', function (obj) {
read = obj;
});
stream.push({ val: 1 });
stream.end({ val: 2 });
process.on('exit', function () {
assert(read.val === 1);
assert(written.val === 2);
});
|