first
This commit is contained in:
23
node_modules/core-js/modules/es.string.is-well-formed.js
generated
vendored
Normal file
23
node_modules/core-js/modules/es.string.is-well-formed.js
generated
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
'use strict';
|
||||
var $ = require('../internals/export');
|
||||
var uncurryThis = require('../internals/function-uncurry-this');
|
||||
var requireObjectCoercible = require('../internals/require-object-coercible');
|
||||
var toString = require('../internals/to-string');
|
||||
|
||||
var charCodeAt = uncurryThis(''.charCodeAt);
|
||||
|
||||
// `String.prototype.isWellFormed` method
|
||||
// https://github.com/tc39/proposal-is-usv-string
|
||||
$({ target: 'String', proto: true }, {
|
||||
isWellFormed: function isWellFormed() {
|
||||
var S = toString(requireObjectCoercible(this));
|
||||
var length = S.length;
|
||||
for (var i = 0; i < length; i++) {
|
||||
var charCode = charCodeAt(S, i);
|
||||
// single UTF-16 code unit
|
||||
if ((charCode & 0xF800) != 0xD800) continue;
|
||||
// unpaired surrogate
|
||||
if (charCode >= 0xDC00 || ++i >= length || (charCodeAt(S, i) & 0xFC00) != 0xDC00) return false;
|
||||
} return true;
|
||||
}
|
||||
});
|
Reference in New Issue
Block a user