HEX
Server: nginx/1.18.0
System: Linux test-ipsremont 5.4.0-214-generic #234-Ubuntu SMP Fri Mar 14 23:50:27 UTC 2025 x86_64
User: ips (1000)
PHP: 8.0.30
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/elite/node_modules/gulp/node_modules/ordered-read-streams/index.js
var Readable = require('readable-stream/readable');
var util = require('util');

function isReadable(stream) {
  if (typeof stream.pipe !== 'function') {
    return false;
  }

  if (!stream.readable) {
    return false;
  }

  if (typeof stream._read !== 'function') {
    return false;
  }

  if (!stream._readableState) {
    return false;
  }

  return true;
}

function addStream (streams, stream) {
  if (!isReadable(stream)) {
    throw new Error('All input streams must be readable');
  }

  var self = this;

  stream._buffer = [];

  stream.on('readable', function () {
    var chunk = stream.read();
    while (chunk) {
      if (this === streams[0]) {
        self.push(chunk);
      } else {
        this._buffer.push(chunk);
      }
      chunk = stream.read();
    }
  });

  stream.on('end', function () {
    for (var stream = streams[0];
      stream && stream._readableState.ended;
      stream = streams[0]) {
      while (stream._buffer.length) {
        self.push(stream._buffer.shift());
      }

      streams.shift();
    }

    if (!streams.length) {
      self.push(null);
    }
  });

  stream.on('error', this.emit.bind(this, 'error'));

  streams.push(stream);
}

function OrderedStreams (streams, options) {
  if (!(this instanceof(OrderedStreams))) {
    return new OrderedStreams(streams, options);
  }

  streams = streams || [];
  options = options || {};

  options.objectMode = true;

  Readable.call(this, options);

  if (!Array.isArray(streams)) {
    streams = [streams];
  }
  if (!streams.length) {
    return this.push(null);  // no streams, close
  }

  var addStreamBinded = addStream.bind(this, []);

  streams.forEach(function (item) {
    if (Array.isArray(item)) {
      item.forEach(addStreamBinded);
    } else {
      addStreamBinded(item);
    }
  });
}
util.inherits(OrderedStreams, Readable);

OrderedStreams.prototype._read = function () {};

module.exports = OrderedStreams;