3 // Always use the latest available version of Unicode!
4 // https://tc39.github.io/ecma262/#sec-conformance
5 const version = "14.0.0";
7 const start = require("@unicode/unicode-" +
9 "/Binary_Property/ID_Start/code-points.js").filter(function (ch) {
13 const cont = [0x200c, 0x200d].concat(
14 require("@unicode/unicode-" +
16 "/Binary_Property/ID_Continue/code-points.js").filter(function (ch) {
17 return ch > 0x7f && search(start, ch, last + 1) == -1;
21 function search(arr, ch, starting) {
22 for (let i = starting; arr[i] <= ch && i < arr.length; last = i++) {
23 if (arr[i] === ch) return i;
28 function pad(str, width) {
29 while (str.length < width) str = "0" + str;
34 const hex = code.toString(16);
35 if (hex.length <= 2) return "\\x" + pad(hex, 2);
36 else return "\\u" + pad(hex, 4);
39 function generate(chars) {
42 for (let i = 0, at = 0x10000; i < chars.length; i++) {
43 const from = chars[i];
45 while (i < chars.length - 1 && chars[i + 1] == to + 1) {
50 if (from == to) re += esc(from);
51 else if (from + 1 == to) re += esc(from) + esc(to);
52 else re += esc(from) + "-" + esc(to);
54 astral.push(from - at, to - from);
58 return { nonASCII: re, astral: astral };
61 const startData = generate(start);
62 const contData = generate(cont);
64 console.log("/* prettier-ignore */");
65 console.log('let nonASCIIidentifierStartChars = "' + startData.nonASCII + '";');
66 console.log("/* prettier-ignore */");
67 console.log('let nonASCIIidentifierChars = "' + contData.nonASCII + '";');
68 console.log("/* prettier-ignore */");
70 "const astralIdentifierStartCodes = " + JSON.stringify(startData.astral) + ";"
72 console.log("/* prettier-ignore */");
74 "const astralIdentifierCodes = " + JSON.stringify(contData.astral) + ";"