|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
631 bytes
|
| Line | |
|---|
| 1 | 'use strict';
|
|---|
| 2 |
|
|---|
| 3 | var CodePointAt = require('./CodePointAt');
|
|---|
| 4 |
|
|---|
| 5 | var $TypeError = require('es-errors/type');
|
|---|
| 6 |
|
|---|
| 7 | // https://262.ecma-international.org/14.0/#sec-isstringwellformedunicode
|
|---|
| 8 |
|
|---|
| 9 | module.exports = function IsStringWellFormedUnicode(string) {
|
|---|
| 10 | if (typeof string !== 'string') {
|
|---|
| 11 | throw new $TypeError('Assertion failed: `string` must be a String');
|
|---|
| 12 | }
|
|---|
| 13 | var len = string.length; // step 1
|
|---|
| 14 | var k = 0; // step 2
|
|---|
| 15 | while (k < len) { // step 3
|
|---|
| 16 | var cp = CodePointAt(string, k); // step 3.a
|
|---|
| 17 | if (cp['[[IsUnpairedSurrogate]]']) {
|
|---|
| 18 | return false; // step 3.b
|
|---|
| 19 | }
|
|---|
| 20 | k += cp['[[CodeUnitCount]]']; // step 3.c
|
|---|
| 21 | }
|
|---|
| 22 | return true; // step 4
|
|---|
| 23 | };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.