Skip to content

Commit 35b834d

Browse files
committed
🎨 improve unicode
1 parent c9536f1 commit 35b834d

File tree

4 files changed

+137
-609
lines changed

4 files changed

+137
-609
lines changed

‎scripts/update-unicode-ids.ts

+5-9
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,9 @@ function isInRange(cp: number, ranges: number[]): boolean {
101101
return false
102102
}
103103
104-
function restoreRanges(diffs: number[]): number[] {
104+
function restoreRanges(data: string): number[] {
105105
let last = 0
106-
for (let i = 0; i < diffs.length; ++i) {
107-
last = (diffs[i] += last)
108-
}
109-
return diffs
106+
return data.split(" ").map(s => (last += parseInt(s, 10) | 0))
110107
}
111108
`
112109

@@ -179,14 +176,13 @@ function makeSmallCondition(ranges: [number, number][]): string {
179176
}
180177

181178
function makeInitLargeIdRanges(ranges: [number, number][]): string {
182-
const strings: string[] = ["return restoreRanges(["]
179+
const diffs: number[] = []
183180
let last = 0
184181
for (const [min, max] of ranges) {
185-
strings.push(`${min - last},${max - min},`)
182+
diffs.push(min - last, max - min)
186183
last = max
187184
}
188-
strings.push("]) //eslint-disable-line @mysticatea/prettier")
189-
return strings.join("")
185+
return `return restoreRanges("${diffs.join(" ")}")`
190186
}
191187

192188
function save(content: string): Promise<void> {

‎scripts/update-unicode-properties.ts

+67-45
Original file line numberDiff line numberDiff line change
@@ -87,46 +87,47 @@ type Datum = {
8787
logger.log("Generating code...")
8888
let code = `/* This file was generated with ECMAScript specifications. */
8989
90-
const gcNamePattern = new Set(["General_Category", "gc"])
91-
const scNamePattern = new Set(["Script", "Script_Extensions", "sc", "scx"])
92-
const gcValuePatterns = {
93-
${Array.from(
94-
Object.keys(data),
95-
version => `es${version}: null as Set<string> | null,`,
96-
).join("\n")}
97-
}
98-
const scValuePatterns = {
99-
${Array.from(
100-
Object.keys(data),
101-
version => `es${version}: null as Set<string> | null,`,
102-
).join("\n")}
103-
}
104-
const binPropertyPatterns = {
105-
${Array.from(
106-
Object.keys(data),
107-
version => `es${version}: null as Set<string> | null,`,
108-
).join("\n")}
109-
}
90+
${makeClassDeclarationCode(Object.keys(data))}
91+
92+
const gcNameSet = new Set(["General_Category", "gc"])
93+
const scNameSet = new Set(["Script", "Script_Extensions", "sc", "scx"])
94+
const gcValueSets = new DataSet(${Object.values(data)
95+
.map(d => makeDataCode(d.gcValues))
96+
.join(",")})
97+
const scValueSets = new DataSet(${Object.values(data)
98+
.map(d => makeDataCode(d.scValues))
99+
.join(",")})
100+
const binPropertySets = new DataSet(${Object.values(data)
101+
.map(d => makeDataCode(d.binProperties))
102+
.join(",")})
110103
111104
export function isValidUnicodeProperty(version: number, name: string, value: string): boolean {
112-
if (gcNamePattern.has(name)) {
113-
${Array.from(Object.entries(data), ([version, { gcValues }]) =>
114-
makeVerificationCode(version, "gcValuePatterns", gcValues, 52),
115-
).join("\n")}
105+
if (gcNameSet.has(name)) {
106+
return ${Object.entries(data)
107+
.map(([version, { gcValues }]) =>
108+
makeVerificationCode(version, "gcValueSets", gcValues),
109+
)
110+
.filter(Boolean)
111+
.join(" || ")}
116112
}
117-
if (scNamePattern.has(name)) {
118-
${Array.from(Object.entries(data), ([version, { scValues }]) =>
119-
makeVerificationCode(version, "scValuePatterns", scValues, 52),
120-
).join("\n")}
113+
if (scNameSet.has(name)) {
114+
return ${Object.entries(data)
115+
.map(([version, { scValues }]) =>
116+
makeVerificationCode(version, "scValueSets", scValues),
117+
)
118+
.filter(Boolean)
119+
.join(" || ")}
121120
}
122121
return false
123122
}
124123
125124
export function isValidLoneUnicodeProperty(version: number, value: string): boolean {
126-
${Array.from(Object.entries(data), ([version, { binProperties }]) =>
127-
makeVerificationCode(version, "binPropertyPatterns", binProperties, 56),
128-
).join("\n")}
129-
return false
125+
return ${Object.entries(data)
126+
.map(([version, { binProperties }]) =>
127+
makeVerificationCode(version, "binPropertySets", binProperties),
128+
)
129+
.filter(Boolean)
130+
.join(" || ")}
130131
}
131132
`
132133

@@ -172,28 +173,49 @@ function collectValues(
172173
return values
173174
}
174175

176+
function makeClassDeclarationCode(versions: string[]): string {
177+
const fields = versions
178+
.map(
179+
v =>
180+
`private _raw${v}: string\nprivate _set${v}: Set<string> | undefined`,
181+
)
182+
.join("\n")
183+
const parameters = versions.map(v => `raw${v}: string`).join(", ")
184+
const init = versions.map(v => `this._raw${v} = raw${v}`).join("\n")
185+
const getters = versions
186+
.map(
187+
v =>
188+
`public get es${v}(): Set<string> { return this._set${v} || (this._set${v} = new Set(this._raw${v}.split(" "))) }`,
189+
)
190+
.join("\n")
191+
192+
return `
193+
class DataSet {
194+
${fields}
195+
public constructor(${parameters}) {
196+
${init}
197+
}
198+
${getters}
199+
}
200+
`
201+
}
202+
203+
function makeDataCode(values: string[]): string {
204+
return `"${values
205+
.map(value => JSON.stringify(value).slice(1, -1))
206+
.join(" ")}"`
207+
}
208+
175209
function makeVerificationCode(
176210
version: string,
177211
patternVar: string,
178212
values: string[],
179-
maxLen: number,
180213
): string {
181214
if (values.length === 0) {
182215
return ""
183216
}
184217

185-
return `
186-
if (version >= ${version}) {
187-
if (${patternVar}.es${version} === null) {
188-
${patternVar}.es${version} = new Set([${values
189-
.map(v => `"${v}"`)
190-
.join()}])
191-
}
192-
if (${patternVar}.es${version}.has(value)) {
193-
return true
194-
}
195-
}
196-
`
218+
return `(version >= ${version} && ${patternVar}.es${version}.has(value))`
197219
}
198220

199221
function save(content: string): Promise<void> {

‎src/unicode/ids.ts

+8-7
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,15 @@ function isLargeIdContinue(cp: number): boolean {
4040
}
4141

4242
function initLargeIdStartRanges(): number[] {
43-
return restoreRanges([170,0,11,0,5,0,6,22,2,30,2,457,5,11,15,4,8,0,2,0,130,4,2,1,3,3,2,0,7,0,2,2,2,0,2,19,2,82,2,138,9,165,2,37,3,0,7,40,72,26,5,3,46,42,36,1,2,98,2,0,16,1,8,1,11,2,3,0,17,0,2,29,30,88,12,0,25,32,10,1,5,0,6,21,5,0,10,0,4,0,24,24,8,10,54,20,2,17,61,53,4,0,19,0,8,9,16,15,5,7,3,1,3,21,2,6,2,0,4,3,4,0,17,0,14,1,2,2,15,1,11,0,9,5,5,1,3,21,2,6,2,1,2,1,2,1,32,3,2,0,20,2,17,8,2,2,2,21,2,6,2,1,2,4,4,0,19,0,16,1,24,0,12,7,3,1,3,21,2,6,2,1,2,4,4,0,31,1,2,2,16,0,18,0,2,5,4,2,2,3,4,1,2,0,2,1,4,1,4,2,4,11,23,0,53,7,2,2,2,22,2,15,4,0,27,2,6,1,31,0,5,7,2,2,2,22,2,9,2,4,4,0,33,0,2,1,16,1,18,8,2,2,2,40,3,0,17,0,6,2,9,2,25,5,6,17,4,23,2,8,2,0,3,6,59,47,2,1,13,6,59,1,2,0,2,4,2,23,2,0,2,9,2,1,10,0,3,4,2,0,22,3,33,0,64,7,2,35,28,4,116,42,21,0,17,5,5,3,4,0,4,1,8,2,5,12,13,0,18,37,2,0,6,0,3,42,2,332,2,3,3,6,2,0,2,3,3,40,2,3,3,32,2,3,3,6,2,0,2,3,3,14,2,56,2,3,3,66,38,15,17,85,3,5,4,619,3,16,2,25,6,74,4,10,8,12,2,3,15,17,15,17,15,12,2,2,16,51,36,0,5,0,68,88,8,40,2,0,6,69,11,30,50,29,3,4,12,43,5,25,55,22,10,52,83,0,94,46,18,6,56,29,14,1,11,43,27,35,42,2,11,35,3,8,8,42,3,2,42,3,2,5,2,1,4,0,6,191,65,277,3,5,3,37,3,5,3,7,2,0,2,0,2,0,2,30,3,52,2,6,2,0,4,2,2,6,4,3,3,5,5,12,6,2,2,6,117,0,14,0,17,12,102,0,5,0,3,9,2,0,3,5,7,0,2,0,2,0,2,15,3,3,6,4,5,0,18,40,2680,46,2,46,2,132,7,3,4,1,13,37,2,0,6,0,3,55,8,0,17,22,10,6,2,6,2,6,2,6,2,6,2,6,2,6,2,6,551,2,26,8,8,4,3,4,5,85,5,4,2,89,2,3,6,42,2,93,18,31,49,15,513,6591,65,20988,4,1164,68,45,3,268,4,15,11,1,21,46,17,30,3,79,40,8,3,102,3,52,3,8,43,12,2,2,2,3,2,22,30,51,15,49,63,5,4,0,2,1,12,27,11,22,26,28,8,46,29,0,17,4,2,9,11,4,2,40,24,2,2,7,21,22,4,0,4,49,2,0,4,1,3,4,3,0,2,0,25,2,3,10,8,2,13,5,3,5,3,5,10,6,2,6,2,42,2,13,7,114,30,11171,13,22,5,48,8453,365,3,105,39,6,13,4,6,0,2,9,2,12,2,4,2,0,2,1,2,1,2,107,34,362,19,63,3,53,41,11,117,4,2,134,37,25,7,25,12,88,4,5,3,5,3,5,3,2,36,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,157,310,10,21,11,7,153,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,349,41,7,1,79,28,11,0,9,21,107,20,28,22,13,52,76,44,33,24,27,35,30,0,3,0,9,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,85,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,159,52,19,3,21,2,31,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,14,0,72,26,230,43,117,63,32,7,3,0,3,7,2,1,2,23,16,0,2,0,95,7,3,38,17,0,2,0,29,0,11,39,8,0,22,0,12,45,20,0,35,56,264,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,328,18,190,0,80,921,103,110,18,195,2749,1070,4050,582,8634,568,8,30,114,29,19,47,17,3,32,20,6,18,689,63,129,74,6,0,67,12,65,1,2,0,29,6135,9,1237,43,8,8952,286,50,2,18,3,9,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,2357,44,11,6,17,0,370,43,1301,196,60,67,8,0,1205,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42717,35,4148,12,221,3,5761,15,7472,3104,541,1507,4938,]) //eslint-disable-line @mysticatea/prettier
43+
return restoreRanges(
44+
"170 0 11 0 5 0 6 22 2 30 2 457 5 11 15 4 8 0 2 0 130 4 2 1 3 3 2 0 7 0 2 2 2 0 2 19 2 82 2 138 9 165 2 37 3 0 7 40 72 26 5 3 46 42 36 1 2 98 2 0 16 1 8 1 11 2 3 0 17 0 2 29 30 88 12 0 25 32 10 1 5 0 6 21 5 0 10 0 4 0 24 24 8 10 54 20 2 17 61 53 4 0 19 0 8 9 16 15 5 7 3 1 3 21 2 6 2 0 4 3 4 0 17 0 14 1 2 2 15 1 11 0 9 5 5 1 3 21 2 6 2 1 2 1 2 1 32 3 2 0 20 2 17 8 2 2 2 21 2 6 2 1 2 4 4 0 19 0 16 1 24 0 12 7 3 1 3 21 2 6 2 1 2 4 4 0 31 1 2 2 16 0 18 0 2 5 4 2 2 3 4 1 2 0 2 1 4 1 4 2 4 11 23 0 53 7 2 2 2 22 2 15 4 0 27 2 6 1 31 0 5 7 2 2 2 22 2 9 2 4 4 0 33 0 2 1 16 1 18 8 2 2 2 40 3 0 17 0 6 2 9 2 25 5 6 17 4 23 2 8 2 0 3 6 59 47 2 1 13 6 59 1 2 0 2 4 2 23 2 0 2 9 2 1 10 0 3 4 2 0 22 3 33 0 64 7 2 35 28 4 116 42 21 0 17 5 5 3 4 0 4 1 8 2 5 12 13 0 18 37 2 0 6 0 3 42 2 332 2 3 3 6 2 0 2 3 3 40 2 3 3 32 2 3 3 6 2 0 2 3 3 14 2 56 2 3 3 66 38 15 17 85 3 5 4 619 3 16 2 25 6 74 4 10 8 12 2 3 15 17 15 17 15 12 2 2 16 51 36 0 5 0 68 88 8 40 2 0 6 69 11 30 50 29 3 4 12 43 5 25 55 22 10 52 83 0 94 46 18 6 56 29 14 1 11 43 27 35 42 2 11 35 3 8 8 42 3 2 42 3 2 5 2 1 4 0 6 191 65 277 3 5 3 37 3 5 3 7 2 0 2 0 2 0 2 30 3 52 2 6 2 0 4 2 2 6 4 3 3 5 5 12 6 2 2 6 117 0 14 0 17 12 102 0 5 0 3 9 2 0 3 5 7 0 2 0 2 0 2 15 3 3 6 4 5 0 18 40 2680 46 2 46 2 132 7 3 4 1 13 37 2 0 6 0 3 55 8 0 17 22 10 6 2 6 2 6 2 6 2 6 2 6 2 6 2 6 551 2 26 8 8 4 3 4 5 85 5 4 2 89 2 3 6 42 2 93 18 31 49 15 513 6591 65 20988 4 1164 68 45 3 268 4 15 11 1 21 46 17 30 3 79 40 8 3 102 3 52 3 8 43 12 2 2 2 3 2 22 30 51 15 49 63 5 4 0 2 1 12 27 11 22 26 28 8 46 29 0 17 4 2 9 11 4 2 40 24 2 2 7 21 22 4 0 4 49 2 0 4 1 3 4 3 0 2 0 25 2 3 10 8 2 13 5 3 5 3 5 10 6 2 6 2 42 2 13 7 114 30 11171 13 22 5 48 8453 365 3 105 39 6 13 4 6 0 2 9 2 12 2 4 2 0 2 1 2 1 2 107 34 362 19 63 3 53 41 11 117 4 2 134 37 25 7 25 12 88 4 5 3 5 3 5 3 2 36 11 2 25 2 18 2 1 2 14 3 13 35 122 70 52 268 28 4 48 48 31 14 29 6 37 11 29 3 35 5 7 2 4 43 157 19 35 5 35 5 39 9 51 157 310 10 21 11 7 153 5 3 0 2 43 2 1 4 0 3 22 11 22 10 30 66 18 2 1 11 21 11 25 71 55 7 1 65 0 16 3 2 2 2 28 43 28 4 28 36 7 2 27 28 53 11 21 11 18 14 17 111 72 56 50 14 50 14 35 349 41 7 1 79 28 11 0 9 21 107 20 28 22 13 52 76 44 33 24 27 35 30 0 3 0 9 34 4 0 13 47 15 3 22 0 2 0 36 17 2 24 85 6 2 0 2 3 2 14 2 9 8 46 39 7 3 1 3 21 2 6 2 1 2 4 4 0 19 0 13 4 159 52 19 3 21 2 31 47 21 1 2 0 185 46 42 3 37 47 21 0 60 42 14 0 72 26 230 43 117 63 32 7 3 0 3 7 2 1 2 23 16 0 2 0 95 7 3 38 17 0 2 0 29 0 11 39 8 0 22 0 12 45 20 0 35 56 264 8 2 36 18 0 50 29 113 6 2 1 2 37 22 0 26 5 2 1 2 31 15 0 328 18 190 0 80 921 103 110 18 195 2749 1070 4050 582 8634 568 8 30 114 29 19 47 17 3 32 20 6 18 689 63 129 74 6 0 67 12 65 1 2 0 29 6135 9 1237 43 8 8952 286 50 2 18 3 9 395 2309 106 6 12 4 8 8 9 5991 84 2 70 2 1 3 0 3 1 3 3 2 11 2 0 2 6 2 64 2 3 3 7 2 6 2 27 2 3 2 4 2 0 4 6 2 339 3 24 2 24 2 30 2 24 2 30 2 24 2 30 2 24 2 30 2 24 2 7 2357 44 11 6 17 0 370 43 1301 196 60 67 8 0 1205 3 2 26 2 1 2 0 3 0 2 9 2 3 2 0 2 0 7 0 5 0 2 0 2 0 2 2 2 1 2 0 3 0 2 0 2 0 2 0 2 0 2 1 2 0 3 3 2 6 2 3 2 3 2 0 2 9 2 16 6 2 2 4 2 16 4421 42717 35 4148 12 221 3 5761 15 7472 3104 541 1507 4938",
45+
)
4446
}
4547

4648
function initLargeIdContinueRanges(): number[] {
47-
return restoreRanges([183,0,585,111,24,0,252,4,266,44,2,0,2,1,2,1,2,0,73,10,49,30,7,0,102,6,3,5,3,1,2,3,3,9,24,0,31,26,92,10,16,9,34,8,10,0,25,3,2,8,2,2,2,4,44,2,120,14,2,32,55,2,2,17,2,6,11,1,3,9,18,2,57,0,2,6,3,1,3,2,10,0,11,1,3,9,15,0,3,2,57,0,2,4,5,1,3,2,4,0,21,11,4,0,12,2,57,0,2,7,2,2,2,2,21,1,3,9,11,5,2,2,57,0,2,6,3,1,3,2,8,2,11,1,3,9,19,0,60,4,4,2,2,3,10,0,15,9,17,4,58,6,2,2,2,3,8,1,12,1,3,9,18,2,57,0,2,6,2,2,2,3,8,1,12,1,3,9,17,3,56,1,2,6,2,2,2,3,10,0,11,1,3,9,18,2,71,0,5,5,2,0,2,7,7,9,3,1,62,0,3,6,13,7,2,9,88,0,3,8,12,5,3,9,63,1,7,9,12,0,2,0,2,0,5,1,50,19,2,1,6,10,2,35,10,0,101,19,2,9,13,3,5,2,2,2,3,6,4,3,14,11,2,14,704,2,10,8,929,2,30,2,30,1,31,1,65,31,10,0,3,9,34,2,3,9,144,0,119,11,5,11,11,9,129,10,61,4,58,9,2,28,3,10,7,9,23,13,2,1,64,4,48,16,12,9,18,8,13,2,31,12,3,9,45,13,49,19,9,9,7,9,119,2,2,20,5,0,7,0,3,2,199,57,2,4,576,1,20,0,124,12,5,0,4,11,3071,2,142,0,97,31,555,5,106,1,30086,9,70,0,5,9,33,1,81,1,273,0,4,0,5,0,24,4,5,0,84,1,51,17,11,9,7,17,14,10,29,7,26,12,45,3,48,13,16,9,12,0,11,9,48,13,13,0,9,1,3,9,34,2,51,0,2,2,3,1,6,1,2,0,42,4,6,1,237,7,2,1,3,9,20261,0,738,15,17,15,4,1,25,2,193,9,38,0,702,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,370,1,154,10,176,2,54,14,32,9,16,3,46,10,54,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,2,11,83,11,7,0,161,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,193,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,84,14,5,9,243,14,166,9,71,5,2,1,3,3,2,0,2,1,13,9,120,6,3,6,4,0,29,9,41,6,2,3,9,0,10,10,47,15,406,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,330,3,19306,9,135,4,60,6,26,9,1014,0,2,54,8,3,82,0,12,1,19628,1,5319,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,262,6,10,9,419,13,1495,6,110,6,6,9,4759,9,787719,239,]) //eslint-disable-line @mysticatea/prettier
49+
return restoreRanges(
50+
"183 0 585 111 24 0 252 4 266 44 2 0 2 1 2 1 2 0 73 10 49 30 7 0 102 6 3 5 3 1 2 3 3 9 24 0 31 26 92 10 16 9 34 8 10 0 25 3 2 8 2 2 2 4 44 2 120 14 2 32 55 2 2 17 2 6 11 1 3 9 18 2 57 0 2 6 3 1 3 2 10 0 11 1 3 9 15 0 3 2 57 0 2 4 5 1 3 2 4 0 21 11 4 0 12 2 57 0 2 7 2 2 2 2 21 1 3 9 11 5 2 2 57 0 2 6 3 1 3 2 8 2 11 1 3 9 19 0 60 4 4 2 2 3 10 0 15 9 17 4 58 6 2 2 2 3 8 1 12 1 3 9 18 2 57 0 2 6 2 2 2 3 8 1 12 1 3 9 17 3 56 1 2 6 2 2 2 3 10 0 11 1 3 9 18 2 71 0 5 5 2 0 2 7 7 9 3 1 62 0 3 6 13 7 2 9 88 0 3 8 12 5 3 9 63 1 7 9 12 0 2 0 2 0 5 1 50 19 2 1 6 10 2 35 10 0 101 19 2 9 13 3 5 2 2 2 3 6 4 3 14 11 2 14 704 2 10 8 929 2 30 2 30 1 31 1 65 31 10 0 3 9 34 2 3 9 144 0 119 11 5 11 11 9 129 10 61 4 58 9 2 28 3 10 7 9 23 13 2 1 64 4 48 16 12 9 18 8 13 2 31 12 3 9 45 13 49 19 9 9 7 9 119 2 2 20 5 0 7 0 3 2 199 57 2 4 576 1 20 0 124 12 5 0 4 11 3071 2 142 0 97 31 555 5 106 1 30086 9 70 0 5 9 33 1 81 1 273 0 4 0 5 0 24 4 5 0 84 1 51 17 11 9 7 17 14 10 29 7 26 12 45 3 48 13 16 9 12 0 11 9 48 13 13 0 9 1 3 9 34 2 51 0 2 2 3 1 6 1 2 0 42 4 6 1 237 7 2 1 3 9 20261 0 738 15 17 15 4 1 25 2 193 9 38 0 702 0 227 0 150 4 294 9 1368 2 2 1 6 3 41 2 5 0 166 1 574 3 9 9 370 1 154 10 176 2 54 14 32 9 16 3 46 10 54 9 7 2 37 13 2 9 6 1 45 0 13 2 49 13 9 3 2 11 83 11 7 0 161 11 6 9 7 3 56 1 2 6 3 1 3 2 10 0 11 1 3 6 4 4 193 17 10 9 5 0 82 19 13 9 214 6 3 8 28 1 83 16 16 9 82 12 9 9 84 14 5 9 243 14 166 9 71 5 2 1 3 3 2 0 2 1 13 9 120 6 3 6 4 0 29 9 41 6 2 3 9 0 10 10 47 15 406 7 2 7 17 9 57 21 2 13 123 5 4 0 2 1 2 6 2 0 9 9 49 4 2 1 2 4 9 9 330 3 19306 9 135 4 60 6 26 9 1014 0 2 54 8 3 82 0 12 1 19628 1 5319 4 4 5 9 7 3 6 31 3 149 2 1418 49 513 54 5 49 9 0 15 0 23 4 2 14 1361 6 2 16 3 6 2 1 2 4 262 6 10 9 419 13 1495 6 110 6 6 9 4759 9 787719 239",
51+
)
4852
}
4953

5054
function isInRange(cp: number, ranges: number[]): boolean {
@@ -68,10 +72,7 @@ function isInRange(cp: number, ranges: number[]): boolean {
6872
return false
6973
}
7074

71-
function restoreRanges(diffs: number[]): number[] {
75+
function restoreRanges(data: string): number[] {
7276
let last = 0
73-
for (let i = 0; i < diffs.length; ++i) {
74-
last = diffs[i] += last
75-
}
76-
return diffs
77+
return data.split(" ").map(s => (last += parseInt(s, 10) | 0))
7778
}

0 commit comments

Comments
 (0)