decode-property-map.js 421 B

1234567891011121314151617181920
  1. /**
  2. * Generate [codePoint, value] pairs from RLE array of values.
  3. */
  4. function * generateEntries(runs) {
  5. const len = runs.length - 2;
  6. for (let cp = 0, i = 0; i < len; ) {
  7. cp += runs[i++];
  8. const end = cp + runs[i++];
  9. const value = runs[i++];
  10. while (cp < end) {
  11. yield [cp++, value];
  12. }
  13. }
  14. }
  15. function decodePropertyMap(runs) {
  16. return new Map(generateEntries(runs));
  17. }
  18. module.exports = decodePropertyMap;