https://freshlymessy.com/Designer/Scripts/Responsive/Plugins/polyfill.min.js?_version=20211217144519
1/* Polyfill service v3.108.0 2 * For detailed credits and licence information see https://github.com/financial-times/polyfill-service. 3 * 4 * Features requested: Array.prototype.filter,Array.prototype.find,Array.prototype.map,Array.prototype.some,Array.prototype.sort,String.prototype.startsWith 5 * 6 * - _ESAbstract.ArrayCreate, License: CC0 (required by "Array.prototype.map", "_ESAbstract.ArraySpeciesCreate") 7 * - _ESAbstract.Call, License: CC0 (required by "String.prototype.startsWith", "_ESAbstract.ToString", "_ESAbstract.ToPrimitive", "_ESAbstract.OrdinaryToPrimitive") 8 * - _ESAbstract.Get, License: CC0 (required by "Array.prototype.map", "_ESAbstract.ArraySpeciesCreate", "_ESAbstract.Construct", "_ESAbstract.OrdinaryCreateFromConstructor", "Object.create", "Object.defineProperties") 9 * - _ESAbstract.HasOwnProperty, License: CC0 (required by "Array.prototype.map", "_ESAbstract.ArraySpeciesCreate", "_ESAbstract.Construct", "_ESAbstract.OrdinaryCreateFromConstructor", "Object.create", "Object.defineProperties", "Object.getOwnPropertyDescriptor") 10 * - _ESAbstract.HasProperty, License: CC0 (required by "Array.prototype.some") 11 * - _ESAbstract.IsArray, License: CC0 (required by "Array.prototype.map", "_ESAbstract.ArraySpeciesCreate") 12 * - _ESAbstract.IsCallable, License: CC0 (required by "String.prototype.startsWith", "_ESAbstract.ToString", "_ESAbstract.ToPrimitive", "_ESAbstract.OrdinaryToPrimitive") 13 * - _ESAbstract.RequireObjectCoercible, License: CC0 (required by "String.prototype.startsWith") 14 * - _ESAbstract.ToBoolean, License: CC0 (required by "String.prototype.startsWith", "_ESAbstract.IsRegExp") 15 * - _ESAbstract.ToObject, License: CC0 (required by "Array.prototype.map", "_ESAbstract.ArraySpeciesCreate", "_ESAbstract.Construct", "_ESAbstract.OrdinaryCreateFromConstructor", "Object.create", "Object.defineProperties", "Object.getOwnPropertyDescriptor") 16 * - _ESAbstract.GetV, License: CC0 (required by "String.prototype.startsWith", "_ESAbstract.ToString", "_ESAbstract.ToPrimitive", "_ESAbstract.GetMethod") 17 * - _ESAbstract.GetMethod, License: CC0 (required by "String.prototype.startsWith", "_ESAbstract.ToString", "_ESAbstract.ToPrimitive") 18 * - _ESAbstract.Type, License: CC0 (required by "Array.prototype.map", "_ESAbstract.ArraySpeciesCreate", "_ESAbstract.Construct", "_ESAbstract.OrdinaryCreateFromConstructor", "Object.create", "Object.defineProperties", "Object.getOwnPropertyDescriptor", "_ESAbstract.ToPropertyKey") 19 * - _ESAbstract.GetPrototypeFromConstructor, License: CC0 (required by "Array.prototype.map", "_ESAbstract.ArraySpeciesCreate", "_ESAbstract.Construct", "_ESAbstract.OrdinaryCreateFromConstructor") 20 * - _ESAbstract.IsConstructor, License: CC0 (required by "Array.prototype.map", "_ESAbstract.ArraySpeciesCreate", "_ESAbstract.Construct") 21 * - _ESAbstract.IsRegExp, License: CC0 (required by "String.prototype.startsWith") 22 * - _ESAbstract.OrdinaryToPrimitive, License: CC0 (required by "String.prototype.startsWith", "_ESAbstract.ToString", "_ESAbstract.ToPrimitive") 23 * - _ESAbstract.ToInteger, License: CC0 (required by "Array.prototype.some", "_ESAbstract.ToLength") 24 * - _ESAbstract.ToLength, License: CC0 (required by "Array.prototype.some") 25 * - _ESAbstract.ToPrimitive, License: CC0 (required by "Array.prototype.map", "_ESAbstract.ArraySpeciesCreate", "_ESAbstract.Construct", "_ESAbstract.OrdinaryCreateFromConstructor", "Object.create", "Object.defineProperties", "Object.getOwnPropertyDescriptor", "_ESAbstract.ToPropertyKey") 26 * - _ESAbstract.ToString, License: CC0 (required by "Array.prototype.map", "_ESAbstract.ArraySpeciesCreate", "_ESAbstract.Construct", "_ESAbstract.OrdinaryCreateFromConstructor", "Object.create", "Object.defineProperties", "Object.getOwnPropertyDescriptor", "_ESAbstract.ToPropertyKey") 27 * - _ESAbstract.ToPropertyKey, License: CC0 (required by "Array.prototype.map", "_ESAbstract.ArraySpeciesCreate", "_ESAbstract.Construct", "_ESAbstract.OrdinaryCreateFromConstructor", "Object.create", "Object.defineProperties", "Object.getOwnPropertyDescriptor") 28 * - Object.defineProperty, License: CC0 (required by "Array.prototype.map", "_ESAbstract.ArraySpeciesCreate", "_ESAbstract.Construct", "_ESAbstract.OrdinaryCreateFromConstructor", "Object.create", "Object.defineProperties") 29 * - _ESAbstract.CreateDataProperty, License: CC0 (required by "Array.prototype.map", "_ESAbstract.CreateDataPropertyOrThrow") 30 * - _ESAbstract.CreateDataPropertyOrThrow, License: CC0 (required by "Array.prototype.map") 31 * - _ESAbstract.CreateMethodProperty, License: CC0 (required by "Array.prototype.map", "_ESAbstract.ArraySpeciesCreate", "_ESAbstract.Construct", "_ESAbstract.OrdinaryCreateFromConstructor", "Object.create", "Object.defineProperties", "Object.getOwnPropertyDescriptor") 32 * - Array.prototype.find, License: CC0 33 * - Array.prototype.some, License: CC0 34 * - Function.prototype.bind, License: MIT (required by "Array.prototype.map", "_ESAbstract.ArraySpeciesCreate", "_ESAbstract.Construct", "_ESAbstract.OrdinaryCreateFromConstructor", "Object.create", "Object.defineProperties", "Object.getOwnPropertyDescriptor") 35 * - Object.getOwnPropertyDescriptor, License: CC0 (required by "Array.prototype.map", "_ESAbstract.ArraySpeciesCreate", "_ESAbstract.Construct", "_ESAbstract.OrdinaryCreateFromConstructor", "Object.create", "Object.defineProperties") 36 * - Object.getPrototypeOf, License: CC0 (required by "Array.prototype.map", "_ESAbstract.ArraySpeciesCreate", "_ESAbstract.Construct", "_ESAbstract.OrdinaryCreateFromConstructor") 37 * - Object.keys, License: MIT (required by "Array.prototype.map", "_ESAbstract.ArraySpeciesCreate", "_ESAbstract.Construct", "_ESAbstract.OrdinaryCreateFromConstructor", "Object.create", "Object.defineProperties") 38 * - Object.defineProperties, License: CC0 (required by "Array.prototype.map", "_ESAbstract.ArraySpeciesCreate", "_ESAbstract.Construct", "_ESAbstract.OrdinaryCreateFromConstructor", "Object.create") 39 * - Object.create, License: CC0 (required by "Array.prototype.map", "_ESAbstract.ArraySpeciesCreate", "_ESAbstract.Construct", "_ESAbstract.OrdinaryCreateFromConstructor") 40 * - _ESAbstract.OrdinaryCreateFromConstructor, License: CC0 (required by "Array.prototype.map", "_ESAbstract.ArraySpeciesCreate", "_ESAbstract.Construct") 41 * - _ESAbstract.Construct, License: CC0 (required by "Array.prototype.map", "_ESAbstract.ArraySpeciesCreate") 42 * - _ESAbstract.ArraySpeciesCreate, License: CC0 (required by "Array.prototype.map") 43 * - Array.prototype.filter, License: CC0 44 * - Array.prototype.map, License: CC0 (required by "Array.prototype.sort") 45 * - Array.prototype.sort, License: MIT 46 * - String.prototype.startsWith, License: CC0 */ 47 48(function (self, undefined) { 49 50 // _ESAbstract.ArrayCreate 51 // 9.4.2.2. ArrayCreate ( length [ , proto ] ) 52 function ArrayCreate(length /* [, proto] */) { // eslint-disable-line no-unused-vars 53 // 1. Assert: length is an integer Number ⥠0. 54 // 2. If length is -0, set length to +0. 55 if (1 / length === -Infinity) { 56 length = 0; 57 } 58 // 3. If length>2^32-1, throw a RangeError exception. 59 if (length > (Math.pow(2, 32) - 1)) { 60 throw new RangeError('Invalid array length'); 61 } 62 // 4. If proto is not present, set proto to the intrinsic object %ArrayPrototype%. 63 // 5. Let A be a newly created Array exotic object. 64 var A = []; 65 // 6. Set A's essential internal methods except for [[DefineOwnProperty]] to the default ordinary object definitions specified in 9.1. 66 // 7. Set A.[[DefineOwnProperty]] as specified in 9.4.2.1. 67 // 8. Set A.[[Prototype]] to proto. 68 // 9. Set A.[[Extensible]] to true. 69 // 10. Perform ! OrdinaryDefineOwnProperty(A, "length", PropertyDescriptor{[[Value]]: length, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: false}). 70 A.length = length; 71 // 11. Return A. 72 return A; 73 } 74 75 // _ESAbstract.Call 76 /* global IsCallable */ 77 // 7.3.12. Call ( F, V [ , argumentsList ] ) 78 function Call(F, V /* [, argumentsList] */) { // eslint-disable-line no-unused-vars 79 // 1. If argumentsList is not present, set argumentsList to a new empty List. 80 var argumentsList = arguments.length > 2 ? arguments[2] : []; 81 // 2. If IsCallable(F) is false, throw a TypeError exception. 82 if (IsCallable(F) === false) { 83 throw new TypeError(Object.prototype.toString.call(F) + 'is not a function.'); 84 } 85 // 3. Return ? F.[[Call]](V, argumentsList). 86 return F.apply(V, argumentsList); 87 } 88 89 // _ESAbstract.Get 90 // 7.3.1. Get ( O, P ) 91 function Get(O, P) { // eslint-disable-line no-unused-vars
92 // 1. Assert: Type(O) is Object. 93 // 2. Assert: IsPropertyKey(P) is true. 94 // 3. Return ? O.[[Get]](P, O). 95 return O[P]; 96 } 97 98 // _ESAbstract.HasOwnProperty 99 // 7.3.11 HasOwnProperty (O, P) 100 function HasOwnProperty(o, p) { // eslint-disable-line no-unused-vars 101 // 1. Assert: Type(O) is Object. 102 // 2. Assert: IsPropertyKey(P) is true. 103 // 3. Let desc be ? O.[[GetOwnProperty]](P). 104 // 4. If desc is undefined, return false. 105 // 5. Return true. 106 // Polyfill.io - As we expect user agents to support ES3 fully we can skip the above steps and use Object.prototype.hasOwnProperty to do them for us. 107 return Object.prototype.hasOwnProperty.call(o, p); 108 } 109 110 // _ESAbstract.HasProperty 111 // 7.3.10. HasProperty ( O, P ) 112 function HasProperty(O, P) { // eslint-disable-line no-unused-vars 113 // Assert: Type(O) is Object. 114 // Assert: IsPropertyKey(P) is true. 115 // Return ? O.[[HasProperty]](P). 116 return P in O; 117 } 118 119 // _ESAbstract.IsArray 120 // 7.2.2. IsArray ( argument ) 121 function IsArray(argument) { // eslint-disable-line no-unused-vars 122 // 1. If Type(argument) is not Object, return false. 123 // 2. If argument is an Array exotic object, return true. 124 // 3. If argument is a Proxy exotic object, then 125 // a. If argument.[[ProxyHandler]] is null, throw a TypeError exception. 126 // b. Let target be argument.[[ProxyTarget]]. 127 // c. Return ? IsArray(target). 128 // 4. Return false. 129 130 // Polyfill.io - We can skip all the above steps and check the string returned from Object.prototype.toString(). 131 return Object.prototype.toString.call(argument) === '[object Array]'; 132 } 133 134 // _ESAbstract.IsCallable 135 // 7.2.3. IsCallable ( argument ) 136 function IsCallable(argument) { // eslint-disable-line no-unused-vars 137 // 1. If Type(argument) is not Object, return false. 138 // 2. If argument has a [[Call]] internal method, return true. 139 // 3. Return false. 140 141 // Polyfill.io - Only function objects have a [[Call]] internal method. This means we can simplify this function to check that the argument has a type of function. 142 return typeof argument === 'function'; 143 } 144 145 // _ESAbstract.RequireObjectCoercible 146 // 7.2.1. RequireObjectCoercible ( argument ) 147 // The abstract operation ToObject converts argument to a value of type Object according to Table 12: 148 // Table 12: ToObject Conversions 149 /* 150 |----------------------------------------------------------------------------------------------------------------------------------------------------| 151 | Argument Type | Result | 152 |----------------------------------------------------------------------------------------------------------------------------------------------------| 153 | Undefined | Throw a TypeError exception. | 154 | Null | Throw a TypeError exception. | 155 | Boolean | Return argument. | 156 | Number | Return argument. | 157 | String | Return argument. | 158 | Symbol | Return argument. | 159 | Object | Return argument. | 160 |----------------------------------------------------------------------------------------------------------------------------------------------------| 161 */ 162 function RequireObjectCoercible(argument) { // eslint-disable-line no-unused-vars 163 if (argument === null || argument === undefined) { 164 throw TypeError(Object.prototype.toString.call(argument) + ' is not coercible to Object.'); 165 } 166 return argument; 167 } 168 169 // _ESAbstract.ToBoolean 170 // 7.1.2. ToBoolean ( argument ) 171 // The abstract operation ToBoolean converts argument to a value of type Boolean according to Table 9: 172 /* 173 -------------------------------------------------------------------------------------------------------------- 174 | Argument Type | Result | 175 --------------------------------------------------------------------------------------------------------------
176 | Undefined | Return false. | 177 | Null | Return false. | 178 | Boolean | Return argument. | 179 | Number | If argument is +0, -0, or NaN, return false; otherwise return true. | 180 | String | If argument is the empty String (its length is zero), return false; otherwise return true. | 181 | Symbol | Return true. | 182 | Object | Return true. | 183 -------------------------------------------------------------------------------------------------------------- 184 */ 185 function ToBoolean(argument) { // eslint-disable-line no-unused-vars 186 return Boolean(argument); 187 } 188 189 // _ESAbstract.ToObject 190 // 7.1.13 ToObject ( argument ) 191 // The abstract operation ToObject converts argument to a value of type Object according to Table 12: 192 // Table 12: ToObject Conversions 193 /* 194 |----------------------------------------------------------------------------------------------------------------------------------------------------| 195 | Argument Type | Result | 196 |----------------------------------------------------------------------------------------------------------------------------------------------------| 197 | Undefined | Throw a TypeError exception. | 198 | Null | Throw a TypeError exception. | 199 | Boolean | Return a new Boolean object whose [[BooleanData]] internal slot is set to argument. See 19.3 for a description of Boolean objects. | 200 | Number | Return a new Number object whose [[NumberData]] internal slot is set to argument. See 20.1 for a description of Number objects. | 201 | String | Return a new String object whose [[StringData]] internal slot is set to argument. See 21.1 for a description of String objects. | 202 | Symbol | Return a new Symbol object whose [[SymbolData]] internal slot is set to argument. See 19.4 for a description of Symbol objects. | 203 | Object | Return argument. | 204 |----------------------------------------------------------------------------------------------------------------------------------------------------| 205 */ 206 function ToObject(argument) { // eslint-disable-line no-unused-vars 207 if (argument === null || argument === undefined) { 208 throw TypeError(); 209 } 210 return Object(argument); 211 } 212 213 // _ESAbstract.GetV 214 /* global ToObject */ 215 // 7.3.2 GetV (V, P) 216 function GetV(v, p) { // eslint-disable-line no-unused-vars 217 // 1. Assert: IsPropertyKey(P) is true. 218 // 2. Let O be ? ToObject(V). 219 var o = ToObject(v); 220 // 3. Return ? O.[[Get]](P, V). 221 return o[p]; 222 } 223 224 // _ESAbstract.GetMethod 225 /* global GetV, IsCallable */ 226 // 7.3.9. GetMethod ( V, P ) 227 function GetMethod(V, P) { // eslint-disable-line no-unused-vars 228 // 1. Assert: IsPropertyKey(P) is true. 229 // 2. Let func be ? GetV(V, P). 230 var func = GetV(V, P); 231 // 3. If func is either undefined or null, return undefined. 232 if (func === null || func === undefined) { 233 return undefined; 234 } 235 // 4. If IsCallable(func) is false, throw a TypeError exception. 236 if (IsCallable(func) === false) { 237 throw new TypeError('Method not callable: ' + P); 238 } 239 // 5. Return func. 240 return func; 241 } 242 243 // _ESAbstract.Type 244 // "Type(x)" is used as shorthand for "the type of x"... 245 function Type(x) { // eslint-disable-line no-unused-vars 246 switch (typeof x) { 247 case 'undefined': 248 return 'undefined'; 249 case 'boolean': 250 return 'boolean'; 251 case 'number': 252 return 'number'; 253 case 'string': 254 return 'string'; 255 case 'symbol': 256 return 'symbol'; 257 default: 258 // typeof null is 'object' 259 if (x === null) return 'null'; 260 // Polyfill.io - This is here because a Symbol polyfill will have a typeof `object`. 261 if ('Symbol' in self && (x instanceof self.Symbol || x.constructor === self.Symbol)) return 'symbol'; 262 263 return 'object'; 264 } 265 } 266 267 // _ESAbstract.GetPrototypeFromConstructor 268 /* global Get, Type */ 269 // 9.1.14. GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto ) 270 function GetPrototypeFromConstructor(constructor, intrinsicDefaultProto) { // eslint-disable-line no-unused-vars 271 // 1. Assert: intrinsicDefaultProto is a String value that is this specification's name of an intrinsic object. The corresponding object must be an intrinsic that is intended to be used as the [[Prototype]] value of an object. 272 // 2. Assert: IsCallable(constructor) is true. 273 // 3. Let proto be ? Get(constructor, "prototype"). 274 var proto = Get(constructor, "prototype"); 275 // 4. If Type(proto) is not Object, then 276 if (Type(proto) !== 'object') { 277 // a. Let realm be ? GetFunctionRealm(constructor). 278 // b. Set proto to realm's intrinsic object named intrinsicDefaultProto. 279 proto = intrinsicDefaultProto; 280 } 281 // 5. Return proto. 282 return proto; 283 } 284 285 // _ESAbstract.IsConstructor 286 /* global Type */ 287 // 7.2.4. IsConstructor ( argument ) 288 function IsConstructor(argument) { // eslint-disable-line no-unused-vars 289 // 1. If Type(argument) is not Object, return false. 290 if (Type(argument) !== 'object') { 291 return false; 292 } 293 // 2. If argument has a [[Construct]] internal method, return true. 294 // 3. Return false. 295 296 // Polyfill.io - `new argument` is the only way to truly test if a function is a constructor. 297 // We choose to not use`new argument` because the argument could have side effects when called. 298 // Instead we check to see if the argument is a function and if it has a prototype. 299 // Arrow functions do not have a [[Construct]] internal method, nor do they have a prototype. 300 return typeof argument === 'function' && !!argument.prototype; 301 } 302 303 // _ESAbstract.IsRegExp 304 /* global Type, Get, ToBoolean */ 305 // 7.2.8. IsRegExp ( argument ) 306 function IsRegExp(argument) { // eslint-disable-line no-unused-vars 307 // 1. If Type(argument) is not Object, return false. 308 if (Type(argument) !== 'object') { 309 return false; 310 } 311 // 2. Let matcher be ? Get(argument, @@match). 312 var matcher = 'Symbol' in self && 'match' in self.Symbol ? Get(argument, self.Symbol.match) : undefined; 313 // 3. If matcher is not undefined, return ToBoolean(matcher). 314 if (matcher !== undefined) { 315 return ToBoolean(matcher); 316 } 317 // 4. If argument has a [[RegExpMatcher]] internal slot, return true. 318 try { 319 var lastIndex = argument.lastIndex; 320 argument.lastIndex = 0; 321 RegExp.prototype.exec.call(argument); 322 return true; 323 // eslint-disable-next-line no-empty 324 } catch (e) { } finally { 325 argument.lastIndex = lastIndex; 326 } 327 // 5. Return false. 328 return false; 329 } 330 331 // _ESAbstract.OrdinaryToPrimitive 332 /* global Get, IsCallable, Call, Type */ 333 // 7.1.1.1. OrdinaryToPrimitive ( O, hint ) 334 function OrdinaryToPrimitive(O, hint) { // eslint-disable-line no-unused-vars
335 // 1. Assert: Type(O) is Object. 336 // 2. Assert: Type(hint) is String and its value is either "string" or "number". 337 // 3. If hint is "string", then 338 if (hint === 'string') { 339 // a. Let methodNames be « "toString", "valueOf" ». 340 var methodNames = ['toString', 'valueOf']; 341 // 4. Else, 342 } else { 343 // a. Let methodNames be « "valueOf", "toString" ». 344 methodNames = ['valueOf', 'toString']; 345 } 346 // 5. For each name in methodNames in List order, do 347 for (var i = 0; i < methodNames.length; ++i) { 348 var name = methodNames[i]; 349 // a. Let method be ? Get(O, name). 350 var method = Get(O, name); 351 // b. If IsCallable(method) is true, then 352 if (IsCallable(method)) { 353 // i. Let result be ? Call(method, O). 354 var result = Call(method, O); 355 // ii. If Type(result) is not Object, return result. 356 if (Type(result) !== 'object') { 357 return result; 358 } 359 } 360 } 361 // 6. Throw a TypeError exception. 362 throw new TypeError('Cannot convert to primitive.'); 363 } 364 365 // _ESAbstract.ToInteger 366 /* global Type */ 367 // 7.1.4. ToInteger ( argument ) 368 function ToInteger(argument) { // eslint-disable-line no-unused-vars 369 if (Type(argument) === 'symbol') { 370 throw new TypeError('Cannot convert a Symbol value to a number'); 371 } 372 373 // 1. Let number be ? ToNumber(argument). 374 var number = Number(argument); 375 // 2. If number is NaN, return +0. 376 if (isNaN(number)) { 377 return 0; 378 } 379 // 3. If number is +0, -0, +â, or -â, return number. 380 if (1 / number === Infinity || 1 / number === -Infinity || number === Infinity || number === -Infinity) { 381 return number; 382 } 383 // 4. Return the number value that is the same sign as number and whose magnitude is floor(abs(number)). 384 return ((number < 0) ? -1 : 1) * Math.floor(Math.abs(number)); 385 } 386 387 // _ESAbstract.ToLength 388 /* global ToInteger */ 389 // 7.1.15. ToLength ( argument ) 390 function ToLength(argument) { // eslint-disable-line no-unused-vars 391 // 1. Let len be ? ToInteger(argument). 392 var len = ToInteger(argument); 393 // 2. If len ⤠+0, return +0. 394 if (len <= 0) { 395 return 0; 396 } 397 // 3. Return min(len, 253-1). 398 return Math.min(len, Math.pow(2, 53) - 1); 399 } 400 401 // _ESAbstract.ToPrimitive 402 /* global Type, GetMethod, Call, OrdinaryToPrimitive */ 403 // 7.1.1. ToPrimitive ( input [ , PreferredType ] ) 404 function ToPrimitive(input /* [, PreferredType] */) { // eslint-disable-line no-unused-vars 405 var PreferredType = arguments.length > 1 ? arguments[1] : undefined; 406 // 1. Assert: input is an ECMAScript language value. 407 // 2. If Type(input) is Object, then 408 if (Type(input) === 'object') { 409 // a. If PreferredType is not present, let hint be "default". 410 if (arguments.length < 2) { 411 var hint = 'default'; 412 // b. Else if PreferredType is hint String, let hint be "string". 413 } else if (PreferredType === String) { 414 hint = 'string'; 415 // c. Else PreferredType is hint Number, let hint be "number". 416 } else if (PreferredType === Number) { 417 hint = 'number'; 418 } 419 // d. Let exoticToPrim be ? GetMethod(input, @@toPrimitive). 420 var exoticToPrim = typeof self.Symbol === 'function' && typeof self.Symbol.toPrimitive === 'symbol' ? GetMethod(input, self.Symbol.toPrimitive) : undefined; 421 // e. If exoticToPrim is not undefined, then 422 if (exoticToPrim !== undefined) { 423 // i. Let result be ? Call(exoticToPrim, input, « hint »). 424 var result = Call(exoticToPrim, input, [hint]); 425 // ii. If Type(result) is not Object, return result. 426 if (Type(result) !== 'object') { 427 return result; 428 } 429 // iii. Throw a TypeError exception. 430 throw new TypeError('Cannot convert exotic object to primitive.'); 431 } 432 // f. If hint is "default", set hint to "number". 433 if (hint === 'default') { 434 hint = 'number'; 435 } 436 // g. Return ? OrdinaryToPrimitive(input, hint). 437 return OrdinaryToPrimitive(input, hint); 438 } 439 // 3. Return input 440 return input; 441 } 442 443 // _ESAbstract.ToString 444 /* global Type, ToPrimitive */ 445 // 7.1.12. ToString ( argument ) 446 // The abstract operation ToString converts argument to a value of type Str
446ing according to Table 11: 447 // Table 11: ToString Conversions 448 /* 449 |---------------|--------------------------------------------------------| 450 | Argument Type | Result | 451 |---------------|--------------------------------------------------------| 452 | Undefined | Return "undefined". | 453 |---------------|--------------------------------------------------------| 454 | Null | Return "null". | 455 |---------------|--------------------------------------------------------| 456 | Boolean | If argument is true, return "true". | 457 | | If argument is false, return "false". | 458 |---------------|--------------------------------------------------------| 459 | Number | Return NumberToString(argument). | 460 |---------------|--------------------------------------------------------| 461 | String | Return argument. | 462 |---------------|--------------------------------------------------------| 463 | Symbol | Throw a TypeError exception. | 464 |---------------|--------------------------------------------------------| 465 | Object | Apply the following steps: | 466 | | Let primValue be ? ToPrimitive(argument, hint String). | 467 | | Return ? ToString(primValue). | 468 |---------------|--------------------------------------------------------| 469 */ 470 function ToString(argument) { // eslint-disable-line no-unused-vars 471 switch (Type(argument)) { 472 case 'symbol': 473 throw new TypeError('Cannot convert a Symbol value to a string'); 474 case 'object': 475 var primValue = ToPrimitive(argument, String); 476 return ToString(primValue); // eslint-disable-line no-unused-vars 477 default: 478 return String(argument); 479 } 480 } 481 482 // _ESAbstract.ToPropertyKey 483 /* globals ToPrimitive, Type, ToString */ 484 // 7.1.14. ToPropertyKey ( argument ) 485 function ToPropertyKey(argument) { // eslint-disable-line no-unused-vars 486 // 1. Let key be ? ToPrimitive(argument, hint String). 487 var key = ToPrimitive(argument, String); 488 // 2. If Type(key) is Symbol, then 489 if (Type(key) === 'symbol') { 490 // a. Return key. 491 return key; 492 } 493 // 3. Return ! ToString(key). 494 return ToString(key); 495 } 496 497 // Object.defineProperty 498 499 // _ESAbstract.CreateDataProperty 500 // 7.3.4. CreateDataProperty ( O, P, V ) 501 // NOTE 502 // This abstract operation creates a property whose attributes are set to the same defaults used for properties created by the ECMAScript language assignment operator. 503 // Normally, the property will not already exist. If it does exist and is not configurable or if O is not extensible, [[DefineOwnProperty]] will return false. 504 function CreateDataProperty(O, P, V) { // eslint-disable-line no-unused-vars 505 // 1. Assert: Type(O) is Object. 506 // 2. Assert: IsPropertyKey(P) is true. 507 // 3. Let newDesc be the PropertyDescriptor{ [[Value]]: V, [[Writable]]: true, [[Enumerable]]: true, [[Configurable]]: true }. 508 var newDesc = { 509 value: V, 510 writable: true, 511 enumerable: true, 512 configurable: true 513 }; 514 // 4. Return ? O.[[DefineOwnProperty]](P, newDesc). 515 try { 516 Object.defineProperty(O, P, newDesc); 517 return true; 518 } catch (e) { 519 return false; 520 } 521 } 522 523 // _ESAbstract.CreateDataPropertyOrThrow 524 /* global CreateDataProperty */ 525 // 7.3.6. CreateDataPropertyOrThrow ( O, P, V ) 526 function CreateDataPropertyOrThrow(O, P, V) { // eslint-disable-line no-unused-vars 527 // 1. Assert: Type(O) is Object. 528 // 2. Assert: IsPropertyKey(P) is true. 529 // 3. Let success be ? CreateDataProperty(O, P, V). 530 var success = CreateDataProperty(O, P, V); 531 // 4. If success is false, throw a TypeError exception. 532 if (!success) { 533 throw new TypeError('Cannot assign value `' + Object.prototype.toString.call(V) + '` to property `' + Object.prototype.toString.call(P) + '` on object `' + Object.prototype.toString.call(O) + '`'); 534 } 535 // 5. Return success. 536 return success; 537 } 538 539 // _ESAbstract.CreateMethodProperty 540 // 7.3.5. CreateMethodProperty ( O, P, V ) 541 function CreateMethodProperty(O, P, V) { // eslint-disable-line no-unused-vars
542 // 1. Assert: Type(O) is Object. 543 // 2. Assert: IsPropertyKey(P) is true. 544 // 3. Let newDesc be the PropertyDescriptor{[[Value]]: V, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true}. 545 var newDesc = { 546 value: V, 547 writable: true, 548 enumerable: false, 549 configurable: true 550 }; 551 // 4. Return ? O.[[DefineOwnProperty]](P, newDesc). 552 Object.defineProperty(O, P, newDesc); 553 } 554 555 // Array.prototype.find 556 /* global Call, CreateMethodProperty, Get, IsCallable, ToBoolean, ToLength, ToObject, ToString */ 557 // 22.1.3.8 Array.prototype.find ( predicate [ , thisArg ] ) 558 CreateMethodProperty(Array.prototype, 'find', function find(predicate /* [ , thisArg ] */) { 559 // 1. Let O be ? ToObject(this value). 560 var O = ToObject(this); 561 // 2. Let len be ? ToLength(? Get(O, "length")). 562 var len = ToLength(Get(O, "length")); 563 // 3. If IsCallable(predicate) is false, throw a TypeError exception. 564 if (IsCallable(predicate) === false) { 565 throw new TypeError(predicate + ' is not a function'); 566 } 567 // 4. If thisArg is present, let T be thisArg; else let T be undefined. 568 var T = arguments.length > 1 ? arguments[1] : undefined; 569 // 5. Let k be 0. 570 var k = 0; 571 // 6. Repeat, while k < len 572 while (k < len) { 573 // a. Let Pk be ! ToString(k). 574 var Pk = ToString(k); 575 // b. Let kValue be ? Get(O, Pk). 576 var kValue = Get(O, Pk); 577 // c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). 578 var testResult = ToBoolean(Call(predicate, T, [kValue, k, O])); 579 // d. If testResult is true, return kValue. 580 if (testResult) { 581 return kValue; 582 } 583 // e. Increase k by 1. 584 k = k + 1; 585 } 586 // 7. Return undefined. 587 return undefined; 588 }); 589 590 // Array.prototype.some 591 /* global Call, CreateMethodProperty, Get, HasProperty, IsCallable, ToBoolean, ToLength, ToObject, ToString */ 592 // 22.1.3.24. Array.prototype.some ( callbackfn [ , thisArg ] ) 593 CreateMethodProperty(Array.prototype, 'some', function some(callbackfn /* [ , thisArg ] */) { 594 // 1. Let O be ? ToObject(this value). 595 var O = ToObject(this); 596 // 2. Let len be ? ToLength(? Get(O, "length")). 597 var len = ToLength(Get(O, "length")); 598 // 3. If IsCallable(callbackfn) is false, throw a TypeError exception. 599 if (IsCallable(callbackfn) === false) { 600 throw new TypeError(callbackfn + ' is not a function'); 601 } 602 // 4. If thisArg is present, let T be thisArg; else let T be undefined. 603 var T = arguments.length > 1 ? arguments[1] : undefined; 604 // 5. Let k be 0. 605 var k = 0; 606 // 6. Repeat, while k < len 607 while (k < len) { 608 // a. Let Pk be ! ToString(k). 609 var Pk = ToString(k); 610 // b. Let kPresent be ? HasProperty(O, Pk). 611 var kPresent = HasProperty(O, Pk); 612 // c. If kPresent is true, then 613 if (kPresent) { 614 // i. Let kValue be ? Get(O, Pk). 615 var kValue = Get(O, Pk); 616 // ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). 617 var testResult = ToBoolean(Call(callbackfn, T, [kValue, k, O])); 618 // iii. If testResult is true, return true. 619 if (testResult) { 620 return true; 621 } 622 } 623 // d. Increase k by 1. 624 k = k + 1; 625 } 626 // 7. Return false. 627 return false; 628 }); 629 630 // Object.getOwnPropertyDescriptor 631 /* global CreateMethodProperty, ToObject, ToPropertyKey, HasOwnProperty, Type */ 632 (function () { 633 var nativeGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; 634 635 var supportsDOMDescriptors = (function () { 636 try { 637 return Object.defineProperty(document.createElement('div'), 'one', { 638 get: function () { 639 return 1; 640 } 641 }).one === 1; 642 } catch (e) { 643 return false; 644 } 645 }); 646 647 var toString = ({}).toString; 648 var split = ''.split; 649 650 // 19.1.2.8 Object.getOwnPropertyDescriptor ( O, P ) 651 CreateMethodProperty(Object, 'getOwnPropertyDescriptor', function getOwnPropertyDescriptor(O, P) { 652 // 1. Let obj be ? ToObject(O). 653 var obj = ToObject(O); 654 // Polyfill.io fallback for non-array-like strings which exist in some ES3 user-agents (IE 8) 655 obj = (Type(obj) === 'string' || obj instanceof String) && toString.call(O) == '[object String]' ? split.call(O, '') : Object(O); 656 657 // 2. Let key be ? ToPropertyKey(P). 658 var key = ToPropertyKey(P); 659 660 // 3. Let desc be ? obj.[[GetOwnProperty]](key). 661 // 4. Return FromPropertyDescriptor(desc). 662 // Polyfill.io Internet Explorer 8 natively supports property descriptors only on DOM objects. 663 // We will fallback to the polyfill implementation if the native implementation throws an error. 664 if (supportsDOMDescriptors) { 665 try { 666 return nativeGetOwnPropertyDescriptor(obj, key); 667 // eslint-disable-next-line no-empty 668 } catch (error) { } 669 } 670 if (HasOwnProperty(obj, key)) { 671 return { 672 enumerable: true, 673 configurable: true, 674 writable: true, 675 value: obj[key] 676 }; 677 } 678 }); 679 }()); 680 681 // Object.getPrototypeOf 682 /* global CreateMethodProperty */ 683 // Based on: https://github.com/es-shims/es5-shim/blob/master/es5-sham.js 684 685 // https://github.com/es-shims/es5-shim/issues#issue/2 686 // http://ejohn.org/blog/objectgetprototypeof/ 687 // recommended by fschaefer on github 688 // 689 // sure, and webreflection says ^_^ 690 // ... this will nerever possibly return null 691 // ... Opera Mini breaks here with infinite loops 692 CreateMethodProperty(Object, 'getPrototypeOf', function getPrototypeOf(object) { 693 if (object !== Object(object)) { 694 throw new TypeError('Object.getPrototypeOf called on non-object'); 695 } 696 var proto = object.__proto__; 697 if (proto || proto === null) { 698 return proto; 699 } else if (typeof object.constructor == 'function' && object instanceof object.constructor) { 700 return object.constructor.prototype; 701 } else if (object instanceof Object) { 702 return Object.prototype; 703 } else { 704 // Correctly return null for Objects created with `Object.create(null)` 705 // (shammed or native) or `{ __proto__: null}`. Also returns null for 706 // cross-realm objects on browsers that lack `__proto__` support (like 707 // IE <11), but that's the best we can do. 708 return null; 709 } 710 }); 711 712 // Object.keys 713 /* global CreateMethodProperty */ 714 CreateMethodProperty(Object, "keys", (function () { 715 'use strict'; 716 717 // modified from https://github.com/es-shims/object-keys 718 719 var has = Object.prototype.hasOwnProperty; 720 var toStr = Object.prototype.toString; 721 var isEnumerable = Object.prototype.propertyIsEnumerable; 722 var hasDontEnumBug = !isEnumerable.call({ toString: null }, 'toString'); 723 var hasPrototypeEnumBug = isEnumerable.call(function () { }, 'prototype'); 724 function hasProtoEnumBug() { 725 // Object.create polyfill creates an enumerable __proto__ 726 var createdObj; 727 try { 728 createdObj = Object.create({}); 729 } catch (e) { 730 // If this fails the polyfil isn't loaded yet, but will be.
vendor: 4,859 bytes, lines 731-885
731 // Can't add it to depedencies because of it would create a circular depedency. 732 return true; 733 } 734 735 return isEnumerable.call(createdObj, '__proto__') 736 } 737 738 var dontEnums = [ 739 'toString', 740 'toLocaleString', 741 'valueOf', 742 'hasOwnProperty', 743 'isPrototypeOf', 744 'propertyIsEnumerable', 745 'constructor' 746 ]; 747 var equalsConstructorPrototype = function (o) { 748 var ctor = o.constructor; 749 return ctor && ctor.prototype === o; 750 }; 751 var excludedKeys = { 752 $console: true, 753 $external: true, 754 $frame: true, 755 $frameElement: true, 756 $frames: true, 757 $innerHeight: true, 758 $innerWidth: true, 759 $outerHeight: true, 760 $outerWidth: true, 761 $pageXOffset: true, 762 $pageYOffset: true, 763 $parent: true, 764 $scrollLeft: true, 765 $scrollTop: true, 766 $scrollX: true, 767 $scrollY: true, 768 $self: true, 769 $webkitIndexedDB: true, 770 $webkitStorageInfo: true, 771 $window: true 772 }; 773 var hasAutomationEqualityBug = (function () { 774 if (typeof window === 'undefined') { return false; } 775 for (var k in window) { 776 try { 777 if (!excludedKeys['$' + k] && has.call(window, k) && window[k] !== null && typeof window[k] === 'object') { 778 try { 779 equalsConstructorPrototype(window[k]); 780 } catch (e) { 781 return true; 782 } 783 } 784 } catch (e) { 785 return true; 786 } 787 } 788 return false; 789 }()); 790 var equalsConstructorPrototypeIfNotBuggy = function (o) { 791 if (typeof window === 'undefined' || !hasAutomationEqualityBug) { 792 return equalsConstructorPrototype(o); 793 } 794 try { 795 return equalsConstructorPrototype(o); 796 } catch (e) { 797 return false; 798 } 799 }; 800 801 function isArgumentsObject(value) { 802 var str = toStr.call(value); 803 var isArgs = str === '[object Arguments]'; 804 if (!isArgs) { 805 isArgs = str !== '[object Array]' && 806 value !== null && 807 typeof value === 'object' && 808 typeof value.length === 'number' && 809 value.length >= 0 && 810 toStr.call(value.callee) === '[object Function]'; 811 } 812 return isArgs; 813 } 814 815 return function keys(object) { 816 var isFunction = toStr.call(object) === '[object Function]'; 817 var isArguments = isArgumentsObject(object); 818 var isString = toStr.call(object) === '[object String]'; 819 var theKeys = []; 820 821 if (object === undefined || object === null) { 822 throw new TypeError('Cannot convert undefined or null to object'); 823 } 824 825 var skipPrototype = hasPrototypeEnumBug && isFunction; 826 if (isString && object.length > 0 && !has.call(object, 0)) { 827 for (var i = 0; i < object.length; ++i) { 828 theKeys.push(String(i)); 829 } 830 } 831 832 if (isArguments && object.length > 0) { 833 for (var j = 0; j < object.length; ++j) { 834 theKeys.push(String(j)); 835 } 836 } else { 837 for (var name in object) { 838 if (!(hasProtoEnumBug() && name === '__proto__') && !(skipPrototype && name === 'prototype') && has.call(object, name)) { 839 theKeys.push(String(name)); 840 } 841 } 842 } 843 844 if (hasDontEnumBug) { 845 var skipConstructor = equalsConstructorPrototypeIfNotBuggy(object); 846 847 for (var k = 0; k < dontEnums.length; ++k) { 848 if (!(skipConstructor && dontEnums[k] === 'constructor') && has.call(object, dontEnums[k])) { 849 theKeys.push(dontEnums[k]); 850 } 851 } 852 } 853 return theKeys; 854 }; 855 }())); 856 857 // Object.defineProperties 858 /* global CreateMethodProperty, Get, ToObject, Type */ 859 // 19.1.2.3. Object.defineProperties ( O, Properties ) 860 CreateMethodProperty(Object, 'defineProperties', function defineProperties(O, Properties) { 861 // 1. If Type(O) is not Object, throw a TypeError exception. 862 if (Type(O) !== 'object') { 863 throw new TypeError('Object.defineProperties called on non-object'); 864 } 865 // 2. Let props be ? ToObject(Properties). 866 var props = ToObject(Properties); 867 // 3. Let keys be ? props.[[OwnPropertyKeys]](). 868 /* 869 Polyfill.io - This step in our polyfill is not complying with the specification. 870 [[OwnPropertyKeys]] is meant to return ALL keys, including non-enumerable and symbols. 871 TODO: When we have Reflect.ownKeys, use that instead as it is the userland equivalent of [[OwnPropertyKeys]]. 872 */ 873 var keys = Object.keys(props); 874 // 4. Let descriptors be a new empty List. 875 var descriptors = []; 876 // 5. For each element nextKey of keys in List order, do 877 for (var i = 0; i < keys.length; i++) { 878 var nextKey = keys[i]; 879 // a. Let propDesc be ? props.[[GetOwnProperty]](nextKey). 880 var propDesc = Object.getOwnPropertyDescriptor(props, nextKey); 881 // b. If propDesc is not undefined and propDesc.[[Enumerable]] is true, then 882 if (propDesc !== undefined && propDesc.enumerable) { 883 // i. Let descObj be ? Get(props, nextKey). 884 var descObj = Get(props, nextKey); 885 // ii. Let desc be ? ToPropertyDescriptor(descObj).
886 // Polyfill.io - We skip this step because Object.defineProperty deals with it. 887 // TODO: Implement this step? 888 var desc = descObj; 889 // iii. Append the pair (a two element List) consisting of nextKey and desc to the end of descriptors. 890 descriptors.push([nextKey, desc]); 891 } 892 } 893 // 6. For each pair from descriptors in list order, do 894 for (var j = 0; j < descriptors.length; j++) { 895 // a. Let P be the first element of pair. 896 var P = descriptors[j][0]; 897 // b. Let desc be the second element of pair. 898 desc = descriptors[j][1]; 899 // c. Perform ? DefinePropertyOrThrow(O, P, desc). 900 Object.defineProperty(O, P, desc); 901 } 902 // 7. Return O. 903 return O; 904 }); 905 906 907 // _ESAbstract.OrdinaryCreateFromConstructor 908 /* global GetPrototypeFromConstructor */ 909 // 9.1.13. OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto [ , internalSlotsList ] ) 910 function OrdinaryCreateFromConstructor(constructor, intrinsicDefaultProto) { // eslint-disable-line no-unused-vars 911 var internalSlotsList = arguments[2] || {}; 912 // 1. Assert: intrinsicDefaultProto is a String value that is this specification's name of an intrinsic object. 913 // The corresponding object must be an intrinsic that is intended to be used as the[[Prototype]] value of an object. 914 915 // 2. Let proto be ? GetPrototypeFromConstructor(constructor, intrinsicDefaultProto). 916 var proto = GetPrototypeFromConstructor(constructor, intrinsicDefaultProto); 917 918 // 3. Return ObjectCreate(proto, internalSlotsList). 919 // Polyfill.io - We do not pass internalSlotsList to Object.create because Object.create does not use the default ordinary object definitions specified in 9.1. 920 var obj = Object.create(proto); 921 for (var name in internalSlotsList) { 922 if (Object.prototype.hasOwnProperty.call(internalSlotsList, name)) { 923 Object.defineProperty(obj, name, { 924 configurable: true, 925 enumerable: false, 926 writable: true, 927 value: internalSlotsList[name] 928 }); 929 } 930 } 931 return obj; 932 } 933 934 // _ESAbstract.Construct 935 /* global IsConstructor, OrdinaryCreateFromConstructor, Call */ 936 // 7.3.13. Construct ( F [ , argumentsList [ , newTarget ]] ) 937 function Construct(F /* [ , argumentsList [ , newTarget ]] */) { // eslint-disable-line no-unused-vars 938 // 1. If newTarget is not present, set newTarget to F. 939 var newTarget = arguments.length > 2 ? arguments[2] : F; 940 941 // 2. If argumentsList is not present, set argumentsList to a new empty List. 942 var argumentsList = arguments.length > 1 ? arguments[1] : []; 943 944 // 3. Assert: IsConstructor(F) is true. 945 if (!IsConstructor(F)) { 946 throw new TypeError('F must be a constructor.'); 947 } 948 949 // 4. Assert: IsConstructor(newTarget) is true. 950 if (!IsConstructor(newTarget)) { 951 throw new TypeError('newTarget must be a constructor.'); 952 } 953 954 // 5. Return ? F.[[Construct]](argumentsList, newTarget). 955 // Polyfill.io - If newTarget is the same as F, it is equivalent to new F(...argumentsList). 956 if (newTarget === F) { 957 return new (Function.prototype.bind.apply(F, [null].concat(argumentsList)))(); 958 } else { 959 // Polyfill.io - This is mimicking section 9.2.2 step 5.a. 960 var obj = OrdinaryCreateFromConstructor(newTarget, Object.prototype); 961 return Call(F, obj, argumentsList); 962 } 963 } 964 965 // _ESAbstract.ArraySpeciesCreate 966 /* global IsArray, ArrayCreate, Get, Type, IsConstructor, Construct */ 967 // 9.4.2.3. ArraySpeciesCreate ( originalArray, length ) 968 function ArraySpeciesCreate(originalArray, length) { // eslint-disable-line no-unused-vars 969 // 1. Assert: length is an integer Number ⥠0. 970 // 2. If length is -0, set length to +0. 971 if (length === 0 && 1 / length === -Infinity) { 972 length = 0; 973 } 974 975 // 3. Let isArray be ? IsArray(originalArray). 976 var isArray = IsArray(originalArray); 977 978 // 4. If isArray is false, return ? ArrayCreate(length). 979 if (isArray === false) { 980 return ArrayCreate(length); 981 } 982 983 // 5. Let C be ? Get(originalArray, "constructor"). 984 var C = Get(originalArray, 'constructor'); 985
986 // Polyfill.io - We skip this section as not sure how to make a cross-realm normal Array, a same-realm Array. 987 // 6. If IsConstructor(C) is true, then 988 // if (IsConstructor(C)) { 989 // a. Let thisRealm be the current Realm Record. 990 // b. Let realmC be ? GetFunctionRealm(C). 991 // c. If thisRealm and realmC are not the same Realm Record, then 992 // i. If SameValue(C, realmC.[[Intrinsics]].[[%Array%]]) is true, set C to undefined. 993 // } 994 // 7. If Type(C) is Object, then 995 if (Type(C) === 'object') { 996 // a. Set C to ? Get(C, @@species). 997 C = 'Symbol' in self && 'species' in self.Symbol ? Get(C, self.Symbol.species) : undefined; 998 // b. If C is null, set C to undefined. 999 if (C === null) { 1000 C = undefined; 1001 } 1002 } 1003 // 8. If C is undefined, return ? ArrayCreate(length). 1004 if (C === undefined) { 1005 return ArrayCreate(length); 1006 } 1007 // 9. If IsConstructor(C) is false, throw a TypeError exception. 1008 if (!IsConstructor(C)) { 1009 throw new TypeError('C must be a constructor'); 1010 } 1011 // 10. Return ? Construct(C, « length »). 1012 return Construct(C, [length]); 1013 } 1014 1015 // Array.prototype.filter 1016 /* global CreateMethodProperty, ToObject, ToLength, Get, IsCallable, ArraySpeciesCreate, ToString, HasProperty, ToBoolean, Call, CreateDataPropertyOrThrow */ 1017 // 22.1.3.7. Array.prototype.filter ( callbackfn [ , thisArg ] ) 1018 CreateMethodProperty(Array.prototype, 'filter', function filter(callbackfn /* [ , thisArg ] */) { 1019 // 1. Let O be ? ToObject(this value). 1020 var O = ToObject(this); 1021 // 2. Let len be ? ToLength(? Get(O, "length")). 1022 var len = ToLength(Get(O, "length")); 1023 // 3. If IsCallable(callbackfn) is false, throw a TypeError exception. 1024 if (IsCallable(callbackfn) === false) { 1025 throw new TypeError(callbackfn + ' is not a function'); 1026 } 1027 // 4. If thisArg is present, let T be thisArg; else let T be undefined. 1028 var T = arguments.length > 1 ? arguments[1] : undefined; 1029 // 5. Let A be ? ArraySpeciesCreate(O, 0). 1030 var A = ArraySpeciesCreate(O, 0); 1031 // 6. Let k be 0. 1032 var k = 0; 1033 // 7. Let to be 0. 1034 var to = 0; 1035 // 8. Repeat, while k < len 1036 while (k < len) { 1037 // a. Let Pk be ! ToString(k). 1038 var Pk = ToString(k); 1039 // b. Let kPresent be ? HasProperty(O, Pk). 1040 var kPresent = HasProperty(O, Pk); 1041 // c. If kPresent is true, then 1042 if (kPresent) { 1043 // i. Let kValue be ? Get(O, Pk). 1044 var kValue = Get(O, Pk); 1045 // ii. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). 1046 var selected = ToBoolean(Call(callbackfn, T, [kValue, k, O])); 1047 // iii. If selected is true, then 1048 if (selected) { 1049 // 1. Perform ? CreateDataPropertyOrThrow(A, ! ToString(to), kValue) 1050 CreateDataPropertyOrThrow(A, ToString(to), kValue); 1051 // 2. Increase to by 1. 1052 to = to + 1; 1053 } 1054 1055 } 1056 // d. Increase k by 1. 1057 k = k + 1; 1058 } 1059 // 9. Return A. 1060 return A; 1061 }); 1062 1063 // Array.prototype.map 1064 /* global ArraySpeciesCreate, Call, CreateDataPropertyOrThrow, CreateMethodProperty, Get, HasProperty, IsCallable, ToLength, ToObject, ToString */ 1065 // 22.1.3.16. Array.prototype.map ( callbackfn [ , thisArg ] ) 1066 CreateMethodProperty(Array.prototype, 'map', function map(callbackfn /* [ , thisArg ] */) { 1067 // 1. Let O be ? ToObject(this value). 1068 var O = ToObject(this); 1069 // 2. Let len be ? ToLength(? Get(O, "length")). 1070 var len = ToLength(Get(O, "length")); 1071 // 3. If IsCallable(callbackfn) is false, throw a TypeError exception. 1072 if (IsCallable(callbackfn) === false) { 1073 throw new TypeError(callbackfn + ' is not a function'); 1074 } 1075 // 4. If thisArg is present, let T be thisArg; else let T be undefined. 1076 var T = arguments.length > 1 ? arguments[1] : undefined; 1077 // 5. Let A be ? ArraySpeciesCreate(O, len). 1078 var A = ArraySpeciesCreate(O, len); 1079 // 6. Let k be 0. 1080 var k = 0; 1081 // 7. Repeat, while k < len 1082 while (k < len) { 1083 // a. Let Pk be ! ToString(k). 1084 var Pk = ToString(k); 1085 // b. Let kPresent be ? HasProperty(O, Pk). 1086 var kPresent = HasProperty(O, Pk); 1087 // c. If kPresent is true, then 1088 if (kPresent) { 1089 // i. Let kValue be ? Get(O, Pk). 1090 var kValue = Get(O, Pk); 1091 // ii. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »). 1092 var mappedValue = Call(callbackfn, T, [kValue, k, O]); 1093 // iii. Perform ? CreateDataPropertyOrThrow(A, Pk, mappedValue). 1094 CreateDataPropertyOrThrow(A, Pk, mappedValue); 1095 } 1096 // d. Increase k by 1. 1097 k = k + 1; 1098 } 1099 // 8. Return A. 1100 return A; 1101 }); 1102 1103 // Array.prototype.sort 1104 /* global CreateMethodProperty, IsCallable */ 1105 "use strict"; 1106 1107 var origSort = Array.prototype.sort; 1108 1109 // 22.1.3.27 Array.prototype.sort ( comparefn ) 1110 // The elements of this array are sorted. The sort must be stable (that is, 1111 // elements that compare equal must remain in their original order). If 1112 // comparefn is not undefined, it should be a function that accepts two 1113 // arguments x and y and returns a negative value 1114 // if x < y, zero if x = y, or a positive value if x > y. 1115 1116 CreateMethodProperty(Array.prototype, "sort", function sort(compareFn) { 1117 // 1. If comparefn is not undefined and IsCallable(comparefn) is false, throw 1118 // a TypeError exception. 1119 if (compareFn !== undefined && IsCallable(compareFn) === false) { 1120 throw new TypeError( 1121 "The comparison function must be either a function or undefined" 1122 ); 1123 } 1124 1125 // Polyfill.io - the steps below are handled by the native 1126 // Array.prototype.sort method that we call. 1127 // 2.Let obj be ? ToObject(this value). 1128 // 3.Let len be ? LengthOfArrayLike(obj). 1129 1130 // if comprateFn does not exist, use the spec defined in-built SortCompare. 1131 if (compareFn === undefined) { 1132 origSort.call(this); 1133 } else { 1134 // if compareFn exists, sort the array, breaking sorting ties by using the 1135 // items' original index position. 1136 1137 // Keep track of the items starting index position. 1138 var that = Array.prototype.map.call(this, function (item, index) { 1139 return { item: item, index: index }; 1140 }); 1141 origSort.call(that, function (a, b) { 1142 var compareResult = compareFn.call(undefined, a.item, b.item); 1143 return compareResult === 0 ? a.index - b.index : compareResult; 1144 }); 1145 // update the original object (`this`) with the new position for the items 1146 // which were moved. 1147 for (var a in that) { 1148 if (Object.prototype.hasOwnProperty.call(that, a)) { 1149 if (that[a].item !== this[a]) { 1150 this[a] = that[a].item; 1151 } 1152 } 1153 } 1154 } 1155 1156 return this; 1157 }); 1158 1159 // String.prototype.startsWith 1160 /* global CreateMethodProperty, IsRegExp, RequireObjectCoercible, ToInteger, ToString */ 1161 // 21.1.3.20. String.prototype.startsWith ( searchString [ , position ] ) 1162 CreateMethodProperty(String.prototype, 'startsWith', function startsWith(searchString /* [ , position ] */) { 1163 'use strict'; 1164 var position = arguments.length > 1 ? arguments[1] : undefined; 1165 // 1. Let O be ? RequireObjectCoercible(this value). 1166 var O = RequireObjectCoercible(this); 1167 // 2. Let S be ? ToString(O). 1168 var S = ToString(O); 1169 // 3. Let isRegExp be ? IsRegExp(searchString). 1170 var isRegExp = IsRegExp(searchString); 1171 // 4. If isRegExp is true, throw a TypeError exception. 1172 if (isRegExp) { 1173 throw new TypeError('First argument to String.prototype.startsWith must not be a regular expression'); 1174 } 1175 // 5. Let searchStr be ? ToString(searchString). 1176 var searchStr = ToString(searchString); 1177 // 6. Let pos be ? ToInteger(position). (If position is undefined, this step produces the value 0.) 1178 var pos = ToInteger(position); 1179 // 7. Let len be the length of S. 1180 var len = S.length; 1181 // 8. Let start be min(max(pos, 0), len). 1182 var start = Math.min(Math.max(pos, 0), len); 1183 // 9. Let searchLength be the length of searchStr. 1184 var searchLength = searchStr.length; 1185 // 10. If searchLength+start is greater than len, return false. 1186 if (searchLength + start > len) { 1187 return false; 1188 } 1189 // 11. If the sequence of elements of S starting at start of length searchLength is the same as the full element sequence of searchStr, return true. 1190 if (S.substr(start).indexOf(searchString) === 0) { 1191 return true; 1192 } 1193 // 12. Otherwise, return false. 1194 return false; 1195 }); 1196}) 1197 ('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.