surrogate-pairs.js 912 B

123456789101112131415161718
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.highSurrogateTo = exports.highSurrogateFrom = exports.getCodePoint = exports.fromCodePoint = void 0;
  4. exports.fromCodePoint = String.fromCodePoint ||
  5. function (astralCodePoint) {
  6. return String.fromCharCode(Math.floor((astralCodePoint - 0x10000) / 0x400) + 0xd800, ((astralCodePoint - 0x10000) % 0x400) + 0xdc00);
  7. };
  8. // @ts-expect-error - String.prototype.codePointAt might not exist in older node versions
  9. exports.getCodePoint = String.prototype.codePointAt
  10. ? function (input, position) {
  11. return input.codePointAt(position);
  12. }
  13. : function (input, position) {
  14. return (input.charCodeAt(position) - 0xd800) * 0x400 + input.charCodeAt(position + 1) - 0xdc00 + 0x10000;
  15. };
  16. exports.highSurrogateFrom = 0xd800;
  17. exports.highSurrogateTo = 0xdbff;
  18. //# sourceMappingURL=surrogate-pairs.js.map