• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/* eslint-disable node-core/require-common-first, node-core/required-modules */
2'use strict';
3
4const { Stream } = require('stream');
5function noop() {}
6
7// A stream to push an array into a REPL
8function ArrayStream() {
9  this.run = function(data) {
10    data.forEach((line) => {
11      this.emit('data', `${line}\n`);
12    });
13  };
14}
15
16Object.setPrototypeOf(ArrayStream.prototype, Stream.prototype);
17Object.setPrototypeOf(ArrayStream, Stream);
18ArrayStream.prototype.readable = true;
19ArrayStream.prototype.writable = true;
20ArrayStream.prototype.pause = noop;
21ArrayStream.prototype.resume = noop;
22ArrayStream.prototype.write = noop;
23
24module.exports = ArrayStream;
25