Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 33 34 | 9x 9x 9x 8x 8x 8x 8x 8x 3x 3x 3x 9x | const {Writable} = require('stream');
const {DataWrapper} = require('./data_wrapper.js');
const {Manager} = require('../manager/manager.js');
/**
* Wrapper for _Writable_ streams that knows what to do with {@link DataWrapper} messages.
* @extends Writable
*/
class WritableWrapper extends Writable {
constructor(options) {
options = {...options, objectMode: true};
super(options);
this.options = options;
this.type = 'Writable';
Eif(this.options.name) Manager.set(this.type, this);
}
write(payload, encoding, cb) {
Eif(this.goal) {
payload = payload instanceof DataWrapper?payload.getChild(this):new DataWrapper(payload, this);
}
super.write(payload, encoding, cb);
}
writev(payloads, cb) {
if(this.goal) {
payloads = payloads.forEach(payload=>payload.chunk = payload.chunk instanceof DataWrapper?payload.chunk.getChild(this):new DataWrapper(payload.chunk, this));
}
super.writev(payloads, cb);
}
}
module.exports.WritableWrapper = WritableWrapper; |