Skip to content

Commit f9d181e

Browse files
committed
feat: add a script to see diff across files
1 parent 3b71c64 commit f9d181e

1 file changed

Lines changed: 41 additions & 0 deletions

File tree

scripts/explore.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
const fs = require('fs');
2+
const { readMap } = require('./read-map');
3+
const a = process.argv[2];
4+
const b = process.argv[3];
5+
if (!a) {
6+
console.error("Please specify at least one file to explore");
7+
process.exit(1);
8+
}
9+
10+
const left = readMap(a);
11+
const right = b ? readMap(b) : {};
12+
13+
const ASCII_START = 33;
14+
const ASCII_END = 256;
15+
16+
const data = [];
17+
18+
const unicodeWrap = (chars) => {
19+
try {
20+
return chars + " (" + chars.split('').map(c => {
21+
return c.codePointAt(0).toString(16).padStart(4, "0").toUpperCase()
22+
}).join(' + ') + " )"
23+
} catch {
24+
console.log(typeof chars)
25+
console.log(`failed at ${chars.charCodeAt(0)}`)
26+
}
27+
}
28+
29+
for (let i = ASCII_START; i < ASCII_END; i++) {
30+
const char = String.fromCharCode(i);
31+
const leftChar = left[char];
32+
const rightChar = right[char];
33+
const same = leftChar === rightChar;
34+
const entry = { char }
35+
if (leftChar !== undefined) entry[a] = unicodeWrap(leftChar);
36+
if (rightChar !== undefined) entry[b] = unicodeWrap(rightChar);
37+
if (!same) entry["same"] = "NOOOO";
38+
data.push(entry);
39+
}
40+
41+
console.table(data, ["char", a, b, "same"])

0 commit comments

Comments
 (0)