All files / lib/wrapper readable.js

93.33% Statements 14/15
50% Branches 4/8
100% Functions 2/2
92.86% Lines 13/14

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 279x 9x 9x               1x 1x 1x 1x 1x 21x     21x   1x 1x         9x
const {Readable} = require('stream');
const {DataWrapper} = require('./data_wrapper.js');
const {Manager} = require('../manager/manager.js');
 
/**
 * Wrapper for _Readable_ streams that knows what to do with {@link DataWrapper} messages.
 * @extends Readable
 */
class ReadableWrapper extends Readable {
    constructor(options) {
        options = {...options, objectMode: true};
        super(options);
        this.options = options;
        this.__real__push = this.push;
        this.push = (payload) => {
            Iif(payload != null && this.goal) {
                payload = payload instanceof DataWrapper?payload.getChild(this):new DataWrapper(payload, this);
            }
            this.__real__push(payload);
        };
        this.type = 'Readable';
        Eif(this.options.name) Manager.set(this.type, this);
    }
 
}
 
module.exports.ReadableWrapper = ReadableWrapper;