Upsilon-VsCode/Client/node_modules/streamifier/lib/index.js

28 lines
685 B
JavaScript
Raw Normal View History

2019-02-17 17:07:28 +00:00
'use strict';
var util = require('util');
var stream = require('stream');
module.exports.createReadStream = function (object, options) {
return new MultiStream (object, options);
};
var MultiStream = function (object, options) {
if (object instanceof Buffer || typeof object === 'string') {
options = options || {};
stream.Readable.call(this, {
highWaterMark: options.highWaterMark,
encoding: options.encoding
});
} else {
stream.Readable.call(this, { objectMode: true });
}
this._object = object;
};
util.inherits(MultiStream, stream.Readable);
MultiStream.prototype._read = function () {
this.push(this._object);
this._object = null;
};