MCPcopy Create free account
hub / github.com/RtlZeroMemory/Rezi / parseInternedStrings

Function parseInternedStrings

packages/core/src/__tests__/drawlistDecode.ts:216–257  ·  view source on GitHub ↗
(bytes: Uint8Array)

Source from the content-addressed store, hash-verified

214}
215
216export function parseInternedStrings(bytes: Uint8Array): readonly string[] {
217 if (!(bytes instanceof Uint8Array) || bytes.byteLength < HEADER_SIZE) {
218 return Object.freeze([]);
219 }
220
221 const merged: string[] = [];
222 let off = 0;
223 let parsedAny = false;
224 while (off + HEADER_SIZE <= bytes.byteLength) {
225 const magic = u32(bytes, off + 0);
226 const headerSize = u32(bytes, off + 8);
227 const totalSize = u32(bytes, off + 12);
228 if (
229 magic !== ZRDL_MAGIC ||
230 headerSize !== HEADER_SIZE ||
231 totalSize < HEADER_SIZE ||
232 (totalSize & 3) !== 0 ||
233 off + totalSize > bytes.byteLength
234 ) {
235 break;
236 }
237
238 parsedAny = true;
239 try {
240 const list = parseInternedStringsSingle(bytes.subarray(off, off + totalSize));
241 merged.push(...list);
242 } catch {
243 return Object.freeze([]);
244 }
245 off += totalSize;
246 }
247
248 if (parsedAny && off === bytes.byteLength) {
249 return Object.freeze(merged);
250 }
251
252 try {
253 return parseInternedStringsSingle(bytes);
254 } catch {
255 return Object.freeze([]);
256 }
257}
258
259export function parseBlobById(bytes: Uint8Array, blobId: number): Uint8Array | null {
260 const resources = parseResourceState(bytes);

Callers 15

parseFrameFunction · 0.85
renderStringsFunction · 0.85
latestFrameStringsFunction · 0.85
latestFrameStringsFunction · 0.85
renderStringsFunction · 0.85

Calls 3

u32Function · 0.70
pushMethod · 0.45

Tested by

no test coverage detected