xref: /third_party/node/test/common/arraystream.js
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/node/test/common/
11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ciconst { Stream } = require('stream');
41cb0ef41Sopenharmony_cifunction noop() {}
51cb0ef41Sopenharmony_ci
61cb0ef41Sopenharmony_ci// A stream to push an array into a REPL
71cb0ef41Sopenharmony_cifunction ArrayStream() {
81cb0ef41Sopenharmony_ci  this.run = function(data) {
91cb0ef41Sopenharmony_ci    data.forEach((line) => {
101cb0ef41Sopenharmony_ci      this.emit('data', `${line}\n`);
111cb0ef41Sopenharmony_ci    });
121cb0ef41Sopenharmony_ci  };
131cb0ef41Sopenharmony_ci}
141cb0ef41Sopenharmony_ci
151cb0ef41Sopenharmony_ciObject.setPrototypeOf(ArrayStream.prototype, Stream.prototype);
161cb0ef41Sopenharmony_ciObject.setPrototypeOf(ArrayStream, Stream);
171cb0ef41Sopenharmony_ciArrayStream.prototype.readable = true;
181cb0ef41Sopenharmony_ciArrayStream.prototype.writable = true;
191cb0ef41Sopenharmony_ciArrayStream.prototype.pause = noop;
201cb0ef41Sopenharmony_ciArrayStream.prototype.resume = noop;
211cb0ef41Sopenharmony_ciArrayStream.prototype.write = noop;
221cb0ef41Sopenharmony_ci
231cb0ef41Sopenharmony_cimodule.exports = ArrayStream;
24

Indexes created Thu Nov 07 10:32:03 CST 2024