TextBuffer
Defined in: packages/format-core/src/text-buffer.ts:12
A DecodeBuffer over accumulated text.
Byte→text conversion happens upstream (a TextDecoderStream or
CharsetDecodeStream); this only concatenates and windows the resulting
strings, so consumed counts UTF-16 code units, matching String indexing.
Implements
Section titled “Implements”DecodeBuffer<string>
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new TextBuffer(
maxSize):TextBuffer
Defined in: packages/format-core/src/text-buffer.ts:25
Construct a buffer with a maximum retained code-unit count.
The ceiling is mandatory for the same reason ByteAccumulator’s is: a
decoder that never reaches a verdict would otherwise let a peer grow this
without bound.
Parameters
Section titled “Parameters”maxSize
Section titled “maxSize”number
Maximum retained code-unit count; must be greater than zero.
Returns
Section titled “Returns”TextBuffer
Accessors
Section titled “Accessors”buffered
Section titled “buffered”Get Signature
Section titled “Get Signature”get buffered():
number
Defined in: packages/format-core/src/text-buffer.ts:31
Unconsumed unit count currently held.
Returns
Section titled “Returns”number
Unconsumed unit count currently held.
Implementation of
Section titled “Implementation of”Methods
Section titled “Methods”append()
Section titled “append()”append(
chunk):void
Defined in: packages/format-core/src/text-buffer.ts:39
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”void
Throws
Section titled “Throws”If the retained count would exceed the configured ceiling.
Implementation of
Section titled “Implementation of”clear()
Section titled “clear()”clear():
void
Defined in: packages/format-core/src/text-buffer.ts:65
Discard everything held.
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”consume()
Section titled “consume()”consume(
count):void
Defined in: packages/format-core/src/text-buffer.ts:53
Drop count units from the front.
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”take()
Section titled “take()”take():
string
Defined in: packages/format-core/src/text-buffer.ts:59
Remove and return the unconsumed units, resetting the buffer.
Returns
Section titled “Returns”string
Implementation of
Section titled “Implementation of”view()
Section titled “view()”view():
string
Defined in: packages/format-core/src/text-buffer.ts:49
Window over the unconsumed units. Invalidated by the next append or consume; copy before retaining.
Returns
Section titled “Returns”string