You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
			
				
					24 lines
				
				868 B
			
		
		
			
		
	
	
					24 lines
				
				868 B
			| 
											11 months ago
										 | '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; | ||
|  |   } | ||
|  | }); |