string-builder.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. "use strict";
  2. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  4. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5. // StringBuilder - a way to keep string memory operations to a minimum
  6. // while building the strings for the xml files
  7. var StringBuilder = /*#__PURE__*/function () {
  8. function StringBuilder() {
  9. _classCallCheck(this, StringBuilder);
  10. this.reset();
  11. }
  12. _createClass(StringBuilder, [{
  13. key: "toString",
  14. value: function toString() {
  15. return this._buf.join('');
  16. }
  17. }, {
  18. key: "reset",
  19. value: function reset(position) {
  20. if (position) {
  21. while (this._buf.length > position) {
  22. this._buf.pop();
  23. }
  24. } else {
  25. this._buf = [];
  26. }
  27. }
  28. }, {
  29. key: "addText",
  30. value: function addText(text) {
  31. this._buf.push(text);
  32. }
  33. }, {
  34. key: "addStringBuf",
  35. value: function addStringBuf(inBuf) {
  36. this._buf.push(inBuf.toString());
  37. }
  38. }, {
  39. key: "length",
  40. get: function get() {
  41. return this._buf.length;
  42. }
  43. }]);
  44. return StringBuilder;
  45. }();
  46. module.exports = StringBuilder;
  47. //# sourceMappingURL=string-builder.js.map