@@ -717,24 +717,21 @@ exports.stringIterator = (str) => {
717717
718718/**
719719 * A custom made StringBuffer
720- *
721- * @typedef {object } StringAssembler
722- * @property {Function } append -
723- * @property {Function } toString -
724720 */
721+ class StringAssembler {
722+ constructor ( ) { this . clear ( ) ; }
723+ clear ( ) { this . _str = '' ; }
724+ /**
725+ * @param {string } x -
726+ */
727+ append ( x ) { this . _str += String ( x ) ; }
728+ toString ( ) { return this . _str ; }
729+ }
725730
726731/**
727732 * @returns {StringAssembler }
728733 */
729- exports . stringAssembler = ( ) => ( {
730- _str : '' ,
731- clear ( ) { this . _str = '' ; } ,
732- /**
733- * @param {string } x -
734- */
735- append ( x ) { this . _str += String ( x ) ; } ,
736- toString ( ) { return this . _str ; } ,
737- } ) ;
734+ exports . stringAssembler = ( ) => new StringAssembler ( ) ;
738735
739736/**
740737 * @typedef {object } StringArrayLike
@@ -1161,7 +1158,7 @@ exports.applyToText = (cs, str) => {
11611158 assert ( str . length === unpacked . oldLen , `mismatched apply: ${ str . length } / ${ unpacked . oldLen } ` ) ;
11621159 const bankIter = exports . stringIterator ( unpacked . charBank ) ;
11631160 const strIter = exports . stringIterator ( str ) ;
1164- const assem = exports . stringAssembler ( ) ;
1161+ const assem = new StringAssembler ( ) ;
11651162 for ( const op of exports . deserializeOps ( unpacked . ops ) ) {
11661163 switch ( op . opcode ) {
11671164 case '+' :
@@ -1480,7 +1477,7 @@ exports.compose = (cs1, cs2, pool) => {
14801477 const len3 = unpacked2 . newLen ;
14811478 const bankIter1 = exports . stringIterator ( unpacked1 . charBank ) ;
14821479 const bankIter2 = exports . stringIterator ( unpacked2 . charBank ) ;
1483- const bankAssem = exports . stringAssembler ( ) ;
1480+ const bankAssem = new StringAssembler ( ) ;
14841481
14851482 const newOps = applyZip ( unpacked1 . ops , unpacked2 . ops , ( op1 , op2 ) => {
14861483 const op1code = op1 . opcode ;
@@ -1928,7 +1925,7 @@ class Builder {
19281925 constructor ( oldLen ) {
19291926 this . _oldLen = oldLen ;
19301927 this . _ops = [ ] ;
1931- this . _charBank = exports . stringAssembler ( ) ;
1928+ this . _charBank = new StringAssembler ( ) ;
19321929 }
19331930
19341931 /**
@@ -2189,7 +2186,7 @@ exports.inverse = (cs, lines, alines, pool) => {
21892186
21902187 const nextText = ( numChars ) => {
21912188 let len = 0 ;
2192- const assem = exports . stringAssembler ( ) ;
2189+ const assem = new StringAssembler ( ) ;
21932190 const firstString = linesGet ( curLine ) . substring ( curChar ) ;
21942191 len += firstString . length ;
21952192 assem . append ( firstString ) ;
@@ -2415,7 +2412,7 @@ const followAttributes = (att1, att2, pool) => {
24152412 return '' ;
24162413 } ) ;
24172414 // we've only removed attributes, so they're already sorted
2418- const buf = exports . stringAssembler ( ) ;
2415+ const buf = new StringAssembler ( ) ;
24192416 for ( const att of atts ) {
24202417 buf . append ( '*' ) ;
24212418 buf . append ( exports . numToString ( pool . putAttrib ( att ) ) ) ;
0 commit comments