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

Function parseTsUint32Array

scripts/check-unicode-sync.mjs:104–115  ·  view source on GitHub ↗
(tsText, exportName)

Source from the content-addressed store, hash-verified

102}
103
104function parseTsUint32Array(tsText, exportName) {
105 const marker = `export const ${exportName} = new Uint32Array([`;
106 const start = tsText.indexOf(marker);
107 if (start < 0) throw new Error(`missing export Uint32Array: ${exportName}`);
108 const bodyStart = start + marker.length;
109 const end = tsText.indexOf("]);", bodyStart);
110 if (end < 0) throw new Error(`missing array terminator for export: ${exportName}`);
111 const body = tsText.slice(bodyStart, end);
112 const nums = body.match(/0x[0-9A-Fa-f]+|\d+/g) ?? [];
113 if (nums.length === 0) throw new Error(`parsed 0 numbers from TS array: ${exportName}`);
114 return nums.map((t) => (t.startsWith("0x") ? Number.parseInt(t, 16) : Number.parseInt(t, 10)));
115}
116
117function assertEqualArray(a, b, label) {
118 if (a.length !== b.length) {

Callers 1

checkUnicodeSyncFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected