5e3ce64601e968bb2a309d29e88825c090e730de9de855cce42943cd4faef468468699d91227e8b90d457e6e110448a1f3526706ebe59a5eb1bdc9a7646edc 779 B

12345678910111213141516171819
  1. 'use strict';
  2. var GetIntrinsic = require('get-intrinsic');
  3. var $TypeError = require('es-errors/type');
  4. var $fromCharCode = GetIntrinsic('%String.fromCharCode%');
  5. var isLeadingSurrogate = require('../helpers/isLeadingSurrogate');
  6. var isTrailingSurrogate = require('../helpers/isTrailingSurrogate');
  7. // https://262.ecma-international.org/12.0/#sec-utf16decodesurrogatepair
  8. module.exports = function UTF16SurrogatePairToCodePoint(lead, trail) {
  9. if (!isLeadingSurrogate(lead) || !isTrailingSurrogate(trail)) {
  10. throw new $TypeError('Assertion failed: `lead` must be a leading surrogate char code, and `trail` must be a trailing surrogate char code');
  11. }
  12. // var cp = (lead - 0xD800) * 0x400 + (trail - 0xDC00) + 0x10000;
  13. return $fromCharCode(lead) + $fromCharCode(trail);
  14. };