mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
dcc5e51e1c
PR-URL: https://github.com/nodejs/node/pull/27650 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
25 lines
658 B
JavaScript
25 lines
658 B
JavaScript
/* eslint-disable node-core/require-common-first, node-core/required-modules */
|
|
'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`);
|
|
});
|
|
};
|
|
}
|
|
|
|
Object.setPrototypeOf(ArrayStream.prototype, Stream.prototype);
|
|
Object.setPrototypeOf(ArrayStream, Stream);
|
|
ArrayStream.prototype.readable = true;
|
|
ArrayStream.prototype.writable = true;
|
|
ArrayStream.prototype.pause = noop;
|
|
ArrayStream.prototype.resume = noop;
|
|
ArrayStream.prototype.write = noop;
|
|
|
|
module.exports = ArrayStream;
|