based on https://github.com/mozilla/pdf.js/blob/master/src/core/cmap.js#L195, cMap.length can be a really big number (up to 2^32)

I think you shall walk by codespaceRanges arrays and use low-s/high-s as ranges where codes as defined.