webgme-engine
Version:
WebGME server and Client API without a GUI
34 lines (24 loc) • 668 B
JavaScript
/*eslint-env node*/
/**
* @author lattmann / https://github.com/lattmann
*/
;
var Stream = require('stream'),
util = require('util');
var StringStreamReader = function (str, opt) {
Stream.Readable.call(this, opt);
this._str = str;
};
util.inherits(StringStreamReader, Stream.Readable);
StringStreamReader.prototype._read = function () {
var buf = Buffer.from(this._str, 'utf-8');
this.push(buf);
this.push(null);
};
StringStreamReader.prototype.toString = function () {
return this._str;
};
StringStreamReader.prototype.toJSON = function () {
return JSON.parse(this._str);
};
module.exports = StringStreamReader;