MCPcopy Create free account
hub / github.com/Effect-TS/effect / readString

Function readString

packages/effect/src/encoding/Tar.ts:756–768  ·  view source on GitHub ↗
(block: Uint8Array, offset: number, length: number)

Source from the content-addressed store, hash-verified

754}
755
756const readString = (block: Uint8Array, offset: number, length: number): string => {
757 let end = offset
758 let ascii = true
759 const limit = offset + length
760 while (end < limit && block[end] !== 0) {
761 if (block[end] >= 0x80) ascii = false
762 end++
763 }
764 if (end === offset) return ""
765 if (!ascii || end - offset > 256) return textDecoder.decode(block.subarray(offset, end))
766 // Most header strings are short ASCII, which is cheaper to build directly
767 return String.fromCharCode.apply(null, block.subarray(offset, end) as unknown as Array<number>)
768}
769
770const readOctal = (block: Uint8Array, offset: number, length: number): number => {
771 let start = offset

Callers 2

parseHeaderFunction · 0.70
advanceMethod · 0.70

Calls 2

decodeMethod · 0.45
applyMethod · 0.45

Tested by

no test coverage detected