2019-05-12 09:11:13 +02:00
|
|
|
/* eslint-disable node-core/require-common-first, node-core/required-modules */
|
2018-08-21 23:47:47 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const { Stream } = require('stream');
|
|
|
|
function noop() {}
|
|
|
|
|
|
|
|
// A stream to push an array into a REPL
|
|
|
|
function ArrayStream() {
|
|
|
|
this.run = function(data) {
|
|
|
|
data.forEach((line) => {
|
|
|
|
this.emit('data', `${line}\n`);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2018-12-28 05:10:45 +01:00
|
|
|
Object.setPrototypeOf(ArrayStream.prototype, Stream.prototype);
|
|
|
|
Object.setPrototypeOf(ArrayStream, Stream);
|
2018-08-21 23:47:47 +02:00
|
|
|
ArrayStream.prototype.readable = true;
|
|
|
|
ArrayStream.prototype.writable = true;
|
|
|
|
ArrayStream.prototype.pause = noop;
|
|
|
|
ArrayStream.prototype.resume = noop;
|
|
|
|
ArrayStream.prototype.write = noop;
|
|
|
|
|
|
|
|
module.exports = ArrayStream;
|