• File: string-builder.js
  • Full Path: /var/www/nodejs/daily_store_reports_nodejs/node_modules/exceljs/lib/utils/string-builder.js
  • Date Modified: 02/04/2023 9:31 PM
  • File size: 632 bytes
  • MIME-type: text/plain
  • Charset: utf-8
// StringBuilder - a way to keep string memory operations to a minimum
// while building the strings for the xml files
class StringBuilder {
  constructor() {
    this.reset();
  }

  get length() {
    return this._buf.length;
  }

  toString() {
    return this._buf.join('');
  }

  reset(position) {
    if (position) {
      while (this._buf.length > position) {
        this._buf.pop();
      }
    } else {
      this._buf = [];
    }
  }

  addText(text) {
    this._buf.push(text);
  }

  addStringBuf(inBuf) {
    this._buf.push(inBuf.toString());
  }
}

module.exports = StringBuilder;