HEX
Server: LiteSpeed
System: Linux houston.panomity.com 6.8.0-100-generic #100-Ubuntu SMP PREEMPT_DYNAMIC Tue Jan 13 16:40:06 UTC 2026 x86_64
User: nudepix (1011)
PHP: 7.4.33
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: //opt/big-agi/node_modules/webpack-bundle-analyzer/lib/statsUtils.js
"use strict";

const {
  createWriteStream
} = require('fs');

const {
  Readable
} = require('stream');

class StatsSerializeStream extends Readable {
  constructor(stats) {
    super();
    this._indentLevel = 0;
    this._stringifier = this._stringify(stats);
  }

  get _indent() {
    return '  '.repeat(this._indentLevel);
  }

  _read() {
    let readMore = true;

    while (readMore) {
      const {
        value,
        done
      } = this._stringifier.next();

      if (done) {
        this.push(null);
        readMore = false;
      } else {
        readMore = this.push(value);
      }
    }
  }

  *_stringify(obj) {
    if (typeof obj === 'string' || typeof obj === 'number' || typeof obj === 'boolean' || obj === null) {
      yield JSON.stringify(obj);
    } else if (Array.isArray(obj)) {
      yield '[';
      this._indentLevel++;
      let isFirst = true;

      for (let item of obj) {
        if (item === undefined) {
          item = null;
        }

        yield `${isFirst ? '' : ','}\n${this._indent}`;
        yield* this._stringify(item);
        isFirst = false;
      }

      this._indentLevel--;
      yield obj.length ? `\n${this._indent}]` : ']';
    } else {
      yield '{';
      this._indentLevel++;
      let isFirst = true;
      const entries = Object.entries(obj);

      for (const [itemKey, itemValue] of entries) {
        if (itemValue === undefined) {
          continue;
        }

        yield `${isFirst ? '' : ','}\n${this._indent}${JSON.stringify(itemKey)}: `;
        yield* this._stringify(itemValue);
        isFirst = false;
      }

      this._indentLevel--;
      yield entries.length ? `\n${this._indent}}` : '}';
    }
  }

}

exports.StatsSerializeStream = StatsSerializeStream;
exports.writeStats = writeStats;

async function writeStats(stats, filepath) {
  return new Promise((resolve, reject) => {
    new StatsSerializeStream(stats).on('end', resolve).on('error', reject).pipe(createWriteStream(filepath));
  });
}