@@ -142,6 +142,61 @@ if (!Object.is) {
142142 } ;
143143}
144144
145+ /*! https://mths.be/codepointat v0.2.0 by @mathias */
146+ if ( ! String . prototype . codePointAt ) {
147+ ( function ( ) {
148+ 'use strict' ; // needed to support `apply`/`call` with `undefined`/`null`
149+ var defineProperty = ( function ( ) {
150+ // IE 8 only supports `Object.defineProperty` on DOM elements
151+ try {
152+ var object = { } ;
153+ var $defineProperty = Object . defineProperty ;
154+ var result = $defineProperty ( object , object , object ) && $defineProperty ;
155+ } catch ( error ) { }
156+ return result ;
157+ } ( ) ) ;
158+ var codePointAt = function ( position ) {
159+ if ( this == null ) {
160+ throw TypeError ( ) ;
161+ }
162+ var string = String ( this ) ;
163+ var size = string . length ;
164+ // `ToInteger`
165+ var index = position ? Number ( position ) : 0 ;
166+ if ( index != index ) { // better `isNaN`
167+ index = 0 ;
168+ }
169+ // Account for out-of-bounds indices:
170+ if ( index < 0 || index >= size ) {
171+ return undefined ;
172+ }
173+ // Get the first code unit
174+ var first = string . charCodeAt ( index ) ;
175+ var second ;
176+ if ( // check if it’s the start of a surrogate pair
177+ first >= 0xD800 && first <= 0xDBFF && // high surrogate
178+ size > index + 1 // there is a next code unit
179+ ) {
180+ second = string . charCodeAt ( index + 1 ) ;
181+ if ( second >= 0xDC00 && second <= 0xDFFF ) { // low surrogate
182+ // https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
183+ return ( first - 0xD800 ) * 0x400 + second - 0xDC00 + 0x10000 ;
184+ }
185+ }
186+ return first ;
187+ } ;
188+ if ( defineProperty ) {
189+ defineProperty ( String . prototype , 'codePointAt' , {
190+ 'value' : codePointAt ,
191+ 'configurable' : true ,
192+ 'writable' : true
193+ } ) ;
194+ } else {
195+ String . prototype . codePointAt = codePointAt ;
196+ }
197+ } ( ) ) ;
198+ }
199+
145200Math . log10 = Math . log10 || function ( x ) {
146201 return Math . log ( x ) * Math . LOG10E ;
147202} ;
0 commit comments