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