// Row 102 (#1596) N3: the escaped lines mean what the literal lines meant. Run from the repo // root of a tree whose HEAD still has the literals: node same-code-points.mjs import { execFileSync } from 'node:child_process'; import { readFileSync } from 'node:fs'; const head = (f) => execFileSync('git', ['show', `HEAD:${f}`], { encoding: 'utf8' }); const line = (text, n) => text.split('\n')[n - 1]; const BUS = 'packages/webui/src/public/bus.js'; const unseen = (l) => new Function(`return ${/UNSEEN = (\/.*?\/g)/.exec(l)[1]}`)(); const oldRe = unseen(line(head(BUS), 13)); const newRe = unseen(line(readFileSync(BUS, 'utf8'), 13)); let matched = 0, differ = 0; for (let u = 0; u <= 0xffff; u++) { const c = String.fromCharCode(u); const a = (oldRe.lastIndex = 0, oldRe.test(c)), b = (newRe.lastIndex = 0, newRe.test(c)); if (a) matched++; if (a !== b) differ++; } console.log(`${BUS}:13 UNSEEN: old matches ${matched} of 65536 code units, new differs on ${differ}`); for (const [f, n] of [['packages/webui/tests/bus.test.mjs', 20], ['packages/conversation/tests/flows.test.mjs', 495]]) { const lit = (l) => new Function(`return ${/(['"])(?:(?!\1).|\\.)*\1/.exec(l.replace(/^.*?=\s*/, '').replace(/^.*?text:\s*/, ''))[0]}`)(); const a = lit(line(head(f), n)), b = lit(line(readFileSync(f, 'utf8'), n)); console.log(`${f}:${n}: string ${a === b ? 'identical' : 'DIFFERENT'} (${a.length} code units)`); }