@unicode/unicode-17.0.0
Version:
JavaScript-compatible Unicode data. Arrays of code points, arrays of symbols, and regular expressions for Unicode v17.0.0’s categories, scripts, blocks, bidi, and other properties.
21 lines (18 loc) • 421 B
JavaScript
/**
* Generate [codePoint, value] pairs from RLE array of values.
*/
function * generateEntries(runs) {
const len = runs.length - 2;
for (let cp = 0, i = 0; i < len; ) {
cp += runs[i++];
const end = cp + runs[i++];
const value = runs[i++];
while (cp < end) {
yield [cp++, value];
}
}
}
function decodePropertyMap(runs) {
return new Map(generateEntries(runs));
}
module.exports = decodePropertyMap;