@wtasnorg/node-lib / ReaderString
Defined in: src/strings.ts:1329
Reader implements reading from a string. It implements io.Reader, io.ReaderAt, io.ByteReader, io.ByteScanner, io.RuneReader, io.RuneScanner, io.Seeker, and io.WriterTo.
const r = newReader("hello");
const b = new Uint8Array(3);
r.read(b); // b = [104, 101, 108]
new ReaderString(
s):Reader
Defined in: src/strings.ts:1334
string
Reader
len():
number
Defined in: src/strings.ts:1343
Len returns the number of bytes of the unread portion of the string.
number
Number of unread bytes.
read(
b):number
Defined in: src/strings.ts:1364
Read implements io.Reader. It reads from the string into b.
Uint8Array
Buffer to read into.
number
Number of bytes read.
When no more bytes are available.
readAt(
b,off):number
Defined in: src/strings.ts:1385
ReadAt implements io.ReaderAt. It reads from the string starting at byte offset off.
Uint8Array
Buffer to read into.
number
Byte offset to start reading from.
number
Number of bytes read.
If off is negative.
If off is past the end or fewer bytes than b are available.
readByte():
number
Defined in: src/strings.ts:1401
ReadByte implements io.ByteReader. It reads and returns the next byte from the string.
number
Next byte value.
When no more bytes are available.
readRune(): [
number,number]
Defined in: src/strings.ts:1416
ReadRune implements io.RuneReader. It reads and returns the next UTF-8-encoded Unicode code point from the string.
[number, number]
Tuple of [code point, byte size].
When no more runes are available.
reset(
s):void
Defined in: src/strings.ts:1432
Reset resets the Reader to be reading from s.
string
New string to read from.
void
seek(
offset,whence):number
Defined in: src/strings.ts:1448
Seek implements io.Seeker. It sets the offset for the next Read or ReadAt, interpreted according to whence: 0 (start), 1 (current), 2 (end).
number
Byte offset.
number
Seek origin: 0=start, 1=current, 2=end.
number
New absolute offset.
If whence is invalid.
If resulting offset is negative.
size():
number
Defined in: src/strings.ts:1353
Size returns the original length of the underlying string. Size is the number of bytes available for reading via ReadAt.
number
Original byte length of the string.
unreadByte():
void
Defined in: src/strings.ts:1468
UnreadByte complements ReadByte in implementing io.ByteScanner.
void
If the position is at the beginning of the string or the previous operation was not a byte read.
unreadRune():
void
Defined in: src/strings.ts:1482
UnreadRune complements ReadRune in implementing io.RuneScanner.
void
If the previous operation was not ReadRune or position is at start.
writeTo(
w):number
Defined in: src/strings.ts:1496
WriteTo implements io.WriterTo. It writes data to w until there’s no more data to write or when an error occurs.
Writer to write to.
number
Number of bytes written.