main
Last change
on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
868 bytes
|
Rev | Line | |
---|
[d24f17c] | 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://github.com/tc39/proposal-is-usv-string
|
---|
| 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.