@stryker-mutator/core
Version:
The extendable JavaScript mutation testing framework
27 lines • 758 B
JavaScript
import { EOL } from 'os';
const DEFAULT_MAX_SIZE = 2048;
export class StringBuilder {
constructor() {
this.currentLength = 0;
this.strings = [];
this.maxSize = DEFAULT_MAX_SIZE;
}
append(str) {
this.strings.push(str);
this.currentLength += str.length;
while (this.currentLength > this.maxSize && this.strings.length > 1) {
const shifted = this.strings.shift();
this.currentLength -= shifted.length;
}
}
toString() {
return this.strings.join('');
}
static concat(...builders) {
return builders
.map((b) => b.toString())
.filter(Boolean)
.join(EOL);
}
}
//# sourceMappingURL=string-builder.js.map