@wtasnorg/node-lib / BuilderString
Defined in: src/strings.ts:1201
Builder is used to efficiently build a string using Write methods. It minimizes memory copying. The zero value is ready to use. Do not copy a non-zero Builder.
const b = new Builder();
b.writeString("hello");
b.writeString(", world");
console.log(b.string()); // "hello, world"
new BuilderString():
Builder
Builder
cap():
number
Defined in: src/strings.ts:1212
Cap returns the capacity of the builder’s underlying byte slice. It is the total space allocated for the string being built and includes any bytes already written.
number
Current capacity (equals current length in this implementation).
grow(
_n):void
Defined in: src/strings.ts:1223
Grow grows the builder’s capacity, if necessary, to guarantee space for another n bytes. After Grow(n), at least n bytes can be written to the builder without another allocation.
number
Number of bytes to ensure capacity for.
void
len():
number
Defined in: src/strings.ts:1232
Len returns the number of accumulated bytes (UTF-16 code units).
number
Number of bytes written so far.
reset():
void
Defined in: src/strings.ts:1239
Reset resets the builder to be empty.
void
string():
string
Defined in: src/strings.ts:1249
String returns the accumulated string.
string
The built string.
write(
p):number
Defined in: src/strings.ts:1260
Write appends the contents of p to the builder’s buffer. Write always returns len(p), nil.
Uint8Array
Bytes to write (decoded from UTF-8).
number
Number of bytes written.
writeByte(
c):void
Defined in: src/strings.ts:1273
WriteByte appends the byte c to the builder’s buffer. The returned error is always nil.
number
Byte value (0–255) to write.
void
writeRune(
r):number
Defined in: src/strings.ts:1286
WriteRune appends the UTF-8 encoding of Unicode code point r to the builder’s buffer. It returns the length added and a nil error.
number
Unicode code point to write.
number
Number of UTF-16 code units added.
writeString(
s):number
Defined in: src/strings.ts:1300
WriteString appends the contents of s to the builder’s buffer. It returns the length of s and a nil error.
string
String to write.
number
Number of characters written.