main
Last change
on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
676 bytes
|
Line | |
---|
1 | 'use strict';
|
---|
2 |
|
---|
3 | var $TypeError = require('es-errors/type');
|
---|
4 |
|
---|
5 | var callBound = require('call-bind/callBound');
|
---|
6 |
|
---|
7 | var $push = callBound('Array.prototype.push');
|
---|
8 |
|
---|
9 | var CodePointAt = require('./CodePointAt');
|
---|
10 |
|
---|
11 | // https://262.ecma-international.org/11.0/#sec-utf16decodestring
|
---|
12 |
|
---|
13 | module.exports = function UTF16DecodeString(string) {
|
---|
14 | if (typeof string !== 'string') {
|
---|
15 | throw new $TypeError('Assertion failed: `string` must be a String');
|
---|
16 | }
|
---|
17 | var codePoints = [];
|
---|
18 | var size = string.length;
|
---|
19 | var position = 0;
|
---|
20 | while (position < size) {
|
---|
21 | var cp = CodePointAt(string, position);
|
---|
22 | $push(codePoints, cp['[[CodePoint]]']);
|
---|
23 | position += cp['[[CodeUnitCount]]'];
|
---|
24 | }
|
---|
25 | return codePoints;
|
---|
26 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.