source: imaps-frontend/node_modules/es-abstract/2021/StringToCodePoints.js

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: 678 bytes
RevLine 
[d565449]1'use strict';
2
3var $TypeError = require('es-errors/type');
4
5var callBound = require('call-bind/callBound');
6
7var $push = callBound('Array.prototype.push');
8
9var CodePointAt = require('./CodePointAt');
10
11// https://262.ecma-international.org/12.0/#sec-stringtocodepoints
12
13module.exports = function StringToCodePoints(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.