main
Last change
on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
821 bytes
|
Rev | Line | |
---|
[d565449] | 1 | 'use strict';
|
---|
| 2 |
|
---|
| 3 | var GetIntrinsic = require('get-intrinsic');
|
---|
| 4 |
|
---|
| 5 | var $TypeError = require('es-errors/type');
|
---|
| 6 | var $fromCharCode = GetIntrinsic('%String.fromCharCode%');
|
---|
| 7 |
|
---|
| 8 | // https://262.ecma-international.org/7.0/#sec-utf16decode
|
---|
| 9 |
|
---|
| 10 | var isLeadingSurrogate = require('../helpers/isLeadingSurrogate');
|
---|
| 11 | var isTrailingSurrogate = require('../helpers/isTrailingSurrogate');
|
---|
| 12 |
|
---|
| 13 | // https://262.ecma-international.org/11.0/#sec-utf16decodesurrogatepair
|
---|
| 14 |
|
---|
| 15 | module.exports = function UTF16Decode(lead, trail) {
|
---|
| 16 | if (!isLeadingSurrogate(lead) || !isTrailingSurrogate(trail)) {
|
---|
| 17 | throw new $TypeError('Assertion failed: `lead` must be a leading surrogate char code, and `trail` must be a trailing surrogate char code');
|
---|
| 18 | }
|
---|
| 19 | // var cp = (lead - 0xD800) * 0x400 + (trail - 0xDC00) + 0x10000;
|
---|
| 20 | return $fromCharCode(lead) + $fromCharCode(trail);
|
---|
| 21 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.