MCPcopy Create free account
hub / github.com/apache/fory / stringWithHeader

Method stringWithHeader

javascript/packages/core/lib/reader/index.ts:236–250  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

234 }
235
236 stringWithHeader() {
237 const header = this.readVarUint36Small();
238 const type = header & 0b11;
239 const len = header >>> 2;
240 switch (type) {
241 case LATIN1:
242 return len === 0 ? "" : this.stringLatin1(len);
243 case UTF8:
244 return len === 0 ? "" : this.stringUtf8(len);
245 case UTF16:
246 return len === 0 ? "" : this.stringUtf16LE(len);
247 default:
248 throw new Error(`Unsupported string encoding: ${type}`);
249 }
250 }
251
252 stringLatin1(len: number) {
253 if (len < 0 || len > this.byteLength - this.cursor) {

Callers 4

writeStringMethod · 0.45
readStringMethod · 0.45
io.test.tsFile · 0.45
hps.test.tsFile · 0.45

Calls 4

readVarUint36SmallMethod · 0.95
stringLatin1Method · 0.95
stringUtf8Method · 0.95
stringUtf16LEMethod · 0.95

Tested by

no test coverage detected