main
Last change
on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago |
F4 Finalna Verzija
|
-
Property mode
set to
100644
|
File size:
880 bytes
|
Line | |
---|
1 | 'use strict';
|
---|
2 | var $ = require('../internals/export');
|
---|
3 | var uncurryThis = require('../internals/function-uncurry-this');
|
---|
4 | var requireObjectCoercible = require('../internals/require-object-coercible');
|
---|
5 | var toString = require('../internals/to-string');
|
---|
6 |
|
---|
7 | var charCodeAt = uncurryThis(''.charCodeAt);
|
---|
8 |
|
---|
9 | // `String.prototype.isWellFormed` method
|
---|
10 | // https://tc39.es/ecma262/#sec-string.prototype.iswellformed
|
---|
11 | $({ target: 'String', proto: true }, {
|
---|
12 | isWellFormed: function isWellFormed() {
|
---|
13 | var S = toString(requireObjectCoercible(this));
|
---|
14 | var length = S.length;
|
---|
15 | for (var i = 0; i < length; i++) {
|
---|
16 | var charCode = charCodeAt(S, i);
|
---|
17 | // single UTF-16 code unit
|
---|
18 | if ((charCode & 0xF800) !== 0xD800) continue;
|
---|
19 | // unpaired surrogate
|
---|
20 | if (charCode >= 0xDC00 || ++i >= length || (charCodeAt(S, i) & 0xFC00) !== 0xDC00) return false;
|
---|
21 | } return true;
|
---|
22 | }
|
---|
23 | });
|
---|
Note:
See
TracBrowser
for help on using the repository browser.