-/* Polyfill service v3.27.1
+/* Polyfill service v3.34.0
* For detailed credits and licence information see https://github.com/financial-times/polyfill-service.
*
* Features requested: es5
*
- * - Object.defineProperty, License: CC0 (required by "es5", "Object.defineProperties", "Object.create", "_ESAbstract.CreateMethodProperty", "Array.isArray", "Array.prototype.every", "Array.prototype.filter", "Array.prototype.forEach", "Array.prototype.indexOf", "Array.prototype.lastIndexOf", "Array.prototype.map", "Array.prototype.reduce", "Array.prototype.reduceRight", "Array.prototype.some", "Function.prototype.bind", "Object.freeze", "Object.getOwnPropertyDescriptor", "Object.getOwnPropertyNames", "Object.getPrototypeOf", "String.prototype.trim", "_ESAbstract.CreateDataProperty", "_ESAbstract.CreateDataPropertyOrThrow", "_ESAbstract.OrdinaryCreateFromConstructor", "_ESAbstract.Construct", "_ESAbstract.ArraySpeciesCreate")
- * - _ESAbstract.CreateMethodProperty, License: CC0 (required by "Array.isArray", "es5", "Array.prototype.every", "Array.prototype.filter", "Array.prototype.forEach", "Array.prototype.indexOf", "Array.prototype.lastIndexOf", "Array.prototype.map", "Array.prototype.reduce", "Array.prototype.reduceRight", "Array.prototype.some", "Function.prototype.bind", "Object.create", "Object.defineProperties", "Object.freeze", "Object.getOwnPropertyDescriptor", "Object.getOwnPropertyNames", "Object.getPrototypeOf", "String.prototype.trim")
+ * - _ESAbstract.ArrayCreate, License: CC0 (required by "_ESAbstract.ArraySpeciesCreate", "Array.prototype.filter", "es5", "Array.prototype.map")
+ * - _ESAbstract.Call, License: CC0 (required by "Array.prototype.every", "es5", "Array.prototype.filter", "Array.prototype.forEach", "Array.prototype.map", "Array.prototype.reduce", "Array.prototype.reduceRight", "Array.prototype.some", "_ESAbstract.ToPrimitive", "_ESAbstract.ToString", "Array.prototype.indexOf", "Array.prototype.lastIndexOf", "String.prototype.trim", "_ESAbstract.OrdinaryToPrimitive")
+ * - _ESAbstract.Get, License: CC0 (required by "Array.prototype.every", "es5", "Array.prototype.filter", "Array.prototype.forEach", "Array.prototype.indexOf", "Array.prototype.lastIndexOf", "Array.prototype.map", "Array.prototype.reduce", "Array.prototype.reduceRight", "Array.prototype.some", "Object.defineProperties", "Object.create", "_ESAbstract.ArraySpeciesCreate", "_ESAbstract.OrdinaryToPrimitive", "_ESAbstract.ToPrimitive", "_ESAbstract.ToString", "String.prototype.trim", "_ESAbstract.GetPrototypeFromConstructor", "_ESAbstract.OrdinaryCreateFromConstructor", "_ESAbstract.Construct")
+ * - _ESAbstract.HasProperty, License: CC0 (required by "Array.prototype.every", "es5", "Array.prototype.filter", "Array.prototype.forEach", "Array.prototype.indexOf", "Array.prototype.lastIndexOf", "Array.prototype.map", "Array.prototype.reduce", "Array.prototype.reduceRight", "Array.prototype.some")
* - _ESAbstract.IsArray, License: CC0 (required by "Array.isArray", "es5", "_ESAbstract.ArraySpeciesCreate", "Array.prototype.filter", "Array.prototype.map")
- * - Array.isArray, License: CC0 (required by "es5")
- * - _ESAbstract.ToObject, License: CC0 (required by "Array.prototype.every", "es5", "Array.prototype.filter", "Array.prototype.forEach", "Array.prototype.indexOf", "Array.prototype.lastIndexOf", "Array.prototype.map", "Array.prototype.reduce", "Array.prototype.reduceRight", "Array.prototype.some", "Object.defineProperties", "Object.create", "_ESAbstract.GetV", "_ESAbstract.GetMethod", "_ESAbstract.ToPrimitive", "_ESAbstract.ToString", "String.prototype.trim", "_ESAbstract.IsConstructor", "_ESAbstract.ArraySpeciesCreate")
+ * - _ESAbstract.IsCallable, License: CC0 (required by "Array.prototype.every", "es5", "Array.prototype.filter", "Array.prototype.forEach", "Array.prototype.map", "Array.prototype.reduce", "Array.prototype.reduceRight", "Array.prototype.some", "Function.prototype.bind", "_ESAbstract.GetMethod", "_ESAbstract.ToPrimitive", "_ESAbstract.ToString", "Array.prototype.indexOf", "Array.prototype.lastIndexOf", "String.prototype.trim", "_ESAbstract.IsConstructor", "_ESAbstract.ArraySpeciesCreate", "_ESAbstract.OrdinaryToPrimitive")
+ * - _ESAbstract.RequireObjectCoercible, License: CC0 (required by "String.prototype.trim", "es5")
+ * - _ESAbstract.ToBoolean, License: CC0 (required by "Array.prototype.every", "es5", "Array.prototype.filter", "Array.prototype.some")
* - _ESAbstract.ToInteger, License: CC0 (required by "Array.prototype.indexOf", "es5", "Array.prototype.lastIndexOf", "_ESAbstract.ToLength", "Array.prototype.every", "Array.prototype.filter", "Array.prototype.forEach", "Array.prototype.map", "Array.prototype.reduce", "Array.prototype.reduceRight", "Array.prototype.some")
* - _ESAbstract.ToLength, License: CC0 (required by "Array.prototype.every", "es5", "Array.prototype.filter", "Array.prototype.forEach", "Array.prototype.indexOf", "Array.prototype.lastIndexOf", "Array.prototype.map", "Array.prototype.reduce", "Array.prototype.reduceRight", "Array.prototype.some")
- * - _ESAbstract.Get, License: CC0 (required by "Array.prototype.every", "es5", "Array.prototype.filter", "Array.prototype.forEach", "Array.prototype.indexOf", "Array.prototype.lastIndexOf", "Array.prototype.map", "Array.prototype.reduce", "Array.prototype.reduceRight", "Array.prototype.some", "Object.defineProperties", "Object.create", "_ESAbstract.ArraySpeciesCreate", "_ESAbstract.OrdinaryToPrimitive", "_ESAbstract.ToPrimitive", "_ESAbstract.ToString", "String.prototype.trim", "_ESAbstract.GetPrototypeFromConstructor", "_ESAbstract.OrdinaryCreateFromConstructor", "_ESAbstract.Construct")
- * - _ESAbstract.IsCallable, License: CC0 (required by "Array.prototype.every", "es5", "Array.prototype.filter", "Array.prototype.forEach", "Array.prototype.map", "Array.prototype.reduce", "Array.prototype.reduceRight", "Array.prototype.some", "Function.prototype.bind", "_ESAbstract.GetMethod", "_ESAbstract.ToPrimitive", "_ESAbstract.ToString", "Array.prototype.indexOf", "Array.prototype.lastIndexOf", "String.prototype.trim", "_ESAbstract.IsConstructor", "_ESAbstract.ArraySpeciesCreate", "_ESAbstract.OrdinaryToPrimitive")
- * - _ESAbstract.Call, License: CC0 (required by "Array.prototype.every", "es5", "Array.prototype.filter", "Array.prototype.forEach", "Array.prototype.map", "Array.prototype.reduce", "Array.prototype.reduceRight", "Array.prototype.some", "_ESAbstract.ToPrimitive", "_ESAbstract.ToString", "Array.prototype.indexOf", "Array.prototype.lastIndexOf", "String.prototype.trim", "_ESAbstract.OrdinaryToPrimitive")
+ * - _ESAbstract.ToObject, License: CC0 (required by "Array.prototype.every", "es5", "Array.prototype.filter", "Array.prototype.forEach", "Array.prototype.indexOf", "Array.prototype.lastIndexOf", "Array.prototype.map", "Array.prototype.reduce", "Array.prototype.reduceRight", "Array.prototype.some", "Object.defineProperties", "Object.create", "_ESAbstract.GetV", "_ESAbstract.GetMethod", "_ESAbstract.ToPrimitive", "_ESAbstract.ToString", "String.prototype.trim", "_ESAbstract.IsConstructor", "_ESAbstract.ArraySpeciesCreate")
* - _ESAbstract.GetV, License: CC0 (required by "_ESAbstract.GetMethod", "_ESAbstract.ToPrimitive", "_ESAbstract.ToString", "Array.prototype.every", "es5", "Array.prototype.filter", "Array.prototype.forEach", "Array.prototype.indexOf", "Array.prototype.lastIndexOf", "Array.prototype.map", "Array.prototype.reduce", "Array.prototype.reduceRight", "Array.prototype.some", "String.prototype.trim", "_ESAbstract.IsConstructor", "_ESAbstract.ArraySpeciesCreate")
* - _ESAbstract.GetMethod, License: CC0 (required by "_ESAbstract.ToPrimitive", "_ESAbstract.ToString", "Array.prototype.every", "es5", "Array.prototype.filter", "Array.prototype.forEach", "Array.prototype.indexOf", "Array.prototype.lastIndexOf", "Array.prototype.map", "Array.prototype.reduce", "Array.prototype.reduceRight", "Array.prototype.some", "String.prototype.trim", "_ESAbstract.IsConstructor", "_ESAbstract.ArraySpeciesCreate")
* - _ESAbstract.Type, License: CC0 (required by "Object.create", "es5", "Object.defineProperties", "_ESAbstract.ToString", "Array.prototype.every", "Array.prototype.filter", "Array.prototype.forEach", "Array.prototype.indexOf", "Array.prototype.lastIndexOf", "Array.prototype.map", "Array.prototype.reduce", "Array.prototype.reduceRight", "Array.prototype.some", "String.prototype.trim", "_ESAbstract.ArraySpeciesCreate", "_ESAbstract.ToPrimitive", "_ESAbstract.IsConstructor", "_ESAbstract.OrdinaryToPrimitive", "_ESAbstract.GetPrototypeFromConstructor", "_ESAbstract.OrdinaryCreateFromConstructor", "_ESAbstract.Construct")
+ * - _ESAbstract.GetPrototypeFromConstructor, License: CC0 (required by "_ESAbstract.OrdinaryCreateFromConstructor", "_ESAbstract.Construct", "_ESAbstract.ArraySpeciesCreate", "Array.prototype.filter", "es5", "Array.prototype.map")
+ * - _ESAbstract.IsConstructor, License: CC0 (required by "_ESAbstract.ArraySpeciesCreate", "Array.prototype.filter", "es5", "Array.prototype.map", "_ESAbstract.Construct")
* - _ESAbstract.OrdinaryToPrimitive, License: CC0 (required by "_ESAbstract.ToPrimitive", "_ESAbstract.ToString", "Array.prototype.every", "es5", "Array.prototype.filter", "Array.prototype.forEach", "Array.prototype.indexOf", "Array.prototype.lastIndexOf", "Array.prototype.map", "Array.prototype.reduce", "Array.prototype.reduceRight", "Array.prototype.some", "String.prototype.trim")
* - _ESAbstract.ToPrimitive, License: CC0 (required by "_ESAbstract.ToString", "Array.prototype.every", "es5", "Array.prototype.filter", "Array.prototype.forEach", "Array.prototype.indexOf", "Array.prototype.lastIndexOf", "Array.prototype.map", "Array.prototype.reduce", "Array.prototype.reduceRight", "Array.prototype.some", "String.prototype.trim")
* - _ESAbstract.ToString, License: CC0 (required by "Array.prototype.every", "es5", "Array.prototype.filter", "Array.prototype.forEach", "Array.prototype.indexOf", "Array.prototype.lastIndexOf", "Array.prototype.map", "Array.prototype.reduce", "Array.prototype.reduceRight", "Array.prototype.some", "String.prototype.trim")
- * - _ESAbstract.HasProperty, License: CC0 (required by "Array.prototype.every", "es5", "Array.prototype.filter", "Array.prototype.forEach", "Array.prototype.indexOf", "Array.prototype.lastIndexOf", "Array.prototype.map", "Array.prototype.reduce", "Array.prototype.reduceRight", "Array.prototype.some")
- * - _ESAbstract.ToBoolean, License: CC0 (required by "Array.prototype.every", "es5", "Array.prototype.filter", "Array.prototype.some")
- * - Array.prototype.every, License: CC0 (required by "es5")
- * - _ESAbstract.ArrayCreate, License: CC0 (required by "_ESAbstract.ArraySpeciesCreate", "Array.prototype.filter", "es5", "Array.prototype.map")
- * - _ESAbstract.IsConstructor, License: CC0 (required by "_ESAbstract.ArraySpeciesCreate", "Array.prototype.filter", "es5", "Array.prototype.map", "_ESAbstract.Construct")
- * - _ESAbstract.GetPrototypeFromConstructor, License: CC0 (required by "_ESAbstract.OrdinaryCreateFromConstructor", "_ESAbstract.Construct", "_ESAbstract.ArraySpeciesCreate", "Array.prototype.filter", "es5", "Array.prototype.map")
- * - Object.keys, License: MIT (required by "es5", "Object.defineProperties", "Object.create")
- * - Function.prototype.bind, License: MIT (required by "es5", "Object.getOwnPropertyDescriptor", "Object.defineProperties", "Object.create", "_ESAbstract.Construct", "_ESAbstract.ArraySpeciesCreate", "Array.prototype.filter", "Array.prototype.map")
- * - Object.getOwnPropertyDescriptor, License: CC0 (required by "es5", "Object.defineProperties", "Object.create")
- * - Object.defineProperties, License: CC0 (required by "es5", "Object.create")
- * - Object.create, License: CC0 (required by "es5", "_ESAbstract.OrdinaryCreateFromConstructor", "_ESAbstract.Construct", "_ESAbstract.ArraySpeciesCreate", "Array.prototype.filter", "Array.prototype.map")
- * - Object.getPrototypeOf, License: CC0 (required by "es5", "_ESAbstract.OrdinaryCreateFromConstructor", "_ESAbstract.Construct", "_ESAbstract.ArraySpeciesCreate", "Array.prototype.filter", "Array.prototype.map")
- * - _ESAbstract.OrdinaryCreateFromConstructor, License: CC0 (required by "_ESAbstract.Construct", "_ESAbstract.ArraySpeciesCreate", "Array.prototype.filter", "es5", "Array.prototype.map")
- * - _ESAbstract.Construct, License: CC0 (required by "_ESAbstract.ArraySpeciesCreate", "Array.prototype.filter", "es5", "Array.prototype.map")
- * - _ESAbstract.ArraySpeciesCreate, License: CC0 (required by "Array.prototype.filter", "es5", "Array.prototype.map")
+ * - Date.now, License: CC0 (required by "es5")
+ * - Date.prototype.toISOString, License: CC0 (required by "es5")
+ * - Object.defineProperty, License: CC0 (required by "es5", "Object.defineProperties", "Object.create", "_ESAbstract.CreateMethodProperty", "Array.isArray", "Array.prototype.every", "Array.prototype.filter", "Array.prototype.forEach", "Array.prototype.indexOf", "Array.prototype.lastIndexOf", "Array.prototype.map", "Array.prototype.reduce", "Array.prototype.reduceRight", "Array.prototype.some", "Function.prototype.bind", "Object.freeze", "Object.getOwnPropertyDescriptor", "Object.getOwnPropertyNames", "Object.getPrototypeOf", "Object.keys", "String.prototype.trim", "_ESAbstract.CreateDataProperty", "_ESAbstract.CreateDataPropertyOrThrow", "_ESAbstract.OrdinaryCreateFromConstructor", "_ESAbstract.Construct", "_ESAbstract.ArraySpeciesCreate")
* - _ESAbstract.CreateDataProperty, License: CC0 (required by "_ESAbstract.CreateDataPropertyOrThrow", "Array.prototype.filter", "es5", "Array.prototype.map")
* - _ESAbstract.CreateDataPropertyOrThrow, License: CC0 (required by "Array.prototype.filter", "es5", "Array.prototype.map")
- * - Array.prototype.filter, License: CC0 (required by "es5")
+ * - _ESAbstract.CreateMethodProperty, License: CC0 (required by "Array.isArray", "es5", "Array.prototype.every", "Array.prototype.filter", "Array.prototype.forEach", "Array.prototype.indexOf", "Array.prototype.lastIndexOf", "Array.prototype.map", "Array.prototype.reduce", "Array.prototype.reduceRight", "Array.prototype.some", "Function.prototype.bind", "Object.create", "Object.defineProperties", "Object.freeze", "Object.getOwnPropertyDescriptor", "Object.getOwnPropertyNames", "Object.getPrototypeOf", "Object.keys", "String.prototype.trim")
+ * - Array.isArray, License: CC0 (required by "es5")
+ * - Array.prototype.every, License: CC0 (required by "es5")
* - Array.prototype.forEach, License: CC0 (required by "es5")
* - Array.prototype.indexOf, License: CC0 (required by "es5")
* - Array.prototype.lastIndexOf, License: CC0 (required by "es5")
- * - Array.prototype.map, License: CC0 (required by "es5")
* - Array.prototype.reduce, License: CC0 (required by "es5")
* - Array.prototype.reduceRight, License: CC0 (required by "es5")
* - Array.prototype.some, License: CC0 (required by "es5")
- * - Date.now, License: CC0 (required by "es5")
- * - Date.prototype.toISOString, License: CC0 (required by "es5")
+ * - Function.prototype.bind, License: MIT (required by "es5", "Object.getOwnPropertyDescriptor", "Object.defineProperties", "Object.create", "_ESAbstract.Construct", "_ESAbstract.ArraySpeciesCreate", "Array.prototype.filter", "Array.prototype.map")
* - Object.freeze, License: CC0 (required by "es5")
+ * - Object.getOwnPropertyDescriptor, License: CC0 (required by "es5", "Object.defineProperties", "Object.create")
* - Object.getOwnPropertyNames, License: CC0 (required by "es5")
- * - _ESAbstract.RequireObjectCoercible, License: CC0 (required by "String.prototype.trim", "es5")
+ * - Object.getPrototypeOf, License: CC0 (required by "es5", "_ESAbstract.OrdinaryCreateFromConstructor", "_ESAbstract.Construct", "_ESAbstract.ArraySpeciesCreate", "Array.prototype.filter", "Array.prototype.map")
+ * - Object.keys, License: MIT (required by "es5", "Object.defineProperties", "Object.create")
+ * - Object.defineProperties, License: CC0 (required by "es5", "Object.create")
+ * - Object.create, License: CC0 (required by "es5", "_ESAbstract.OrdinaryCreateFromConstructor", "_ESAbstract.Construct", "_ESAbstract.ArraySpeciesCreate", "Array.prototype.filter", "Array.prototype.map")
+ * - _ESAbstract.OrdinaryCreateFromConstructor, License: CC0 (required by "_ESAbstract.Construct", "_ESAbstract.ArraySpeciesCreate", "Array.prototype.filter", "es5", "Array.prototype.map")
+ * - _ESAbstract.Construct, License: CC0 (required by "_ESAbstract.ArraySpeciesCreate", "Array.prototype.filter", "es5", "Array.prototype.map")
+ * - _ESAbstract.ArraySpeciesCreate, License: CC0 (required by "Array.prototype.filter", "es5", "Array.prototype.map")
+ * - Array.prototype.filter, License: CC0 (required by "es5")
+ * - Array.prototype.map, License: CC0 (required by "es5")
* - String.prototype.trim, License: CC0 (required by "es5") */
(function(undefined) {
-if (!(// In IE8, defineProperty could only act on DOM elements, so full support
-// for the feature requires the ability to set a property on an arbitrary object
-'defineProperty' in Object && (function() {
- try {
- var a = {};
- Object.defineProperty(a, 'test', {value:42});
- return true;
- } catch(e) {
- return false
- }
-}()))) {
-
-// Object.defineProperty
-(function (nativeDefineProperty) {
-
- var supportsAccessors = Object.prototype.hasOwnProperty('__defineGetter__');
- var ERR_ACCESSORS_NOT_SUPPORTED = 'Getters & setters cannot be defined on this javascript engine';
- var ERR_VALUE_ACCESSORS = 'A property cannot both have accessors and be writable or have a value';
-
- // Polyfill.io - This does not use CreateMethodProperty because our CreateMethodProperty function uses Object.defineProperty.
- Object['defineProperty'] = function defineProperty(object, property, descriptor) {
-
- // Where native support exists, assume it
- if (nativeDefineProperty && (object === window || object === document || object === Element.prototype || object instanceof Element)) {
- return nativeDefineProperty(object, property, descriptor);
- }
-
- if (object === null || !(object instanceof Object || typeof object === 'object')) {
- throw new TypeError('Object.defineProperty called on non-object');
- }
-
- if (!(descriptor instanceof Object)) {
- throw new TypeError('Property description must be an object');
- }
-
- var propertyString = String(property);
- var hasValueOrWritable = 'value' in descriptor || 'writable' in descriptor;
- var getterType = 'get' in descriptor && typeof descriptor.get;
- var setterType = 'set' in descriptor && typeof descriptor.set;
-
- // handle descriptor.get
- if (getterType) {
- if (getterType !== 'function') {
- throw new TypeError('Getter must be a function');
- }
- if (!supportsAccessors) {
- throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
- }
- if (hasValueOrWritable) {
- throw new TypeError(ERR_VALUE_ACCESSORS);
- }
- Object.__defineGetter__.call(object, propertyString, descriptor.get);
- } else {
- object[propertyString] = descriptor.value;
- }
-
- // handle descriptor.set
- if (setterType) {
- if (setterType !== 'function') {
- throw new TypeError('Setter must be a function');
- }
- if (!supportsAccessors) {
- throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
- }
- if (hasValueOrWritable) {
- throw new TypeError(ERR_VALUE_ACCESSORS);
- }
- Object.__defineSetter__.call(object, propertyString, descriptor.set);
- }
-
- // OK to define value unconditionally - if a getter has been specified as well, an error would be thrown above
- if ('value' in descriptor) {
- object[propertyString] = descriptor.value;
- }
-
- return object;
- };
-}(Object.defineProperty));
+// _ESAbstract.ArrayCreate
+// 9.4.2.2. ArrayCreate ( length [ , proto ] )
+function ArrayCreate(length /* [, proto] */) { // eslint-disable-line no-unused-vars
+ // 1. Assert: length is an integer Number ≥ 0.
+ // 2. If length is -0, set length to +0.
+ if (1 / length === -Infinity) {
+ length = 0;
+ }
+ // 3. If length>2^32-1, throw a RangeError exception.
+ if (length > (Math.pow(2, 32) - 1)) {
+ throw new RangeError('Invalid array length');
+ }
+ // 4. If proto is not present, set proto to the intrinsic object %ArrayPrototype%.
+ // 5. Let A be a newly created Array exotic object.
+ var A = [];
+ // 6. Set A's essential internal methods except for [[DefineOwnProperty]] to the default ordinary object definitions specified in 9.1.
+ // 7. Set A.[[DefineOwnProperty]] as specified in 9.4.2.1.
+ // 8. Set A.[[Prototype]] to proto.
+ // 9. Set A.[[Extensible]] to true.
+ // 10. Perform ! OrdinaryDefineOwnProperty(A, "length", PropertyDescriptor{[[Value]]: length, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: false}).
+ A.length = length;
+ // 11. Return A.
+ return A;
}
+// _ESAbstract.Call
+/* global IsCallable */
+// 7.3.12. Call ( F, V [ , argumentsList ] )
+function Call(F, V /* [, argumentsList] */) { // eslint-disable-line no-unused-vars
+ // 1. If argumentsList is not present, set argumentsList to a new empty List.
+ var argumentsList = arguments.length > 2 ? arguments[2] : [];
+ // 2. If IsCallable(F) is false, throw a TypeError exception.
+ if (IsCallable(F) === false) {
+ throw new TypeError(Object.prototype.toString.call(F) + 'is not a function.');
+ }
+ // 3. Return ? F.[[Call]](V, argumentsList).
+ return F.apply(V, argumentsList);
+}
-// _ESAbstract.CreateMethodProperty
-// 7.3.5. CreateMethodProperty ( O, P, V )
-function CreateMethodProperty(O, P, V) { // eslint-disable-line no-unused-vars
+// _ESAbstract.Get
+// 7.3.1. Get ( O, P )
+function Get(O, P) { // eslint-disable-line no-unused-vars
// 1. Assert: Type(O) is Object.
// 2. Assert: IsPropertyKey(P) is true.
- // 3. Let newDesc be the PropertyDescriptor{[[Value]]: V, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true}.
- var newDesc = {
- value: V,
- writable: true,
- enumerable: false,
- configurable: true
- };
- // 4. Return ? O.[[DefineOwnProperty]](P, newDesc).
- Object.defineProperty(O, P, newDesc);
+ // 3. Return ? O.[[Get]](P, O).
+ return O[P];
+}
+
+// _ESAbstract.HasProperty
+// 7.3.10. HasProperty ( O, P )
+function HasProperty(O, P) { // eslint-disable-line no-unused-vars
+ // Assert: Type(O) is Object.
+ // Assert: IsPropertyKey(P) is true.
+ // Return ? O.[[HasProperty]](P).
+ return P in O;
}
// _ESAbstract.IsArray
// Polyfill.io - We can skip all the above steps and check the string returned from Object.prototype.toString().
return Object.prototype.toString.call(argument) === '[object Array]';
}
-if (!('isArray' in Array)) {
-// Array.isArray
-/* global CreateMethodProperty, IsArray */
-// 22.1.2.2. Array.isArray ( arg )
-CreateMethodProperty(Array, 'isArray', function isArray(arg) {
- // 1. Return ? IsArray(arg).
- return IsArray(arg);
-});
+// _ESAbstract.IsCallable
+// 7.2.3. IsCallable ( argument )
+function IsCallable(argument) { // eslint-disable-line no-unused-vars
+ // 1. If Type(argument) is not Object, return false.
+ // 2. If argument has a [[Call]] internal method, return true.
+ // 3. Return false.
+ // 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.
+ return typeof argument === 'function';
}
-
-// _ESAbstract.ToObject
-// 7.1.13 ToObject ( argument )
+// _ESAbstract.RequireObjectCoercible
+// 7.2.1. RequireObjectCoercible ( argument )
// The abstract operation ToObject converts argument to a value of type Object according to Table 12:
// Table 12: ToObject Conversions
/*
|----------------------------------------------------------------------------------------------------------------------------------------------------|
| Undefined | Throw a TypeError exception. |
| Null | Throw a TypeError exception. |
-| Boolean | Return a new Boolean object whose [[BooleanData]] internal slot is set to argument. See 19.3 for a description of Boolean objects. |
-| Number | Return a new Number object whose [[NumberData]] internal slot is set to argument. See 20.1 for a description of Number objects. |
-| String | Return a new String object whose [[StringData]] internal slot is set to argument. See 21.1 for a description of String objects. |
-| Symbol | Return a new Symbol object whose [[SymbolData]] internal slot is set to argument. See 19.4 for a description of Symbol objects. |
+| Boolean | Return argument. |
+| Number | Return argument. |
+| String | Return argument. |
+| Symbol | Return argument. |
| Object | Return argument. |
|----------------------------------------------------------------------------------------------------------------------------------------------------|
*/
-function ToObject(argument) { // eslint-disable-line no-unused-vars
+function RequireObjectCoercible(argument) { // eslint-disable-line no-unused-vars
if (argument === null || argument === undefined) {
throw TypeError();
}
- return Object(argument);
+ return argument;
+}
+
+// _ESAbstract.ToBoolean
+// 7.1.2. ToBoolean ( argument )
+// The abstract operation ToBoolean converts argument to a value of type Boolean according to Table 9:
+/*
+--------------------------------------------------------------------------------------------------------------
+| Argument Type | Result |
+--------------------------------------------------------------------------------------------------------------
+| Undefined | Return false. |
+| Null | Return false. |
+| Boolean | Return argument. |
+| Number | If argument is +0, -0, or NaN, return false; otherwise return true. |
+| String | If argument is the empty String (its length is zero), return false; otherwise return true. |
+| Symbol | Return true. |
+| Object | Return true. |
+--------------------------------------------------------------------------------------------------------------
+*/
+function ToBoolean(argument) { // eslint-disable-line no-unused-vars
+ return Boolean(argument);
}
// _ESAbstract.ToInteger
return Math.min(len, Math.pow(2, 53) -1);
}
-// _ESAbstract.Get
-// 7.3.1. Get ( O, P )
-function Get(O, P) { // eslint-disable-line no-unused-vars
- // 1. Assert: Type(O) is Object.
- // 2. Assert: IsPropertyKey(P) is true.
- // 3. Return ? O.[[Get]](P, O).
- return O[P];
-}
-
-// _ESAbstract.IsCallable
-// 7.2.3. IsCallable ( argument )
-function IsCallable(argument) { // eslint-disable-line no-unused-vars
- // 1. If Type(argument) is not Object, return false.
- // 2. If argument has a [[Call]] internal method, return true.
- // 3. Return false.
-
- // 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.
- return typeof argument === 'function';
-}
-
-// _ESAbstract.Call
-/* global IsCallable */
-// 7.3.12. Call ( F, V [ , argumentsList ] )
-function Call(F, V /* [, argumentsList] */) { // eslint-disable-line no-unused-vars
- // 1. If argumentsList is not present, set argumentsList to a new empty List.
- var argumentsList = arguments.length > 2 ? arguments[2] : [];
- // 2. If IsCallable(F) is false, throw a TypeError exception.
- if (IsCallable(F) === false) {
- throw new TypeError(Object.prototype.toString.call(F) + 'is not a function.');
+// _ESAbstract.ToObject
+// 7.1.13 ToObject ( argument )
+// The abstract operation ToObject converts argument to a value of type Object according to Table 12:
+// Table 12: ToObject Conversions
+/*
+|----------------------------------------------------------------------------------------------------------------------------------------------------|
+| Argument Type | Result |
+|----------------------------------------------------------------------------------------------------------------------------------------------------|
+| Undefined | Throw a TypeError exception. |
+| Null | Throw a TypeError exception. |
+| Boolean | Return a new Boolean object whose [[BooleanData]] internal slot is set to argument. See 19.3 for a description of Boolean objects. |
+| Number | Return a new Number object whose [[NumberData]] internal slot is set to argument. See 20.1 for a description of Number objects. |
+| String | Return a new String object whose [[StringData]] internal slot is set to argument. See 21.1 for a description of String objects. |
+| Symbol | Return a new Symbol object whose [[SymbolData]] internal slot is set to argument. See 19.4 for a description of Symbol objects. |
+| Object | Return argument. |
+|----------------------------------------------------------------------------------------------------------------------------------------------------|
+*/
+function ToObject(argument) { // eslint-disable-line no-unused-vars
+ if (argument === null || argument === undefined) {
+ throw TypeError();
}
- // 3. Return ? F.[[Call]](V, argumentsList).
- return F.apply(V, argumentsList);
+ return Object(argument);
}
// _ESAbstract.GetV
}
}
+// _ESAbstract.GetPrototypeFromConstructor
+/* global Get, Type */
+// 9.1.14. GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto )
+function GetPrototypeFromConstructor(constructor, intrinsicDefaultProto) { // eslint-disable-line no-unused-vars
+ // 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.
+ // 2. Assert: IsCallable(constructor) is true.
+ // 3. Let proto be ? Get(constructor, "prototype").
+ var proto = Get(constructor, "prototype");
+ // 4. If Type(proto) is not Object, then
+ if (Type(proto) !== 'object') {
+ // a. Let realm be ? GetFunctionRealm(constructor).
+ // b. Set proto to realm's intrinsic object named intrinsicDefaultProto.
+ proto = intrinsicDefaultProto;
+ }
+ // 5. Return proto.
+ return proto;
+}
+
+// _ESAbstract.IsConstructor
+/* global Type */
+// 7.2.4. IsConstructor ( argument )
+function IsConstructor(argument) { // eslint-disable-line no-unused-vars
+ // 1. If Type(argument) is not Object, return false.
+ if (Type(argument) !== 'object') {
+ return false;
+ }
+ // 2. If argument has a [[Construct]] internal method, return true.
+ // 3. Return false.
+
+ // Polyfill.io - `new argument` is the only way to truly test if a function is a constructor.
+ // We choose to not use`new argument` because the argument could have side effects when called.
+ // Instead we check to see if the argument is a function and if it has a prototype.
+ // Arrow functions do not have a [[Construct]] internal method, nor do they have a prototype.
+ return typeof argument === 'function' && !!argument.prototype;
+}
+
// _ESAbstract.OrdinaryToPrimitive
/* global Get, IsCallable, Call, Type */
// 7.1.1.1. OrdinaryToPrimitive ( O, hint )
return String(argument);
}
}
+if (!("Date"in this&&"now"in this.Date&&"getTime"in this.Date.prototype
+)) {
+
+// Date.now
+Date.now = function now() {
+ return new Date().getTime();
+};
-// _ESAbstract.HasProperty
-// 7.3.10. HasProperty ( O, P )
-function HasProperty(O, P) { // eslint-disable-line no-unused-vars
- // Assert: Type(O) is Object.
- // Assert: IsPropertyKey(P) is true.
- // Return ? O.[[HasProperty]](P).
- return P in O;
}
-// _ESAbstract.ToBoolean
-// 7.1.2. ToBoolean ( argument )
-// The abstract operation ToBoolean converts argument to a value of type Boolean according to Table 9:
-/*
---------------------------------------------------------------------------------------------------------------
-| Argument Type | Result |
---------------------------------------------------------------------------------------------------------------
-| Undefined | Return false. |
-| Null | Return false. |
-| Boolean | Return argument. |
-| Number | If argument is +0, -0, or NaN, return false; otherwise return true. |
-| String | If argument is the empty String (its length is zero), return false; otherwise return true. |
-| Symbol | Return true. |
-| Object | Return true. |
---------------------------------------------------------------------------------------------------------------
-*/
-function ToBoolean(argument) { // eslint-disable-line no-unused-vars
- return Boolean(argument);
+if (!("Date"in this&&"toISOString"in Date.prototype
+)) {
+
+// Date.prototype.toISOString
+Date.prototype.toISOString = function toISOString() {
+ var date = this;
+
+ function pad(str, len) {
+ var pad = "0000";
+ str = '' + str;
+ return pad.substr(0, len - str.length) + str;
+ }
+
+ var y = date.getUTCFullYear(),
+ m = pad(date.getUTCMonth() + 1, 2),
+ d = pad(date.getUTCDate(), 2),
+ h = pad(date.getUTCHours(), 2),
+ i = pad(date.getUTCMinutes(), 2),
+ s = pad(date.getUTCSeconds(), 2),
+ ms = pad(date.getUTCMilliseconds(), 3);
+
+ return y +'-'+ m +'-'+ d + 'T' + h +':'+ i +':'+ s +'.'+ ms +'Z';
+};
+
+}
+
+if (!("defineProperty"in Object&&function(){try{var e={}
+return Object.defineProperty(e,"test",{value:42}),!0}catch(t){return!1}}()
+)) {
+
+// Object.defineProperty
+(function (nativeDefineProperty) {
+
+ var supportsAccessors = Object.prototype.hasOwnProperty('__defineGetter__');
+ var ERR_ACCESSORS_NOT_SUPPORTED = 'Getters & setters cannot be defined on this javascript engine';
+ var ERR_VALUE_ACCESSORS = 'A property cannot both have accessors and be writable or have a value';
+
+ // Polyfill.io - This does not use CreateMethodProperty because our CreateMethodProperty function uses Object.defineProperty.
+ Object['defineProperty'] = function defineProperty(object, property, descriptor) {
+
+ // Where native support exists, assume it
+ if (nativeDefineProperty && (object === window || object === document || object === Element.prototype || object instanceof Element)) {
+ return nativeDefineProperty(object, property, descriptor);
+ }
+
+ if (object === null || !(object instanceof Object || typeof object === 'object')) {
+ throw new TypeError('Object.defineProperty called on non-object');
+ }
+
+ if (!(descriptor instanceof Object)) {
+ throw new TypeError('Property description must be an object');
+ }
+
+ var propertyString = String(property);
+ var hasValueOrWritable = 'value' in descriptor || 'writable' in descriptor;
+ var getterType = 'get' in descriptor && typeof descriptor.get;
+ var setterType = 'set' in descriptor && typeof descriptor.set;
+
+ // handle descriptor.get
+ if (getterType) {
+ if (getterType !== 'function') {
+ throw new TypeError('Getter must be a function');
+ }
+ if (!supportsAccessors) {
+ throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
+ }
+ if (hasValueOrWritable) {
+ throw new TypeError(ERR_VALUE_ACCESSORS);
+ }
+ Object.__defineGetter__.call(object, propertyString, descriptor.get);
+ } else {
+ object[propertyString] = descriptor.value;
+ }
+
+ // handle descriptor.set
+ if (setterType) {
+ if (setterType !== 'function') {
+ throw new TypeError('Setter must be a function');
+ }
+ if (!supportsAccessors) {
+ throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
+ }
+ if (hasValueOrWritable) {
+ throw new TypeError(ERR_VALUE_ACCESSORS);
+ }
+ Object.__defineSetter__.call(object, propertyString, descriptor.set);
+ }
+
+ // OK to define value unconditionally - if a getter has been specified as well, an error would be thrown above
+ if ('value' in descriptor) {
+ object[propertyString] = descriptor.value;
+ }
+
+ return object;
+ };
+}(Object.defineProperty));
+
+}
+
+
+// _ESAbstract.CreateDataProperty
+// 7.3.4. CreateDataProperty ( O, P, V )
+// NOTE
+// This abstract operation creates a property whose attributes are set to the same defaults used for properties created by the ECMAScript language assignment operator.
+// 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.
+function CreateDataProperty(O, P, V) { // eslint-disable-line no-unused-vars
+ // 1. Assert: Type(O) is Object.
+ // 2. Assert: IsPropertyKey(P) is true.
+ // 3. Let newDesc be the PropertyDescriptor{ [[Value]]: V, [[Writable]]: true, [[Enumerable]]: true, [[Configurable]]: true }.
+ var newDesc = {
+ value: V,
+ writable: true,
+ enumerable: true,
+ configurable: true
+ };
+ // 4. Return ? O.[[DefineOwnProperty]](P, newDesc).
+ try {
+ Object.defineProperty(O, P, newDesc);
+ return true;
+ } catch (e) {
+ return false;
+ }
+}
+
+// _ESAbstract.CreateDataPropertyOrThrow
+/* global CreateDataProperty */
+// 7.3.6. CreateDataPropertyOrThrow ( O, P, V )
+function CreateDataPropertyOrThrow(O, P, V) { // eslint-disable-line no-unused-vars
+ // 1. Assert: Type(O) is Object.
+ // 2. Assert: IsPropertyKey(P) is true.
+ // 3. Let success be ? CreateDataProperty(O, P, V).
+ var success = CreateDataProperty(O, P, V);
+ // 4. If success is false, throw a TypeError exception.
+ if (!success) {
+ 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) + '`');
+ }
+ // 5. Return success.
+ return success;
+}
+
+// _ESAbstract.CreateMethodProperty
+// 7.3.5. CreateMethodProperty ( O, P, V )
+function CreateMethodProperty(O, P, V) { // eslint-disable-line no-unused-vars
+ // 1. Assert: Type(O) is Object.
+ // 2. Assert: IsPropertyKey(P) is true.
+ // 3. Let newDesc be the PropertyDescriptor{[[Value]]: V, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true}.
+ var newDesc = {
+ value: V,
+ writable: true,
+ enumerable: false,
+ configurable: true
+ };
+ // 4. Return ? O.[[DefineOwnProperty]](P, newDesc).
+ Object.defineProperty(O, P, newDesc);
+}
+if (!("isArray"in Array
+)) {
+
+// Array.isArray
+/* global CreateMethodProperty, IsArray */
+// 22.1.2.2. Array.isArray ( arg )
+CreateMethodProperty(Array, 'isArray', function isArray(arg) {
+ // 1. Return ? IsArray(arg).
+ return IsArray(arg);
+});
+
}
-if (!('every' in Array.prototype)) {
+
+if (!("every"in Array.prototype
+)) {
// Array.prototype.every
/* global Call, CreateMethodProperty, Get, HasProperty, IsCallable, ToBoolean, ToLength, ToObject, ToString */
}
+if (!("forEach"in Array.prototype
+)) {
-// _ESAbstract.ArrayCreate
-// 9.4.2.2. ArrayCreate ( length [ , proto ] )
-function ArrayCreate(length /* [, proto] */) { // eslint-disable-line no-unused-vars
- // 1. Assert: length is an integer Number ≥ 0.
- // 2. If length is -0, set length to +0.
- if (1 / length === -Infinity) {
- length = 0;
+// Array.prototype.forEach
+/* global Call, CreateMethodProperty, Get, HasProperty, IsCallable, ToLength, ToObject, ToString */
+// 22.1.3.10. Array.prototype.forEach ( callbackfn [ , thisArg ] )
+CreateMethodProperty(Array.prototype, 'forEach', function forEach(callbackfn /* [ , thisArg ] */) {
+ // 1. Let O be ? ToObject(this value).
+ var O = ToObject(this);
+ // Polyfill.io - If O is a String object, split it into an array in order to iterate correctly.
+ // We will use arrayLike in place of O when we are iterating through the list.
+ var arraylike = O instanceof String ? O.split('') : O;
+ // 2. Let len be ? ToLength(? Get(O, "length")).
+ var len = ToLength(Get(O, "length"));
+ // 3. If IsCallable(callbackfn) is false, throw a TypeError exception.
+ if (IsCallable(callbackfn) === false) {
+ throw new TypeError(callbackfn + ' is not a function');
}
- // 3. If length>2^32-1, throw a RangeError exception.
- if (length > (Math.pow(2, 32) - 1)) {
- throw new RangeError('Invalid array length');
+ // 4. If thisArg is present, let T be thisArg; else let T be undefined.
+ var T = arguments.length > 1 ? arguments[1] : undefined;
+ // 5. Let k be 0.
+ var k = 0;
+ // 6. Repeat, while k < len
+ while (k < len) {
+ // a. Let Pk be ! ToString(k).
+ var Pk = ToString(k);
+ // b. Let kPresent be ? HasProperty(O, Pk).
+ var kPresent = HasProperty(arraylike, Pk);
+ // c. If kPresent is true, then
+ if (kPresent) {
+ // i. Let kValue be ? Get(O, Pk).
+ var kValue = Get(arraylike, Pk);
+ // ii. Perform ? Call(callbackfn, T, « kValue, k, O »).
+ Call(callbackfn, T, [kValue, k, O]);
+ }
+ // d. Increase k by 1.
+ k = k + 1;
}
- // 4. If proto is not present, set proto to the intrinsic object %ArrayPrototype%.
- // 5. Let A be a newly created Array exotic object.
- var A = [];
- // 6. Set A's essential internal methods except for [[DefineOwnProperty]] to the default ordinary object definitions specified in 9.1.
- // 7. Set A.[[DefineOwnProperty]] as specified in 9.4.2.1.
- // 8. Set A.[[Prototype]] to proto.
- // 9. Set A.[[Extensible]] to true.
- // 10. Perform ! OrdinaryDefineOwnProperty(A, "length", PropertyDescriptor{[[Value]]: length, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: false}).
- A.length = length;
- // 11. Return A.
- return A;
+ // 7. Return undefined.
+ return undefined;
+});
+
}
-// _ESAbstract.IsConstructor
-/* global Type */
-// 7.2.4. IsConstructor ( argument )
-function IsConstructor(argument) { // eslint-disable-line no-unused-vars
- // 1. If Type(argument) is not Object, return false.
- if (Type(argument) !== 'object') {
- return false;
+if (!("indexOf"in Array.prototype
+)) {
+
+// Array.prototype.indexOf
+/* global CreateMethodProperty, Get, HasProperty, ToInteger, ToLength, ToObject, ToString */
+// 22.1.3.12. Array.prototype.indexOf ( searchElement [ , fromIndex ] )
+CreateMethodProperty(Array.prototype, 'indexOf', function indexOf(searchElement /* [ , fromIndex ] */) {
+ // 1. Let O be ? ToObject(this value).
+ var O = ToObject(this);
+ // 2. Let len be ? ToLength(? Get(O, "length")).
+ var len = ToLength(Get(O, "length"));
+ // 3. If len is 0, return -1.
+ if (len === 0) {
+ return -1;
}
- // 2. If argument has a [[Construct]] internal method, return true.
- // 3. Return false.
+ // 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step produces the value 0.)
+ var n = ToInteger(arguments[1]);
+ // 5. If n ≥ len, return -1.
+ if (n >= len) {
+ return -1;
+ }
+ // 6. If n ≥ 0, then
+ if (n >= 0) {
+ // a. If n is -0, let k be +0; else let k be n.
+ var k = n === -0 ? 0 : n;
+ // 7. Else n < 0,
+ } else {
+ // a. Let k be len + n.
+ var k = len + n;
+ // b. If k < 0, let k be 0.
+ if (k < 0) {
+ k = 0;
+ }
+ }
+ // 8. Repeat, while k < len
+ while (k < len) {
+ // a. Let kPresent be ? HasProperty(O, ! ToString(k)).
+ var kPresent = HasProperty(O, ToString(k));
+ // b. If kPresent is true, then
+ if (kPresent) {
+ // i. Let elementK be ? Get(O, ! ToString(k)).
+ var elementK = Get(O, ToString(k));
+ // ii. Let same be the result of performing Strict Equality Comparison searchElement === elementK.
+ var same = searchElement === elementK;
+ // iii. If same is true, return k.
+ if (same) {
+ return k;
+ }
+ }
+ // c. Increase k by 1.
+ k = k + 1;
+ }
+ // 9. Return -1.
+ return -1;
+});
- // Polyfill.io - `new argument` is the only way to truly test if a function is a constructor.
- // We choose to not use`new argument` because the argument could have side effects when called.
- // Instead we check to see if the argument is a function and if it has a prototype.
- // Arrow functions do not have a [[Construct]] internal method, nor do they have a prototype.
- return typeof argument === 'function' && !!argument.prototype;
}
-// _ESAbstract.GetPrototypeFromConstructor
-/* global Get, Type */
-// 9.1.14. GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto )
-function GetPrototypeFromConstructor(constructor, intrinsicDefaultProto) { // eslint-disable-line no-unused-vars
- // 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.
- // 2. Assert: IsCallable(constructor) is true.
- // 3. Let proto be ? Get(constructor, "prototype").
- var proto = Get(constructor, "prototype");
- // 4. If Type(proto) is not Object, then
- if (Type(proto) !== 'object') {
- // a. Let realm be ? GetFunctionRealm(constructor).
- // b. Set proto to realm's intrinsic object named intrinsicDefaultProto.
- proto = intrinsicDefaultProto;
+if (!("lastIndexOf"in Array.prototype
+)) {
+
+// Array.prototype.lastIndexOf
+/* global CreateMethodProperty, Get, HasProperty, ToInteger, ToLength, ToObject, ToString */
+// 22.1.3.15. Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] )
+CreateMethodProperty(Array.prototype, 'lastIndexOf', function lastIndexOf(searchElement /* [ , fromIndex ] */) {
+ // 1. Let O be ? ToObject(this value).
+ var O = ToObject(this);
+ // 2. Let len be ? ToLength(? Get(O, "length")).
+ var len = ToLength(Get(O, "length"));
+ // 3. If len is 0, return -1.
+ if (len === 0) {
+ return -1;
}
- // 5. Return proto.
- return proto;
-}
-if (!('keys' in Object && (function () {
- // Safari 5.0 bug where Object.keys doesn't work with arguments
- return (Object.keys(arguments)).length === 2;
-}(1, 2)) && (function () {
- try {
- // In ES6 Object.keys works on all object except `null` and `undefined`.
- Object.keys('');
- return true;
- } catch (e) {
- return false;
+ // 4. If fromIndex is present, let n be ? ToInteger(fromIndex); else let n be len-1.
+ var n = arguments.length > 1 ? ToInteger(arguments[1]) : len - 1;
+ // 5. If n ≥ 0, then
+ if (n >= 0) {
+ // a. If n is -0, let k be +0; else let k be min(n, len - 1).
+ var k = n === -0 ? 0 : Math.min(n, len - 1);
+ // 6. Else n < 0,
+ } else {
+ // a. Let k be len + n.
+ k = len + n;
+ }
+ // 7. Repeat, while k ≥ 0
+ while (k >= 0) {
+ // a. Let kPresent be ? HasProperty(O, ! ToString(k)).
+ var kPresent = HasProperty(O, ToString(k));
+ // b. If kPresent is true, then
+ if (kPresent) {
+ // i. Let elementK be ? Get(O, ! ToString(k)).
+ var elementK = Get(O, ToString(k));
+ // ii. Let same be the result of performing Strict Equality Comparison searchElement === elementK.
+ var same = searchElement === elementK;
+ // iii. If same is true, return k.
+ if (same) {
+ return k;
+ }
+ }
+ // c. Decrease k by 1.
+ k = k - 1;
}
-}()))) {
+ // 9. Return -1.
+ return -1;
+});
-// Object.keys
-Object.keys = (function() {
- 'use strict';
+}
- // modified from https://github.com/es-shims/object-keys
+if (!("reduce"in Array.prototype
+)) {
- var has = Object.prototype.hasOwnProperty;
- var toStr = Object.prototype.toString;
- var isEnumerable = Object.prototype.propertyIsEnumerable;
- var hasDontEnumBug = !isEnumerable.call({ toString: null }, 'toString');
- var hasProtoEnumBug = isEnumerable.call(function () {}, 'prototype');
- var dontEnums = [
- 'toString',
- 'toLocaleString',
- 'valueOf',
- 'hasOwnProperty',
- 'isPrototypeOf',
- 'propertyIsEnumerable',
- 'constructor'
- ];
- var equalsConstructorPrototype = function (o) {
- var ctor = o.constructor;
- return ctor && ctor.prototype === o;
- };
- var excludedKeys = {
- $console: true,
- $external: true,
- $frame: true,
- $frameElement: true,
- $frames: true,
- $innerHeight: true,
- $innerWidth: true,
- $outerHeight: true,
- $outerWidth: true,
- $pageXOffset: true,
- $pageYOffset: true,
- $parent: true,
- $scrollLeft: true,
- $scrollTop: true,
- $scrollX: true,
- $scrollY: true,
- $self: true,
- $webkitIndexedDB: true,
- $webkitStorageInfo: true,
- $window: true
- };
- var hasAutomationEqualityBug = (function () {
- /* global window */
- if (typeof window === 'undefined') { return false; }
- for (var k in window) {
- try {
- if (!excludedKeys['$' + k] && has.call(window, k) && window[k] !== null && typeof window[k] === 'object') {
- try {
- equalsConstructorPrototype(window[k]);
- } catch (e) {
- return true;
- }
- }
- } catch (e) {
- return true;
+// Array.prototype.reduce
+/* global Call, CreateMethodProperty, Get, HasProperty, IsCallable, ToLength, ToObject, ToString */
+// 22.1.3.19. Array.prototype.reduce ( callbackfn [ , initialValue ] )
+CreateMethodProperty(Array.prototype, 'reduce', function reduce(callbackfn /* [ , initialValue ] */) {
+ // 1. Let O be ? ToObject(this value).
+ var O = ToObject(this);
+ // Polyfill.io - If O is a String object, split it into an array in order to iterate correctly.
+ // We will use arrayLike in place of O when we are iterating through the list.
+ var arraylike = O instanceof String ? O.split('') : O;
+ // 2. Let len be ? ToLength(? Get(O, "length")).
+ var len = ToLength(Get(arraylike, "length"));
+ // 3. If IsCallable(callbackfn) is false, throw a TypeError exception.
+ if (IsCallable(callbackfn) === false) {
+ throw new TypeError(callbackfn + ' is not a function');
+ }
+ // 4. If len is 0 and initialValue is not present, throw a TypeError exception.
+ var initialValue = arguments.length > 1 ? arguments[1] : undefined;
+ if (len === 0 && arguments.length < 2) {
+ throw new TypeError('Reduce of empty array with no initial value');
+ }
+ // 5. Let k be 0.
+ var k = 0;
+ // 6. Let accumulator be undefined.
+ var accumulator = undefined;
+ // 7. If initialValue is present, then
+ if (arguments.length > 1) {
+ // a. Set accumulator to initialValue.
+ accumulator = initialValue;
+ // 8. Else initialValue is not present,
+ } else {
+ // a. Let kPresent be false.
+ var kPresent = false;
+ // b. Repeat, while kPresent is false and k < len
+ while (kPresent === false && k < len) {
+ // i. Let Pk be ! ToString(k).
+ var Pk = ToString(k);
+ // ii. Let kPresent be ? HasProperty(O, Pk).
+ var kPresent = HasProperty(arraylike, Pk);
+ // iii. If kPresent is true, then
+ if (kPresent) {
+ // 1. Set accumulator to ? Get(O, Pk).
+ var accumulator = Get(arraylike, Pk);
}
+ // iv. Increase k by 1.
+ k = k + 1;
}
- return false;
- }());
- var equalsConstructorPrototypeIfNotBuggy = function (o) {
- /* global window */
- if (typeof window === 'undefined' || !hasAutomationEqualityBug) {
- return equalsConstructorPrototype(o);
- }
- try {
- return equalsConstructorPrototype(o);
- } catch (e) {
- return false;
+ // c. If kPresent is false, throw a TypeError exception.
+ if (kPresent === false) {
+ throw new TypeError('Reduce of empty array with no initial value');
}
- };
-
- function isArgumentsObject(value) {
- var str = toStr.call(value);
- var isArgs = str === '[object Arguments]';
- if (!isArgs) {
- isArgs = str !== '[object Array]' &&
- value !== null &&
- typeof value === 'object' &&
- typeof value.length === 'number' &&
- value.length >= 0 &&
- toStr.call(value.callee) === '[object Function]';
+ }
+ // 9. Repeat, while k < len
+ while (k < len) {
+ // a. Let Pk be ! ToString(k).
+ var Pk = ToString(k);
+ // b. Let kPresent be ? HasProperty(O, Pk).
+ var kPresent = HasProperty(arraylike, Pk);
+ // c. If kPresent is true, then
+ if (kPresent) {
+ // i. Let kValue be ? Get(O, Pk).
+ var kValue = Get(arraylike, Pk);
+ // ii. Set accumulator to ? Call(callbackfn, undefined, « accumulator, kValue, k, O »).
+ accumulator = Call(callbackfn, undefined, [accumulator, kValue, k, O]);
}
- return isArgs;
+ // d. Increase k by 1.
+ k = k + 1;
}
+ // 10. Return accumulator.
+ return accumulator;
+});
- return function keys(object) {
- var isFunction = toStr.call(object) === '[object Function]';
- var isArguments = isArgumentsObject(object);
- var isString = toStr.call(object) === '[object String]';
- var theKeys = [];
+}
- if (object === undefined || object === null) {
- throw new TypeError('Cannot convert undefined or null to object');
- }
+if (!("reduceRight"in Array.prototype
+)) {
- var skipProto = hasProtoEnumBug && isFunction;
- if (isString && object.length > 0 && !has.call(object, 0)) {
- for (var i = 0; i < object.length; ++i) {
- theKeys.push(String(i));
+// Array.prototype.reduceRight
+/* global Call, CreateMethodProperty, Get, HasProperty, IsCallable, ToLength, ToObject, ToString */
+// 22.1.3.20. Array.prototype.reduceRight ( callbackfn [ , initialValue ] )
+CreateMethodProperty(Array.prototype, 'reduceRight', function reduceRight(callbackfn /* [ , initialValue ] */) {
+ // 1. Let O be ? ToObject(this value).
+ var O = ToObject(this);
+ // Polyfill.io - If O is a String object, split it into an array in order to iterate correctly.
+ // We will use arrayLike in place of O when we are iterating through the list.
+ var arraylike = O instanceof String ? O.split('') : O;
+ // 2. Let len be ? ToLength(? Get(O, "length")).
+ var len = ToLength(Get(arraylike, "length"));
+ // 3. If IsCallable(callbackfn) is false, throw a TypeError exception.
+ if (IsCallable(callbackfn) === false) {
+ throw new TypeError(callbackfn + ' is not a function');
+ }
+ // 4. If len is 0 and initialValue is not present, throw a TypeError exception.
+ var initialValue = arguments.length > 1 ? arguments[1] : undefined;
+ if (len === 0 && arguments.length < 2) {
+ throw new TypeError('Reduce of empty array with no initial value');
+ }
+ // 5. Let k be len-1.
+ var k = len - 1;
+ // 6. Let accumulator be undefined.
+ var accumulator = undefined;
+ // 7. If initialValue is present, then
+ if (arguments.length > 1) {
+ // a. Set accumulator to initialValue.
+ accumulator = initialValue;
+ // 8.Else initialValue is not present,
+ } else {
+ // a. Let kPresent be false.
+ var kPresent = false;
+ // b. Repeat, while kPresent is false and k ≥ 0
+ while (kPresent === false && k >= 0) {
+ // i. Let Pk be ! ToString(k).
+ var Pk = ToString(k);
+ // ii. Let kPresent be ? HasProperty(O, Pk).
+ var kPresent = HasProperty(arraylike, Pk);
+ // iii. If kPresent is true, then
+ if (kPresent) {
+ // 1. Set accumulator to ? Get(O, Pk).
+ accumulator = Get(arraylike, Pk);
}
+ // iv. Decrease k by 1.
+ k = k - 1;
}
-
- if (isArguments && object.length > 0) {
- for (var j = 0; j < object.length; ++j) {
- theKeys.push(String(j));
- }
- } else {
- for (var name in object) {
- if (!(skipProto && name === 'prototype') && has.call(object, name)) {
- theKeys.push(String(name));
- }
- }
+ // c. If kPresent is false, throw a TypeError exception.
+ if (kPresent === false) {
+ throw new TypeError('Reduce of empty array with no initial value');
}
+ }
+ // 9. Repeat, while k ≥ 0
+ while (k >= 0) {
+ // a. Let Pk be ! ToString(k).
+ var Pk = ToString(k);
+ // b. Let kPresent be ? HasProperty(O, Pk).
+ var kPresent = HasProperty(arraylike, Pk);
+ // c. If kPresent is true, then
+ if (kPresent) {
+ // i. Let kValue be ? Get(O, Pk).
+ var kValue = Get(arraylike, Pk);
+ // ii. Set accumulator to ? Call(callbackfn, undefined, « accumulator, kValue, k, O »).
+ accumulator = Call(callbackfn, undefined, [accumulator, kValue, k, O]);
+ }
+ // d. Decrease k by 1.
+ k = k - 1;
+ }
+ // 10 Return accumulator.
+ return accumulator;
+});
- if (hasDontEnumBug) {
- var skipConstructor = equalsConstructorPrototypeIfNotBuggy(object);
+}
- for (var k = 0; k < dontEnums.length; ++k) {
- if (!(skipConstructor && dontEnums[k] === 'constructor') && has.call(object, dontEnums[k])) {
- theKeys.push(dontEnums[k]);
- }
+if (!("some"in Array.prototype
+)) {
+
+// Array.prototype.some
+/* global Call, CreateMethodProperty, Get, HasProperty, IsCallable, ToBoolean, ToLength, ToObject, ToString */
+// 22.1.3.24. Array.prototype.some ( callbackfn [ , thisArg ] )
+CreateMethodProperty(Array.prototype, 'some', function some(callbackfn /* [ , thisArg ] */) {
+ // 1. Let O be ? ToObject(this value).
+ var O = ToObject(this);
+ // 2. Let len be ? ToLength(? Get(O, "length")).
+ var len = ToLength(Get(O, "length"));
+ // 3. If IsCallable(callbackfn) is false, throw a TypeError exception.
+ if (IsCallable(callbackfn) === false) {
+ throw new TypeError(callbackfn + ' is not a function');
+ }
+ // 4. If thisArg is present, let T be thisArg; else let T be undefined.
+ var T = arguments.length > 1 ? arguments[1] : undefined;
+ // 5. Let k be 0.
+ var k = 0;
+ // 6. Repeat, while k < len
+ while (k < len) {
+ // a. Let Pk be ! ToString(k).
+ var Pk = ToString(k);
+ // b. Let kPresent be ? HasProperty(O, Pk).
+ var kPresent = HasProperty(O, Pk);
+ // c. If kPresent is true, then
+ if (kPresent) {
+ // i. Let kValue be ? Get(O, Pk).
+ var kValue = Get(O, Pk);
+ // ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ var testResult = ToBoolean(Call(callbackfn, T, [kValue, k, O]));
+ // iii. If testResult is true, return true.
+ if (testResult) {
+ return true;
}
}
- return theKeys;
- };
-}());
+ // d. Increase k by 1.
+ k = k + 1;
+ }
+ // 7. Return false.
+ return false;
+});
}
-if (!('bind' in Function.prototype)) {
+if (!("bind"in Function.prototype
+)) {
// Function.prototype.bind
/* global CreateMethodProperty, IsCallable */
}
-if (!('getOwnPropertyDescriptor' in Object && typeof Object.getOwnPropertyDescriptor === 'function' && (function() {
- try {
- var object = {};
- object.test = 0;
- return Object.getOwnPropertyDescriptor(
- object,
- "test"
- ).value === 0;
- } catch (exception) {
- return false
- }
-}()))) {
+if (!("freeze"in Object
+)) {
+
+// Object.freeze
+/* global CreateMethodProperty */
+// 19.1.2.6. Object.freeze ( O )
+CreateMethodProperty(Object, 'freeze', function freeze(O) {
+ // This feature cannot be implemented fully as a polyfill.
+ // We choose to silently fail which allows "securable" code
+ // to "gracefully" degrade to working but insecure code.
+ return O;
+});
+
+}
+
+if (!("getOwnPropertyDescriptor"in Object&&"function"==typeof Object.getOwnPropertyDescriptor&&function(){try{var t={}
+return t.test=0,0===Object.getOwnPropertyDescriptor(t,"test").value}catch(e){return!1}}()
+)) {
// Object.getOwnPropertyDescriptor
/* global CreateMethodProperty */
}
-if (!('defineProperties' in Object)) {
+if (!("getOwnPropertyNames"in Object
+)) {
-// Object.defineProperties
-/* global CreateMethodProperty, Get, ToObject, Type */
-// 19.1.2.3. Object.defineProperties ( O, Properties )
-CreateMethodProperty(Object, 'defineProperties', function defineProperties(O, Properties) {
- // 1. If Type(O) is not Object, throw a TypeError exception.
- if (Type(O) !== 'object') {
- throw new TypeError('Object.defineProperties called on non-object');
- }
- // 2. Let props be ? ToObject(Properties).
- var props = ToObject(Properties);
- // 3. Let keys be ? props.[[OwnPropertyKeys]]().
- /*
- Polyfill.io - This step in our polyfill is not complying with the specification.
- [[OwnPropertyKeys]] is meant to return ALL keys, including non-enumerable and symbols.
- TODO: When we have Reflect.ownKeys, use that instead as it is the userland equivalent of [[OwnPropertyKeys]].
- */
- var keys = Object.keys(props);
- // 4. Let descriptors be a new empty List.
- var descriptors = [];
- // 5. For each element nextKey of keys in List order, do
- for (var i = 0; i < keys.length; i++) {
- var nextKey = keys[i];
- // a. Let propDesc be ? props.[[GetOwnProperty]](nextKey).
- var propDesc = Object.getOwnPropertyDescriptor(props, nextKey);
- // b. If propDesc is not undefined and propDesc.[[Enumerable]] is true, then
- if (propDesc !== undefined && propDesc.enumerable) {
- // i. Let descObj be ? Get(props, nextKey).
- var descObj = Get(props, nextKey);
- // ii. Let desc be ? ToPropertyDescriptor(descObj).
- // Polyfill.io - We skip this step because Object.defineProperty deals with it.
- // TODO: Implement this step?
- var desc = descObj;
- // iii. Append the pair (a two element List) consisting of nextKey and desc to the end of descriptors.
- descriptors.push([nextKey, desc]);
- }
- }
- // 6. For each pair from descriptors in list order, do
- for (var i = 0; i < descriptors.length; i++){
- // a. Let P be the first element of pair.
- var P = descriptors[i][0];
- // b. Let desc be the second element of pair.
- var desc = descriptors[i][1];
- // c. Perform ? DefinePropertyOrThrow(O, P, desc).
- Object.defineProperty(O, P, desc);
- }
- // 7. Return O.
- return O;
-});
+// Object.getOwnPropertyNames
+/* global CreateMethodProperty */
-}
+var toString = ({}).toString;
+var split = ''.split;
-if (!('create' in Object)) {
+CreateMethodProperty(Object, 'getOwnPropertyNames', function getOwnPropertyNames(object) {
+ var buffer = [];
+ var key;
-// Object.create
-/* global CreateMethodProperty, Type */
-CreateMethodProperty(Object, 'create', function create(O, properties) {
- // 1. If Type(O) is neither Object nor Null, throw a TypeError exception.
- if (Type(O) !== 'object' && Type(O) !== 'null') {
- throw new TypeError('Object prototype may only be an Object or null');
+ // Non-enumerable properties cannot be discovered but can be checked for by name.
+ // Define those used internally by JS to allow an incomplete solution
+ var commonProps = ['length', "name", "arguments", "caller", "prototype", "observe", "unobserve"];
+
+ if (typeof object === 'undefined' || object === null) {
+ throw new TypeError('Cannot convert undefined or null to object');
}
- // 2. Let obj be ObjectCreate(O).
- var obj = new Function('e', 'function Object() {}Object.prototype=e;return new Object')(O);
- obj.constructor.prototype = O;
+ // Polyfill.io fallback for non-array-like strings which exist in some ES3 user-agents (IE 8)
+ object = toString.call(object) == '[object String]' ? split.call(object, '') : Object(object);
- // 3. If Properties is not undefined, then
- if (1 in arguments) {
- // a. Return ? ObjectDefineProperties(obj, Properties).
- return Object.defineProperties(obj, properties);
+ // Enumerable properties only
+ for (key in object) {
+ if (Object.prototype.hasOwnProperty.call(object, key)) {
+ buffer.push(key);
+ }
}
- return obj;
+ // Check for and add the common non-enumerable properties
+ for (var i=0, s=commonProps.length; i<s; i++) {
+ if (commonProps[i] in object) buffer.push(commonProps[i]);
+ }
+
+ return buffer;
});
}
-if (!('getPrototypeOf' in Object)) {
+if (!("getPrototypeOf"in Object
+)) {
// Object.getPrototypeOf
/* global CreateMethodProperty */
}
+if (!("keys"in Object&&function(){return 2===Object.keys(arguments).length}(1,2)&&function(){try{return Object.keys(""),!0}catch(t){return!1}}()
+)) {
-// _ESAbstract.OrdinaryCreateFromConstructor
-/* global GetPrototypeFromConstructor */
-// 9.1.13. OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto [ , internalSlotsList ] )
-function OrdinaryCreateFromConstructor(constructor, intrinsicDefaultProto) { // eslint-disable-line no-unused-vars
- var internalSlotsList = arguments[2] || {};
- // 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.
+// Object.keys
+/* global CreateMethodProperty */
+CreateMethodProperty(Object, "keys", (function() {
+ 'use strict';
- // 2. Let proto be ? GetPrototypeFromConstructor(constructor, intrinsicDefaultProto).
- var proto = GetPrototypeFromConstructor(constructor, intrinsicDefaultProto);
+ // modified from https://github.com/es-shims/object-keys
- // 3. Return ObjectCreate(proto, internalSlotsList).
- // 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.
- var obj = Object.create(proto);
- for (var name in internalSlotsList) {
- if (Object.prototype.hasOwnProperty.call(internalSlotsList, name)) {
- Object.defineProperty(obj, name, {
- configurable: true,
- enumerable: false,
- writable: true,
- value: internalSlotsList[name]
- });
+ var has = Object.prototype.hasOwnProperty;
+ var toStr = Object.prototype.toString;
+ var isEnumerable = Object.prototype.propertyIsEnumerable;
+ var hasDontEnumBug = !isEnumerable.call({ toString: null }, 'toString');
+ var hasProtoEnumBug = isEnumerable.call(function () {}, 'prototype');
+ var dontEnums = [
+ 'toString',
+ 'toLocaleString',
+ 'valueOf',
+ 'hasOwnProperty',
+ 'isPrototypeOf',
+ 'propertyIsEnumerable',
+ 'constructor'
+ ];
+ var equalsConstructorPrototype = function (o) {
+ var ctor = o.constructor;
+ return ctor && ctor.prototype === o;
+ };
+ var excludedKeys = {
+ $console: true,
+ $external: true,
+ $frame: true,
+ $frameElement: true,
+ $frames: true,
+ $innerHeight: true,
+ $innerWidth: true,
+ $outerHeight: true,
+ $outerWidth: true,
+ $pageXOffset: true,
+ $pageYOffset: true,
+ $parent: true,
+ $scrollLeft: true,
+ $scrollTop: true,
+ $scrollX: true,
+ $scrollY: true,
+ $self: true,
+ $webkitIndexedDB: true,
+ $webkitStorageInfo: true,
+ $window: true
+ };
+ var hasAutomationEqualityBug = (function () {
+ /* global window */
+ if (typeof window === 'undefined') { return false; }
+ for (var k in window) {
+ try {
+ if (!excludedKeys['$' + k] && has.call(window, k) && window[k] !== null && typeof window[k] === 'object') {
+ try {
+ equalsConstructorPrototype(window[k]);
+ } catch (e) {
+ return true;
+ }
+ }
+ } catch (e) {
+ return true;
+ }
}
- }
- return obj;
-}
-
-// _ESAbstract.Construct
-/* global IsConstructor, OrdinaryCreateFromConstructor, Call */
-// 7.3.13. Construct ( F [ , argumentsList [ , newTarget ]] )
-function Construct(F /* [ , argumentsList [ , newTarget ]] */) { // eslint-disable-line no-unused-vars
- // 1. If newTarget is not present, set newTarget to F.
- var newTarget = arguments.length > 2 ? arguments[2] : F;
-
- // 2. If argumentsList is not present, set argumentsList to a new empty List.
- var argumentsList = arguments.length > 1 ? arguments[1] : [];
-
- // 3. Assert: IsConstructor(F) is true.
- if (!IsConstructor(F)) {
- throw new TypeError('F must be a constructor.');
- }
-
- // 4. Assert: IsConstructor(newTarget) is true.
- if (!IsConstructor(newTarget)) {
- throw new TypeError('newTarget must be a constructor.');
- }
-
- // 5. Return ? F.[[Construct]](argumentsList, newTarget).
- // Polyfill.io - If newTarget is the same as F, it is equivalent to new F(...argumentsList).
- if (newTarget === F) {
- return new (Function.prototype.bind.apply(F, [null].concat(argumentsList)))();
- } else {
- // Polyfill.io - This is mimicking section 9.2.2 step 5.a.
- var obj = OrdinaryCreateFromConstructor(newTarget, Object.prototype);
- return Call(F, obj, argumentsList);
- }
-}
-
-// _ESAbstract.ArraySpeciesCreate
-/* global IsArray, ArrayCreate, Get, Type, IsConstructor, Construct */
-// 9.4.2.3. ArraySpeciesCreate ( originalArray, length )
-function ArraySpeciesCreate(originalArray, length) { // eslint-disable-line no-unused-vars
- // 1. Assert: length is an integer Number ≥ 0.
- // 2. If length is -0, set length to +0.
- if (1/length === -Infinity) {
- length = 0;
- }
-
- // 3. Let isArray be ? IsArray(originalArray).
- var isArray = IsArray(originalArray);
-
- // 4. If isArray is false, return ? ArrayCreate(length).
- if (isArray === false) {
- return ArrayCreate(length);
- }
-
- // 5. Let C be ? Get(originalArray, "constructor").
- var C = Get(originalArray, 'constructor');
+ return false;
+ }());
+ var equalsConstructorPrototypeIfNotBuggy = function (o) {
+ /* global window */
+ if (typeof window === 'undefined' || !hasAutomationEqualityBug) {
+ return equalsConstructorPrototype(o);
+ }
+ try {
+ return equalsConstructorPrototype(o);
+ } catch (e) {
+ return false;
+ }
+ };
- // Polyfill.io - We skip this section as not sure how to make a cross-realm normal Array, a same-realm Array.
- // 6. If IsConstructor(C) is true, then
- // if (IsConstructor(C)) {
- // a. Let thisRealm be the current Realm Record.
- // b. Let realmC be ? GetFunctionRealm(C).
- // c. If thisRealm and realmC are not the same Realm Record, then
- // i. If SameValue(C, realmC.[[Intrinsics]].[[%Array%]]) is true, set C to undefined.
- // }
- // 7. If Type(C) is Object, then
- if (Type(C) === 'object') {
- // a. Set C to ? Get(C, @@species).
- C = 'Symbol' in this && 'species' in this.Symbol ? Get(C, this.Symbol.species) : undefined;
- // b. If C is null, set C to undefined.
- if (C === null) {
- C = undefined;
+ function isArgumentsObject(value) {
+ var str = toStr.call(value);
+ var isArgs = str === '[object Arguments]';
+ if (!isArgs) {
+ isArgs = str !== '[object Array]' &&
+ value !== null &&
+ typeof value === 'object' &&
+ typeof value.length === 'number' &&
+ value.length >= 0 &&
+ toStr.call(value.callee) === '[object Function]';
}
+ return isArgs;
}
- // 8. If C is undefined, return ? ArrayCreate(length).
- if (C === undefined) {
- return ArrayCreate(length);
- }
- // 9. If IsConstructor(C) is false, throw a TypeError exception.
- if (!IsConstructor(C)) {
- throw new TypeError('C must be a constructor');
- }
- // 10. Return ? Construct(C, « length »).
- return Construct(C, [length]);
-}
-// _ESAbstract.CreateDataProperty
-// 7.3.4. CreateDataProperty ( O, P, V )
-// NOTE
-// This abstract operation creates a property whose attributes are set to the same defaults used for properties created by the ECMAScript language assignment operator.
-// 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.
-function CreateDataProperty(O, P, V) { // eslint-disable-line no-unused-vars
- // 1. Assert: Type(O) is Object.
- // 2. Assert: IsPropertyKey(P) is true.
- // 3. Let newDesc be the PropertyDescriptor{ [[Value]]: V, [[Writable]]: true, [[Enumerable]]: true, [[Configurable]]: true }.
- var newDesc = {
- value: V,
- writable: true,
- enumerable: true,
- configurable: true
- };
- // 4. Return ? O.[[DefineOwnProperty]](P, newDesc).
- try {
- Object.defineProperty(O, P, newDesc);
- return true;
- } catch (e) {
- return false;
- }
-}
+ return function keys(object) {
+ var isFunction = toStr.call(object) === '[object Function]';
+ var isArguments = isArgumentsObject(object);
+ var isString = toStr.call(object) === '[object String]';
+ var theKeys = [];
-// _ESAbstract.CreateDataPropertyOrThrow
-/* global CreateDataProperty */
-// 7.3.6. CreateDataPropertyOrThrow ( O, P, V )
-function CreateDataPropertyOrThrow(O, P, V) { // eslint-disable-line no-unused-vars
- // 1. Assert: Type(O) is Object.
- // 2. Assert: IsPropertyKey(P) is true.
- // 3. Let success be ? CreateDataProperty(O, P, V).
- var success = CreateDataProperty(O, P, V);
- // 4. If success is false, throw a TypeError exception.
- if (!success) {
- 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) + '`');
- }
- // 5. Return success.
- return success;
-}
-if (!('filter' in Array.prototype)) {
+ if (object === undefined || object === null) {
+ throw new TypeError('Cannot convert undefined or null to object');
+ }
-// Array.prototype.filter
-/* global CreateMethodProperty, ToObject, ToLength, Get, IsCallable, ArraySpeciesCreate, ToString, HasProperty, ToBoolean, Call, CreateDataPropertyOrThrow */
-// 22.1.3.7. Array.prototype.filter ( callbackfn [ , thisArg ] )
-CreateMethodProperty(Array.prototype, 'filter', function filter(callbackfn /* [ , thisArg ] */) {
- // 1. Let O be ? ToObject(this value).
- var O = ToObject(this);
- // 2. Let len be ? ToLength(? Get(O, "length")).
- var len = ToLength(Get(O, "length"));
- // 3. If IsCallable(callbackfn) is false, throw a TypeError exception.
- if (IsCallable(callbackfn) === false) {
- throw new TypeError(callbackfn + ' is not a function');
- }
- // 4. If thisArg is present, let T be thisArg; else let T be undefined.
- var T = arguments.length > 1 ? arguments[1] : undefined;
- // 5. Let A be ? ArraySpeciesCreate(O, 0).
- var A = ArraySpeciesCreate(O, 0);
- // 6. Let k be 0.
- var k = 0;
- // 7. Let to be 0.
- var to = 0;
- // 8. Repeat, while k < len
- while (k < len) {
- // a. Let Pk be ! ToString(k).
- var Pk = ToString(k);
- // b. Let kPresent be ? HasProperty(O, Pk).
- var kPresent = HasProperty(O, Pk);
- // c. If kPresent is true, then
- if (kPresent) {
- // i. Let kValue be ? Get(O, Pk).
- var kValue = Get(O, Pk);
- // ii. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
- var selected = ToBoolean(Call(callbackfn, T, [kValue, k, O]));
- // iii. If selected is true, then
- if (selected) {
- // 1. Perform ? CreateDataPropertyOrThrow(A, ! ToString(to), kValue)
- CreateDataPropertyOrThrow(A, ToString(to), kValue);
- // 2. Increase to by 1.
- to = to + 1;
+ var skipProto = hasProtoEnumBug && isFunction;
+ if (isString && object.length > 0 && !has.call(object, 0)) {
+ for (var i = 0; i < object.length; ++i) {
+ theKeys.push(String(i));
}
-
}
- // d. Increase k by 1.
- k = k + 1;
- }
- // 9. Return A.
- return A;
-});
-}
+ if (isArguments && object.length > 0) {
+ for (var j = 0; j < object.length; ++j) {
+ theKeys.push(String(j));
+ }
+ } else {
+ for (var name in object) {
+ if (!(skipProto && name === 'prototype') && has.call(object, name)) {
+ theKeys.push(String(name));
+ }
+ }
+ }
-if (!('forEach' in Array.prototype)) {
+ if (hasDontEnumBug) {
+ var skipConstructor = equalsConstructorPrototypeIfNotBuggy(object);
-// Array.prototype.forEach
-/* global Call, CreateMethodProperty, Get, HasProperty, IsCallable, ToLength, ToObject, ToString */
-// 22.1.3.10. Array.prototype.forEach ( callbackfn [ , thisArg ] )
-CreateMethodProperty(Array.prototype, 'forEach', function forEach(callbackfn /* [ , thisArg ] */) {
- // 1. Let O be ? ToObject(this value).
- var O = ToObject(this);
- // Polyfill.io - If O is a String object, split it into an array in order to iterate correctly.
- // We will use arrayLike in place of O when we are iterating through the list.
- var arraylike = O instanceof String ? O.split('') : O;
- // 2. Let len be ? ToLength(? Get(O, "length")).
- var len = ToLength(Get(O, "length"));
- // 3. If IsCallable(callbackfn) is false, throw a TypeError exception.
- if (IsCallable(callbackfn) === false) {
- throw new TypeError(callbackfn + ' is not a function');
- }
- // 4. If thisArg is present, let T be thisArg; else let T be undefined.
- var T = arguments.length > 1 ? arguments[1] : undefined;
- // 5. Let k be 0.
- var k = 0;
- // 6. Repeat, while k < len
- while (k < len) {
- // a. Let Pk be ! ToString(k).
- var Pk = ToString(k);
- // b. Let kPresent be ? HasProperty(O, Pk).
- var kPresent = HasProperty(arraylike, Pk);
- // c. If kPresent is true, then
- if (kPresent) {
- // i. Let kValue be ? Get(O, Pk).
- var kValue = Get(arraylike, Pk);
- // ii. Perform ? Call(callbackfn, T, « kValue, k, O »).
- Call(callbackfn, T, [kValue, k, O]);
+ for (var k = 0; k < dontEnums.length; ++k) {
+ if (!(skipConstructor && dontEnums[k] === 'constructor') && has.call(object, dontEnums[k])) {
+ theKeys.push(dontEnums[k]);
+ }
+ }
}
- // d. Increase k by 1.
- k = k + 1;
- }
- // 7. Return undefined.
- return undefined;
-});
+ return theKeys;
+ };
+}()));
}
-if (!('indexOf' in Array.prototype)) {
+if (!("defineProperties"in Object
+)) {
-// Array.prototype.indexOf
-/* global CreateMethodProperty, Get, HasProperty, ToInteger, ToLength, ToObject, ToString */
-// 22.1.3.12. Array.prototype.indexOf ( searchElement [ , fromIndex ] )
-CreateMethodProperty(Array.prototype, 'indexOf', function indexOf(searchElement /* [ , fromIndex ] */) {
- // 1. Let O be ? ToObject(this value).
- var O = ToObject(this);
- // 2. Let len be ? ToLength(? Get(O, "length")).
- var len = ToLength(Get(O, "length"));
- // 3. If len is 0, return -1.
- if (len === 0) {
- return -1;
- }
- // 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step produces the value 0.)
- var n = ToInteger(arguments[1]);
- // 5. If n ≥ len, return -1.
- if (n >= len) {
- return -1;
+// Object.defineProperties
+/* global CreateMethodProperty, Get, ToObject, Type */
+// 19.1.2.3. Object.defineProperties ( O, Properties )
+CreateMethodProperty(Object, 'defineProperties', function defineProperties(O, Properties) {
+ // 1. If Type(O) is not Object, throw a TypeError exception.
+ if (Type(O) !== 'object') {
+ throw new TypeError('Object.defineProperties called on non-object');
}
- // 6. If n ≥ 0, then
- if (n >= 0) {
- // a. If n is -0, let k be +0; else let k be n.
- var k = n === -0 ? 0 : n;
- // 7. Else n < 0,
- } else {
- // a. Let k be len + n.
- var k = len + n;
- // b. If k < 0, let k be 0.
- if (k < 0) {
- k = 0;
+ // 2. Let props be ? ToObject(Properties).
+ var props = ToObject(Properties);
+ // 3. Let keys be ? props.[[OwnPropertyKeys]]().
+ /*
+ Polyfill.io - This step in our polyfill is not complying with the specification.
+ [[OwnPropertyKeys]] is meant to return ALL keys, including non-enumerable and symbols.
+ TODO: When we have Reflect.ownKeys, use that instead as it is the userland equivalent of [[OwnPropertyKeys]].
+ */
+ var keys = Object.keys(props);
+ // 4. Let descriptors be a new empty List.
+ var descriptors = [];
+ // 5. For each element nextKey of keys in List order, do
+ for (var i = 0; i < keys.length; i++) {
+ var nextKey = keys[i];
+ // a. Let propDesc be ? props.[[GetOwnProperty]](nextKey).
+ var propDesc = Object.getOwnPropertyDescriptor(props, nextKey);
+ // b. If propDesc is not undefined and propDesc.[[Enumerable]] is true, then
+ if (propDesc !== undefined && propDesc.enumerable) {
+ // i. Let descObj be ? Get(props, nextKey).
+ var descObj = Get(props, nextKey);
+ // ii. Let desc be ? ToPropertyDescriptor(descObj).
+ // Polyfill.io - We skip this step because Object.defineProperty deals with it.
+ // TODO: Implement this step?
+ var desc = descObj;
+ // iii. Append the pair (a two element List) consisting of nextKey and desc to the end of descriptors.
+ descriptors.push([nextKey, desc]);
}
}
- // 8. Repeat, while k < len
- while (k < len) {
- // a. Let kPresent be ? HasProperty(O, ! ToString(k)).
- var kPresent = HasProperty(O, ToString(k));
- // b. If kPresent is true, then
- if (kPresent) {
- // i. Let elementK be ? Get(O, ! ToString(k)).
- var elementK = Get(O, ToString(k));
- // ii. Let same be the result of performing Strict Equality Comparison searchElement === elementK.
- var same = searchElement === elementK;
- // iii. If same is true, return k.
- if (same) {
- return k;
- }
- }
- // c. Increase k by 1.
- k = k + 1;
+ // 6. For each pair from descriptors in list order, do
+ for (var i = 0; i < descriptors.length; i++){
+ // a. Let P be the first element of pair.
+ var P = descriptors[i][0];
+ // b. Let desc be the second element of pair.
+ var desc = descriptors[i][1];
+ // c. Perform ? DefinePropertyOrThrow(O, P, desc).
+ Object.defineProperty(O, P, desc);
}
- // 9. Return -1.
- return -1;
+ // 7. Return O.
+ return O;
});
}
-if (!('lastIndexOf' in Array.prototype)) {
+if (!("create"in Object
+)) {
-// Array.prototype.lastIndexOf
-/* global CreateMethodProperty, Get, HasProperty, ToInteger, ToLength, ToObject, ToString */
-// 22.1.3.15. Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] )
-CreateMethodProperty(Array.prototype, 'lastIndexOf', function lastIndexOf(searchElement /* [ , fromIndex ] */) {
- // 1. Let O be ? ToObject(this value).
- var O = ToObject(this);
- // 2. Let len be ? ToLength(? Get(O, "length")).
- var len = ToLength(Get(O, "length"));
- // 3. If len is 0, return -1.
- if (len === 0) {
- return -1;
- }
- // 4. If fromIndex is present, let n be ? ToInteger(fromIndex); else let n be len-1.
- var n = arguments.length > 1 ? ToInteger(arguments[1]) : len - 1;
- // 5. If n ≥ 0, then
- if (n >= 0) {
- // a. If n is -0, let k be +0; else let k be min(n, len - 1).
- var k = n === -0 ? 0 : Math.min(n, len - 1);
- // 6. Else n < 0,
- } else {
- // a. Let k be len + n.
- k = len + n;
+// Object.create
+/* global CreateMethodProperty, Type */
+CreateMethodProperty(Object, 'create', function create(O, properties) {
+ // 1. If Type(O) is neither Object nor Null, throw a TypeError exception.
+ if (Type(O) !== 'object' && Type(O) !== 'null') {
+ throw new TypeError('Object prototype may only be an Object or null');
}
- // 7. Repeat, while k ≥ 0
- while (k >= 0) {
- // a. Let kPresent be ? HasProperty(O, ! ToString(k)).
- var kPresent = HasProperty(O, ToString(k));
- // b. If kPresent is true, then
- if (kPresent) {
- // i. Let elementK be ? Get(O, ! ToString(k)).
- var elementK = Get(O, ToString(k));
- // ii. Let same be the result of performing Strict Equality Comparison searchElement === elementK.
- var same = searchElement === elementK;
- // iii. If same is true, return k.
- if (same) {
- return k;
- }
- }
- // c. Decrease k by 1.
- k = k - 1;
+ // 2. Let obj be ObjectCreate(O).
+ var obj = new Function('e', 'function Object() {}Object.prototype=e;return new Object')(O);
+
+ obj.constructor.prototype = O;
+
+ // 3. If Properties is not undefined, then
+ if (1 in arguments) {
+ // a. Return ? ObjectDefineProperties(obj, Properties).
+ return Object.defineProperties(obj, properties);
}
- // 9. Return -1.
- return -1;
+
+ return obj;
});
}
-if (!('map' in Array.prototype)) {
-// Array.prototype.map
-/* global ArraySpeciesCreate, Call, CreateDataPropertyOrThrow, CreateMethodProperty, Get, HasProperty, IsCallable, ToLength, ToObject, ToString */
-/* global CreateMethodProperty, ToObject, ToLength, Get, ArraySpeciesCreate, ToString, HasProperty, Call, CreateDataPropertyOrThrow */
-// 22.1.3.16. Array.prototype.map ( callbackfn [ , thisArg ] )
-CreateMethodProperty(Array.prototype, 'map', function map(callbackfn /* [ , thisArg ] */) {
- // 1. Let O be ? ToObject(this value).
- var O = ToObject(this);
- // 2. Let len be ? ToLength(? Get(O, "length")).
- var len = ToLength(Get(O, "length"));
- // 3. If IsCallable(callbackfn) is false, throw a TypeError exception.
- if (IsCallable(callbackfn) === false) {
- throw new TypeError(callbackfn + ' is not a function');
- }
- // 4. If thisArg is present, let T be thisArg; else let T be undefined.
- var T = arguments.length > 1 ? arguments[1] : undefined;
- // 5. Let A be ? ArraySpeciesCreate(O, len).
- var A = ArraySpeciesCreate(O, len);
- // 6. Let k be 0.
- var k = 0;
- // 7. Repeat, while k < len
- while (k < len) {
- // a. Let Pk be ! ToString(k).
- var Pk = ToString(k);
- // b. Let kPresent be ? HasProperty(O, Pk).
- var kPresent = HasProperty(O, Pk);
- // c. If kPresent is true, then
- if (kPresent) {
- // i. Let kValue be ? Get(O, Pk).
- var kValue = Get(O, Pk);
- // ii. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »).
- var mappedValue = Call(callbackfn, T, [kValue, k, O]);
- // iii. Perform ? CreateDataPropertyOrThrow(A, Pk, mappedValue).
- CreateDataPropertyOrThrow(A, Pk, mappedValue);
+// _ESAbstract.OrdinaryCreateFromConstructor
+/* global GetPrototypeFromConstructor */
+// 9.1.13. OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto [ , internalSlotsList ] )
+function OrdinaryCreateFromConstructor(constructor, intrinsicDefaultProto) { // eslint-disable-line no-unused-vars
+ var internalSlotsList = arguments[2] || {};
+ // 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.
+
+ // 2. Let proto be ? GetPrototypeFromConstructor(constructor, intrinsicDefaultProto).
+ var proto = GetPrototypeFromConstructor(constructor, intrinsicDefaultProto);
+
+ // 3. Return ObjectCreate(proto, internalSlotsList).
+ // 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.
+ var obj = Object.create(proto);
+ for (var name in internalSlotsList) {
+ if (Object.prototype.hasOwnProperty.call(internalSlotsList, name)) {
+ Object.defineProperty(obj, name, {
+ configurable: true,
+ enumerable: false,
+ writable: true,
+ value: internalSlotsList[name]
+ });
}
- // d. Increase k by 1.
- k = k + 1;
}
- // 8. Return A.
- return A;
-});
-
+ return obj;
}
-if (!('reduce' in Array.prototype)) {
+// _ESAbstract.Construct
+/* global IsConstructor, OrdinaryCreateFromConstructor, Call */
+// 7.3.13. Construct ( F [ , argumentsList [ , newTarget ]] )
+function Construct(F /* [ , argumentsList [ , newTarget ]] */) { // eslint-disable-line no-unused-vars
+ // 1. If newTarget is not present, set newTarget to F.
+ var newTarget = arguments.length > 2 ? arguments[2] : F;
-// Array.prototype.reduce
-/* global Call, CreateMethodProperty, Get, HasProperty, IsCallable, ToLength, ToObject, ToString */
-// 22.1.3.19. Array.prototype.reduce ( callbackfn [ , initialValue ] )
-CreateMethodProperty(Array.prototype, 'reduce', function reduce(callbackfn /* [ , initialValue ] */) {
- // 1. Let O be ? ToObject(this value).
- var O = ToObject(this);
- // Polyfill.io - If O is a String object, split it into an array in order to iterate correctly.
- // We will use arrayLike in place of O when we are iterating through the list.
- var arraylike = O instanceof String ? O.split('') : O;
- // 2. Let len be ? ToLength(? Get(O, "length")).
- var len = ToLength(Get(arraylike, "length"));
- // 3. If IsCallable(callbackfn) is false, throw a TypeError exception.
- if (IsCallable(callbackfn) === false) {
- throw new TypeError(callbackfn + ' is not a function');
+ // 2. If argumentsList is not present, set argumentsList to a new empty List.
+ var argumentsList = arguments.length > 1 ? arguments[1] : [];
+
+ // 3. Assert: IsConstructor(F) is true.
+ if (!IsConstructor(F)) {
+ throw new TypeError('F must be a constructor.');
}
- // 4. If len is 0 and initialValue is not present, throw a TypeError exception.
- var initialValue = arguments.length > 1 ? arguments[1] : undefined;
- if (len === 0 && arguments.length < 2) {
- throw new TypeError('Reduce of empty array with no initial value');
+
+ // 4. Assert: IsConstructor(newTarget) is true.
+ if (!IsConstructor(newTarget)) {
+ throw new TypeError('newTarget must be a constructor.');
}
- // 5. Let k be 0.
- var k = 0;
- // 6. Let accumulator be undefined.
- var accumulator = undefined;
- // 7. If initialValue is present, then
- if (arguments.length > 1) {
- // a. Set accumulator to initialValue.
- accumulator = initialValue;
- // 8. Else initialValue is not present,
+
+ // 5. Return ? F.[[Construct]](argumentsList, newTarget).
+ // Polyfill.io - If newTarget is the same as F, it is equivalent to new F(...argumentsList).
+ if (newTarget === F) {
+ return new (Function.prototype.bind.apply(F, [null].concat(argumentsList)))();
} else {
- // a. Let kPresent be false.
- var kPresent = false;
- // b. Repeat, while kPresent is false and k < len
- while (kPresent === false && k < len) {
- // i. Let Pk be ! ToString(k).
- var Pk = ToString(k);
- // ii. Let kPresent be ? HasProperty(O, Pk).
- var kPresent = HasProperty(arraylike, Pk);
- // iii. If kPresent is true, then
- if (kPresent) {
- // 1. Set accumulator to ? Get(O, Pk).
- var accumulator = Get(arraylike, Pk);
- }
- // iv. Increase k by 1.
- k = k + 1;
- }
- // c. If kPresent is false, throw a TypeError exception.
- if (kPresent === false) {
- throw new TypeError('Reduce of empty array with no initial value');
+ // Polyfill.io - This is mimicking section 9.2.2 step 5.a.
+ var obj = OrdinaryCreateFromConstructor(newTarget, Object.prototype);
+ return Call(F, obj, argumentsList);
+ }
+}
+
+// _ESAbstract.ArraySpeciesCreate
+/* global IsArray, ArrayCreate, Get, Type, IsConstructor, Construct */
+// 9.4.2.3. ArraySpeciesCreate ( originalArray, length )
+function ArraySpeciesCreate(originalArray, length) { // eslint-disable-line no-unused-vars
+ // 1. Assert: length is an integer Number ≥ 0.
+ // 2. If length is -0, set length to +0.
+ if (1/length === -Infinity) {
+ length = 0;
+ }
+
+ // 3. Let isArray be ? IsArray(originalArray).
+ var isArray = IsArray(originalArray);
+
+ // 4. If isArray is false, return ? ArrayCreate(length).
+ if (isArray === false) {
+ return ArrayCreate(length);
+ }
+
+ // 5. Let C be ? Get(originalArray, "constructor").
+ var C = Get(originalArray, 'constructor');
+
+ // Polyfill.io - We skip this section as not sure how to make a cross-realm normal Array, a same-realm Array.
+ // 6. If IsConstructor(C) is true, then
+ // if (IsConstructor(C)) {
+ // a. Let thisRealm be the current Realm Record.
+ // b. Let realmC be ? GetFunctionRealm(C).
+ // c. If thisRealm and realmC are not the same Realm Record, then
+ // i. If SameValue(C, realmC.[[Intrinsics]].[[%Array%]]) is true, set C to undefined.
+ // }
+ // 7. If Type(C) is Object, then
+ if (Type(C) === 'object') {
+ // a. Set C to ? Get(C, @@species).
+ C = 'Symbol' in this && 'species' in this.Symbol ? Get(C, this.Symbol.species) : undefined;
+ // b. If C is null, set C to undefined.
+ if (C === null) {
+ C = undefined;
}
}
- // 9. Repeat, while k < len
- while (k < len) {
- // a. Let Pk be ! ToString(k).
- var Pk = ToString(k);
- // b. Let kPresent be ? HasProperty(O, Pk).
- var kPresent = HasProperty(arraylike, Pk);
- // c. If kPresent is true, then
- if (kPresent) {
- // i. Let kValue be ? Get(O, Pk).
- var kValue = Get(arraylike, Pk);
- // ii. Set accumulator to ? Call(callbackfn, undefined, « accumulator, kValue, k, O »).
- accumulator = Call(callbackfn, undefined, [accumulator, kValue, k, O]);
- }
- // d. Increase k by 1.
- k = k + 1;
+ // 8. If C is undefined, return ? ArrayCreate(length).
+ if (C === undefined) {
+ return ArrayCreate(length);
}
- // 10. Return accumulator.
- return accumulator;
-});
-
+ // 9. If IsConstructor(C) is false, throw a TypeError exception.
+ if (!IsConstructor(C)) {
+ throw new TypeError('C must be a constructor');
+ }
+ // 10. Return ? Construct(C, « length »).
+ return Construct(C, [length]);
}
+if (!("filter"in Array.prototype
+)) {
-if (!('reduceRight' in Array.prototype)) {
-
-// Array.prototype.reduceRight
-/* global Call, CreateMethodProperty, Get, HasProperty, IsCallable, ToLength, ToObject, ToString */
-// 22.1.3.20. Array.prototype.reduceRight ( callbackfn [ , initialValue ] )
-CreateMethodProperty(Array.prototype, 'reduceRight', function reduceRight(callbackfn /* [ , initialValue ] */) {
+// Array.prototype.filter
+/* global CreateMethodProperty, ToObject, ToLength, Get, IsCallable, ArraySpeciesCreate, ToString, HasProperty, ToBoolean, Call, CreateDataPropertyOrThrow */
+// 22.1.3.7. Array.prototype.filter ( callbackfn [ , thisArg ] )
+CreateMethodProperty(Array.prototype, 'filter', function filter(callbackfn /* [ , thisArg ] */) {
// 1. Let O be ? ToObject(this value).
var O = ToObject(this);
- // Polyfill.io - If O is a String object, split it into an array in order to iterate correctly.
- // We will use arrayLike in place of O when we are iterating through the list.
- var arraylike = O instanceof String ? O.split('') : O;
// 2. Let len be ? ToLength(? Get(O, "length")).
- var len = ToLength(Get(arraylike, "length"));
+ var len = ToLength(Get(O, "length"));
// 3. If IsCallable(callbackfn) is false, throw a TypeError exception.
if (IsCallable(callbackfn) === false) {
throw new TypeError(callbackfn + ' is not a function');
}
- // 4. If len is 0 and initialValue is not present, throw a TypeError exception.
- var initialValue = arguments.length > 1 ? arguments[1] : undefined;
- if (len === 0 && arguments.length < 2) {
- throw new TypeError('Reduce of empty array with no initial value');
- }
- // 5. Let k be len-1.
- var k = len - 1;
- // 6. Let accumulator be undefined.
- var accumulator = undefined;
- // 7. If initialValue is present, then
- if (arguments.length > 1) {
- // a. Set accumulator to initialValue.
- accumulator = initialValue;
- // 8.Else initialValue is not present,
- } else {
- // a. Let kPresent be false.
- var kPresent = false;
- // b. Repeat, while kPresent is false and k ≥ 0
- while (kPresent === false && k >= 0) {
- // i. Let Pk be ! ToString(k).
- var Pk = ToString(k);
- // ii. Let kPresent be ? HasProperty(O, Pk).
- var kPresent = HasProperty(arraylike, Pk);
- // iii. If kPresent is true, then
- if (kPresent) {
- // 1. Set accumulator to ? Get(O, Pk).
- accumulator = Get(arraylike, Pk);
- }
- // iv. Decrease k by 1.
- k = k - 1;
- }
- // c. If kPresent is false, throw a TypeError exception.
- if (kPresent === false) {
- throw new TypeError('Reduce of empty array with no initial value');
- }
- }
- // 9. Repeat, while k ≥ 0
- while (k >= 0) {
+ // 4. If thisArg is present, let T be thisArg; else let T be undefined.
+ var T = arguments.length > 1 ? arguments[1] : undefined;
+ // 5. Let A be ? ArraySpeciesCreate(O, 0).
+ var A = ArraySpeciesCreate(O, 0);
+ // 6. Let k be 0.
+ var k = 0;
+ // 7. Let to be 0.
+ var to = 0;
+ // 8. Repeat, while k < len
+ while (k < len) {
// a. Let Pk be ! ToString(k).
var Pk = ToString(k);
// b. Let kPresent be ? HasProperty(O, Pk).
- var kPresent = HasProperty(arraylike, Pk);
+ var kPresent = HasProperty(O, Pk);
// c. If kPresent is true, then
if (kPresent) {
// i. Let kValue be ? Get(O, Pk).
- var kValue = Get(arraylike, Pk);
- // ii. Set accumulator to ? Call(callbackfn, undefined, « accumulator, kValue, k, O »).
- accumulator = Call(callbackfn, undefined, [accumulator, kValue, k, O]);
+ var kValue = Get(O, Pk);
+ // ii. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ var selected = ToBoolean(Call(callbackfn, T, [kValue, k, O]));
+ // iii. If selected is true, then
+ if (selected) {
+ // 1. Perform ? CreateDataPropertyOrThrow(A, ! ToString(to), kValue)
+ CreateDataPropertyOrThrow(A, ToString(to), kValue);
+ // 2. Increase to by 1.
+ to = to + 1;
+ }
+
}
- // d. Decrease k by 1.
- k = k - 1;
+ // d. Increase k by 1.
+ k = k + 1;
}
- // 10 Return accumulator.
- return accumulator;
+ // 9. Return A.
+ return A;
});
}
-if (!('some' in Array.prototype)) {
+if (!("map"in Array.prototype
+)) {
-// Array.prototype.some
-/* global Call, CreateMethodProperty, Get, HasProperty, IsCallable, ToBoolean, ToLength, ToObject, ToString */
-// 22.1.3.24. Array.prototype.some ( callbackfn [ , thisArg ] )
-CreateMethodProperty(Array.prototype, 'some', function some(callbackfn /* [ , thisArg ] */) {
+// Array.prototype.map
+/* global ArraySpeciesCreate, Call, CreateDataPropertyOrThrow, CreateMethodProperty, Get, HasProperty, IsCallable, ToLength, ToObject, ToString */
+/* global CreateMethodProperty, ToObject, ToLength, Get, ArraySpeciesCreate, ToString, HasProperty, Call, CreateDataPropertyOrThrow */
+// 22.1.3.16. Array.prototype.map ( callbackfn [ , thisArg ] )
+CreateMethodProperty(Array.prototype, 'map', function map(callbackfn /* [ , thisArg ] */) {
// 1. Let O be ? ToObject(this value).
var O = ToObject(this);
// 2. Let len be ? ToLength(? Get(O, "length")).
}
// 4. If thisArg is present, let T be thisArg; else let T be undefined.
var T = arguments.length > 1 ? arguments[1] : undefined;
- // 5. Let k be 0.
+ // 5. Let A be ? ArraySpeciesCreate(O, len).
+ var A = ArraySpeciesCreate(O, len);
+ // 6. Let k be 0.
var k = 0;
- // 6. Repeat, while k < len
+ // 7. Repeat, while k < len
while (k < len) {
// a. Let Pk be ! ToString(k).
var Pk = ToString(k);
if (kPresent) {
// i. Let kValue be ? Get(O, Pk).
var kValue = Get(O, Pk);
- // ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
- var testResult = ToBoolean(Call(callbackfn, T, [kValue, k, O]));
- // iii. If testResult is true, return true.
- if (testResult) {
- return true;
- }
+ // ii. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »).
+ var mappedValue = Call(callbackfn, T, [kValue, k, O]);
+ // iii. Perform ? CreateDataPropertyOrThrow(A, Pk, mappedValue).
+ CreateDataPropertyOrThrow(A, Pk, mappedValue);
}
// d. Increase k by 1.
k = k + 1;
}
- // 7. Return false.
- return false;
-});
-
-}
-
-if (!('Date' in this && 'now' in this.Date && 'getTime' in this.Date.prototype)) {
-
-// Date.now
-Date.now = function now() {
- return new Date().getTime();
-};
-
-}
-
-if (!('Date' in this && 'toISOString' in Date.prototype)) {
-
-// Date.prototype.toISOString
-Date.prototype.toISOString = function toISOString() {
- var date = this;
-
- function pad(str, len) {
- var pad = "0000";
- str = '' + str;
- return pad.substr(0, len - str.length) + str;
- }
-
- var y = date.getUTCFullYear(),
- m = pad(date.getUTCMonth() + 1, 2),
- d = pad(date.getUTCDate(), 2),
- h = pad(date.getUTCHours(), 2),
- i = pad(date.getUTCMinutes(), 2),
- s = pad(date.getUTCSeconds(), 2),
- ms = pad(date.getUTCMilliseconds(), 3);
-
- return y +'-'+ m +'-'+ d + 'T' + h +':'+ i +':'+ s +'.'+ ms +'Z';
-};
-
-}
-
-if (!('freeze' in Object)) {
-
-// Object.freeze
-/* global CreateMethodProperty */
-// 19.1.2.6. Object.freeze ( O )
-CreateMethodProperty(Object, 'freeze', function freeze(O) {
- // This feature cannot be implemented fully as a polyfill.
- // We choose to silently fail which allows "securable" code
- // to "gracefully" degrade to working but insecure code.
- return O;
-});
-
-}
-
-if (!('getOwnPropertyNames' in Object)) {
-
-// Object.getOwnPropertyNames
-/* global CreateMethodProperty */
-
-var toString = ({}).toString;
-var split = ''.split;
-
-CreateMethodProperty(Object, 'getOwnPropertyNames', function getOwnPropertyNames(object) {
- var buffer = [];
- var key;
-
- // Non-enumerable properties cannot be discovered but can be checked for by name.
- // Define those used internally by JS to allow an incomplete solution
- var commonProps = ['length', "name", "arguments", "caller", "prototype", "observe", "unobserve"];
-
- if (typeof object === 'undefined' || object === null) {
- throw new TypeError('Cannot convert undefined or null to object');
- }
-
- // Polyfill.io fallback for non-array-like strings which exist in some ES3 user-agents (IE 8)
- object = toString.call(object) == '[object String]' ? split.call(object, '') : Object(object);
-
- // Enumerable properties only
- for (key in object) {
- if (Object.prototype.hasOwnProperty.call(object, key)) {
- buffer.push(key);
- }
- }
-
- // Check for and add the common non-enumerable properties
- for (var i=0, s=commonProps.length; i<s; i++) {
- if (commonProps[i] in object) buffer.push(commonProps[i]);
- }
-
- return buffer;
+ // 8. Return A.
+ return A;
});
}
-
-// _ESAbstract.RequireObjectCoercible
-// 7.2.1. RequireObjectCoercible ( argument )
-// The abstract operation ToObject converts argument to a value of type Object according to Table 12:
-// Table 12: ToObject Conversions
-/*
-|----------------------------------------------------------------------------------------------------------------------------------------------------|
-| Argument Type | Result |
-|----------------------------------------------------------------------------------------------------------------------------------------------------|
-| Undefined | Throw a TypeError exception. |
-| Null | Throw a TypeError exception. |
-| Boolean | Return argument. |
-| Number | Return argument. |
-| String | Return argument. |
-| Symbol | Return argument. |
-| Object | Return argument. |
-|----------------------------------------------------------------------------------------------------------------------------------------------------|
-*/
-function RequireObjectCoercible(argument) { // eslint-disable-line no-unused-vars
- if (argument === null || argument === undefined) {
- throw TypeError();
- }
- return argument;
-}
-if (!('trim' in String.prototype)) {
+if (!("trim"in String.prototype
+)) {
// String.prototype.trim
/* global CreateMethodProperty, RequireObjectCoercible, ToString */
-/* Polyfill service v3.27.1
+/* Polyfill service v3.34.0
* For detailed credits and licence information see https://github.com/financial-times/polyfill-service.
*
* Features requested: es6
*
+ * - _ESAbstract.ArrayCreate, License: CC0 (required by "Array.from", "es6", "Array.of", "_ESAbstract.ArraySpeciesCreate", "Array.prototype.filter", "Symbol", "Map", "Set", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "Array.prototype.map")
+ * - _ESAbstract.Call, License: CC0 (required by "Array.from", "es6", "Array.prototype.find", "Array.prototype.findIndex", "WeakMap", "WeakSet", "_ESAbstract.GetIterator", "Map", "Set", "_ESAbstract.IteratorClose", "_ESAbstract.IteratorNext", "_ESAbstract.IteratorStep", "Array.prototype.forEach", "Object.setPrototypeOf", "Symbol", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "Array.prototype.filter", "Array.prototype.map", "_ESAbstract.ToPrimitive", "_ESAbstract.ToString", "Array.of", "Array.prototype.fill", "String.prototype.codePointAt", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.repeat", "String.prototype.startsWith", "_ESAbstract.OrdinaryToPrimitive")
+ * - _ESAbstract.Get, License: CC0 (required by "Array.from", "es6", "Array.prototype.fill", "Array.prototype.find", "Array.prototype.findIndex", "Object.assign", "RegExp.prototype.flags", "WeakMap", "WeakSet", "_ESAbstract.IteratorValue", "Map", "Set", "_ESAbstract.IteratorComplete", "_ESAbstract.IteratorStep", "Array.prototype.forEach", "Object.setPrototypeOf", "Symbol", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "_ESAbstract.IsRegExp", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.startsWith", "Array.prototype.filter", "Array.prototype.map", "_ESAbstract.GetPrototypeFromConstructor", "_ESAbstract.OrdinaryCreateFromConstructor", "_ESAbstract.Construct", "Array.of", "Object.defineProperties", "Object.create", "_ESAbstract.GetIterator", "_ArrayIterator", "Array.prototype.entries", "Array.prototype.keys", "Array.prototype.values", "_Iterator", "_StringIterator", "_ESAbstract.ArraySpeciesCreate", "_ESAbstract.OrdinaryToPrimitive", "_ESAbstract.ToPrimitive", "_ESAbstract.ToString", "String.prototype.codePointAt", "String.prototype.repeat")
+ * - _ESAbstract.HasProperty, License: CC0 (required by "Array.prototype.copyWithin", "es6", "Array.prototype.forEach", "Object.setPrototypeOf", "Symbol", "Map", "Array.from", "Set", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "Array.prototype.filter", "Array.prototype.map")
+ * - _ESAbstract.IsArray, License: CC0 (required by "String.fromCodePoint", "es6", "WeakMap", "WeakSet", "Array.isArray", "Map", "Array.from", "Set", "_ESAbstract.ArraySpeciesCreate", "Array.prototype.filter", "Symbol", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "Array.prototype.map")
* - _ESAbstract.IsCallable, License: CC0 (required by "Array.from", "es6", "Array.prototype.find", "Array.prototype.findIndex", "Map", "Set", "WeakMap", "WeakSet", "_ESAbstract.GetMethod", "Array.prototype.forEach", "Object.setPrototypeOf", "Symbol", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "Array.prototype.filter", "Array.prototype.map", "Function.prototype.bind", "_ESAbstract.Construct", "Array.of", "Object.getOwnPropertyDescriptor", "Object.assign", "_ESAbstract.OrdinaryToPrimitive", "_ESAbstract.ToPrimitive", "_ESAbstract.ToString", "Array.prototype.fill", "String.prototype.codePointAt", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.repeat", "String.prototype.startsWith")
- * - Object.defineProperty, License: CC0 (required by "Function.name", "es6", "Map", "Array.from", "Number.Epsilon", "Number.MAX_SAFE_INTEGER", "Number.MIN_SAFE_INTEGER", "Object.setPrototypeOf", "RegExp.prototype.flags", "Set", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "Symbol", "WeakMap", "WeakSet", "_ESAbstract.CreateMethodProperty", "Array.of", "Array.prototype.copyWithin", "Array.prototype.entries", "Array.prototype.fill", "Array.prototype.find", "Array.prototype.findIndex", "Array.prototype.keys", "Array.prototype.values", "Math.acosh", "Math.asinh", "Math.atanh", "Math.cbrt", "Math.clz32", "Math.cosh", "Math.expm1", "Math.fround", "Math.hypot", "Math.imul", "Math.log10", "Math.log1p", "Math.log2", "Math.sign", "Math.sinh", "Math.tanh", "Math.trunc", "Number.isFinite", "Number.isInteger", "Number.isNaN", "Number.isSafeInteger", "Number.parseFloat", "Number.parseInt", "Object.assign", "Object.is", "String.prototype.codePointAt", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.repeat", "String.prototype.startsWith", "_ArrayIterator", "_ESAbstract.OrdinaryCreateFromConstructor", "_ESAbstract.Construct", "_StringIterator", "_ESAbstract.CreateDataProperty", "_ESAbstract.CreateDataPropertyOrThrow", "_ESAbstract.CreateIterResultObject", "_Iterator", "Object.defineProperties", "Object.create", "_ESAbstract.GetIterator")
- * - _ESAbstract.CreateMethodProperty, License: CC0 (required by "Array.from", "es6", "Array.of", "Array.prototype.@@iterator", "Array.prototype.copyWithin", "Array.prototype.entries", "Array.prototype.fill", "Array.prototype.find", "Array.prototype.findIndex", "Array.prototype.keys", "Array.prototype.values", "Map", "Math.acosh", "Math.asinh", "Math.atanh", "Math.cbrt", "Math.clz32", "Math.cosh", "Math.expm1", "Math.fround", "Math.hypot", "Math.imul", "Math.log10", "Math.log1p", "Math.log2", "Math.sign", "Math.sinh", "Math.tanh", "Math.trunc", "Number.isFinite", "Number.isInteger", "Number.isNaN", "Number.isSafeInteger", "Number.parseFloat", "Number.parseInt", "Object.assign", "Object.is", "Object.setPrototypeOf", "Set", "String.prototype.@@iterator", "String.prototype.codePointAt", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.repeat", "String.prototype.startsWith", "WeakMap", "WeakSet", "Array.isArray", "Object.create", "Symbol", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "_ESAbstract.GetIterator", "_ArrayIterator", "_ESAbstract.OrdinaryCreateFromConstructor", "_ESAbstract.Construct", "Object.getOwnPropertyDescriptor", "Array.prototype.forEach", "Object.getPrototypeOf", "Object.getOwnPropertyNames", "Array.prototype.filter", "Array.prototype.map", "Object.freeze", "Function.prototype.bind", "Object.defineProperties", "_Iterator", "_StringIterator")
+ * - _ESAbstract.RequireObjectCoercible, License: CC0 (required by "String.prototype.@@iterator", "es6", "String.prototype.codePointAt", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.repeat", "String.prototype.startsWith")
+ * - _ESAbstract.SameValueNonNumber, License: CC0 (required by "_ESAbstract.SameValueZero", "Map", "es6", "Array.from", "Set", "WeakSet", "_ESAbstract.SameValue", "Object.is", "String.fromCodePoint", "WeakMap")
+ * - _ESAbstract.ToBoolean, License: CC0 (required by "Array.prototype.find", "es6", "Array.prototype.findIndex", "RegExp.prototype.flags", "_ESAbstract.IteratorComplete", "Map", "Array.from", "Set", "_ESAbstract.IteratorStep", "WeakMap", "WeakSet", "_ESAbstract.IsRegExp", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.startsWith", "Array.prototype.filter", "Symbol", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables")
+ * - _ESAbstract.ToInteger, License: CC0 (required by "Array.prototype.copyWithin", "es6", "Array.prototype.fill", "Number.isInteger", "Number.isSafeInteger", "String.fromCodePoint", "String.prototype.codePointAt", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.repeat", "String.prototype.startsWith", "_ESAbstract.ToLength", "Array.from", "Array.prototype.find", "Array.prototype.findIndex")
+ * - _ESAbstract.ToLength, License: CC0 (required by "Array.from", "es6", "Array.prototype.fill", "Array.prototype.find", "Array.prototype.findIndex", "Array.prototype.forEach", "Object.setPrototypeOf", "Symbol", "Map", "Set", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "Array.prototype.filter", "Array.prototype.map")
+ * - _ESAbstract.ToNumber, License: CC0 (required by "String.fromCodePoint", "es6")
* - _ESAbstract.ToObject, License: CC0 (required by "Array.from", "es6", "Array.prototype.entries", "Array.prototype.fill", "Array.prototype.find", "Array.prototype.findIndex", "Array.prototype.keys", "Array.prototype.values", "Array.prototype.@@iterator", "Object.assign", "Array.prototype.forEach", "Object.setPrototypeOf", "Symbol", "Map", "Set", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "Array.prototype.filter", "Array.prototype.map", "_ESAbstract.GetV", "_ESAbstract.GetMethod", "_ESAbstract.GetIterator", "WeakMap", "WeakSet", "Object.defineProperties", "Object.create", "_ArrayIterator", "_ESAbstract.OrdinaryCreateFromConstructor", "_ESAbstract.Construct", "Array.of", "_Iterator", "_StringIterator")
* - _ESAbstract.GetV, License: CC0 (required by "_ESAbstract.GetMethod", "Array.from", "es6", "Map", "Set", "_ESAbstract.GetIterator", "WeakMap", "WeakSet")
* - _ESAbstract.GetMethod, License: CC0 (required by "Array.from", "es6", "Map", "Set", "_ESAbstract.IsConstructor", "Array.of", "_ESAbstract.GetIterator", "WeakMap", "WeakSet", "_ESAbstract.IteratorClose", "_ESAbstract.ToPrimitive", "_ESAbstract.ToString", "Array.prototype.fill", "Array.prototype.find", "Array.prototype.findIndex", "String.prototype.@@iterator", "String.prototype.codePointAt", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.repeat", "String.prototype.startsWith")
- * - _ESAbstract.ToInteger, License: CC0 (required by "Array.prototype.copyWithin", "es6", "Array.prototype.fill", "Number.isInteger", "Number.isSafeInteger", "String.prototype.codePointAt", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.repeat", "String.prototype.startsWith", "_ESAbstract.ToLength", "Array.from", "Array.prototype.find", "Array.prototype.findIndex")
- * - _ESAbstract.ToLength, License: CC0 (required by "Array.from", "es6", "Array.prototype.fill", "Array.prototype.find", "Array.prototype.findIndex", "Array.prototype.forEach", "Object.setPrototypeOf", "Symbol", "Map", "Set", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "Array.prototype.filter", "Array.prototype.map")
- * - _ESAbstract.Get, License: CC0 (required by "Array.from", "es6", "Array.prototype.fill", "Array.prototype.find", "Array.prototype.findIndex", "Object.assign", "RegExp.prototype.flags", "WeakMap", "WeakSet", "_ESAbstract.IteratorValue", "Map", "Set", "_ESAbstract.IteratorComplete", "_ESAbstract.IteratorStep", "Array.prototype.forEach", "Object.setPrototypeOf", "Symbol", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "_ESAbstract.IsRegExp", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.startsWith", "Array.prototype.filter", "Array.prototype.map", "_ESAbstract.GetPrototypeFromConstructor", "_ESAbstract.OrdinaryCreateFromConstructor", "_ESAbstract.Construct", "Array.of", "Object.defineProperties", "Object.create", "_ESAbstract.GetIterator", "_ArrayIterator", "Array.prototype.entries", "Array.prototype.keys", "Array.prototype.values", "_Iterator", "_StringIterator", "_ESAbstract.ArraySpeciesCreate", "_ESAbstract.OrdinaryToPrimitive", "_ESAbstract.ToPrimitive", "_ESAbstract.ToString", "String.prototype.codePointAt", "String.prototype.repeat")
- * - _ESAbstract.HasProperty, License: CC0 (required by "Array.prototype.copyWithin", "es6", "Array.prototype.forEach", "Object.setPrototypeOf", "Symbol", "Map", "Array.from", "Set", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "Array.prototype.filter", "Array.prototype.map")
- * - _ESAbstract.Call, License: CC0 (required by "Array.from", "es6", "Array.prototype.find", "Array.prototype.findIndex", "WeakMap", "WeakSet", "_ESAbstract.GetIterator", "Map", "Set", "_ESAbstract.IteratorClose", "_ESAbstract.IteratorNext", "_ESAbstract.IteratorStep", "Array.prototype.forEach", "Object.setPrototypeOf", "Symbol", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "Array.prototype.filter", "Array.prototype.map", "_ESAbstract.ToPrimitive", "_ESAbstract.ToString", "Array.of", "Array.prototype.fill", "String.prototype.codePointAt", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.repeat", "String.prototype.startsWith", "_ESAbstract.OrdinaryToPrimitive")
- * - _ESAbstract.Type, License: CC0 (required by "Map", "es6", "Array.from", "Number.isFinite", "Number.isInteger", "Number.isNaN", "Number.isSafeInteger", "RegExp.prototype.flags", "WeakMap", "WeakSet", "_ESAbstract.IsConstructor", "Array.of", "_ESAbstract.GetIterator", "Set", "_ESAbstract.IteratorClose", "_ESAbstract.ToString", "Array.prototype.fill", "Array.prototype.find", "Array.prototype.findIndex", "String.prototype.@@iterator", "String.prototype.codePointAt", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.repeat", "String.prototype.startsWith", "_ESAbstract.IteratorValue", "_ESAbstract.CreateIterResultObject", "_ESAbstract.IteratorComplete", "_ESAbstract.IteratorStep", "_ESAbstract.IteratorNext", "_ESAbstract.SameValueZero", "Object.create", "Object.setPrototypeOf", "Symbol", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "_ArrayIterator", "Array.prototype.entries", "Array.prototype.keys", "Array.prototype.values", "_ESAbstract.OrdinaryCreateFromConstructor", "_ESAbstract.Construct", "_ESAbstract.SameValue", "Object.is", "_ESAbstract.IsRegExp", "_ESAbstract.ToPrimitive", "_ESAbstract.GetPrototypeFromConstructor", "Object.defineProperties", "_Iterator", "_StringIterator", "_ESAbstract.ArraySpeciesCreate", "Array.prototype.filter", "Array.prototype.map", "_ESAbstract.OrdinaryToPrimitive")
- * - _ESAbstract.OrdinaryToPrimitive, License: CC0 (required by "_ESAbstract.ToPrimitive", "_ESAbstract.ToString", "Array.from", "es6", "Array.of", "Array.prototype.fill", "Array.prototype.find", "Array.prototype.findIndex", "String.prototype.@@iterator", "String.prototype.codePointAt", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.repeat", "String.prototype.startsWith")
- * - _ESAbstract.ToPrimitive, License: CC0 (required by "_ESAbstract.ToString", "Array.from", "es6", "Array.of", "Array.prototype.fill", "Array.prototype.find", "Array.prototype.findIndex", "String.prototype.@@iterator", "String.prototype.codePointAt", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.repeat", "String.prototype.startsWith")
- * - _ESAbstract.ToString, License: CC0 (required by "Array.from", "es6", "Array.of", "Array.prototype.fill", "Array.prototype.find", "Array.prototype.findIndex", "String.prototype.@@iterator", "String.prototype.codePointAt", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.repeat", "String.prototype.startsWith", "Array.prototype.forEach", "Object.setPrototypeOf", "Symbol", "Map", "Set", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "Array.prototype.filter", "Array.prototype.map")
- * - Array.prototype.forEach, License: CC0 (required by "Object.setPrototypeOf", "es6", "Symbol", "Map", "Array.from", "Set", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables")
- * - _ESAbstract.IsArray, License: CC0 (required by "WeakMap", "es6", "WeakSet", "Array.isArray", "Map", "Array.from", "Set", "_ESAbstract.ArraySpeciesCreate", "Array.prototype.filter", "Symbol", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "Array.prototype.map")
- * - _ESAbstract.ArrayCreate, License: CC0 (required by "Array.from", "es6", "Array.of", "_ESAbstract.ArraySpeciesCreate", "Array.prototype.filter", "Symbol", "Map", "Set", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "Array.prototype.map")
- * - _ESAbstract.IsConstructor, License: CC0 (required by "Array.from", "es6", "Array.of", "_ESAbstract.Construct", "_ESAbstract.ArraySpeciesCreate", "Array.prototype.filter", "Symbol", "Map", "Set", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "Array.prototype.map")
+ * - _ESAbstract.ToUint32, License: CC0 (required by "Math.clz32", "es6", "Math.imul")
+ * - _ESAbstract.Type, License: CC0 (required by "Map", "es6", "Array.from", "Number.isFinite", "Number.isInteger", "Number.isNaN", "Number.isSafeInteger", "Object.seal", "RegExp.prototype.flags", "WeakMap", "WeakSet", "_ESAbstract.IsConstructor", "Array.of", "_ESAbstract.GetIterator", "Set", "_ESAbstract.IteratorClose", "_ESAbstract.ToString", "Array.prototype.fill", "Array.prototype.find", "Array.prototype.findIndex", "String.prototype.@@iterator", "String.prototype.codePointAt", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.repeat", "String.prototype.startsWith", "_ESAbstract.IteratorValue", "_ESAbstract.CreateIterResultObject", "_ESAbstract.IteratorComplete", "_ESAbstract.IteratorStep", "_ESAbstract.IteratorNext", "_ESAbstract.SameValueZero", "Object.create", "Object.setPrototypeOf", "Symbol", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "_ArrayIterator", "Array.prototype.entries", "Array.prototype.keys", "Array.prototype.values", "_ESAbstract.OrdinaryCreateFromConstructor", "_ESAbstract.Construct", "_ESAbstract.SameValue", "Object.is", "String.fromCodePoint", "_ESAbstract.IsRegExp", "_ESAbstract.ToPrimitive", "_ESAbstract.GetPrototypeFromConstructor", "Object.defineProperties", "_Iterator", "_StringIterator", "_ESAbstract.ArraySpeciesCreate", "Array.prototype.filter", "Array.prototype.map", "_ESAbstract.OrdinaryToPrimitive")
* - _ESAbstract.GetPrototypeFromConstructor, License: CC0 (required by "_ESAbstract.OrdinaryCreateFromConstructor", "Map", "es6", "Array.from", "Set", "WeakMap", "WeakSet", "_ESAbstract.Construct", "Array.of")
- * - Object.keys, License: MIT (required by "Object.assign", "es6", "Symbol", "Map", "Array.from", "Set", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "Object.defineProperties", "Object.create", "Object.setPrototypeOf", "_ESAbstract.GetIterator", "WeakMap", "WeakSet", "_ArrayIterator", "Array.prototype.entries", "Array.prototype.keys", "Array.prototype.values", "_ESAbstract.OrdinaryCreateFromConstructor", "_ESAbstract.Construct", "Array.of", "_Iterator", "_StringIterator")
- * - Function.prototype.bind, License: MIT (required by "_ESAbstract.Construct", "Array.from", "es6", "Array.of", "Object.getOwnPropertyDescriptor", "Object.assign", "Object.setPrototypeOf", "Symbol", "Map", "Set", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "_Iterator", "_ArrayIterator", "Array.prototype.entries", "Array.prototype.keys", "Array.prototype.values", "_StringIterator")
- * - Object.getOwnPropertyDescriptor, License: CC0 (required by "Object.assign", "es6", "Object.setPrototypeOf", "Symbol", "Map", "Array.from", "Set", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "Object.defineProperties", "Object.create", "_ESAbstract.GetIterator", "WeakMap", "WeakSet", "_ArrayIterator", "Array.prototype.entries", "Array.prototype.keys", "Array.prototype.values", "_ESAbstract.OrdinaryCreateFromConstructor", "_ESAbstract.Construct", "Array.of", "_Iterator", "_StringIterator")
- * - Object.defineProperties, License: CC0 (required by "Object.create", "Map", "es6", "Array.from", "Object.setPrototypeOf", "Set", "Symbol", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "_ESAbstract.GetIterator", "WeakMap", "WeakSet", "_ArrayIterator", "Array.prototype.entries", "Array.prototype.keys", "Array.prototype.values", "_ESAbstract.OrdinaryCreateFromConstructor", "_ESAbstract.Construct", "Array.of", "_Iterator", "_StringIterator")
- * - Object.create, License: CC0 (required by "Map", "es6", "Array.from", "Object.setPrototypeOf", "Set", "Symbol", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "_ESAbstract.GetIterator", "WeakMap", "WeakSet", "_ArrayIterator", "Array.prototype.entries", "Array.prototype.keys", "Array.prototype.values", "_ESAbstract.OrdinaryCreateFromConstructor", "_ESAbstract.Construct", "Array.of", "_StringIterator")
- * - Object.getPrototypeOf, License: CC0 (required by "Object.setPrototypeOf", "es6", "_ESAbstract.OrdinaryCreateFromConstructor", "Map", "Array.from", "Set", "WeakMap", "WeakSet", "_ESAbstract.Construct", "Array.of")
- * - _ESAbstract.OrdinaryCreateFromConstructor, License: CC0 (required by "Map", "es6", "Array.from", "Set", "WeakMap", "WeakSet", "_ESAbstract.Construct", "Array.of")
- * - _ESAbstract.Construct, License: CC0 (required by "Array.from", "es6", "Array.of", "_ESAbstract.ArraySpeciesCreate", "Array.prototype.filter", "Symbol", "Map", "Set", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "Array.prototype.map")
- * - _ESAbstract.ArraySpeciesCreate, License: CC0 (required by "Array.prototype.filter", "Symbol", "es6", "Map", "Array.from", "Set", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "Array.prototype.map")
- * - _ESAbstract.ToBoolean, License: CC0 (required by "Array.prototype.find", "es6", "Array.prototype.findIndex", "RegExp.prototype.flags", "_ESAbstract.IteratorComplete", "Map", "Array.from", "Set", "_ESAbstract.IteratorStep", "WeakMap", "WeakSet", "_ESAbstract.IsRegExp", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.startsWith", "Array.prototype.filter", "Symbol", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables")
- * - _ESAbstract.CreateDataProperty, License: CC0 (required by "_ESAbstract.CreateDataPropertyOrThrow", "Array.from", "es6", "Array.of", "_ESAbstract.CreateIterResultObject", "Map", "Set")
- * - _ESAbstract.CreateDataPropertyOrThrow, License: CC0 (required by "Array.from", "es6", "Array.of", "Array.prototype.filter", "Symbol", "Map", "Set", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "Array.prototype.map")
- * - Array.prototype.filter, License: CC0 (required by "Symbol", "es6", "Map", "Array.from", "Set", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables")
- * - Array.prototype.map, License: CC0 (required by "Symbol", "es6", "Map", "Array.from", "Set", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables")
- * - Object.getOwnPropertyNames, License: CC0 (required by "Object.setPrototypeOf", "es6", "Symbol", "Map", "Array.from", "Set", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables")
- * - Object.freeze, License: CC0 (required by "Symbol", "es6", "Map", "Array.from", "Set", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables")
- * - Symbol, License: MIT (required by "es6", "Map", "Array.from", "Set", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "WeakMap", "WeakSet", "_Iterator", "_ArrayIterator", "Array.prototype.entries", "Array.prototype.keys", "Array.prototype.values", "_StringIterator")
- * - Symbol.iterator, License: MIT (required by "es6", "Array.from", "Array.prototype.@@iterator", "Map", "Set", "String.prototype.@@iterator", "_Iterator", "_ArrayIterator", "Array.prototype.entries", "Array.prototype.keys", "Array.prototype.values", "_StringIterator")
- * - _ESAbstract.GetIterator, License: CC0 (required by "Array.from", "es6", "Map", "Set", "WeakMap", "WeakSet")
+ * - _ESAbstract.IsConstructor, License: CC0 (required by "Array.from", "es6", "Array.of", "_ESAbstract.Construct", "_ESAbstract.ArraySpeciesCreate", "Array.prototype.filter", "Symbol", "Map", "Set", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "Array.prototype.map")
+ * - _ESAbstract.IsRegExp, License: CC0 (required by "String.prototype.endsWith", "es6", "String.prototype.includes", "String.prototype.startsWith")
* - _ESAbstract.IteratorClose, License: CC0 (required by "Array.from", "es6", "Map", "Set", "WeakMap", "WeakSet")
- * - _ESAbstract.IteratorNext, License: CC0 (required by "Map", "es6", "Array.from", "Set", "_ESAbstract.IteratorStep", "WeakMap", "WeakSet")
* - _ESAbstract.IteratorComplete, License: CC0 (required by "Map", "es6", "Array.from", "Set", "_ESAbstract.IteratorStep", "WeakMap", "WeakSet")
+ * - _ESAbstract.IteratorNext, License: CC0 (required by "Map", "es6", "Array.from", "Set", "_ESAbstract.IteratorStep", "WeakMap", "WeakSet")
* - _ESAbstract.IteratorStep, License: CC0 (required by "Array.from", "es6", "Map", "Set", "WeakMap", "WeakSet")
* - _ESAbstract.IteratorValue, License: CC0 (required by "Array.from", "es6", "Map", "Set", "WeakMap", "WeakSet")
- * - _ESAbstract.CreateIterResultObject, License: CC0 (required by "Map", "es6", "Array.from", "Set")
- * - _ESAbstract.SameValueNonNumber, License: CC0 (required by "_ESAbstract.SameValueZero", "Map", "es6", "Array.from", "Set", "WeakSet", "_ESAbstract.SameValue", "Object.is", "WeakMap")
+ * - _ESAbstract.OrdinaryToPrimitive, License: CC0 (required by "_ESAbstract.ToPrimitive", "_ESAbstract.ToString", "Array.from", "es6", "Array.of", "Array.prototype.fill", "Array.prototype.find", "Array.prototype.findIndex", "String.prototype.@@iterator", "String.prototype.codePointAt", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.repeat", "String.prototype.startsWith")
+ * - _ESAbstract.SameValue, License: CC0 (required by "Object.is", "es6", "String.fromCodePoint", "WeakMap")
* - _ESAbstract.SameValueZero, License: CC0 (required by "Map", "es6", "Array.from", "Set", "WeakSet")
+ * - _ESAbstract.ToPrimitive, License: CC0 (required by "_ESAbstract.ToString", "Array.from", "es6", "Array.of", "Array.prototype.fill", "Array.prototype.find", "Array.prototype.findIndex", "String.prototype.@@iterator", "String.prototype.codePointAt", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.repeat", "String.prototype.startsWith")
+ * - _ESAbstract.ToString, License: CC0 (required by "Array.from", "es6", "Array.of", "Array.prototype.fill", "Array.prototype.find", "Array.prototype.findIndex", "String.prototype.@@iterator", "String.prototype.codePointAt", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.repeat", "String.prototype.startsWith", "Array.prototype.forEach", "Object.setPrototypeOf", "Symbol", "Map", "Set", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "Array.prototype.filter", "Array.prototype.map")
+ * - _ESAbstract.UTF16Decode, License: CC0 (required by "String.prototype.codePointAt", "es6")
+ * - _ESAbstract.UTF16Encoding, License: CC0 (required by "String.fromCodePoint", "es6")
+ * - _TypedArray, License: MIT (required by "Math.fround", "es6")
+ * - Object.defineProperty, License: CC0 (required by "Function.prototype.name", "es6", "Map", "Array.from", "Number.Epsilon", "Number.MAX_SAFE_INTEGER", "Number.MIN_SAFE_INTEGER", "Object.setPrototypeOf", "RegExp.prototype.flags", "Set", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "Symbol", "WeakMap", "WeakSet", "_ESAbstract.CreateMethodProperty", "Array.of", "Array.prototype.copyWithin", "Array.prototype.entries", "Array.prototype.fill", "Array.prototype.find", "Array.prototype.findIndex", "Array.prototype.keys", "Array.prototype.values", "Math.acosh", "Math.asinh", "Math.atanh", "Math.cbrt", "Math.clz32", "Math.cosh", "Math.expm1", "Math.fround", "Math.hypot", "Math.imul", "Math.log10", "Math.log1p", "Math.log2", "Math.sign", "Math.sinh", "Math.tanh", "Math.trunc", "Number.isFinite", "Number.isInteger", "Number.isNaN", "Number.isSafeInteger", "Number.parseFloat", "Number.parseInt", "Object.assign", "Object.is", "Object.seal", "String.fromCodePoint", "String.prototype.codePointAt", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.repeat", "String.prototype.startsWith", "_ArrayIterator", "_ESAbstract.OrdinaryCreateFromConstructor", "_ESAbstract.Construct", "_StringIterator", "_ESAbstract.CreateDataProperty", "_ESAbstract.CreateDataPropertyOrThrow", "_ESAbstract.CreateIterResultObject", "_Iterator", "Object.defineProperties", "Object.create", "_ESAbstract.GetIterator")
+ * - _ESAbstract.CreateDataProperty, License: CC0 (required by "_ESAbstract.CreateDataPropertyOrThrow", "Array.from", "es6", "Array.of", "_ESAbstract.CreateIterResultObject", "Map", "Set")
+ * - _ESAbstract.CreateDataPropertyOrThrow, License: CC0 (required by "Array.from", "es6", "Array.of", "Array.prototype.filter", "Symbol", "Map", "Set", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "Array.prototype.map")
+ * - _ESAbstract.CreateIterResultObject, License: CC0 (required by "Map", "es6", "Array.from", "Set")
+ * - _ESAbstract.CreateMethodProperty, License: CC0 (required by "Array.from", "es6", "Array.of", "Array.prototype.@@iterator", "Array.prototype.copyWithin", "Array.prototype.entries", "Array.prototype.fill", "Array.prototype.find", "Array.prototype.findIndex", "Array.prototype.keys", "Array.prototype.values", "Map", "Math.acosh", "Math.asinh", "Math.atanh", "Math.cbrt", "Math.clz32", "Math.cosh", "Math.expm1", "Math.fround", "Math.hypot", "Math.imul", "Math.log10", "Math.log1p", "Math.log2", "Math.sign", "Math.sinh", "Math.tanh", "Math.trunc", "Number.isFinite", "Number.isInteger", "Number.isNaN", "Number.isSafeInteger", "Number.parseFloat", "Number.parseInt", "Object.assign", "Object.is", "Object.seal", "Object.setPrototypeOf", "Set", "String.fromCodePoint", "String.prototype.@@iterator", "String.prototype.codePointAt", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.repeat", "String.prototype.startsWith", "WeakMap", "WeakSet", "Array.isArray", "Object.create", "Symbol", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "_ESAbstract.GetIterator", "_ArrayIterator", "_ESAbstract.OrdinaryCreateFromConstructor", "_ESAbstract.Construct", "Object.getOwnPropertyDescriptor", "Object.keys", "Array.prototype.forEach", "Object.getPrototypeOf", "Object.getOwnPropertyNames", "Array.prototype.filter", "Array.prototype.map", "Object.freeze", "Function.prototype.bind", "Object.defineProperties", "_Iterator", "_StringIterator")
* - Array.isArray, License: CC0 (required by "Map", "es6", "Array.from", "Set", "WeakMap")
- * - Symbol.species, License: MIT (required by "es6", "Map", "Array.from", "Set")
- * - Map, License: CC0 (required by "es6", "Array.from")
- * - Set, License: CC0 (required by "es6", "Array.from")
- * - Array.from, License: CC0 (required by "es6")
- * - Array.of, License: CC0 (required by "es6")
- * - Object.assign, License: CC0 (required by "es6", "_Iterator", "_ArrayIterator", "Array.prototype.entries", "Array.prototype.keys", "Array.prototype.values", "Array.prototype.@@iterator", "_StringIterator", "String.prototype.@@iterator")
- * - Symbol.toStringTag, License: MIT (required by "es6", "_Iterator", "_ArrayIterator", "Array.prototype.entries", "Array.prototype.keys", "Array.prototype.values", "Array.prototype.@@iterator", "_StringIterator", "String.prototype.@@iterator")
- * - _Iterator, License: MIT (required by "_ArrayIterator", "Array.prototype.entries", "es6", "Array.prototype.keys", "Array.prototype.values", "Array.prototype.@@iterator", "_StringIterator", "String.prototype.@@iterator")
- * - Object.setPrototypeOf, License: MIT (required by "es6", "_ArrayIterator", "Array.prototype.entries", "Array.prototype.keys", "Array.prototype.values", "Array.prototype.@@iterator", "_StringIterator", "String.prototype.@@iterator")
- * - _ESAbstract.RequireObjectCoercible, License: CC0 (required by "String.prototype.@@iterator", "es6", "String.prototype.codePointAt", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.repeat", "String.prototype.startsWith")
- * - _ESAbstract.IsRegExp, License: CC0 (required by "String.prototype.endsWith", "es6", "String.prototype.includes", "String.prototype.startsWith")
- * - String.prototype.includes, License: CC0 (required by "es6", "_ArrayIterator", "Array.prototype.entries", "Array.prototype.keys", "Array.prototype.values", "Array.prototype.@@iterator")
- * - _ArrayIterator, License: MIT (required by "Array.prototype.entries", "es6", "Array.prototype.keys", "Array.prototype.values", "Array.prototype.@@iterator")
- * - Array.prototype.values, License: MIT (required by "es6", "Array.prototype.@@iterator")
- * - Array.prototype.@@iterator, License: CC0 (required by "es6")
* - Array.prototype.copyWithin, License: MIT (required by "es6")
- * - Array.prototype.entries, License: CC0 (required by "es6")
* - Array.prototype.fill, License: CC0 (required by "es6")
* - Array.prototype.find, License: CC0 (required by "es6")
* - Array.prototype.findIndex, License: CC0 (required by "es6")
- * - Array.prototype.keys, License: CC0 (required by "es6")
- * - Function.name, License: MIT (required by "es6")
+ * - Array.prototype.forEach, License: CC0 (required by "Object.setPrototypeOf", "es6", "Symbol", "Map", "Array.from", "Set", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables")
+ * - Function.prototype.bind, License: MIT (required by "_ESAbstract.Construct", "Array.from", "es6", "Array.of", "Object.getOwnPropertyDescriptor", "Object.assign", "Object.setPrototypeOf", "Symbol", "Map", "Set", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "_Iterator", "_ArrayIterator", "Array.prototype.entries", "Array.prototype.keys", "Array.prototype.values", "_StringIterator")
* - Math.acosh, License: CC0 (required by "es6")
* - Math.asinh, License: CC0 (required by "es6")
* - Math.atanh, License: CC0 (required by "es6")
* - Math.cbrt, License: CC0 (required by "es6")
- * - _ESAbstract.ToUint32, License: CC0 (required by "Math.clz32", "es6", "Math.imul")
* - Math.clz32, License: CC0 (required by "es6")
* - Math.cosh, License: CC0 (required by "es6")
* - Math.expm1, License: CC0 (required by "es6")
- * - _TypedArray, License: Copyright 2010, Linden Research, Inc. Copyright 2014, Joshua Bell. (required by "Math.fround", "es6")
* - Math.fround, License: CC0 (required by "es6")
* - Math.hypot, License: CC0 (required by "es6")
* - Math.imul, License: CC0 (required by "es6")
* - Math.sinh, License: CC0 (required by "es6")
* - Math.tanh, License: CC0 (required by "es6")
* - Math.trunc, License: CC0 (required by "es6")
- * - Number.Epsilon, License: MIT (required by "es6")
- * - Number.MAX_SAFE_INTEGER, License: MIT (required by "es6")
- * - Number.MIN_SAFE_INTEGER, License: MIT (required by "es6")
* - Number.isFinite, License: MIT (required by "es6")
* - Number.isInteger, License: MIT (required by "es6")
* - Number.isNaN, License: MIT (required by "es6")
* - Number.isSafeInteger, License: MIT (required by "es6")
* - Number.parseFloat, License: MIT (required by "es6")
* - Number.parseInt, License: MIT (required by "es6")
- * - _ESAbstract.SameValue, License: CC0 (required by "Object.is", "es6", "WeakMap")
+ * - Function.prototype.name, License: MIT (required by "es6")
+ * - Number.Epsilon, License: MIT (required by "es6")
+ * - Number.MAX_SAFE_INTEGER, License: MIT (required by "es6")
+ * - Number.MIN_SAFE_INTEGER, License: MIT (required by "es6")
+ * - Object.freeze, License: CC0 (required by "Symbol", "es6", "Map", "Array.from", "Set", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables")
+ * - Object.getOwnPropertyDescriptor, License: CC0 (required by "Object.assign", "es6", "Object.setPrototypeOf", "Symbol", "Map", "Array.from", "Set", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "Object.defineProperties", "Object.create", "_ESAbstract.GetIterator", "WeakMap", "WeakSet", "_ArrayIterator", "Array.prototype.entries", "Array.prototype.keys", "Array.prototype.values", "_ESAbstract.OrdinaryCreateFromConstructor", "_ESAbstract.Construct", "Array.of", "_Iterator", "_StringIterator")
+ * - Object.getOwnPropertyNames, License: CC0 (required by "Object.setPrototypeOf", "es6", "Symbol", "Map", "Array.from", "Set", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables")
+ * - Object.getPrototypeOf, License: CC0 (required by "Object.setPrototypeOf", "es6", "_ESAbstract.OrdinaryCreateFromConstructor", "Map", "Array.from", "Set", "WeakMap", "WeakSet", "_ESAbstract.Construct", "Array.of")
* - Object.is, License: CC0 (required by "es6")
+ * - Object.keys, License: MIT (required by "Object.assign", "es6", "Symbol", "Map", "Array.from", "Set", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "Object.defineProperties", "Object.create", "Object.setPrototypeOf", "_ESAbstract.GetIterator", "WeakMap", "WeakSet", "_ArrayIterator", "Array.prototype.entries", "Array.prototype.keys", "Array.prototype.values", "_ESAbstract.OrdinaryCreateFromConstructor", "_ESAbstract.Construct", "Array.of", "_Iterator", "_StringIterator")
+ * - Object.assign, License: CC0 (required by "es6", "_Iterator", "_ArrayIterator", "Array.prototype.entries", "Array.prototype.keys", "Array.prototype.values", "Array.prototype.@@iterator", "_StringIterator", "String.prototype.@@iterator")
+ * - Object.defineProperties, License: CC0 (required by "Object.create", "Map", "es6", "Array.from", "Object.setPrototypeOf", "Set", "Symbol", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "_ESAbstract.GetIterator", "WeakMap", "WeakSet", "_ArrayIterator", "Array.prototype.entries", "Array.prototype.keys", "Array.prototype.values", "_ESAbstract.OrdinaryCreateFromConstructor", "_ESAbstract.Construct", "Array.of", "_Iterator", "_StringIterator")
+ * - Object.create, License: CC0 (required by "Map", "es6", "Array.from", "Object.setPrototypeOf", "Set", "Symbol", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "_ESAbstract.GetIterator", "WeakMap", "WeakSet", "_ArrayIterator", "Array.prototype.entries", "Array.prototype.keys", "Array.prototype.values", "_ESAbstract.OrdinaryCreateFromConstructor", "_ESAbstract.Construct", "Array.of", "_StringIterator")
+ * - _ESAbstract.GetIterator, License: CC0 (required by "Array.from", "es6", "Map", "Set", "WeakMap", "WeakSet")
+ * - _ESAbstract.OrdinaryCreateFromConstructor, License: CC0 (required by "Map", "es6", "Array.from", "Set", "WeakMap", "WeakSet", "_ESAbstract.Construct", "Array.of")
+ * - _ESAbstract.Construct, License: CC0 (required by "Array.from", "es6", "Array.of", "_ESAbstract.ArraySpeciesCreate", "Array.prototype.filter", "Symbol", "Map", "Set", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "Array.prototype.map")
+ * - _ESAbstract.ArraySpeciesCreate, License: CC0 (required by "Array.prototype.filter", "Symbol", "es6", "Map", "Array.from", "Set", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "Array.prototype.map")
+ * - Array.prototype.filter, License: CC0 (required by "Symbol", "es6", "Map", "Array.from", "Set", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables")
+ * - Array.prototype.map, License: CC0 (required by "Symbol", "es6", "Map", "Array.from", "Set", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables")
+ * - Array.of, License: CC0 (required by "es6")
+ * - Object.seal, License: MIT (required by "es6")
+ * - Object.setPrototypeOf, License: MIT (required by "es6", "_ArrayIterator", "Array.prototype.entries", "Array.prototype.keys", "Array.prototype.values", "Array.prototype.@@iterator", "_StringIterator", "String.prototype.@@iterator")
* - Promise, License: MIT (required by "es6")
* - RegExp.prototype.flags, License: MIT (required by "es6")
- * - _StringIterator, License: MIT (required by "String.prototype.@@iterator", "es6")
- * - String.prototype.@@iterator, License: CC0 (required by "es6")
- * - _ESAbstract.UTF16Decode, License: CC0 (required by "String.prototype.codePointAt", "es6")
+ * - String.fromCodePoint, License: MIT (required by "es6")
* - String.prototype.codePointAt, License: MIT (required by "es6")
* - String.prototype.endsWith, License: CC0 (required by "es6")
+ * - String.prototype.includes, License: CC0 (required by "es6", "_ArrayIterator", "Array.prototype.entries", "Array.prototype.keys", "Array.prototype.values", "Array.prototype.@@iterator")
* - String.prototype.repeat, License: CC0 (required by "es6")
* - String.prototype.startsWith, License: CC0 (required by "es6")
+ * - Symbol, License: MIT (required by "es6", "Map", "Array.from", "Set", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "WeakMap", "WeakSet", "_Iterator", "_ArrayIterator", "Array.prototype.entries", "Array.prototype.keys", "Array.prototype.values", "_StringIterator")
* - Symbol.hasInstance, License: MIT (required by "es6")
* - Symbol.isConcatSpreadable, License: MIT (required by "es6")
+ * - Symbol.iterator, License: MIT (required by "es6", "Array.from", "Array.prototype.@@iterator", "Map", "Set", "String.prototype.@@iterator", "_Iterator", "_ArrayIterator", "Array.prototype.entries", "Array.prototype.keys", "Array.prototype.values", "_StringIterator")
* - Symbol.match, License: MIT (required by "es6")
* - Symbol.replace, License: MIT (required by "es6")
* - Symbol.search, License: MIT (required by "es6")
+ * - Symbol.species, License: MIT (required by "es6", "Map", "Array.from", "Set")
+ * - Map, License: CC0 (required by "es6", "Array.from")
+ * - Set, License: CC0 (required by "es6", "Array.from")
+ * - Array.from, License: CC0 (required by "es6")
* - Symbol.split, License: MIT (required by "es6")
* - Symbol.toPrimitive, License: MIT (required by "es6")
+ * - Symbol.toStringTag, License: MIT (required by "es6", "_Iterator", "_ArrayIterator", "Array.prototype.entries", "Array.prototype.keys", "Array.prototype.values", "Array.prototype.@@iterator", "_StringIterator", "String.prototype.@@iterator")
+ * - _Iterator, License: MIT (required by "_ArrayIterator", "Array.prototype.entries", "es6", "Array.prototype.keys", "Array.prototype.values", "Array.prototype.@@iterator", "_StringIterator", "String.prototype.@@iterator")
+ * - _ArrayIterator, License: MIT (required by "Array.prototype.entries", "es6", "Array.prototype.keys", "Array.prototype.values", "Array.prototype.@@iterator")
+ * - Array.prototype.entries, License: CC0 (required by "es6")
+ * - Array.prototype.keys, License: CC0 (required by "es6")
+ * - Array.prototype.values, License: MIT (required by "es6", "Array.prototype.@@iterator")
+ * - Array.prototype.@@iterator, License: CC0 (required by "es6")
+ * - _StringIterator, License: MIT (required by "String.prototype.@@iterator", "es6")
+ * - String.prototype.@@iterator, License: CC0 (required by "es6")
* - Symbol.unscopables, License: MIT (required by "es6")
- * - WeakMap, License: CC0 (required by "es6")
- * - WeakSet, License: CC0 (required by "es6") */
+ * - WeakMap, License: MIT (required by "es6")
+ * - WeakSet, License: MIT (required by "es6") */
(function(undefined) {
+// _ESAbstract.ArrayCreate
+// 9.4.2.2. ArrayCreate ( length [ , proto ] )
+function ArrayCreate(length /* [, proto] */) { // eslint-disable-line no-unused-vars
+ // 1. Assert: length is an integer Number ≥ 0.
+ // 2. If length is -0, set length to +0.
+ if (1 / length === -Infinity) {
+ length = 0;
+ }
+ // 3. If length>2^32-1, throw a RangeError exception.
+ if (length > (Math.pow(2, 32) - 1)) {
+ throw new RangeError('Invalid array length');
+ }
+ // 4. If proto is not present, set proto to the intrinsic object %ArrayPrototype%.
+ // 5. Let A be a newly created Array exotic object.
+ var A = [];
+ // 6. Set A's essential internal methods except for [[DefineOwnProperty]] to the default ordinary object definitions specified in 9.1.
+ // 7. Set A.[[DefineOwnProperty]] as specified in 9.4.2.1.
+ // 8. Set A.[[Prototype]] to proto.
+ // 9. Set A.[[Extensible]] to true.
+ // 10. Perform ! OrdinaryDefineOwnProperty(A, "length", PropertyDescriptor{[[Value]]: length, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: false}).
+ A.length = length;
+ // 11. Return A.
+ return A;
+}
+
+// _ESAbstract.Call
+/* global IsCallable */
+// 7.3.12. Call ( F, V [ , argumentsList ] )
+function Call(F, V /* [, argumentsList] */) { // eslint-disable-line no-unused-vars
+ // 1. If argumentsList is not present, set argumentsList to a new empty List.
+ var argumentsList = arguments.length > 2 ? arguments[2] : [];
+ // 2. If IsCallable(F) is false, throw a TypeError exception.
+ if (IsCallable(F) === false) {
+ throw new TypeError(Object.prototype.toString.call(F) + 'is not a function.');
+ }
+ // 3. Return ? F.[[Call]](V, argumentsList).
+ return F.apply(V, argumentsList);
+}
+
+// _ESAbstract.Get
+// 7.3.1. Get ( O, P )
+function Get(O, P) { // eslint-disable-line no-unused-vars
+ // 1. Assert: Type(O) is Object.
+ // 2. Assert: IsPropertyKey(P) is true.
+ // 3. Return ? O.[[Get]](P, O).
+ return O[P];
+}
+
+// _ESAbstract.HasProperty
+// 7.3.10. HasProperty ( O, P )
+function HasProperty(O, P) { // eslint-disable-line no-unused-vars
+ // Assert: Type(O) is Object.
+ // Assert: IsPropertyKey(P) is true.
+ // Return ? O.[[HasProperty]](P).
+ return P in O;
+}
+
+// _ESAbstract.IsArray
+// 7.2.2. IsArray ( argument )
+function IsArray(argument) { // eslint-disable-line no-unused-vars
+ // 1. If Type(argument) is not Object, return false.
+ // 2. If argument is an Array exotic object, return true.
+ // 3. If argument is a Proxy exotic object, then
+ // a. If argument.[[ProxyHandler]] is null, throw a TypeError exception.
+ // b. Let target be argument.[[ProxyTarget]].
+ // c. Return ? IsArray(target).
+ // 4. Return false.
+
+ // Polyfill.io - We can skip all the above steps and check the string returned from Object.prototype.toString().
+ return Object.prototype.toString.call(argument) === '[object Array]';
+}
+
// _ESAbstract.IsCallable
// 7.2.3. IsCallable ( argument )
function IsCallable(argument) { // eslint-disable-line no-unused-vars
// 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.
return typeof argument === 'function';
}
-if (!(// In IE8, defineProperty could only act on DOM elements, so full support
-// for the feature requires the ability to set a property on an arbitrary object
-'defineProperty' in Object && (function() {
- try {
- var a = {};
- Object.defineProperty(a, 'test', {value:42});
- return true;
- } catch(e) {
- return false
- }
-}()))) {
-// Object.defineProperty
-(function (nativeDefineProperty) {
+// _ESAbstract.RequireObjectCoercible
+// 7.2.1. RequireObjectCoercible ( argument )
+// The abstract operation ToObject converts argument to a value of type Object according to Table 12:
+// Table 12: ToObject Conversions
+/*
+|----------------------------------------------------------------------------------------------------------------------------------------------------|
+| Argument Type | Result |
+|----------------------------------------------------------------------------------------------------------------------------------------------------|
+| Undefined | Throw a TypeError exception. |
+| Null | Throw a TypeError exception. |
+| Boolean | Return argument. |
+| Number | Return argument. |
+| String | Return argument. |
+| Symbol | Return argument. |
+| Object | Return argument. |
+|----------------------------------------------------------------------------------------------------------------------------------------------------|
+*/
+function RequireObjectCoercible(argument) { // eslint-disable-line no-unused-vars
+ if (argument === null || argument === undefined) {
+ throw TypeError();
+ }
+ return argument;
+}
- var supportsAccessors = Object.prototype.hasOwnProperty('__defineGetter__');
- var ERR_ACCESSORS_NOT_SUPPORTED = 'Getters & setters cannot be defined on this javascript engine';
- var ERR_VALUE_ACCESSORS = 'A property cannot both have accessors and be writable or have a value';
+// _ESAbstract.SameValueNonNumber
+// 7.2.12. SameValueNonNumber ( x, y )
+function SameValueNonNumber(x, y) { // eslint-disable-line no-unused-vars
+ // 1. Assert: Type(x) is not Number.
+ // 2. Assert: Type(x) is the same as Type(y).
+ // 3. If Type(x) is Undefined, return true.
+ // 4. If Type(x) is Null, return true.
+ // 5. If Type(x) is String, then
+ // a. If x and y are exactly the same sequence of code units (same length and same code units at corresponding indices), return true; otherwise, return false.
+ // 6. If Type(x) is Boolean, then
+ // a. If x and y are both true or both false, return true; otherwise, return false.
+ // 7. If Type(x) is Symbol, then
+ // a. If x and y are both the same Symbol value, return true; otherwise, return false.
+ // 8. If x and y are the same Object value, return true. Otherwise, return false.
- // Polyfill.io - This does not use CreateMethodProperty because our CreateMethodProperty function uses Object.defineProperty.
- Object['defineProperty'] = function defineProperty(object, property, descriptor) {
+ // Polyfill.io - We can skip all above steps because the === operator does it all for us.
+ return x === y;
+}
- // Where native support exists, assume it
- if (nativeDefineProperty && (object === window || object === document || object === Element.prototype || object instanceof Element)) {
- return nativeDefineProperty(object, property, descriptor);
- }
-
- if (object === null || !(object instanceof Object || typeof object === 'object')) {
- throw new TypeError('Object.defineProperty called on non-object');
- }
-
- if (!(descriptor instanceof Object)) {
- throw new TypeError('Property description must be an object');
- }
-
- var propertyString = String(property);
- var hasValueOrWritable = 'value' in descriptor || 'writable' in descriptor;
- var getterType = 'get' in descriptor && typeof descriptor.get;
- var setterType = 'set' in descriptor && typeof descriptor.set;
-
- // handle descriptor.get
- if (getterType) {
- if (getterType !== 'function') {
- throw new TypeError('Getter must be a function');
- }
- if (!supportsAccessors) {
- throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
- }
- if (hasValueOrWritable) {
- throw new TypeError(ERR_VALUE_ACCESSORS);
- }
- Object.__defineGetter__.call(object, propertyString, descriptor.get);
- } else {
- object[propertyString] = descriptor.value;
- }
-
- // handle descriptor.set
- if (setterType) {
- if (setterType !== 'function') {
- throw new TypeError('Setter must be a function');
- }
- if (!supportsAccessors) {
- throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
- }
- if (hasValueOrWritable) {
- throw new TypeError(ERR_VALUE_ACCESSORS);
- }
- Object.__defineSetter__.call(object, propertyString, descriptor.set);
- }
-
- // OK to define value unconditionally - if a getter has been specified as well, an error would be thrown above
- if ('value' in descriptor) {
- object[propertyString] = descriptor.value;
- }
-
- return object;
- };
-}(Object.defineProperty));
+// _ESAbstract.ToBoolean
+// 7.1.2. ToBoolean ( argument )
+// The abstract operation ToBoolean converts argument to a value of type Boolean according to Table 9:
+/*
+--------------------------------------------------------------------------------------------------------------
+| Argument Type | Result |
+--------------------------------------------------------------------------------------------------------------
+| Undefined | Return false. |
+| Null | Return false. |
+| Boolean | Return argument. |
+| Number | If argument is +0, -0, or NaN, return false; otherwise return true. |
+| String | If argument is the empty String (its length is zero), return false; otherwise return true. |
+| Symbol | Return true. |
+| Object | Return true. |
+--------------------------------------------------------------------------------------------------------------
+*/
+function ToBoolean(argument) { // eslint-disable-line no-unused-vars
+ return Boolean(argument);
+}
+// _ESAbstract.ToInteger
+// 7.1.4. ToInteger ( argument )
+function ToInteger(argument) { // eslint-disable-line no-unused-vars
+ // 1. Let number be ? ToNumber(argument).
+ var number = Number(argument);
+ // 2. If number is NaN, return +0.
+ if (isNaN(number)) {
+ return 0;
+ }
+ // 3. If number is +0, -0, +∞, or -∞, return number.
+ if (1/number === Infinity || 1/number === -Infinity || number === Infinity || number === -Infinity) {
+ return number;
+ }
+ // 4. Return the number value that is the same sign as number and whose magnitude is floor(abs(number)).
+ return ((number < 0) ? -1 : 1) * Math.floor(Math.abs(number));
}
+// _ESAbstract.ToLength
+/* global ToInteger */
+// 7.1.15. ToLength ( argument )
+function ToLength(argument) { // eslint-disable-line no-unused-vars
+ // 1. Let len be ? ToInteger(argument).
+ var len = ToInteger(argument);
+ // 2. If len ≤ +0, return +0.
+ if (len <= 0) {
+ return 0;
+ }
+ // 3. Return min(len, 253-1).
+ return Math.min(len, Math.pow(2, 53) -1);
+}
-// _ESAbstract.CreateMethodProperty
-// 7.3.5. CreateMethodProperty ( O, P, V )
-function CreateMethodProperty(O, P, V) { // eslint-disable-line no-unused-vars
- // 1. Assert: Type(O) is Object.
- // 2. Assert: IsPropertyKey(P) is true.
- // 3. Let newDesc be the PropertyDescriptor{[[Value]]: V, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true}.
- var newDesc = {
- value: V,
- writable: true,
- enumerable: false,
- configurable: true
- };
- // 4. Return ? O.[[DefineOwnProperty]](P, newDesc).
- Object.defineProperty(O, P, newDesc);
+// _ESAbstract.ToNumber
+// 7.1.3. ToNumber ( argument )
+function ToNumber(argument) { // eslint-disable-line no-unused-vars
+ return Number(argument);
}
// _ESAbstract.ToObject
return func;
}
-// _ESAbstract.ToInteger
-// 7.1.4. ToInteger ( argument )
-function ToInteger(argument) { // eslint-disable-line no-unused-vars
+// _ESAbstract.ToUint32
+// 7.1.6. ToUint32 ( argument )
+function ToUint32(argument) { // eslint-disable-line no-unused-vars
// 1. Let number be ? ToNumber(argument).
var number = Number(argument);
- // 2. If number is NaN, return +0.
- if (isNaN(number)) {
- return 0;
- }
- // 3. If number is +0, -0, +∞, or -∞, return number.
- if (1/number === Infinity || 1/number === -Infinity || number === Infinity || number === -Infinity) {
- return number;
- }
- // 4. Return the number value that is the same sign as number and whose magnitude is floor(abs(number)).
- return ((number < 0) ? -1 : 1) * Math.floor(Math.abs(number));
-}
-
-// _ESAbstract.ToLength
-/* global ToInteger */
-// 7.1.15. ToLength ( argument )
-function ToLength(argument) { // eslint-disable-line no-unused-vars
- // 1. Let len be ? ToInteger(argument).
- var len = ToInteger(argument);
- // 2. If len ≤ +0, return +0.
- if (len <= 0) {
+ // 2. If number is NaN, +0, -0, +∞, or -∞, return +0.
+ if (isNaN(number) || 1/number === Infinity || 1/number === -Infinity || number === Infinity || number === -Infinity) {
return 0;
}
- // 3. Return min(len, 253-1).
- return Math.min(len, Math.pow(2, 53) -1);
-}
-
-// _ESAbstract.Get
-// 7.3.1. Get ( O, P )
-function Get(O, P) { // eslint-disable-line no-unused-vars
- // 1. Assert: Type(O) is Object.
- // 2. Assert: IsPropertyKey(P) is true.
- // 3. Return ? O.[[Get]](P, O).
- return O[P];
-}
-
-// _ESAbstract.HasProperty
-// 7.3.10. HasProperty ( O, P )
-function HasProperty(O, P) { // eslint-disable-line no-unused-vars
- // Assert: Type(O) is Object.
- // Assert: IsPropertyKey(P) is true.
- // Return ? O.[[HasProperty]](P).
- return P in O;
-}
-
-// _ESAbstract.Call
-/* global IsCallable */
-// 7.3.12. Call ( F, V [ , argumentsList ] )
-function Call(F, V /* [, argumentsList] */) { // eslint-disable-line no-unused-vars
- // 1. If argumentsList is not present, set argumentsList to a new empty List.
- var argumentsList = arguments.length > 2 ? arguments[2] : [];
- // 2. If IsCallable(F) is false, throw a TypeError exception.
- if (IsCallable(F) === false) {
- throw new TypeError(Object.prototype.toString.call(F) + 'is not a function.');
- }
- // 3. Return ? F.[[Call]](V, argumentsList).
- return F.apply(V, argumentsList);
+ // 3. Let int be the mathematical value that is the same sign as number and whose magnitude is floor(abs(number)).
+ var int = ((number < 0) ? -1 : 1) * Math.floor(Math.abs(number));
+ // 4. Let int32bit be int modulo 2^32.
+ var int32bit = int >>> 0;
+ // 5. Return int32bit.
+ return int32bit;
}
// _ESAbstract.Type
}
}
-// _ESAbstract.OrdinaryToPrimitive
-/* global Get, IsCallable, Call, Type */
-// 7.1.1.1. OrdinaryToPrimitive ( O, hint )
-function OrdinaryToPrimitive(O, hint) { // eslint-disable-line no-unused-vars
- // 1. Assert: Type(O) is Object.
- // 2. Assert: Type(hint) is String and its value is either "string" or "number".
- // 3. If hint is "string", then
- if (hint === 'string') {
- // a. Let methodNames be « "toString", "valueOf" ».
- var methodNames = ['toString', 'valueOf'];
- // 4. Else,
- } else {
- // a. Let methodNames be « "valueOf", "toString" ».
- methodNames = ['valueOf', 'toString'];
- }
- // 5. For each name in methodNames in List order, do
- for (var i = 0; i < methodNames.length; ++i) {
- var name = methodNames[i];
- // a. Let method be ? Get(O, name).
- var method = Get(O, name);
- // b. If IsCallable(method) is true, then
- if (IsCallable(method)) {
- // i. Let result be ? Call(method, O).
- var result = Call(method, O);
- // ii. If Type(result) is not Object, return result.
- if (Type(result) !== 'object') {
- return result;
- }
- }
+// _ESAbstract.GetPrototypeFromConstructor
+/* global Get, Type */
+// 9.1.14. GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto )
+function GetPrototypeFromConstructor(constructor, intrinsicDefaultProto) { // eslint-disable-line no-unused-vars
+ // 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.
+ // 2. Assert: IsCallable(constructor) is true.
+ // 3. Let proto be ? Get(constructor, "prototype").
+ var proto = Get(constructor, "prototype");
+ // 4. If Type(proto) is not Object, then
+ if (Type(proto) !== 'object') {
+ // a. Let realm be ? GetFunctionRealm(constructor).
+ // b. Set proto to realm's intrinsic object named intrinsicDefaultProto.
+ proto = intrinsicDefaultProto;
}
- // 6. Throw a TypeError exception.
- throw new TypeError('Cannot convert to primitive.');
+ // 5. Return proto.
+ return proto;
}
-// _ESAbstract.ToPrimitive
-/* global Type, GetMethod, Call, OrdinaryToPrimitive */
-// 7.1.1. ToPrimitive ( input [ , PreferredType ] )
-function ToPrimitive(input /* [, PreferredType] */) { // eslint-disable-line no-unused-vars
- var PreferredType = arguments.length > 1 ? arguments[1] : undefined;
- // 1. Assert: input is an ECMAScript language value.
- // 2. If Type(input) is Object, then
- if (Type(input) === 'object') {
- // a. If PreferredType is not present, let hint be "default".
- if (arguments.length < 2) {
- var hint = 'default';
- // b. Else if PreferredType is hint String, let hint be "string".
- } else if (PreferredType === String) {
- hint = 'string';
- // c. Else PreferredType is hint Number, let hint be "number".
- } else if (PreferredType === Number) {
- hint = 'number';
- }
- // d. Let exoticToPrim be ? GetMethod(input, @@toPrimitive).
- var exoticToPrim = typeof this.Symbol === 'function' && typeof this.Symbol.toPrimitive === 'symbol' ? GetMethod(input, this.Symbol.toPrimitive) : undefined;
- // e. If exoticToPrim is not undefined, then
- if (exoticToPrim !== undefined) {
- // i. Let result be ? Call(exoticToPrim, input, « hint »).
- var result = Call(exoticToPrim, input, [hint]);
- // ii. If Type(result) is not Object, return result.
- if (Type(result) !== 'object') {
- return result;
- }
- // iii. Throw a TypeError exception.
- throw new TypeError('Cannot convert exotic object to primitive.');
- }
- // f. If hint is "default", set hint to "number".
- if (hint === 'default') {
- hint = 'number';
- }
- // g. Return ? OrdinaryToPrimitive(input, hint).
- return OrdinaryToPrimitive(input, hint);
+// _ESAbstract.IsConstructor
+/* global Type */
+// 7.2.4. IsConstructor ( argument )
+function IsConstructor(argument) { // eslint-disable-line no-unused-vars
+ // 1. If Type(argument) is not Object, return false.
+ if (Type(argument) !== 'object') {
+ return false;
}
- // 3. Return input
- return input;
-}
+ // 2. If argument has a [[Construct]] internal method, return true.
+ // 3. Return false.
-// _ESAbstract.ToString
-/* global Type, ToPrimitive */
-// 7.1.12. ToString ( argument )
-// The abstract operation ToString converts argument to a value of type String according to Table 11:
-// Table 11: ToString Conversions
-/*
-|---------------|--------------------------------------------------------|
-| Argument Type | Result |
-|---------------|--------------------------------------------------------|
-| Undefined | Return "undefined". |
-|---------------|--------------------------------------------------------|
-| Null | Return "null". |
-|---------------|--------------------------------------------------------|
-| Boolean | If argument is true, return "true". |
-| | If argument is false, return "false". |
-|---------------|--------------------------------------------------------|
-| Number | Return NumberToString(argument). |
-|---------------|--------------------------------------------------------|
-| String | Return argument. |
-|---------------|--------------------------------------------------------|
-| Symbol | Throw a TypeError exception. |
-|---------------|--------------------------------------------------------|
-| Object | Apply the following steps: |
-| | Let primValue be ? ToPrimitive(argument, hint String). |
-| | Return ? ToString(primValue). |
-|---------------|--------------------------------------------------------|
-*/
-function ToString(argument) { // eslint-disable-line no-unused-vars
- switch(Type(argument)) {
- case 'symbol':
- throw new TypeError('Cannot convert a Symbol value to a string');
- break;
- case 'object':
- var primValue = ToPrimitive(argument, 'string');
- return ToString(primValue);
- default:
- return String(argument);
- }
+ // Polyfill.io - `new argument` is the only way to truly test if a function is a constructor.
+ // We choose to not use`new argument` because the argument could have side effects when called.
+ // Instead we check to see if the argument is a function and if it has a prototype.
+ // Arrow functions do not have a [[Construct]] internal method, nor do they have a prototype.
+ return typeof argument === 'function' && !!argument.prototype;
}
-if (!('forEach' in Array.prototype)) {
-// Array.prototype.forEach
-/* global Call, CreateMethodProperty, Get, HasProperty, IsCallable, ToLength, ToObject, ToString */
-// 22.1.3.10. Array.prototype.forEach ( callbackfn [ , thisArg ] )
-CreateMethodProperty(Array.prototype, 'forEach', function forEach(callbackfn /* [ , thisArg ] */) {
- // 1. Let O be ? ToObject(this value).
- var O = ToObject(this);
- // Polyfill.io - If O is a String object, split it into an array in order to iterate correctly.
- // We will use arrayLike in place of O when we are iterating through the list.
- var arraylike = O instanceof String ? O.split('') : O;
- // 2. Let len be ? ToLength(? Get(O, "length")).
- var len = ToLength(Get(O, "length"));
- // 3. If IsCallable(callbackfn) is false, throw a TypeError exception.
- if (IsCallable(callbackfn) === false) {
- throw new TypeError(callbackfn + ' is not a function');
+// _ESAbstract.IsRegExp
+/* global Type, Get, ToBoolean */
+// 7.2.8. IsRegExp ( argument )
+function IsRegExp(argument) { // eslint-disable-line no-unused-vars
+ // 1. If Type(argument) is not Object, return false.
+ if (Type(argument) !== 'object') {
+ return false;
}
- // 4. If thisArg is present, let T be thisArg; else let T be undefined.
- var T = arguments.length > 1 ? arguments[1] : undefined;
- // 5. Let k be 0.
- var k = 0;
- // 6. Repeat, while k < len
- while (k < len) {
- // a. Let Pk be ! ToString(k).
- var Pk = ToString(k);
- // b. Let kPresent be ? HasProperty(O, Pk).
- var kPresent = HasProperty(arraylike, Pk);
- // c. If kPresent is true, then
- if (kPresent) {
- // i. Let kValue be ? Get(O, Pk).
- var kValue = Get(arraylike, Pk);
- // ii. Perform ? Call(callbackfn, T, « kValue, k, O »).
- Call(callbackfn, T, [kValue, k, O]);
- }
- // d. Increase k by 1.
- k = k + 1;
+ // 2. Let matcher be ? Get(argument, @@match).
+ var matcher = 'Symbol' in this && 'match' in this.Symbol ? Get(argument, this.Symbol.match) : undefined;
+ // 3. If matcher is not undefined, return ToBoolean(matcher).
+ if (matcher !== undefined) {
+ return ToBoolean(matcher);
}
- // 7. Return undefined.
- return undefined;
-});
-
+ // 4. If argument has a [[RegExpMatcher]] internal slot, return true.
+ try {
+ var lastIndex = argument.lastIndex;
+ argument.lastIndex = 0;
+ RegExp.prototype.exec.call(argument);
+ return true;
+ } catch (e) {} finally {
+ argument.lastIndex = lastIndex;
+ }
+ // 5. Return false.
+ return false;
}
+// _ESAbstract.IteratorClose
+/* global GetMethod, Type, Call */
+// 7.4.6. IteratorClose ( iteratorRecord, completion )
+function IteratorClose(iteratorRecord, completion) { // eslint-disable-line no-unused-vars
+ // 1. Assert: Type(iteratorRecord.[[Iterator]]) is Object.
+ if (Type(iteratorRecord['[[Iterator]]']) !== 'object') {
+ throw new Error(Object.prototype.toString.call(iteratorRecord['[[Iterator]]']) + 'is not an Object.');
+ }
+ // 2. Assert: completion is a Completion Record.
+ // Polyfill.io - Ignoring this step as there is no way to check if something is a Completion Record in userland JavaScript.
-// _ESAbstract.IsArray
-// 7.2.2. IsArray ( argument )
-function IsArray(argument) { // eslint-disable-line no-unused-vars
- // 1. If Type(argument) is not Object, return false.
- // 2. If argument is an Array exotic object, return true.
- // 3. If argument is a Proxy exotic object, then
- // a. If argument.[[ProxyHandler]] is null, throw a TypeError exception.
- // b. Let target be argument.[[ProxyTarget]].
- // c. Return ? IsArray(target).
- // 4. Return false.
+ // 3. Let iterator be iteratorRecord.[[Iterator]].
+ var iterator = iteratorRecord['[[Iterator]]'];
+ // 4. Let return be ? GetMethod(iterator, "return").
+ // Polyfill.io - We name it returnMethod because return is a keyword and can not be used as an identifier (E.G. variable name, function name etc).
+ var returnMethod = GetMethod(iterator, "return");
+ // 5. If return is undefined, return Completion(completion).
+ if (returnMethod === undefined) {
+ return completion;
+ }
+ // 6. Let innerResult be Call(return, iterator, « »).
+ try {
+ var innerResult = Call(returnMethod, iterator);
+ } catch (error) {
+ var innerException = error;
+ }
+ // 7. If completion.[[Type]] is throw, return Completion(completion).
+ if (completion) {
+ return completion;
+ }
+ // 8. If innerResult.[[Type]] is throw, return Completion(innerResult).
+ if (innerException) {
+ throw innerException;
+ }
+ // 9. If Type(innerResult.[[Value]]) is not Object, throw a TypeError exception.
+ if (Type(innerResult) !== 'object') {
+ throw new TypeError("Iterator's return method returned a non-object.");
+ }
+ // 10. Return Completion(completion).
+ return completion;
+}
- // Polyfill.io - We can skip all the above steps and check the string returned from Object.prototype.toString().
- return Object.prototype.toString.call(argument) === '[object Array]';
+// _ESAbstract.IteratorComplete
+/* global Type, ToBoolean, Get */
+// 7.4.3 IteratorComplete ( iterResult )
+function IteratorComplete(iterResult) { // eslint-disable-line no-unused-vars
+ // 1. Assert: Type(iterResult) is Object.
+ if (Type(iterResult) !== 'object') {
+ throw new Error(Object.prototype.toString.call(iterResult) + 'is not an Object.');
+ }
+ // 2. Return ToBoolean(? Get(iterResult, "done")).
+ return ToBoolean(Get(iterResult, "done"));
}
-// _ESAbstract.ArrayCreate
-// 9.4.2.2. ArrayCreate ( length [ , proto ] )
-function ArrayCreate(length /* [, proto] */) { // eslint-disable-line no-unused-vars
- // 1. Assert: length is an integer Number ≥ 0.
- // 2. If length is -0, set length to +0.
- if (1 / length === -Infinity) {
- length = 0;
+// _ESAbstract.IteratorNext
+/* global Call, Type */
+// 7.4.2. IteratorNext ( iteratorRecord [ , value ] )
+function IteratorNext(iteratorRecord /* [, value] */) { // eslint-disable-line no-unused-vars
+ // 1. If value is not present, then
+ if (arguments.length < 2) {
+ // a. Let result be ? Call(iteratorRecord.[[NextMethod]], iteratorRecord.[[Iterator]], « »).
+ var result = Call(iteratorRecord['[[NextMethod]]'], iteratorRecord['[[Iterator]]']);
+ // 2. Else,
+ } else {
+ // a. Let result be ? Call(iteratorRecord.[[NextMethod]], iteratorRecord.[[Iterator]], « value »).
+ result = Call(iteratorRecord['[[NextMethod]]'], iteratorRecord['[[Iterator]]'], [arguments[1]]);
}
- // 3. If length>2^32-1, throw a RangeError exception.
- if (length > (Math.pow(2, 32) - 1)) {
- throw new RangeError('Invalid array length');
+ // 3. If Type(result) is not Object, throw a TypeError exception.
+ if (Type(result) !== 'object') {
+ throw new TypeError('bad iterator');
}
- // 4. If proto is not present, set proto to the intrinsic object %ArrayPrototype%.
- // 5. Let A be a newly created Array exotic object.
- var A = [];
- // 6. Set A's essential internal methods except for [[DefineOwnProperty]] to the default ordinary object definitions specified in 9.1.
- // 7. Set A.[[DefineOwnProperty]] as specified in 9.4.2.1.
- // 8. Set A.[[Prototype]] to proto.
- // 9. Set A.[[Extensible]] to true.
- // 10. Perform ! OrdinaryDefineOwnProperty(A, "length", PropertyDescriptor{[[Value]]: length, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: false}).
- A.length = length;
- // 11. Return A.
- return A;
+ // 4. Return result.
+ return result;
}
-// _ESAbstract.IsConstructor
-/* global Type */
-// 7.2.4. IsConstructor ( argument )
-function IsConstructor(argument) { // eslint-disable-line no-unused-vars
- // 1. If Type(argument) is not Object, return false.
- if (Type(argument) !== 'object') {
+// _ESAbstract.IteratorStep
+/* global IteratorNext, IteratorComplete */
+// 7.4.5. IteratorStep ( iteratorRecord )
+function IteratorStep(iteratorRecord) { // eslint-disable-line no-unused-vars
+ // 1. Let result be ? IteratorNext(iteratorRecord).
+ var result = IteratorNext(iteratorRecord);
+ // 2. Let done be ? IteratorComplete(result).
+ var done = IteratorComplete(result);
+ // 3. If done is true, return false.
+ if (done === true) {
return false;
}
- // 2. If argument has a [[Construct]] internal method, return true.
- // 3. Return false.
-
- // Polyfill.io - `new argument` is the only way to truly test if a function is a constructor.
- // We choose to not use`new argument` because the argument could have side effects when called.
- // Instead we check to see if the argument is a function and if it has a prototype.
- // Arrow functions do not have a [[Construct]] internal method, nor do they have a prototype.
- return typeof argument === 'function' && !!argument.prototype;
+ // 4. Return result.
+ return result;
}
-// _ESAbstract.GetPrototypeFromConstructor
-/* global Get, Type */
-// 9.1.14. GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto )
-function GetPrototypeFromConstructor(constructor, intrinsicDefaultProto) { // eslint-disable-line no-unused-vars
- // 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.
- // 2. Assert: IsCallable(constructor) is true.
- // 3. Let proto be ? Get(constructor, "prototype").
- var proto = Get(constructor, "prototype");
- // 4. If Type(proto) is not Object, then
- if (Type(proto) !== 'object') {
- // a. Let realm be ? GetFunctionRealm(constructor).
- // b. Set proto to realm's intrinsic object named intrinsicDefaultProto.
- proto = intrinsicDefaultProto;
+// _ESAbstract.IteratorValue
+/* global Type, Get */
+// 7.4.4 IteratorValue ( iterResult )
+function IteratorValue(iterResult) { // eslint-disable-line no-unused-vars
+ // Assert: Type(iterResult) is Object.
+ if (Type(iterResult) !== 'object') {
+ throw new Error(Object.prototype.toString.call(iterResult) + 'is not an Object.');
}
- // 5. Return proto.
- return proto;
+ // Return ? Get(iterResult, "value").
+ return Get(iterResult, "value");
}
-if (!('keys' in Object && (function () {
- // Safari 5.0 bug where Object.keys doesn't work with arguments
- return (Object.keys(arguments)).length === 2;
-}(1, 2)) && (function () {
- try {
- // In ES6 Object.keys works on all object except `null` and `undefined`.
- Object.keys('');
- return true;
- } catch (e) {
- return false;
- }
-}()))) {
-
-// Object.keys
-Object.keys = (function() {
- 'use strict';
-
- // modified from https://github.com/es-shims/object-keys
- var has = Object.prototype.hasOwnProperty;
- var toStr = Object.prototype.toString;
- var isEnumerable = Object.prototype.propertyIsEnumerable;
- var hasDontEnumBug = !isEnumerable.call({ toString: null }, 'toString');
- var hasProtoEnumBug = isEnumerable.call(function () {}, 'prototype');
- var dontEnums = [
- 'toString',
- 'toLocaleString',
- 'valueOf',
- 'hasOwnProperty',
- 'isPrototypeOf',
- 'propertyIsEnumerable',
- 'constructor'
- ];
- var equalsConstructorPrototype = function (o) {
- var ctor = o.constructor;
- return ctor && ctor.prototype === o;
- };
- var excludedKeys = {
- $console: true,
- $external: true,
- $frame: true,
- $frameElement: true,
- $frames: true,
- $innerHeight: true,
- $innerWidth: true,
- $outerHeight: true,
- $outerWidth: true,
- $pageXOffset: true,
- $pageYOffset: true,
- $parent: true,
- $scrollLeft: true,
- $scrollTop: true,
- $scrollX: true,
- $scrollY: true,
- $self: true,
- $webkitIndexedDB: true,
- $webkitStorageInfo: true,
- $window: true
- };
- var hasAutomationEqualityBug = (function () {
- /* global window */
- if (typeof window === 'undefined') { return false; }
- for (var k in window) {
- try {
- if (!excludedKeys['$' + k] && has.call(window, k) && window[k] !== null && typeof window[k] === 'object') {
- try {
- equalsConstructorPrototype(window[k]);
- } catch (e) {
- return true;
- }
- }
- } catch (e) {
- return true;
+// _ESAbstract.OrdinaryToPrimitive
+/* global Get, IsCallable, Call, Type */
+// 7.1.1.1. OrdinaryToPrimitive ( O, hint )
+function OrdinaryToPrimitive(O, hint) { // eslint-disable-line no-unused-vars
+ // 1. Assert: Type(O) is Object.
+ // 2. Assert: Type(hint) is String and its value is either "string" or "number".
+ // 3. If hint is "string", then
+ if (hint === 'string') {
+ // a. Let methodNames be « "toString", "valueOf" ».
+ var methodNames = ['toString', 'valueOf'];
+ // 4. Else,
+ } else {
+ // a. Let methodNames be « "valueOf", "toString" ».
+ methodNames = ['valueOf', 'toString'];
+ }
+ // 5. For each name in methodNames in List order, do
+ for (var i = 0; i < methodNames.length; ++i) {
+ var name = methodNames[i];
+ // a. Let method be ? Get(O, name).
+ var method = Get(O, name);
+ // b. If IsCallable(method) is true, then
+ if (IsCallable(method)) {
+ // i. Let result be ? Call(method, O).
+ var result = Call(method, O);
+ // ii. If Type(result) is not Object, return result.
+ if (Type(result) !== 'object') {
+ return result;
}
}
+ }
+ // 6. Throw a TypeError exception.
+ throw new TypeError('Cannot convert to primitive.');
+}
+
+// _ESAbstract.SameValue
+/* global Type, SameValueNonNumber */
+// 7.2.10. SameValue ( x, y )
+function SameValue(x, y) { // eslint-disable-line no-unused-vars
+ // 1. If Type(x) is different from Type(y), return false.
+ if (Type(x) !== Type(y)) {
return false;
- }());
- var equalsConstructorPrototypeIfNotBuggy = function (o) {
- /* global window */
- if (typeof window === 'undefined' || !hasAutomationEqualityBug) {
- return equalsConstructorPrototype(o);
+ }
+ // 2. If Type(x) is Number, then
+ if (Type(x) === 'number') {
+ // a. If x is NaN and y is NaN, return true.
+ if (isNaN(x) && isNaN(y)) {
+ return true;
}
- try {
- return equalsConstructorPrototype(o);
- } catch (e) {
+ // Polyfill.io - 0 === -0 is true, but they are not the same value.
+ // b. If x is +0 and y is -0, return false.
+ // c. If x is -0 and y is +0, return false.
+ if (x === 0 && y === 0 && 1/x !== 1/y) {
return false;
}
- };
-
- function isArgumentsObject(value) {
- var str = toStr.call(value);
- var isArgs = str === '[object Arguments]';
- if (!isArgs) {
- isArgs = str !== '[object Array]' &&
- value !== null &&
- typeof value === 'object' &&
- typeof value.length === 'number' &&
- value.length >= 0 &&
- toStr.call(value.callee) === '[object Function]';
+ // d. If x is the same Number value as y, return true.
+ if (x === y) {
+ return true;
}
- return isArgs;
+ // e. Return false.
+ return false;
}
+ // 3. Return SameValueNonNumber(x, y).
+ return SameValueNonNumber(x, y);
+}
- return function keys(object) {
- var isFunction = toStr.call(object) === '[object Function]';
- var isArguments = isArgumentsObject(object);
- var isString = toStr.call(object) === '[object String]';
- var theKeys = [];
-
- if (object === undefined || object === null) {
- throw new TypeError('Cannot convert undefined or null to object');
+// _ESAbstract.SameValueZero
+/* global Type, SameValueNonNumber */
+// 7.2.11. SameValueZero ( x, y )
+function SameValueZero (x, y) { // eslint-disable-line no-unused-vars
+ // 1. If Type(x) is different from Type(y), return false.
+ if (Type(x) !== Type(y)) {
+ return false;
+ }
+ // 2. If Type(x) is Number, then
+ if (Type(x) === 'number') {
+ // a. If x is NaN and y is NaN, return true.
+ if (isNaN(x) && isNaN(y)) {
+ return true;
}
-
- var skipProto = hasProtoEnumBug && isFunction;
- if (isString && object.length > 0 && !has.call(object, 0)) {
- for (var i = 0; i < object.length; ++i) {
- theKeys.push(String(i));
- }
+ // b. If x is +0 and y is -0, return true.
+ if (1/x === Infinity && 1/y === -Infinity) {
+ return true;
}
-
- if (isArguments && object.length > 0) {
- for (var j = 0; j < object.length; ++j) {
- theKeys.push(String(j));
- }
- } else {
- for (var name in object) {
- if (!(skipProto && name === 'prototype') && has.call(object, name)) {
- theKeys.push(String(name));
- }
- }
+ // c. If x is -0 and y is +0, return true.
+ if (1/x === -Infinity && 1/y === Infinity) {
+ return true;
}
+ // d. If x is the same Number value as y, return true.
+ if (x === y) {
+ return true;
+ }
+ // e. Return false.
+ return false;
+ }
+ // 3. Return SameValueNonNumber(x, y).
+ return SameValueNonNumber(x, y);
+}
- if (hasDontEnumBug) {
- var skipConstructor = equalsConstructorPrototypeIfNotBuggy(object);
-
- for (var k = 0; k < dontEnums.length; ++k) {
- if (!(skipConstructor && dontEnums[k] === 'constructor') && has.call(object, dontEnums[k])) {
- theKeys.push(dontEnums[k]);
- }
+// _ESAbstract.ToPrimitive
+/* global Type, GetMethod, Call, OrdinaryToPrimitive */
+// 7.1.1. ToPrimitive ( input [ , PreferredType ] )
+function ToPrimitive(input /* [, PreferredType] */) { // eslint-disable-line no-unused-vars
+ var PreferredType = arguments.length > 1 ? arguments[1] : undefined;
+ // 1. Assert: input is an ECMAScript language value.
+ // 2. If Type(input) is Object, then
+ if (Type(input) === 'object') {
+ // a. If PreferredType is not present, let hint be "default".
+ if (arguments.length < 2) {
+ var hint = 'default';
+ // b. Else if PreferredType is hint String, let hint be "string".
+ } else if (PreferredType === String) {
+ hint = 'string';
+ // c. Else PreferredType is hint Number, let hint be "number".
+ } else if (PreferredType === Number) {
+ hint = 'number';
+ }
+ // d. Let exoticToPrim be ? GetMethod(input, @@toPrimitive).
+ var exoticToPrim = typeof this.Symbol === 'function' && typeof this.Symbol.toPrimitive === 'symbol' ? GetMethod(input, this.Symbol.toPrimitive) : undefined;
+ // e. If exoticToPrim is not undefined, then
+ if (exoticToPrim !== undefined) {
+ // i. Let result be ? Call(exoticToPrim, input, « hint »).
+ var result = Call(exoticToPrim, input, [hint]);
+ // ii. If Type(result) is not Object, return result.
+ if (Type(result) !== 'object') {
+ return result;
}
+ // iii. Throw a TypeError exception.
+ throw new TypeError('Cannot convert exotic object to primitive.');
}
- return theKeys;
- };
-}());
-
+ // f. If hint is "default", set hint to "number".
+ if (hint === 'default') {
+ hint = 'number';
+ }
+ // g. Return ? OrdinaryToPrimitive(input, hint).
+ return OrdinaryToPrimitive(input, hint);
+ }
+ // 3. Return input
+ return input;
}
-if (!('bind' in Function.prototype)) {
-
-// Function.prototype.bind
-/* global CreateMethodProperty, IsCallable */
-// 19.2.3.2. Function.prototype.bind ( thisArg, ...args )
-// https://github.com/es-shims/es5-shim/blob/d6d7ff1b131c7ba14c798cafc598bb6780d37d3b/es5-shim.js#L182
-CreateMethodProperty(Function.prototype, 'bind', function bind(that) { // .length is 1
- // add necessary es5-shim utilities
- var $Array = Array;
- var $Object = Object;
- var ArrayPrototype = $Array.prototype;
- var Empty = function Empty() { };
- var array_slice = ArrayPrototype.slice;
- var array_concat = ArrayPrototype.concat;
- var array_push = ArrayPrototype.push;
- var max = Math.max;
- // /add necessary es5-shim utilities
-
- // 1. Let Target be the this value.
- var target = this;
- // 2. If IsCallable(Target) is false, throw a TypeError exception.
- if (!IsCallable(target)) {
- throw new TypeError('Function.prototype.bind called on incompatible ' + target);
+// _ESAbstract.ToString
+/* global Type, ToPrimitive */
+// 7.1.12. ToString ( argument )
+// The abstract operation ToString converts argument to a value of type String according to Table 11:
+// Table 11: ToString Conversions
+/*
+|---------------|--------------------------------------------------------|
+| Argument Type | Result |
+|---------------|--------------------------------------------------------|
+| Undefined | Return "undefined". |
+|---------------|--------------------------------------------------------|
+| Null | Return "null". |
+|---------------|--------------------------------------------------------|
+| Boolean | If argument is true, return "true". |
+| | If argument is false, return "false". |
+|---------------|--------------------------------------------------------|
+| Number | Return NumberToString(argument). |
+|---------------|--------------------------------------------------------|
+| String | Return argument. |
+|---------------|--------------------------------------------------------|
+| Symbol | Throw a TypeError exception. |
+|---------------|--------------------------------------------------------|
+| Object | Apply the following steps: |
+| | Let primValue be ? ToPrimitive(argument, hint String). |
+| | Return ? ToString(primValue). |
+|---------------|--------------------------------------------------------|
+*/
+function ToString(argument) { // eslint-disable-line no-unused-vars
+ switch(Type(argument)) {
+ case 'symbol':
+ throw new TypeError('Cannot convert a Symbol value to a string');
+ break;
+ case 'object':
+ var primValue = ToPrimitive(argument, 'string');
+ return ToString(primValue);
+ default:
+ return String(argument);
}
- // 3. Let A be a new (possibly empty) internal list of all of the
- // argument values provided after thisArg (arg1, arg2 etc), in order.
- // XXX slicedArgs will stand in for "A" if used
- var args = array_slice.call(arguments, 1); // for normal call
- // 4. Let F be a new native ECMAScript object.
- // 11. Set the [[Prototype]] internal property of F to the standard
- // built-in Function prototype object as specified in 15.3.3.1.
- // 12. Set the [[Call]] internal property of F as described in
- // 15.3.4.5.1.
- // 13. Set the [[Construct]] internal property of F as described in
- // 15.3.4.5.2.
- // 14. Set the [[HasInstance]] internal property of F as described in
- // 15.3.4.5.3.
- var bound;
- var binder = function () {
-
- if (this instanceof bound) {
- // 15.3.4.5.2 [[Construct]]
- // When the [[Construct]] internal method of a function object,
- // F that was created using the bind function is called with a
- // list of arguments ExtraArgs, the following steps are taken:
- // 1. Let target be the value of F's [[TargetFunction]]
- // internal property.
- // 2. If target has no [[Construct]] internal method, a
- // TypeError exception is thrown.
- // 3. Let boundArgs be the value of F's [[BoundArgs]] internal
- // property.
- // 4. Let args be a new list containing the same values as the
- // list boundArgs in the same order followed by the same
- // values as the list ExtraArgs in the same order.
- // 5. Return the result of calling the [[Construct]] internal
- // method of target providing args as the arguments.
-
- var result = target.apply(
- this,
- array_concat.call(args, array_slice.call(arguments))
- );
- if ($Object(result) === result) {
- return result;
- }
- return this;
-
- } else {
- // 15.3.4.5.1 [[Call]]
- // When the [[Call]] internal method of a function object, F,
- // which was created using the bind function is called with a
- // this value and a list of arguments ExtraArgs, the following
- // steps are taken:
- // 1. Let boundArgs be the value of F's [[BoundArgs]] internal
- // property.
- // 2. Let boundThis be the value of F's [[BoundThis]] internal
- // property.
- // 3. Let target be the value of F's [[TargetFunction]] internal
- // property.
- // 4. Let args be a new list containing the same values as the
- // list boundArgs in the same order followed by the same
- // values as the list ExtraArgs in the same order.
- // 5. Return the result of calling the [[Call]] internal method
- // of target providing boundThis as the this value and
- // providing args as the arguments.
+}
- // equiv: target.call(this, ...boundArgs, ...args)
- return target.apply(
- that,
- array_concat.call(args, array_slice.call(arguments))
- );
+// _ESAbstract.UTF16Decode
+// 10.1.2. Static Semantics: UTF16Decode( lead, trail )
+function UTF16Decode(lead, trail) { // eslint-disable-line no-unused-vars
+ // 1. Assert: 0xD800 ≤ lead ≤ 0xDBFF and 0xDC00 ≤ trail ≤ 0xDFFF.
+ // 2. Let cp be (lead - 0xD800) × 0x400 + (trail - 0xDC00) + 0x10000.
+ var cp = (lead - 0xD800) * 0x400 + (trail - 0xDC00) + 0x10000;
+ // 3. Return the code point cp.
+ return cp;
+}
- }
+// _ESAbstract.UTF16Encoding
+// 10.1.1. Static Semantics: UTF16Encoding ( cp )
+function UTF16Encoding(cp) { // eslint-disable-line no-unused-vars
+ // 1. Assert: 0 ≤ cp ≤ 0x10FFFF.
+ // 2. If cp ≤ 0xFFFF, return cp.
+ if (cp <= 0xFFFF) {
+ return cp;
+ } else {
+ // 3. Let cu1 be floor((cp - 0x10000) / 0x400) + 0xD800.
+ var cu1 = Math.floor((cp - 0x10000) / 0x400) + 0xD800;
+ // 4. Let cu2 be ((cp - 0x10000) modulo 0x400) + 0xDC00.
+ var cu2 = ((cp - 0x10000) % 0x400) + 0xDC00;
+ // 5. Return the code unit sequence consisting of cu1 followed by cu2.
+ return [cu1, cu2];
+ }
+}
- };
+// _TypedArray
+/*
+ Copyright (c) 2010, Linden Research, Inc.
+ Copyright (c) 2014, Joshua Bell
- // 15. If the [[Class]] internal property of Target is "Function", then
- // a. Let L be the length property of Target minus the length of A.
- // b. Set the length own property of F to either 0 or L, whichever is
- // larger.
- // 16. Else set the length own property of F to 0.
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
- var boundLength = max(0, target.length - args.length);
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
- // 17. Set the attributes of the length own property of F to the values
- // specified in 15.3.5.1.
- var boundArgs = [];
- for (var i = 0; i < boundLength; i++) {
- array_push.call(boundArgs, '$' + i);
- }
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
+ $/LicenseInfo$
+ */
- // XXX Build a dynamic function with desired amount of arguments is the only
- // way to set the length property of a function.
- // In environments where Content Security Policies enabled (Chrome extensions,
- // for ex.) all use of eval or Function costructor throws an exception.
- // However in all of these environments Function.prototype.bind exists
- // and so this code will never be executed.
- bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this, arguments); }')(binder);
+// Original can be found at:
+// https://bitbucket.org/lindenlab/llsd
+// Modifications by Joshua Bell inexorabletash@gmail.com
+// https://github.com/inexorabletash/polyfill
- if (target.prototype) {
- Empty.prototype = target.prototype;
- bound.prototype = new Empty();
- // Clean up dangling references.
- Empty.prototype = null;
- }
+// ES3/ES5 implementation of the Krhonos Typed Array Specification
+// Ref: http://www.khronos.org/registry/typedarray/specs/latest/
+// Date: 2011-02-01
+//
+// Variations:
+// * Allows typed_array.get/set() as alias for subscripts (typed_array[])
+// * Gradually migrating structure from Khronos spec to ES2015 spec
+//
+// Caveats:
+// * Beyond 10000 or so entries, polyfilled array accessors (ta[0],
+// etc) become memory-prohibitive, so array creation will fail. Set
+// self.TYPED_ARRAY_POLYFILL_NO_ARRAY_ACCESSORS=true to disable
+// creation of accessors. Your code will need to use the
+// non-standard get()/set() instead, and will need to add those to
+// native arrays for interop.
+(function(global) {
+ 'use strict';
+ var undefined = (void 0); // Paranoia
- // TODO
- // 18. Set the [[Extensible]] internal property of F to true.
+ // Beyond this value, index getters/setters (i.e. array[0], array[1]) are so slow to
+ // create, and consume so much memory, that the browser appears frozen.
+ var MAX_ARRAY_LENGTH = 1e5;
- // TODO
- // 19. Let thrower be the [[ThrowTypeError]] function Object (13.2.3).
- // 20. Call the [[DefineOwnProperty]] internal method of F with
- // arguments "caller", PropertyDescriptor {[[Get]]: thrower, [[Set]]:
- // thrower, [[Enumerable]]: false, [[Configurable]]: false}, and
- // false.
- // 21. Call the [[DefineOwnProperty]] internal method of F with
- // arguments "arguments", PropertyDescriptor {[[Get]]: thrower,
- // [[Set]]: thrower, [[Enumerable]]: false, [[Configurable]]: false},
- // and false.
+ // Approximations of internal ECMAScript conversion functions
+ function Type(v) {
+ switch(typeof v) {
+ case 'undefined': return 'undefined';
+ case 'boolean': return 'boolean';
+ case 'number': return 'number';
+ case 'string': return 'string';
+ default: return v === null ? 'null' : 'object';
+ }
+ }
- // TODO
- // NOTE Function objects created using Function.prototype.bind do not
- // have a prototype property or the [[Code]], [[FormalParameters]], and
- // [[Scope]] internal properties.
- // XXX can't delete prototype in pure-js.
+ // Class returns internal [[Class]] property, used to avoid cross-frame instanceof issues:
+ function Class(v) { return Object.prototype.toString.call(v).replace(/^\[object *|\]$/g, ''); }
+ function IsCallable(o) { return typeof o === 'function'; }
+ function ToObject(v) {
+ if (v === null || v === undefined) throw TypeError();
+ return Object(v);
+ }
+ function ToInt32(v) { return v >> 0; }
+ function ToUint32(v) { return v >>> 0; }
- // 22. Return F.
- return bound;
-});
+ // Snapshot intrinsics
+ var LN2 = Math.LN2,
+ abs = Math.abs,
+ floor = Math.floor,
+ log = Math.log,
+ max = Math.max,
+ min = Math.min,
+ pow = Math.pow,
+ round = Math.round;
-}
+ // emulate ES5 getter/setter API using legacy APIs
+ // http://blogs.msdn.com/b/ie/archive/2010/09/07/transitioning-existing-code-to-the-es5-getter-setter-apis.aspx
+ // (second clause tests for Object.defineProperty() in IE<9 that only supports extending DOM prototypes, but
+ // note that IE<9 does not support __defineGetter__ or __defineSetter__ so it just renders the method harmless)
-if (!('getOwnPropertyDescriptor' in Object && typeof Object.getOwnPropertyDescriptor === 'function' && (function() {
- try {
- var object = {};
- object.test = 0;
- return Object.getOwnPropertyDescriptor(
- object,
- "test"
- ).value === 0;
- } catch (exception) {
- return false
- }
-}()))) {
+ (function() {
+ var orig = Object.defineProperty;
+ var dom_only = !(function(){try{return Object.defineProperty({},'x',{});}catch(_){return false;}}());
-// Object.getOwnPropertyDescriptor
-/* global CreateMethodProperty */
-(function () {
- var call = Function.prototype.call;
- var prototypeOfObject = Object.prototype;
- var owns = call.bind(prototypeOfObject.hasOwnProperty);
+ if (!orig || dom_only) {
+ Object.defineProperty = function (o, prop, desc) {
+ // In IE8 try built-in implementation for defining properties on DOM prototypes.
+ if (orig)
+ try { return orig(o, prop, desc); } catch (_) {}
+ if (o !== Object(o))
+ throw TypeError('Object.defineProperty called on non-object');
+ if (Object.prototype.__defineGetter__ && ('get' in desc))
+ Object.prototype.__defineGetter__.call(o, prop, desc.get);
+ if (Object.prototype.__defineSetter__ && ('set' in desc))
+ Object.prototype.__defineSetter__.call(o, prop, desc.set);
+ if ('value' in desc)
+ o[prop] = desc.value;
+ return o;
+ };
+ }
+ }());
- var lookupGetter;
- var lookupSetter;
- var supportsAccessors;
- if ((supportsAccessors = owns(prototypeOfObject, "__defineGetter__"))) {
- lookupGetter = call.bind(prototypeOfObject.__lookupGetter__);
- lookupSetter = call.bind(prototypeOfObject.__lookupSetter__);
- }
- function doesGetOwnPropertyDescriptorWork(object) {
- try {
- object.sentinel = 0;
- return Object.getOwnPropertyDescriptor(
- object,
- "sentinel"
- ).value === 0;
- } catch (exception) {
- // returns falsy
- }
- }
- // check whether getOwnPropertyDescriptor works if it's given. Otherwise,
- // shim partially.
- if (Object.defineProperty) {
- var getOwnPropertyDescriptorWorksOnObject =
- doesGetOwnPropertyDescriptorWork({});
- var getOwnPropertyDescriptorWorksOnDom = typeof document == "undefined" ||
- doesGetOwnPropertyDescriptorWork(document.createElement("div"));
- if (!getOwnPropertyDescriptorWorksOnDom ||
- !getOwnPropertyDescriptorWorksOnObject
- ) {
- var getOwnPropertyDescriptorFallback = Object.getOwnPropertyDescriptor;
- }
- }
+ // ES5: Make obj[index] an alias for obj._getter(index)/obj._setter(index, value)
+ // for index in 0 ... obj.length
+ function makeArrayAccessors(obj) {
+ if ('TYPED_ARRAY_POLYFILL_NO_ARRAY_ACCESSORS' in global)
+ return;
- if (!Object.getOwnPropertyDescriptor || getOwnPropertyDescriptorFallback) {
- var ERR_NON_OBJECT = "Object.getOwnPropertyDescriptor called on a non-object: ";
+ if (obj.length > MAX_ARRAY_LENGTH) throw RangeError('Array too large for polyfill');
- CreateMethodProperty(Object, 'getOwnPropertyDescriptor', function getOwnPropertyDescriptor(object, property) {
- if ((typeof object != "object" && typeof object != "function") || object === null) {
- throw new TypeError(ERR_NON_OBJECT + object);
- }
+ function makeArrayAccessor(index) {
+ Object.defineProperty(obj, index, {
+ 'get': function() { return obj._getter(index); },
+ 'set': function(v) { obj._setter(index, v); },
+ enumerable: true,
+ configurable: false
+ });
+ }
- // make a valiant attempt to use the real getOwnPropertyDescriptor
- // for I8's DOM elements.
- if (getOwnPropertyDescriptorFallback) {
- try {
- return getOwnPropertyDescriptorFallback.call(Object, object, property);
- } catch (exception) {
- // try the shim if the real one doesn't work
- }
- }
+ var i;
+ for (i = 0; i < obj.length; i += 1) {
+ makeArrayAccessor(i);
+ }
+ }
- // If object does not owns property return undefined immediately.
- if (!owns(object, property)) {
- return;
- }
+ // Internal conversion functions:
+ // pack<Type>() - take a number (interpreted as Type), output a byte array
+ // unpack<Type>() - take a byte array, output a Type-like number
- // If object has a property then it's for sure both `enumerable` and
- // `configurable`.
- var descriptor = { enumerable: true, configurable: true };
+ function as_signed(value, bits) { var s = 32 - bits; return (value << s) >> s; }
+ function as_unsigned(value, bits) { var s = 32 - bits; return (value << s) >>> s; }
- // If JS engine supports accessor properties then property may be a
- // getter or setter.
- if (supportsAccessors) {
- // Unfortunately `__lookupGetter__` will return a getter even
- // if object has own non getter property along with a same named
- // inherited getter. To avoid misbehavior we temporary remove
- // `__proto__` so that `__lookupGetter__` will return getter only
- // if it's owned by an object.
- var prototype = object.__proto__;
- object.__proto__ = prototypeOfObject;
+ function packI8(n) { return [n & 0xff]; }
+ function unpackI8(bytes) { return as_signed(bytes[0], 8); }
- var getter = lookupGetter(object, property);
- var setter = lookupSetter(object, property);
+ function packU8(n) { return [n & 0xff]; }
+ function unpackU8(bytes) { return as_unsigned(bytes[0], 8); }
- // Once we have getter and setter we can put values back.
- object.__proto__ = prototype;
+ function packU8Clamped(n) { n = round(Number(n)); return [n < 0 ? 0 : n > 0xff ? 0xff : n & 0xff]; }
- if (getter || setter) {
- if (getter) {
- descriptor.get = getter;
- }
- if (setter) {
- descriptor.set = setter;
- }
- // If it was accessor property we're done and return here
- // in order to avoid adding `value` to the descriptor.
- return descriptor;
- }
- }
+ function packI16(n) { return [n & 0xff, (n >> 8) & 0xff]; }
+ function unpackI16(bytes) { return as_signed(bytes[1] << 8 | bytes[0], 16); }
- // If we got this far we know that object has an own property that is
- // not an accessor so we set it as a value and return descriptor.
- descriptor.value = object[property];
- descriptor.writable = true;
- return descriptor;
- });
- }
-}());
+ function packU16(n) { return [n & 0xff, (n >> 8) & 0xff]; }
+ function unpackU16(bytes) { return as_unsigned(bytes[1] << 8 | bytes[0], 16); }
-}
+ function packI32(n) { return [n & 0xff, (n >> 8) & 0xff, (n >> 16) & 0xff, (n >> 24) & 0xff]; }
+ function unpackI32(bytes) { return as_signed(bytes[3] << 24 | bytes[2] << 16 | bytes[1] << 8 | bytes[0], 32); }
-if (!('defineProperties' in Object)) {
+ function packU32(n) { return [n & 0xff, (n >> 8) & 0xff, (n >> 16) & 0xff, (n >> 24) & 0xff]; }
+ function unpackU32(bytes) { return as_unsigned(bytes[3] << 24 | bytes[2] << 16 | bytes[1] << 8 | bytes[0], 32); }
-// Object.defineProperties
-/* global CreateMethodProperty, Get, ToObject, Type */
-// 19.1.2.3. Object.defineProperties ( O, Properties )
-CreateMethodProperty(Object, 'defineProperties', function defineProperties(O, Properties) {
- // 1. If Type(O) is not Object, throw a TypeError exception.
- if (Type(O) !== 'object') {
- throw new TypeError('Object.defineProperties called on non-object');
- }
- // 2. Let props be ? ToObject(Properties).
- var props = ToObject(Properties);
- // 3. Let keys be ? props.[[OwnPropertyKeys]]().
- /*
- Polyfill.io - This step in our polyfill is not complying with the specification.
- [[OwnPropertyKeys]] is meant to return ALL keys, including non-enumerable and symbols.
- TODO: When we have Reflect.ownKeys, use that instead as it is the userland equivalent of [[OwnPropertyKeys]].
- */
- var keys = Object.keys(props);
- // 4. Let descriptors be a new empty List.
- var descriptors = [];
- // 5. For each element nextKey of keys in List order, do
- for (var i = 0; i < keys.length; i++) {
- var nextKey = keys[i];
- // a. Let propDesc be ? props.[[GetOwnProperty]](nextKey).
- var propDesc = Object.getOwnPropertyDescriptor(props, nextKey);
- // b. If propDesc is not undefined and propDesc.[[Enumerable]] is true, then
- if (propDesc !== undefined && propDesc.enumerable) {
- // i. Let descObj be ? Get(props, nextKey).
- var descObj = Get(props, nextKey);
- // ii. Let desc be ? ToPropertyDescriptor(descObj).
- // Polyfill.io - We skip this step because Object.defineProperty deals with it.
- // TODO: Implement this step?
- var desc = descObj;
- // iii. Append the pair (a two element List) consisting of nextKey and desc to the end of descriptors.
- descriptors.push([nextKey, desc]);
- }
- }
- // 6. For each pair from descriptors in list order, do
- for (var i = 0; i < descriptors.length; i++){
- // a. Let P be the first element of pair.
- var P = descriptors[i][0];
- // b. Let desc be the second element of pair.
- var desc = descriptors[i][1];
- // c. Perform ? DefinePropertyOrThrow(O, P, desc).
- Object.defineProperty(O, P, desc);
- }
- // 7. Return O.
- return O;
-});
+ function packIEEE754(v, ebits, fbits) {
-}
+ var bias = (1 << (ebits - 1)) - 1;
-if (!('create' in Object)) {
+ function roundToEven(n) {
+ var w = floor(n), f = n - w;
+ if (f < 0.5)
+ return w;
+ if (f > 0.5)
+ return w + 1;
+ return w % 2 ? w + 1 : w;
+ }
-// Object.create
-/* global CreateMethodProperty, Type */
-CreateMethodProperty(Object, 'create', function create(O, properties) {
- // 1. If Type(O) is neither Object nor Null, throw a TypeError exception.
- if (Type(O) !== 'object' && Type(O) !== 'null') {
- throw new TypeError('Object prototype may only be an Object or null');
- }
- // 2. Let obj be ObjectCreate(O).
- var obj = new Function('e', 'function Object() {}Object.prototype=e;return new Object')(O);
+ // Compute sign, exponent, fraction
+ var s, e, f;
+ if (v !== v) {
+ // NaN
+ // http://dev.w3.org/2006/webapi/WebIDL/#es-type-mapping
+ e = (1 << ebits) - 1; f = pow(2, fbits - 1); s = 0;
+ } else if (v === Infinity || v === -Infinity) {
+ e = (1 << ebits) - 1; f = 0; s = (v < 0) ? 1 : 0;
+ } else if (v === 0) {
+ e = 0; f = 0; s = (1 / v === -Infinity) ? 1 : 0;
+ } else {
+ s = v < 0;
+ v = abs(v);
- obj.constructor.prototype = O;
+ if (v >= pow(2, 1 - bias)) {
+ // Normalized
+ e = min(floor(log(v) / LN2), 1023);
+ var significand = v / pow(2, e);
+ if (significand < 1) {
+ e -= 1;
+ significand *= 2;
+ }
+ if (significand >= 2) {
+ e += 1;
+ significand /= 2;
+ }
+ var d = pow(2, fbits);
+ f = roundToEven(significand * d) - d;
+ e += bias;
+ if (f / d >= 1) {
+ e += 1;
+ f = 0;
+ }
+ if (e > 2 * bias) {
+ // Overflow
+ e = (1 << ebits) - 1;
+ f = 0;
+ }
+ } else {
+ // Denormalized
+ e = 0;
+ f = roundToEven(v / pow(2, 1 - bias - fbits));
+ }
+ }
- // 3. If Properties is not undefined, then
- if (1 in arguments) {
- // a. Return ? ObjectDefineProperties(obj, Properties).
- return Object.defineProperties(obj, properties);
- }
+ // Pack sign, exponent, fraction
+ var bits = [], i;
+ for (i = fbits; i; i -= 1) { bits.push(f % 2 ? 1 : 0); f = floor(f / 2); }
+ for (i = ebits; i; i -= 1) { bits.push(e % 2 ? 1 : 0); e = floor(e / 2); }
+ bits.push(s ? 1 : 0);
+ bits.reverse();
+ var str = bits.join('');
- return obj;
-});
+ // Bits to bytes
+ var bytes = [];
+ while (str.length) {
+ bytes.unshift(parseInt(str.substring(0, 8), 2));
+ str = str.substring(8);
+ }
+ return bytes;
+ }
-}
+ function unpackIEEE754(bytes, ebits, fbits) {
+ // Bytes to bits
+ var bits = [], i, j, b, str,
+ bias, s, e, f;
-if (!('getPrototypeOf' in Object)) {
+ for (i = 0; i < bytes.length; ++i) {
+ b = bytes[i];
+ for (j = 8; j; j -= 1) {
+ bits.push(b % 2 ? 1 : 0); b = b >> 1;
+ }
+ }
+ bits.reverse();
+ str = bits.join('');
-// Object.getPrototypeOf
-/* global CreateMethodProperty */
-// Based on: https://github.com/es-shims/es5-shim/blob/master/es5-sham.js
+ // Unpack sign, exponent, fraction
+ bias = (1 << (ebits - 1)) - 1;
+ s = parseInt(str.substring(0, 1), 2) ? -1 : 1;
+ e = parseInt(str.substring(1, 1 + ebits), 2);
+ f = parseInt(str.substring(1 + ebits), 2);
-// https://github.com/es-shims/es5-shim/issues#issue/2
-// http://ejohn.org/blog/objectgetprototypeof/
-// recommended by fschaefer on github
-//
-// sure, and webreflection says ^_^
-// ... this will nerever possibly return null
-// ... Opera Mini breaks here with infinite loops
-CreateMethodProperty(Object, 'getPrototypeOf', function getPrototypeOf(object) {
- if (object !== Object(object)) {
- throw new TypeError('Object.getPrototypeOf called on non-object');
- }
- var proto = object.__proto__;
- if (proto || proto === null) {
- return proto;
- } else if (typeof object.constructor == 'function' && object instanceof object.constructor) {
- return object.constructor.prototype;
- } else if (object instanceof Object) {
- return Object.prototype;
- } else {
- // Correctly return null for Objects created with `Object.create(null)`
- // (shammed or native) or `{ __proto__: null}`. Also returns null for
- // cross-realm objects on browsers that lack `__proto__` support (like
- // IE <11), but that's the best we can do.
- return null;
- }
-});
+ // Produce number
+ if (e === (1 << ebits) - 1) {
+ return f !== 0 ? NaN : s * Infinity;
+ } else if (e > 0) {
+ // Normalized
+ return s * pow(2, e - bias) * (1 + f / pow(2, fbits));
+ } else if (f !== 0) {
+ // Denormalized
+ return s * pow(2, -(bias - 1)) * (f / pow(2, fbits));
+ } else {
+ return s < 0 ? -0 : 0;
+ }
+ }
-}
+ function unpackF64(b) { return unpackIEEE754(b, 11, 52); }
+ function packF64(v) { return packIEEE754(v, 11, 52); }
+ function unpackF32(b) { return unpackIEEE754(b, 8, 23); }
+ function packF32(v) { return packIEEE754(v, 8, 23); }
+ //
+ // 3 The ArrayBuffer Type
+ //
-// _ESAbstract.OrdinaryCreateFromConstructor
-/* global GetPrototypeFromConstructor */
-// 9.1.13. OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto [ , internalSlotsList ] )
-function OrdinaryCreateFromConstructor(constructor, intrinsicDefaultProto) { // eslint-disable-line no-unused-vars
- var internalSlotsList = arguments[2] || {};
- // 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.
+ (function() {
- // 2. Let proto be ? GetPrototypeFromConstructor(constructor, intrinsicDefaultProto).
- var proto = GetPrototypeFromConstructor(constructor, intrinsicDefaultProto);
+ function ArrayBuffer(length) {
+ length = ToInt32(length);
+ if (length < 0) throw RangeError('ArrayBuffer size is not a small enough positive integer.');
+ Object.defineProperty(this, 'byteLength', {value: length});
+ Object.defineProperty(this, '_bytes', {value: Array(length)});
- // 3. Return ObjectCreate(proto, internalSlotsList).
- // 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.
- var obj = Object.create(proto);
- for (var name in internalSlotsList) {
- if (Object.prototype.hasOwnProperty.call(internalSlotsList, name)) {
- Object.defineProperty(obj, name, {
- configurable: true,
- enumerable: false,
- writable: true,
- value: internalSlotsList[name]
- });
- }
- }
- return obj;
-}
+ for (var i = 0; i < length; i += 1)
+ this._bytes[i] = 0;
+ }
-// _ESAbstract.Construct
-/* global IsConstructor, OrdinaryCreateFromConstructor, Call */
-// 7.3.13. Construct ( F [ , argumentsList [ , newTarget ]] )
-function Construct(F /* [ , argumentsList [ , newTarget ]] */) { // eslint-disable-line no-unused-vars
- // 1. If newTarget is not present, set newTarget to F.
- var newTarget = arguments.length > 2 ? arguments[2] : F;
+ global.ArrayBuffer = global.ArrayBuffer || ArrayBuffer;
- // 2. If argumentsList is not present, set argumentsList to a new empty List.
- var argumentsList = arguments.length > 1 ? arguments[1] : [];
+ //
+ // 5 The Typed Array View Types
+ //
- // 3. Assert: IsConstructor(F) is true.
- if (!IsConstructor(F)) {
- throw new TypeError('F must be a constructor.');
- }
+ function $TypedArray$() {
- // 4. Assert: IsConstructor(newTarget) is true.
- if (!IsConstructor(newTarget)) {
- throw new TypeError('newTarget must be a constructor.');
- }
+ // %TypedArray% ( length )
+ if (!arguments.length || typeof arguments[0] !== 'object') {
+ return (function(length) {
+ length = ToInt32(length);
+ if (length < 0) throw RangeError('length is not a small enough positive integer.');
+ Object.defineProperty(this, 'length', {value: length});
+ Object.defineProperty(this, 'byteLength', {value: length * this.BYTES_PER_ELEMENT});
+ Object.defineProperty(this, 'buffer', {value: new ArrayBuffer(this.byteLength)});
+ Object.defineProperty(this, 'byteOffset', {value: 0});
- // 5. Return ? F.[[Construct]](argumentsList, newTarget).
- // Polyfill.io - If newTarget is the same as F, it is equivalent to new F(...argumentsList).
- if (newTarget === F) {
- return new (Function.prototype.bind.apply(F, [null].concat(argumentsList)))();
- } else {
- // Polyfill.io - This is mimicking section 9.2.2 step 5.a.
- var obj = OrdinaryCreateFromConstructor(newTarget, Object.prototype);
- return Call(F, obj, argumentsList);
- }
-}
+ }).apply(this, arguments);
+ }
-// _ESAbstract.ArraySpeciesCreate
-/* global IsArray, ArrayCreate, Get, Type, IsConstructor, Construct */
-// 9.4.2.3. ArraySpeciesCreate ( originalArray, length )
-function ArraySpeciesCreate(originalArray, length) { // eslint-disable-line no-unused-vars
- // 1. Assert: length is an integer Number ≥ 0.
- // 2. If length is -0, set length to +0.
- if (1/length === -Infinity) {
- length = 0;
- }
+ // %TypedArray% ( typedArray )
+ if (arguments.length >= 1 &&
+ Type(arguments[0]) === 'object' &&
+ arguments[0] instanceof $TypedArray$) {
+ return (function(typedArray){
+ if (this.constructor !== typedArray.constructor) throw TypeError();
- // 3. Let isArray be ? IsArray(originalArray).
- var isArray = IsArray(originalArray);
+ var byteLength = typedArray.length * this.BYTES_PER_ELEMENT;
+ Object.defineProperty(this, 'buffer', {value: new ArrayBuffer(byteLength)});
+ Object.defineProperty(this, 'byteLength', {value: byteLength});
+ Object.defineProperty(this, 'byteOffset', {value: 0});
+ Object.defineProperty(this, 'length', {value: typedArray.length});
- // 4. If isArray is false, return ? ArrayCreate(length).
- if (isArray === false) {
- return ArrayCreate(length);
- }
+ for (var i = 0; i < this.length; i += 1)
+ this._setter(i, typedArray._getter(i));
- // 5. Let C be ? Get(originalArray, "constructor").
- var C = Get(originalArray, 'constructor');
+ }).apply(this, arguments);
+ }
- // Polyfill.io - We skip this section as not sure how to make a cross-realm normal Array, a same-realm Array.
- // 6. If IsConstructor(C) is true, then
- // if (IsConstructor(C)) {
- // a. Let thisRealm be the current Realm Record.
- // b. Let realmC be ? GetFunctionRealm(C).
- // c. If thisRealm and realmC are not the same Realm Record, then
- // i. If SameValue(C, realmC.[[Intrinsics]].[[%Array%]]) is true, set C to undefined.
- // }
- // 7. If Type(C) is Object, then
- if (Type(C) === 'object') {
- // a. Set C to ? Get(C, @@species).
- C = 'Symbol' in this && 'species' in this.Symbol ? Get(C, this.Symbol.species) : undefined;
- // b. If C is null, set C to undefined.
- if (C === null) {
- C = undefined;
- }
- }
- // 8. If C is undefined, return ? ArrayCreate(length).
- if (C === undefined) {
- return ArrayCreate(length);
- }
- // 9. If IsConstructor(C) is false, throw a TypeError exception.
- if (!IsConstructor(C)) {
- throw new TypeError('C must be a constructor');
- }
- // 10. Return ? Construct(C, « length »).
- return Construct(C, [length]);
-}
+ // %TypedArray% ( array )
+ if (arguments.length >= 1 &&
+ Type(arguments[0]) === 'object' &&
+ !(arguments[0] instanceof $TypedArray$) &&
+ !(arguments[0] instanceof ArrayBuffer || Class(arguments[0]) === 'ArrayBuffer')) {
+ return (function(array) {
-// _ESAbstract.ToBoolean
-// 7.1.2. ToBoolean ( argument )
-// The abstract operation ToBoolean converts argument to a value of type Boolean according to Table 9:
-/*
---------------------------------------------------------------------------------------------------------------
-| Argument Type | Result |
---------------------------------------------------------------------------------------------------------------
-| Undefined | Return false. |
-| Null | Return false. |
-| Boolean | Return argument. |
-| Number | If argument is +0, -0, or NaN, return false; otherwise return true. |
-| String | If argument is the empty String (its length is zero), return false; otherwise return true. |
-| Symbol | Return true. |
-| Object | Return true. |
---------------------------------------------------------------------------------------------------------------
-*/
-function ToBoolean(argument) { // eslint-disable-line no-unused-vars
- return Boolean(argument);
-}
+ var byteLength = array.length * this.BYTES_PER_ELEMENT;
+ Object.defineProperty(this, 'buffer', {value: new ArrayBuffer(byteLength)});
+ Object.defineProperty(this, 'byteLength', {value: byteLength});
+ Object.defineProperty(this, 'byteOffset', {value: 0});
+ Object.defineProperty(this, 'length', {value: array.length});
-// _ESAbstract.CreateDataProperty
-// 7.3.4. CreateDataProperty ( O, P, V )
-// NOTE
-// This abstract operation creates a property whose attributes are set to the same defaults used for properties created by the ECMAScript language assignment operator.
-// 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.
-function CreateDataProperty(O, P, V) { // eslint-disable-line no-unused-vars
- // 1. Assert: Type(O) is Object.
- // 2. Assert: IsPropertyKey(P) is true.
- // 3. Let newDesc be the PropertyDescriptor{ [[Value]]: V, [[Writable]]: true, [[Enumerable]]: true, [[Configurable]]: true }.
- var newDesc = {
- value: V,
- writable: true,
- enumerable: true,
- configurable: true
- };
- // 4. Return ? O.[[DefineOwnProperty]](P, newDesc).
- try {
- Object.defineProperty(O, P, newDesc);
- return true;
- } catch (e) {
- return false;
- }
-}
-
-// _ESAbstract.CreateDataPropertyOrThrow
-/* global CreateDataProperty */
-// 7.3.6. CreateDataPropertyOrThrow ( O, P, V )
-function CreateDataPropertyOrThrow(O, P, V) { // eslint-disable-line no-unused-vars
- // 1. Assert: Type(O) is Object.
- // 2. Assert: IsPropertyKey(P) is true.
- // 3. Let success be ? CreateDataProperty(O, P, V).
- var success = CreateDataProperty(O, P, V);
- // 4. If success is false, throw a TypeError exception.
- if (!success) {
- 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) + '`');
- }
- // 5. Return success.
- return success;
-}
-if (!('filter' in Array.prototype)) {
+ for (var i = 0; i < this.length; i += 1) {
+ var s = array[i];
+ this._setter(i, Number(s));
+ }
+ }).apply(this, arguments);
+ }
-// Array.prototype.filter
-/* global CreateMethodProperty, ToObject, ToLength, Get, IsCallable, ArraySpeciesCreate, ToString, HasProperty, ToBoolean, Call, CreateDataPropertyOrThrow */
-// 22.1.3.7. Array.prototype.filter ( callbackfn [ , thisArg ] )
-CreateMethodProperty(Array.prototype, 'filter', function filter(callbackfn /* [ , thisArg ] */) {
- // 1. Let O be ? ToObject(this value).
- var O = ToObject(this);
- // 2. Let len be ? ToLength(? Get(O, "length")).
- var len = ToLength(Get(O, "length"));
- // 3. If IsCallable(callbackfn) is false, throw a TypeError exception.
- if (IsCallable(callbackfn) === false) {
- throw new TypeError(callbackfn + ' is not a function');
- }
- // 4. If thisArg is present, let T be thisArg; else let T be undefined.
- var T = arguments.length > 1 ? arguments[1] : undefined;
- // 5. Let A be ? ArraySpeciesCreate(O, 0).
- var A = ArraySpeciesCreate(O, 0);
- // 6. Let k be 0.
- var k = 0;
- // 7. Let to be 0.
- var to = 0;
- // 8. Repeat, while k < len
- while (k < len) {
- // a. Let Pk be ! ToString(k).
- var Pk = ToString(k);
- // b. Let kPresent be ? HasProperty(O, Pk).
- var kPresent = HasProperty(O, Pk);
- // c. If kPresent is true, then
- if (kPresent) {
- // i. Let kValue be ? Get(O, Pk).
- var kValue = Get(O, Pk);
- // ii. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
- var selected = ToBoolean(Call(callbackfn, T, [kValue, k, O]));
- // iii. If selected is true, then
- if (selected) {
- // 1. Perform ? CreateDataPropertyOrThrow(A, ! ToString(to), kValue)
- CreateDataPropertyOrThrow(A, ToString(to), kValue);
- // 2. Increase to by 1.
- to = to + 1;
- }
+ // %TypedArray% ( buffer, byteOffset=0, length=undefined )
+ if (arguments.length >= 1 &&
+ Type(arguments[0]) === 'object' &&
+ (arguments[0] instanceof ArrayBuffer || Class(arguments[0]) === 'ArrayBuffer')) {
+ return (function(buffer, byteOffset, length) {
- }
- // d. Increase k by 1.
- k = k + 1;
- }
- // 9. Return A.
- return A;
-});
+ byteOffset = ToUint32(byteOffset);
+ if (byteOffset > buffer.byteLength)
+ throw RangeError('byteOffset out of range');
-}
+ // The given byteOffset must be a multiple of the element
+ // size of the specific type, otherwise an exception is raised.
+ if (byteOffset % this.BYTES_PER_ELEMENT)
+ throw RangeError('buffer length minus the byteOffset is not a multiple of the element size.');
-if (!('map' in Array.prototype)) {
+ if (length === undefined) {
+ var byteLength = buffer.byteLength - byteOffset;
+ if (byteLength % this.BYTES_PER_ELEMENT)
+ throw RangeError('length of buffer minus byteOffset not a multiple of the element size');
+ length = byteLength / this.BYTES_PER_ELEMENT;
-// Array.prototype.map
-/* global ArraySpeciesCreate, Call, CreateDataPropertyOrThrow, CreateMethodProperty, Get, HasProperty, IsCallable, ToLength, ToObject, ToString */
-/* global CreateMethodProperty, ToObject, ToLength, Get, ArraySpeciesCreate, ToString, HasProperty, Call, CreateDataPropertyOrThrow */
-// 22.1.3.16. Array.prototype.map ( callbackfn [ , thisArg ] )
-CreateMethodProperty(Array.prototype, 'map', function map(callbackfn /* [ , thisArg ] */) {
- // 1. Let O be ? ToObject(this value).
- var O = ToObject(this);
- // 2. Let len be ? ToLength(? Get(O, "length")).
- var len = ToLength(Get(O, "length"));
- // 3. If IsCallable(callbackfn) is false, throw a TypeError exception.
- if (IsCallable(callbackfn) === false) {
- throw new TypeError(callbackfn + ' is not a function');
- }
- // 4. If thisArg is present, let T be thisArg; else let T be undefined.
- var T = arguments.length > 1 ? arguments[1] : undefined;
- // 5. Let A be ? ArraySpeciesCreate(O, len).
- var A = ArraySpeciesCreate(O, len);
- // 6. Let k be 0.
- var k = 0;
- // 7. Repeat, while k < len
- while (k < len) {
- // a. Let Pk be ! ToString(k).
- var Pk = ToString(k);
- // b. Let kPresent be ? HasProperty(O, Pk).
- var kPresent = HasProperty(O, Pk);
- // c. If kPresent is true, then
- if (kPresent) {
- // i. Let kValue be ? Get(O, Pk).
- var kValue = Get(O, Pk);
- // ii. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »).
- var mappedValue = Call(callbackfn, T, [kValue, k, O]);
- // iii. Perform ? CreateDataPropertyOrThrow(A, Pk, mappedValue).
- CreateDataPropertyOrThrow(A, Pk, mappedValue);
- }
- // d. Increase k by 1.
- k = k + 1;
- }
- // 8. Return A.
- return A;
-});
+ } else {
+ length = ToUint32(length);
+ byteLength = length * this.BYTES_PER_ELEMENT;
+ }
-}
+ if ((byteOffset + byteLength) > buffer.byteLength)
+ throw RangeError('byteOffset and length reference an area beyond the end of the buffer');
-if (!('getOwnPropertyNames' in Object)) {
+ Object.defineProperty(this, 'buffer', {value: buffer});
+ Object.defineProperty(this, 'byteLength', {value: byteLength});
+ Object.defineProperty(this, 'byteOffset', {value: byteOffset});
+ Object.defineProperty(this, 'length', {value: length});
-// Object.getOwnPropertyNames
-/* global CreateMethodProperty */
+ }).apply(this, arguments);
+ }
-var toString = ({}).toString;
-var split = ''.split;
+ // %TypedArray% ( all other argument combinations )
+ throw TypeError();
+ }
-CreateMethodProperty(Object, 'getOwnPropertyNames', function getOwnPropertyNames(object) {
- var buffer = [];
- var key;
+ // Properties of the %TypedArray Instrinsic Object
- // Non-enumerable properties cannot be discovered but can be checked for by name.
- // Define those used internally by JS to allow an incomplete solution
- var commonProps = ['length', "name", "arguments", "caller", "prototype", "observe", "unobserve"];
+ // %TypedArray%.from ( source , mapfn=undefined, thisArg=undefined )
+ Object.defineProperty($TypedArray$, 'from', {value: function(iterable) {
+ return new this(iterable);
+ }});
- if (typeof object === 'undefined' || object === null) {
- throw new TypeError('Cannot convert undefined or null to object');
- }
+ // %TypedArray%.of ( ...items )
+ Object.defineProperty($TypedArray$, 'of', {value: function(/*...items*/) {
+ return new this(arguments);
+ }});
- // Polyfill.io fallback for non-array-like strings which exist in some ES3 user-agents (IE 8)
- object = toString.call(object) == '[object String]' ? split.call(object, '') : Object(object);
+ // %TypedArray%.prototype
+ var $TypedArrayPrototype$ = {};
+ $TypedArray$.prototype = $TypedArrayPrototype$;
- // Enumerable properties only
- for (key in object) {
- if (Object.prototype.hasOwnProperty.call(object, key)) {
- buffer.push(key);
- }
- }
+ // WebIDL: getter type (unsigned long index);
+ Object.defineProperty($TypedArray$.prototype, '_getter', {value: function(index) {
+ if (arguments.length < 1) throw SyntaxError('Not enough arguments');
- // Check for and add the common non-enumerable properties
- for (var i=0, s=commonProps.length; i<s; i++) {
- if (commonProps[i] in object) buffer.push(commonProps[i]);
- }
+ index = ToUint32(index);
+ if (index >= this.length)
+ return undefined;
- return buffer;
-});
+ var bytes = [], i, o;
+ for (i = 0, o = this.byteOffset + index * this.BYTES_PER_ELEMENT;
+ i < this.BYTES_PER_ELEMENT;
+ i += 1, o += 1) {
+ bytes.push(this.buffer._bytes[o]);
+ }
+ return this._unpack(bytes);
+ }});
-}
+ // NONSTANDARD: convenience alias for getter: type get(unsigned long index);
+ Object.defineProperty($TypedArray$.prototype, 'get', {value: $TypedArray$.prototype._getter});
-if (!('freeze' in Object)) {
+ // WebIDL: setter void (unsigned long index, type value);
+ Object.defineProperty($TypedArray$.prototype, '_setter', {value: function(index, value) {
+ if (arguments.length < 2) throw SyntaxError('Not enough arguments');
-// Object.freeze
-/* global CreateMethodProperty */
-// 19.1.2.6. Object.freeze ( O )
-CreateMethodProperty(Object, 'freeze', function freeze(O) {
- // This feature cannot be implemented fully as a polyfill.
- // We choose to silently fail which allows "securable" code
- // to "gracefully" degrade to working but insecure code.
- return O;
-});
+ index = ToUint32(index);
+ if (index >= this.length)
+ return;
-}
+ var bytes = this._pack(value), i, o;
+ for (i = 0, o = this.byteOffset + index * this.BYTES_PER_ELEMENT;
+ i < this.BYTES_PER_ELEMENT;
+ i += 1, o += 1) {
+ this.buffer._bytes[o] = bytes[i];
+ }
+ }});
-if (!('Symbol' in this && this.Symbol.length === 0)) {
+ // get %TypedArray%.prototype.buffer
+ // get %TypedArray%.prototype.byteLength
+ // get %TypedArray%.prototype.byteOffset
+ // -- applied directly to the object in the constructor
-// Symbol
-// A modification of https://github.com/WebReflection/get-own-property-symbols
-// (C) Andrea Giammarchi - MIT Licensed
+ // %TypedArray%.prototype.constructor
+ Object.defineProperty($TypedArray$.prototype, 'constructor', {value: $TypedArray$});
-(function (Object, GOPS, global) {
+ // %TypedArray%.prototype.copyWithin (target, start, end = this.length )
+ Object.defineProperty($TypedArray$.prototype, 'copyWithin', {value: function(target, start) {
+ var end = arguments[2];
- var setDescriptor;
- var id = 0;
- var random = '' + Math.random();
- var prefix = '__\x01symbol:';
- var prefixLength = prefix.length;
- var internalSymbol = '__\x01symbol@@' + random;
- var DP = 'defineProperty';
- var DPies = 'defineProperties';
- var GOPN = 'getOwnPropertyNames';
- var GOPD = 'getOwnPropertyDescriptor';
- var PIE = 'propertyIsEnumerable';
- var ObjectProto = Object.prototype;
- var hOP = ObjectProto.hasOwnProperty;
- var pIE = ObjectProto[PIE];
- var toString = ObjectProto.toString;
- var concat = Array.prototype.concat;
- var cachedWindowNames = typeof window === 'object' ? Object.getOwnPropertyNames(window) : [];
- var nGOPN = Object[GOPN];
- var gOPN = function getOwnPropertyNames (obj) {
- if (toString.call(obj) === '[object Window]') {
- try {
- return nGOPN(obj);
- } catch (e) {
- // IE bug where layout engine calls userland gOPN for cross-domain `window` objects
- return concat.call([], cachedWindowNames);
- }
- }
- return nGOPN(obj);
- };
- var gOPD = Object[GOPD];
- var create = Object.create;
- var keys = Object.keys;
- var freeze = Object.freeze || Object;
- var defineProperty = Object[DP];
- var $defineProperties = Object[DPies];
- var descriptor = gOPD(Object, GOPN);
- var addInternalIfNeeded = function (o, uid, enumerable) {
- if (!hOP.call(o, internalSymbol)) {
- try {
- defineProperty(o, internalSymbol, {
- enumerable: false,
- configurable: false,
- writable: false,
- value: {}
- });
- } catch (e) {
- o[internalSymbol] = {};
- }
- }
- o[internalSymbol]['@@' + uid] = enumerable;
- };
- var createWithSymbols = function (proto, descriptors) {
- var self = create(proto);
- gOPN(descriptors).forEach(function (key) {
- if (propertyIsEnumerable.call(descriptors, key)) {
- $defineProperty(self, key, descriptors[key]);
- }
- });
- return self;
- };
- var copyAsNonEnumerable = function (descriptor) {
- var newDescriptor = create(descriptor);
- newDescriptor.enumerable = false;
- return newDescriptor;
- };
- var get = function get(){};
- var onlyNonSymbols = function (name) {
- return name != internalSymbol &&
- !hOP.call(source, name);
- };
- var onlySymbols = function (name) {
- return name != internalSymbol &&
- hOP.call(source, name);
- };
- var propertyIsEnumerable = function propertyIsEnumerable(key) {
- var uid = '' + key;
- return onlySymbols(uid) ? (
- hOP.call(this, uid) &&
- this[internalSymbol]['@@' + uid]
- ) : pIE.call(this, key);
- };
- var setAndGetSymbol = function (uid) {
- var descriptor = {
- enumerable: false,
- configurable: true,
- get: get,
- set: function (value) {
- setDescriptor(this, uid, {
- enumerable: false,
- configurable: true,
- writable: true,
- value: value
- });
- addInternalIfNeeded(this, uid, true);
- }
- };
- try {
- defineProperty(ObjectProto, uid, descriptor);
- } catch (e) {
- ObjectProto[uid] = descriptor.value;
- }
- return freeze(source[uid] = defineProperty(
- Object(uid),
- 'constructor',
- sourceConstructor
- ));
- };
- var Symbol = function Symbol() {
- var description = arguments[0];
- if (this instanceof Symbol) {
- throw new TypeError('Symbol is not a constructor');
- }
- return setAndGetSymbol(
- prefix.concat(description || '', random, ++id)
- );
- };
- var source = create(null);
- var sourceConstructor = {value: Symbol};
- var sourceMap = function (uid) {
- return source[uid];
- };
- var $defineProperty = function defineProp(o, key, descriptor) {
- var uid = '' + key;
- if (onlySymbols(uid)) {
- setDescriptor(o, uid, descriptor.enumerable ?
- copyAsNonEnumerable(descriptor) : descriptor);
- addInternalIfNeeded(o, uid, !!descriptor.enumerable);
- } else {
- defineProperty(o, key, descriptor);
- }
- return o;
- };
+ var o = ToObject(this);
+ var lenVal = o.length;
+ var len = ToUint32(lenVal);
+ len = max(len, 0);
+ var relativeTarget = ToInt32(target);
+ var to;
+ if (relativeTarget < 0)
+ to = max(len + relativeTarget, 0);
+ else
+ to = min(relativeTarget, len);
+ var relativeStart = ToInt32(start);
+ var from;
+ if (relativeStart < 0)
+ from = max(len + relativeStart, 0);
+ else
+ from = min(relativeStart, len);
+ var relativeEnd;
+ if (end === undefined)
+ relativeEnd = len;
+ else
+ relativeEnd = ToInt32(end);
+ var final;
+ if (relativeEnd < 0)
+ final = max(len + relativeEnd, 0);
+ else
+ final = min(relativeEnd, len);
+ var count = min(final - from, len - to);
+ var direction;
+ if (from < to && to < from + count) {
+ direction = -1;
+ from = from + count - 1;
+ to = to + count - 1;
+ } else {
+ direction = 1;
+ }
+ while (count > 0) {
+ o._setter(to, o._getter(from));
+ from = from + direction;
+ to = to + direction;
+ count = count - 1;
+ }
+ return o;
+ }});
+
+ // %TypedArray%.prototype.entries ( )
+ // -- defined in es6.js to shim browsers w/ native TypedArrays
+
+ // %TypedArray%.prototype.every ( callbackfn, thisArg = undefined )
+ Object.defineProperty($TypedArray$.prototype, 'every', {value: function(callbackfn) {
+ if (this === undefined || this === null) throw TypeError();
+ var t = Object(this);
+ var len = ToUint32(t.length);
+ if (!IsCallable(callbackfn)) throw TypeError();
+ var thisArg = arguments[1];
+ for (var i = 0; i < len; i++) {
+ if (!callbackfn.call(thisArg, t._getter(i), i, t))
+ return false;
+ }
+ return true;
+ }});
+
+ // %TypedArray%.prototype.fill (value, start = 0, end = this.length )
+ Object.defineProperty($TypedArray$.prototype, 'fill', {value: function(value) {
+ var start = arguments[1],
+ end = arguments[2];
+
+ var o = ToObject(this);
+ var lenVal = o.length;
+ var len = ToUint32(lenVal);
+ len = max(len, 0);
+ var relativeStart = ToInt32(start);
+ var k;
+ if (relativeStart < 0)
+ k = max((len + relativeStart), 0);
+ else
+ k = min(relativeStart, len);
+ var relativeEnd;
+ if (end === undefined)
+ relativeEnd = len;
+ else
+ relativeEnd = ToInt32(end);
+ var final;
+ if (relativeEnd < 0)
+ final = max((len + relativeEnd), 0);
+ else
+ final = min(relativeEnd, len);
+ while (k < final) {
+ o._setter(k, value);
+ k += 1;
+ }
+ return o;
+ }});
+
+ // %TypedArray%.prototype.filter ( callbackfn, thisArg = undefined )
+ Object.defineProperty($TypedArray$.prototype, 'filter', {value: function(callbackfn) {
+ if (this === undefined || this === null) throw TypeError();
+ var t = Object(this);
+ var len = ToUint32(t.length);
+ if (!IsCallable(callbackfn)) throw TypeError();
+ var res = [];
+ var thisp = arguments[1];
+ for (var i = 0; i < len; i++) {
+ var val = t._getter(i); // in case fun mutates this
+ if (callbackfn.call(thisp, val, i, t))
+ res.push(val);
+ }
+ return new this.constructor(res);
+ }});
+
+ // %TypedArray%.prototype.find (predicate, thisArg = undefined)
+ Object.defineProperty($TypedArray$.prototype, 'find', {value: function(predicate) {
+ var o = ToObject(this);
+ var lenValue = o.length;
+ var len = ToUint32(lenValue);
+ if (!IsCallable(predicate)) throw TypeError();
+ var t = arguments.length > 1 ? arguments[1] : undefined;
+ var k = 0;
+ while (k < len) {
+ var kValue = o._getter(k);
+ var testResult = predicate.call(t, kValue, k, o);
+ if (Boolean(testResult))
+ return kValue;
+ ++k;
+ }
+ return undefined;
+ }});
+
+ // %TypedArray%.prototype.findIndex ( predicate, thisArg = undefined )
+ Object.defineProperty($TypedArray$.prototype, 'findIndex', {value: function(predicate) {
+ var o = ToObject(this);
+ var lenValue = o.length;
+ var len = ToUint32(lenValue);
+ if (!IsCallable(predicate)) throw TypeError();
+ var t = arguments.length > 1 ? arguments[1] : undefined;
+ var k = 0;
+ while (k < len) {
+ var kValue = o._getter(k);
+ var testResult = predicate.call(t, kValue, k, o);
+ if (Boolean(testResult))
+ return k;
+ ++k;
+ }
+ return -1;
+ }});
- var onlyInternalSymbols = function (obj) {
- return function (name) {
- return hOP.call(obj, internalSymbol) && hOP.call(obj[internalSymbol], '@@' + name);
- };
- };
- var $getOwnPropertySymbols = function getOwnPropertySymbols(o) {
- return gOPN(o).filter(o === ObjectProto ? onlyInternalSymbols(o) : onlySymbols).map(sourceMap);
- }
- ;
+ // %TypedArray%.prototype.forEach ( callbackfn, thisArg = undefined )
+ Object.defineProperty($TypedArray$.prototype, 'forEach', {value: function(callbackfn) {
+ if (this === undefined || this === null) throw TypeError();
+ var t = Object(this);
+ var len = ToUint32(t.length);
+ if (!IsCallable(callbackfn)) throw TypeError();
+ var thisp = arguments[1];
+ for (var i = 0; i < len; i++)
+ callbackfn.call(thisp, t._getter(i), i, t);
+ }});
+
+ // %TypedArray%.prototype.indexOf (searchElement, fromIndex = 0 )
+ Object.defineProperty($TypedArray$.prototype, 'indexOf', {value: function(searchElement) {
+ if (this === undefined || this === null) throw TypeError();
+ var t = Object(this);
+ var len = ToUint32(t.length);
+ if (len === 0) return -1;
+ var n = 0;
+ if (arguments.length > 0) {
+ n = Number(arguments[1]);
+ if (n !== n) {
+ n = 0;
+ } else if (n !== 0 && n !== (1 / 0) && n !== -(1 / 0)) {
+ n = (n > 0 || -1) * floor(abs(n));
+ }
+ }
+ if (n >= len) return -1;
+ var k = n >= 0 ? n : max(len - abs(n), 0);
+ for (; k < len; k++) {
+ if (t._getter(k) === searchElement) {
+ return k;
+ }
+ }
+ return -1;
+ }});
+
+ // %TypedArray%.prototype.join ( separator )
+ Object.defineProperty($TypedArray$.prototype, 'join', {value: function(separator) {
+ if (this === undefined || this === null) throw TypeError();
+ var t = Object(this);
+ var len = ToUint32(t.length);
+ var tmp = Array(len);
+ for (var i = 0; i < len; ++i)
+ tmp[i] = t._getter(i);
+ return tmp.join(separator === undefined ? ',' : separator); // Hack for IE7
+ }});
+
+ // %TypedArray%.prototype.keys ( )
+ // -- defined in es6.js to shim browsers w/ native TypedArrays
+
+ // %TypedArray%.prototype.lastIndexOf ( searchElement, fromIndex = this.length-1 )
+ Object.defineProperty($TypedArray$.prototype, 'lastIndexOf', {value: function(searchElement) {
+ if (this === undefined || this === null) throw TypeError();
+ var t = Object(this);
+ var len = ToUint32(t.length);
+ if (len === 0) return -1;
+ var n = len;
+ if (arguments.length > 1) {
+ n = Number(arguments[1]);
+ if (n !== n) {
+ n = 0;
+ } else if (n !== 0 && n !== (1 / 0) && n !== -(1 / 0)) {
+ n = (n > 0 || -1) * floor(abs(n));
+ }
+ }
+ var k = n >= 0 ? min(n, len - 1) : len - abs(n);
+ for (; k >= 0; k--) {
+ if (t._getter(k) === searchElement)
+ return k;
+ }
+ return -1;
+ }});
+
+ // get %TypedArray%.prototype.length
+ // -- applied directly to the object in the constructor
+
+ // %TypedArray%.prototype.map ( callbackfn, thisArg = undefined )
+ Object.defineProperty($TypedArray$.prototype, 'map', {value: function(callbackfn) {
+ if (this === undefined || this === null) throw TypeError();
+ var t = Object(this);
+ var len = ToUint32(t.length);
+ if (!IsCallable(callbackfn)) throw TypeError();
+ var res = []; res.length = len;
+ var thisp = arguments[1];
+ for (var i = 0; i < len; i++)
+ res[i] = callbackfn.call(thisp, t._getter(i), i, t);
+ return new this.constructor(res);
+ }});
+
+ // %TypedArray%.prototype.reduce ( callbackfn [, initialValue] )
+ Object.defineProperty($TypedArray$.prototype, 'reduce', {value: function(callbackfn) {
+ if (this === undefined || this === null) throw TypeError();
+ var t = Object(this);
+ var len = ToUint32(t.length);
+ if (!IsCallable(callbackfn)) throw TypeError();
+ // no value to return if no initial value and an empty array
+ if (len === 0 && arguments.length === 1) throw TypeError();
+ var k = 0;
+ var accumulator;
+ if (arguments.length >= 2) {
+ accumulator = arguments[1];
+ } else {
+ accumulator = t._getter(k++);
+ }
+ while (k < len) {
+ accumulator = callbackfn.call(undefined, accumulator, t._getter(k), k, t);
+ k++;
+ }
+ return accumulator;
+ }});
+
+ // %TypedArray%.prototype.reduceRight ( callbackfn [, initialValue] )
+ Object.defineProperty($TypedArray$.prototype, 'reduceRight', {value: function(callbackfn) {
+ if (this === undefined || this === null) throw TypeError();
+ var t = Object(this);
+ var len = ToUint32(t.length);
+ if (!IsCallable(callbackfn)) throw TypeError();
+ // no value to return if no initial value, empty array
+ if (len === 0 && arguments.length === 1) throw TypeError();
+ var k = len - 1;
+ var accumulator;
+ if (arguments.length >= 2) {
+ accumulator = arguments[1];
+ } else {
+ accumulator = t._getter(k--);
+ }
+ while (k >= 0) {
+ accumulator = callbackfn.call(undefined, accumulator, t._getter(k), k, t);
+ k--;
+ }
+ return accumulator;
+ }});
+
+ // %TypedArray%.prototype.reverse ( )
+ Object.defineProperty($TypedArray$.prototype, 'reverse', {value: function() {
+ if (this === undefined || this === null) throw TypeError();
+ var t = Object(this);
+ var len = ToUint32(t.length);
+ var half = floor(len / 2);
+ for (var i = 0, j = len - 1; i < half; ++i, --j) {
+ var tmp = t._getter(i);
+ t._setter(i, t._getter(j));
+ t._setter(j, tmp);
+ }
+ return t;
+ }});
+
+ // %TypedArray%.prototype.set(array, offset = 0 )
+ // %TypedArray%.prototype.set(typedArray, offset = 0 )
+ // WebIDL: void set(TypedArray array, optional unsigned long offset);
+ // WebIDL: void set(sequence<type> array, optional unsigned long offset);
+ Object.defineProperty($TypedArray$.prototype, 'set', {value: function(index, value) {
+ if (arguments.length < 1) throw SyntaxError('Not enough arguments');
+ var array, sequence, offset, len,
+ i, s, d,
+ byteOffset, byteLength, tmp;
+
+ if (typeof arguments[0] === 'object' && arguments[0].constructor === this.constructor) {
+ // void set(TypedArray array, optional unsigned long offset);
+ array = arguments[0];
+ offset = ToUint32(arguments[1]);
+
+ if (offset + array.length > this.length) {
+ throw RangeError('Offset plus length of array is out of range');
+ }
+
+ byteOffset = this.byteOffset + offset * this.BYTES_PER_ELEMENT;
+ byteLength = array.length * this.BYTES_PER_ELEMENT;
+
+ if (array.buffer === this.buffer) {
+ tmp = [];
+ for (i = 0, s = array.byteOffset; i < byteLength; i += 1, s += 1) {
+ tmp[i] = array.buffer._bytes[s];
+ }
+ for (i = 0, d = byteOffset; i < byteLength; i += 1, d += 1) {
+ this.buffer._bytes[d] = tmp[i];
+ }
+ } else {
+ for (i = 0, s = array.byteOffset, d = byteOffset;
+ i < byteLength; i += 1, s += 1, d += 1) {
+ this.buffer._bytes[d] = array.buffer._bytes[s];
+ }
+ }
+ } else if (typeof arguments[0] === 'object' && typeof arguments[0].length !== 'undefined') {
+ // void set(sequence<type> array, optional unsigned long offset);
+ sequence = arguments[0];
+ len = ToUint32(sequence.length);
+ offset = ToUint32(arguments[1]);
+
+ if (offset + len > this.length) {
+ throw RangeError('Offset plus length of array is out of range');
+ }
+
+ for (i = 0; i < len; i += 1) {
+ s = sequence[i];
+ this._setter(offset + i, Number(s));
+ }
+ } else {
+ throw TypeError('Unexpected argument type(s)');
+ }
+ }});
+
+ // %TypedArray%.prototype.slice ( start, end )
+ Object.defineProperty($TypedArray$.prototype, 'slice', {value: function(start, end) {
+ var o = ToObject(this);
+ var lenVal = o.length;
+ var len = ToUint32(lenVal);
+ var relativeStart = ToInt32(start);
+ var k = (relativeStart < 0) ? max(len + relativeStart, 0) : min(relativeStart, len);
+ var relativeEnd = (end === undefined) ? len : ToInt32(end);
+ var final = (relativeEnd < 0) ? max(len + relativeEnd, 0) : min(relativeEnd, len);
+ var count = final - k;
+ var c = o.constructor;
+ var a = new c(count);
+ var n = 0;
+ while (k < final) {
+ var kValue = o._getter(k);
+ a._setter(n, kValue);
+ ++k;
+ ++n;
+ }
+ return a;
+ }});
+
+ // %TypedArray%.prototype.some ( callbackfn, thisArg = undefined )
+ Object.defineProperty($TypedArray$.prototype, 'some', {value: function(callbackfn) {
+ if (this === undefined || this === null) throw TypeError();
+ var t = Object(this);
+ var len = ToUint32(t.length);
+ if (!IsCallable(callbackfn)) throw TypeError();
+ var thisp = arguments[1];
+ for (var i = 0; i < len; i++) {
+ if (callbackfn.call(thisp, t._getter(i), i, t)) {
+ return true;
+ }
+ }
+ return false;
+ }});
- descriptor.value = $defineProperty;
- defineProperty(Object, DP, descriptor);
+ // %TypedArray%.prototype.sort ( comparefn )
+ Object.defineProperty($TypedArray$.prototype, 'sort', {value: function(comparefn) {
+ if (this === undefined || this === null) throw TypeError();
+ var t = Object(this);
+ var len = ToUint32(t.length);
+ var tmp = Array(len);
+ for (var i = 0; i < len; ++i)
+ tmp[i] = t._getter(i);
+ function sortCompare(x, y) {
+ if (x !== x && y !== y) return +0;
+ if (x !== x) return 1;
+ if (y !== y) return -1;
+ if (comparefn !== undefined) {
+ return comparefn(x, y);
+ }
+ if (x < y) return -1;
+ if (x > y) return 1;
+ return +0;
+ }
+ tmp.sort(sortCompare);
+ for (i = 0; i < len; ++i)
+ t._setter(i, tmp[i]);
+ return t;
+ }});
- descriptor.value = $getOwnPropertySymbols;
- defineProperty(Object, GOPS, descriptor);
+ // %TypedArray%.prototype.subarray(begin = 0, end = this.length )
+ // WebIDL: TypedArray subarray(long begin, optional long end);
+ Object.defineProperty($TypedArray$.prototype, 'subarray', {value: function(start, end) {
+ function clamp(v, min, max) { return v < min ? min : v > max ? max : v; }
- descriptor.value = function getOwnPropertyNames(o) {
- return gOPN(o).filter(onlyNonSymbols);
- };
- defineProperty(Object, GOPN, descriptor);
+ start = ToInt32(start);
+ end = ToInt32(end);
- descriptor.value = function defineProperties(o, descriptors) {
- var symbols = $getOwnPropertySymbols(descriptors);
- if (symbols.length) {
- keys(descriptors).concat(symbols).forEach(function (uid) {
- if (propertyIsEnumerable.call(descriptors, uid)) {
- $defineProperty(o, uid, descriptors[uid]);
- }
- });
- } else {
- $defineProperties(o, descriptors);
- }
- return o;
- };
- defineProperty(Object, DPies, descriptor);
+ if (arguments.length < 1) { start = 0; }
+ if (arguments.length < 2) { end = this.length; }
- descriptor.value = propertyIsEnumerable;
- defineProperty(ObjectProto, PIE, descriptor);
+ if (start < 0) { start = this.length + start; }
+ if (end < 0) { end = this.length + end; }
- descriptor.value = Symbol;
- defineProperty(global, 'Symbol', descriptor);
+ start = clamp(start, 0, this.length);
+ end = clamp(end, 0, this.length);
- // defining `Symbol.for(key)`
- descriptor.value = function (key) {
- var uid = prefix.concat(prefix, key, random);
- return uid in ObjectProto ? source[uid] : setAndGetSymbol(uid);
- };
- defineProperty(Symbol, 'for', descriptor);
+ var len = end - start;
+ if (len < 0) {
+ len = 0;
+ }
- // defining `Symbol.keyFor(symbol)`
- descriptor.value = function (symbol) {
- if (onlyNonSymbols(symbol))
- throw new TypeError(symbol + ' is not a symbol');
- return hOP.call(source, symbol) ?
- symbol.slice(prefixLength * 2, -random.length) :
- void 0
- ;
- };
- defineProperty(Symbol, 'keyFor', descriptor);
+ return new this.constructor(
+ this.buffer, this.byteOffset + start * this.BYTES_PER_ELEMENT, len);
+ }});
- descriptor.value = function getOwnPropertyDescriptor(o, key) {
- var descriptor = gOPD(o, key);
- if (descriptor && onlySymbols(key)) {
- descriptor.enumerable = propertyIsEnumerable.call(o, key);
- }
- return descriptor;
- };
- defineProperty(Object, GOPD, descriptor);
+ // %TypedArray%.prototype.toLocaleString ( )
+ // %TypedArray%.prototype.toString ( )
+ // %TypedArray%.prototype.values ( )
+ // %TypedArray%.prototype [ @@iterator ] ( )
+ // get %TypedArray%.prototype [ @@toStringTag ]
+ // -- defined in es6.js to shim browsers w/ native TypedArrays
- descriptor.value = function (proto, descriptors) {
- return arguments.length === 1 || typeof descriptors === "undefined" ?
- create(proto) :
- createWithSymbols(proto, descriptors);
- };
- defineProperty(Object, 'create', descriptor);
+ function makeTypedArray(elementSize, pack, unpack) {
+ // Each TypedArray type requires a distinct constructor instance with
+ // identical logic, which this produces.
+ var TypedArray = function() {
+ Object.defineProperty(this, 'constructor', {value: TypedArray});
+ $TypedArray$.apply(this, arguments);
+ makeArrayAccessors(this);
+ };
+ if ('__proto__' in TypedArray) {
+ TypedArray.__proto__ = $TypedArray$;
+ } else {
+ TypedArray.from = $TypedArray$.from;
+ TypedArray.of = $TypedArray$.of;
+ }
- descriptor.value = function () {
- var str = toString.call(this);
- return (str === '[object String]' && onlySymbols(this)) ? '[object Symbol]' : str;
- };
- defineProperty(ObjectProto, 'toString', descriptor);
+ TypedArray.BYTES_PER_ELEMENT = elementSize;
+
+ var TypedArrayPrototype = function() {};
+ TypedArrayPrototype.prototype = $TypedArrayPrototype$;
+ TypedArray.prototype = new TypedArrayPrototype();
- setDescriptor = function (o, key, descriptor) {
- var protoDescriptor = gOPD(ObjectProto, key);
- delete ObjectProto[key];
- defineProperty(o, key, descriptor);
- if (o !== ObjectProto) {
- defineProperty(ObjectProto, key, protoDescriptor);
- }
- };
+ Object.defineProperty(TypedArray.prototype, 'BYTES_PER_ELEMENT', {value: elementSize});
+ Object.defineProperty(TypedArray.prototype, '_pack', {value: pack});
+ Object.defineProperty(TypedArray.prototype, '_unpack', {value: unpack});
-}(Object, 'getOwnPropertySymbols', this));
+ return TypedArray;
+ }
-}
+ var Int8Array = makeTypedArray(1, packI8, unpackI8);
+ var Uint8Array = makeTypedArray(1, packU8, unpackU8);
+ var Uint8ClampedArray = makeTypedArray(1, packU8Clamped, unpackU8);
+ var Int16Array = makeTypedArray(2, packI16, unpackI16);
+ var Uint16Array = makeTypedArray(2, packU16, unpackU16);
+ var Int32Array = makeTypedArray(4, packI32, unpackI32);
+ var Uint32Array = makeTypedArray(4, packU32, unpackU32);
+ var Float32Array = makeTypedArray(4, packF32, unpackF32);
+ var Float64Array = makeTypedArray(8, packF64, unpackF64);
-if (!('Symbol' in this && 'iterator' in this.Symbol)) {
+ global.Int8Array = global.Int8Array || Int8Array;
+ global.Uint8Array = global.Uint8Array || Uint8Array;
+ global.Uint8ClampedArray = global.Uint8ClampedArray || Uint8ClampedArray;
+ global.Int16Array = global.Int16Array || Int16Array;
+ global.Uint16Array = global.Uint16Array || Uint16Array;
+ global.Int32Array = global.Int32Array || Int32Array;
+ global.Uint32Array = global.Uint32Array || Uint32Array;
+ global.Float32Array = global.Float32Array || Float32Array;
+ global.Float64Array = global.Float64Array || Float64Array;
+ }());
-// Symbol.iterator
-/* global Symbol */
-Object.defineProperty(Symbol, 'iterator', { value: Symbol('iterator') });
+ //
+ // 6 The DataView View Type
+ //
-}
+ (function() {
+ function r(array, index) {
+ return IsCallable(array.get) ? array.get(index) : array[index];
+ }
+ var IS_BIG_ENDIAN = (function() {
+ var u16array = new Uint16Array([0x1234]),
+ u8array = new Uint8Array(u16array.buffer);
+ return r(u8array, 0) === 0x12;
+ }());
-// _ESAbstract.GetIterator
-/* global GetMethod, Symbol, Call, Type, GetV */
-// 7.4.1. GetIterator ( obj [ , method ] )
-// The abstract operation GetIterator with argument obj and optional argument method performs the following steps:
-function GetIterator(obj /*, method */) { // eslint-disable-line no-unused-vars
- // 1. If method is not present, then
- // a. Set method to ? GetMethod(obj, @@iterator).
- var method = arguments.length > 1 ? arguments[1] : GetMethod(obj, Symbol.iterator);
- // 2. Let iterator be ? Call(method, obj).
- var iterator = Call(method, obj);
- // 3. If Type(iterator) is not Object, throw a TypeError exception.
- if (Type(iterator) !== 'object') {
- throw new TypeError('bad iterator');
- }
- // 4. Let nextMethod be ? GetV(iterator, "next").
- var nextMethod = GetV(iterator, "next");
- // 5. Let iteratorRecord be Record {[[Iterator]]: iterator, [[NextMethod]]: nextMethod, [[Done]]: false}.
- var iteratorRecord = Object.create(null);
- iteratorRecord['[[Iterator]]'] = iterator;
- iteratorRecord['[[NextMethod]]'] = nextMethod;
- iteratorRecord['[[Done]]'] = false;
- // 6. Return iteratorRecord.
- return iteratorRecord;
-}
+ // DataView(buffer, byteOffset=0, byteLength=undefined)
+ // WebIDL: Constructor(ArrayBuffer buffer,
+ // optional unsigned long byteOffset,
+ // optional unsigned long byteLength)
+ function DataView(buffer, byteOffset, byteLength) {
+ if (!(buffer instanceof ArrayBuffer || Class(buffer) === 'ArrayBuffer')) throw TypeError();
-// _ESAbstract.IteratorClose
-/* global GetMethod, Type, Call */
-// 7.4.6. IteratorClose ( iteratorRecord, completion )
-function IteratorClose(iteratorRecord, completion) { // eslint-disable-line no-unused-vars
- // 1. Assert: Type(iteratorRecord.[[Iterator]]) is Object.
- if (Type(iteratorRecord['[[Iterator]]']) !== 'object') {
- throw new Error(Object.prototype.toString.call(iteratorRecord['[[Iterator]]']) + 'is not an Object.');
- }
- // 2. Assert: completion is a Completion Record.
- // Polyfill.io - Ignoring this step as there is no way to check if something is a Completion Record in userland JavaScript.
+ byteOffset = ToUint32(byteOffset);
+ if (byteOffset > buffer.byteLength)
+ throw RangeError('byteOffset out of range');
- // 3. Let iterator be iteratorRecord.[[Iterator]].
- var iterator = iteratorRecord['[[Iterator]]'];
- // 4. Let return be ? GetMethod(iterator, "return").
- // Polyfill.io - We name it returnMethod because return is a keyword and can not be used as an identifier (E.G. variable name, function name etc).
- var returnMethod = GetMethod(iterator, "return");
- // 5. If return is undefined, return Completion(completion).
- if (returnMethod === undefined) {
- return completion;
- }
- // 6. Let innerResult be Call(return, iterator, « »).
- try {
- var innerResult = Call(returnMethod, iterator);
- } catch (error) {
- var innerException = error;
- }
- // 7. If completion.[[Type]] is throw, return Completion(completion).
- if (completion) {
- return completion;
- }
- // 8. If innerResult.[[Type]] is throw, return Completion(innerResult).
- if (innerException) {
- throw innerException;
- }
- // 9. If Type(innerResult.[[Value]]) is not Object, throw a TypeError exception.
- if (Type(innerResult) !== 'object') {
- throw new TypeError("Iterator's return method returned a non-object.");
- }
- // 10. Return Completion(completion).
- return completion;
-}
+ if (byteLength === undefined)
+ byteLength = buffer.byteLength - byteOffset;
+ else
+ byteLength = ToUint32(byteLength);
-// _ESAbstract.IteratorNext
-/* global Call, Type */
-// 7.4.2. IteratorNext ( iteratorRecord [ , value ] )
-function IteratorNext(iteratorRecord /* [, value] */) { // eslint-disable-line no-unused-vars
- // 1. If value is not present, then
- if (arguments.length < 2) {
- // a. Let result be ? Call(iteratorRecord.[[NextMethod]], iteratorRecord.[[Iterator]], « »).
- var result = Call(iteratorRecord['[[NextMethod]]'], iteratorRecord['[[Iterator]]']);
- // 2. Else,
- } else {
- // a. Let result be ? Call(iteratorRecord.[[NextMethod]], iteratorRecord.[[Iterator]], « value »).
- result = Call(iteratorRecord['[[NextMethod]]'], iteratorRecord['[[Iterator]]'], [arguments[1]]);
- }
- // 3. If Type(result) is not Object, throw a TypeError exception.
- if (Type(result) !== 'object') {
- throw new TypeError('bad iterator');
- }
- // 4. Return result.
- return result;
-}
+ if ((byteOffset + byteLength) > buffer.byteLength)
+ throw RangeError('byteOffset and length reference an area beyond the end of the buffer');
-// _ESAbstract.IteratorComplete
-/* global Type, ToBoolean, Get */
-// 7.4.3 IteratorComplete ( iterResult )
-function IteratorComplete(iterResult) { // eslint-disable-line no-unused-vars
- // 1. Assert: Type(iterResult) is Object.
- if (Type(iterResult) !== 'object') {
- throw new Error(Object.prototype.toString.call(iterResult) + 'is not an Object.');
- }
- // 2. Return ToBoolean(? Get(iterResult, "done")).
- return ToBoolean(Get(iterResult, "done"));
-}
+ Object.defineProperty(this, 'buffer', {value: buffer});
+ Object.defineProperty(this, 'byteLength', {value: byteLength});
+ Object.defineProperty(this, 'byteOffset', {value: byteOffset});
+ };
-// _ESAbstract.IteratorStep
-/* global IteratorNext, IteratorComplete */
-// 7.4.5. IteratorStep ( iteratorRecord )
-function IteratorStep(iteratorRecord) { // eslint-disable-line no-unused-vars
- // 1. Let result be ? IteratorNext(iteratorRecord).
- var result = IteratorNext(iteratorRecord);
- // 2. Let done be ? IteratorComplete(result).
- var done = IteratorComplete(result);
- // 3. If done is true, return false.
- if (done === true) {
- return false;
- }
- // 4. Return result.
- return result;
-}
+ // get DataView.prototype.buffer
+ // get DataView.prototype.byteLength
+ // get DataView.prototype.byteOffset
+ // -- applied directly to instances by the constructor
-// _ESAbstract.IteratorValue
-/* global Type, Get */
-// 7.4.4 IteratorValue ( iterResult )
-function IteratorValue(iterResult) { // eslint-disable-line no-unused-vars
- // Assert: Type(iterResult) is Object.
- if (Type(iterResult) !== 'object') {
- throw new Error(Object.prototype.toString.call(iterResult) + 'is not an Object.');
- }
- // Return ? Get(iterResult, "value").
- return Get(iterResult, "value");
-}
+ function makeGetter(arrayType) {
+ return function GetViewValue(byteOffset, littleEndian) {
+ byteOffset = ToUint32(byteOffset);
-// _ESAbstract.CreateIterResultObject
-/* global Type, CreateDataProperty */
-// 7.4.7. CreateIterResultObject ( value, done )
-function CreateIterResultObject(value, done) { // eslint-disable-line no-unused-vars
- // 1. Assert: Type(done) is Boolean.
- if (Type(done) !== 'boolean') {
- throw new Error();
- }
- // 2. Let obj be ObjectCreate(%ObjectPrototype%).
- var obj = {};
- // 3. Perform CreateDataProperty(obj, "value", value).
- CreateDataProperty(obj, "value", value);
- // 4. Perform CreateDataProperty(obj, "done", done).
- CreateDataProperty(obj, "done", done);
- // 5. Return obj.
- return obj;
-}
+ if (byteOffset + arrayType.BYTES_PER_ELEMENT > this.byteLength)
+ throw RangeError('Array index out of range');
-// _ESAbstract.SameValueNonNumber
-// 7.2.12. SameValueNonNumber ( x, y )
-function SameValueNonNumber(x, y) { // eslint-disable-line no-unused-vars
- // 1. Assert: Type(x) is not Number.
- // 2. Assert: Type(x) is the same as Type(y).
- // 3. If Type(x) is Undefined, return true.
- // 4. If Type(x) is Null, return true.
- // 5. If Type(x) is String, then
- // a. If x and y are exactly the same sequence of code units (same length and same code units at corresponding indices), return true; otherwise, return false.
- // 6. If Type(x) is Boolean, then
- // a. If x and y are both true or both false, return true; otherwise, return false.
- // 7. If Type(x) is Symbol, then
- // a. If x and y are both the same Symbol value, return true; otherwise, return false.
- // 8. If x and y are the same Object value, return true. Otherwise, return false.
+ byteOffset += this.byteOffset;
- // Polyfill.io - We can skip all above steps because the === operator does it all for us.
- return x === y;
-}
+ var uint8Array = new Uint8Array(this.buffer, byteOffset, arrayType.BYTES_PER_ELEMENT),
+ bytes = [];
+ for (var i = 0; i < arrayType.BYTES_PER_ELEMENT; i += 1)
+ bytes.push(r(uint8Array, i));
-// _ESAbstract.SameValueZero
-/* global Type, SameValueNonNumber */
-// 7.2.11. SameValueZero ( x, y )
-function SameValueZero (x, y) { // eslint-disable-line no-unused-vars
- // 1. If Type(x) is different from Type(y), return false.
- if (Type(x) !== Type(y)) {
- return false;
- }
- // 2. If Type(x) is Number, then
- if (Type(x) === 'number') {
- // a. If x is NaN and y is NaN, return true.
- if (isNaN(x) && isNaN(y)) {
- return true;
- }
- // b. If x is +0 and y is -0, return true.
- if (1/x === Infinity && 1/y === -Infinity) {
- return true;
- }
- // c. If x is -0 and y is +0, return true.
- if (1/x === -Infinity && 1/y === Infinity) {
- return true;
- }
- // d. If x is the same Number value as y, return true.
- if (x === y) {
- return true;
- }
- // e. Return false.
- return false;
- }
- // 3. Return SameValueNonNumber(x, y).
- return SameValueNonNumber(x, y);
-}
-if (!('isArray' in Array)) {
+ if (Boolean(littleEndian) === Boolean(IS_BIG_ENDIAN))
+ bytes.reverse();
-// Array.isArray
-/* global CreateMethodProperty, IsArray */
-// 22.1.2.2. Array.isArray ( arg )
-CreateMethodProperty(Array, 'isArray', function isArray(arg) {
- // 1. Return ? IsArray(arg).
- return IsArray(arg);
-});
+ return r(new arrayType(new Uint8Array(bytes).buffer), 0);
+ };
+ }
-}
+ Object.defineProperty(DataView.prototype, 'getUint8', {value: makeGetter(Uint8Array)});
+ Object.defineProperty(DataView.prototype, 'getInt8', {value: makeGetter(Int8Array)});
+ Object.defineProperty(DataView.prototype, 'getUint16', {value: makeGetter(Uint16Array)});
+ Object.defineProperty(DataView.prototype, 'getInt16', {value: makeGetter(Int16Array)});
+ Object.defineProperty(DataView.prototype, 'getUint32', {value: makeGetter(Uint32Array)});
+ Object.defineProperty(DataView.prototype, 'getInt32', {value: makeGetter(Int32Array)});
+ Object.defineProperty(DataView.prototype, 'getFloat32', {value: makeGetter(Float32Array)});
+ Object.defineProperty(DataView.prototype, 'getFloat64', {value: makeGetter(Float64Array)});
-if (!('Symbol' in this && 'species' in this.Symbol)) {
+ function makeSetter(arrayType) {
+ return function SetViewValue(byteOffset, value, littleEndian) {
+ byteOffset = ToUint32(byteOffset);
+ if (byteOffset + arrayType.BYTES_PER_ELEMENT > this.byteLength)
+ throw RangeError('Array index out of range');
-// Symbol.species
-/* global Symbol */
-Object.defineProperty(Symbol, 'species', { value: Symbol('species') });
+ // Get bytes
+ var typeArray = new arrayType([value]),
+ byteArray = new Uint8Array(typeArray.buffer),
+ bytes = [], i, byteView;
-}
+ for (i = 0; i < arrayType.BYTES_PER_ELEMENT; i += 1)
+ bytes.push(r(byteArray, i));
-if (!('Map' in this && (function() {
- try {
- var m = new Map([[1, 1], [2, 2]]);
- if (Map.length === 0) {
- if (m.size === 2) {
- if ('Symbol' in this && 'iterator' in Symbol && typeof m[Symbol.iterator] === 'function') {
- return true;
- }
- }
- }
- return false;
- } catch (e) {
- return false;
- }
-}()))) {
+ // Flip if necessary
+ if (Boolean(littleEndian) === Boolean(IS_BIG_ENDIAN))
+ bytes.reverse();
-// Map
-/* global CreateIterResultObject, CreateMethodProperty, GetIterator, IsCallable, IteratorClose, IteratorStep, IteratorValue, OrdinaryCreateFromConstructor, SameValueZero, Type, Symbol */
-(function (global) {
- var supportsGetters = (function () {
- try {
- var a = {};
- Object.defineProperty(a, 't', {
- configurable: true,
- enumerable: false,
- get: function () {
- return true;
- },
- set: undefined
- });
- return !!a.t;
- } catch (e) {
- return false;
- }
- }());
+ // Write them
+ byteView = new Uint8Array(this.buffer, byteOffset, arrayType.BYTES_PER_ELEMENT);
+ byteView.set(bytes);
+ };
+ }
- // Deleted map items mess with iterator pointers, so rather than removing them mark them as deleted. Can't use undefined or null since those both valid keys so use a private symbol.
- var undefMarker = Symbol('undef');
- // 23.1.1.1 Map ( [ iterable ] )
- var Map = function Map(/* iterable */) {
- // 1. If NewTarget is undefined, throw a TypeError exception.
- if (!(this instanceof Map)) {
- throw new TypeError('Constructor Map requires "new"');
- }
- // 2. Let map be ? OrdinaryCreateFromConstructor(NewTarget, "%MapPrototype%", « [[MapData]] »).
- var map = OrdinaryCreateFromConstructor(this, Map.prototype, {
- _keys: [],
- _values: [],
- _size: 0,
- _es6Map: true
- });
+ Object.defineProperty(DataView.prototype, 'setUint8', {value: makeSetter(Uint8Array)});
+ Object.defineProperty(DataView.prototype, 'setInt8', {value: makeSetter(Int8Array)});
+ Object.defineProperty(DataView.prototype, 'setUint16', {value: makeSetter(Uint16Array)});
+ Object.defineProperty(DataView.prototype, 'setInt16', {value: makeSetter(Int16Array)});
+ Object.defineProperty(DataView.prototype, 'setUint32', {value: makeSetter(Uint32Array)});
+ Object.defineProperty(DataView.prototype, 'setInt32', {value: makeSetter(Int32Array)});
+ Object.defineProperty(DataView.prototype, 'setFloat32', {value: makeSetter(Float32Array)});
+ Object.defineProperty(DataView.prototype, 'setFloat64', {value: makeSetter(Float64Array)});
- // 3. Set map.[[MapData]] to a new empty List.
- // Polyfill.io - This step was done as part of step two.
+ global.DataView = global.DataView || DataView;
- // Some old engines do not support ES5 getters/setters. Since Map only requires these for the size property, we can fall back to setting the size property statically each time the size of the map changes.
- if (!supportsGetters) {
- Object.defineProperty(map, 'size', {
- configurable: true,
- enumerable: false,
- writable: true,
- value: 0
- });
- }
+ }());
- // 4. If iterable is not present, let iterable be undefined.
- var iterable = arguments.length > 0 ? arguments[0] : undefined;
+}(self));
+if (!("defineProperty"in Object&&function(){try{var e={}
+return Object.defineProperty(e,"test",{value:42}),!0}catch(t){return!1}}()
+)) {
+
+// Object.defineProperty
+(function (nativeDefineProperty) {
- // 5. If iterable is either undefined or null, return map.
- if (iterable === null || iterable === undefined) {
- return map;
- }
+ var supportsAccessors = Object.prototype.hasOwnProperty('__defineGetter__');
+ var ERR_ACCESSORS_NOT_SUPPORTED = 'Getters & setters cannot be defined on this javascript engine';
+ var ERR_VALUE_ACCESSORS = 'A property cannot both have accessors and be writable or have a value';
- // 6. Let adder be ? Get(map, "set").
- var adder = map.set;
+ // Polyfill.io - This does not use CreateMethodProperty because our CreateMethodProperty function uses Object.defineProperty.
+ Object['defineProperty'] = function defineProperty(object, property, descriptor) {
- // 7. If IsCallable(adder) is false, throw a TypeError exception.
- if (!IsCallable(adder)) {
- throw new TypeError("Map.prototype.set is not a function");
+ // Where native support exists, assume it
+ if (nativeDefineProperty && (object === window || object === document || object === Element.prototype || object instanceof Element)) {
+ return nativeDefineProperty(object, property, descriptor);
}
- // 8. Let iteratorRecord be ? GetIterator(iterable).
- try {
- var iteratorRecord = GetIterator(iterable);
- // 9. Repeat,
- while (true) {
- // a. Let next be ? IteratorStep(iteratorRecord).
- var next = IteratorStep(iteratorRecord);
- // b. If next is false, return map.
- if (next === false) {
- return map;
- }
- // c. Let nextItem be ? IteratorValue(next).
- var nextItem = IteratorValue(next);
- // d. If Type(nextItem) is not Object, then
- if (Type(nextItem) !== 'object') {
- // i. Let error be Completion{[[Type]]: throw, [[Value]]: a newly created TypeError object, [[Target]]: empty}.
- try {
- throw new TypeError('Iterator value ' + nextItem + ' is not an entry object');
- } catch (error) {
- // ii. Return ? IteratorClose(iteratorRecord, error).
- return IteratorClose(iteratorRecord, error);
- }
- }
- try {
- // Polyfill.io - The try catch accounts for steps: f, h, and j.
-
- // e. Let k be Get(nextItem, "0").
- var k = nextItem[0];
- // f. If k is an abrupt completion, return ? IteratorClose(iteratorRecord, k).
- // g. Let v be Get(nextItem, "1").
- var v = nextItem[1];
- // h. If v is an abrupt completion, return ? IteratorClose(iteratorRecord, v).
- // i. Let status be Call(adder, map, « k.[[Value]], v.[[Value]] »).
- adder.call(map, k, v);
- } catch (e) {
- // j. If status is an abrupt completion, return ? IteratorClose(iteratorRecord, status).
- return IteratorClose(iteratorRecord, e);
- }
- }
- } catch (e) {
- // Polyfill.io - For user agents which do not have iteration methods on argument objects or arrays, we can special case those.
- if (Array.isArray(iterable) ||
- Object.prototype.toString.call(iterable) === '[object Arguments]' ||
- // IE 7 & IE 8 return '[object Object]' for the arguments object, we can detect by checking for the existence of the callee property
- (!!iterable.callee)) {
- var index;
- var length = iterable.length;
- for (index = 0; index < length; index++) {
- adder.call(map, iterable[index][0], iterable[index][1]);
- }
- }
+ if (object === null || !(object instanceof Object || typeof object === 'object')) {
+ throw new TypeError('Object.defineProperty called on non-object');
}
- return map;
- };
- // 23.1.2.1. Map.prototype
- // The initial value of Map.prototype is the intrinsic object %MapPrototype%.
- // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
- Object.defineProperty(Map, 'prototype', {
- configurable: false,
- enumerable: false,
- writable: false,
- value: {}
- });
+ if (!(descriptor instanceof Object)) {
+ throw new TypeError('Property description must be an object');
+ }
- // 23.1.2.2 get Map [ @@species ]
- if (supportsGetters) {
- Object.defineProperty(Map, Symbol.species, {
- configurable: true,
- enumerable: false,
- get: function () {
- // 1. Return the this value.
- return this;
- },
- set: undefined
- });
- } else {
- CreateMethodProperty(Map, Symbol.species, Map);
- }
+ var propertyString = String(property);
+ var hasValueOrWritable = 'value' in descriptor || 'writable' in descriptor;
+ var getterType = 'get' in descriptor && typeof descriptor.get;
+ var setterType = 'set' in descriptor && typeof descriptor.set;
- // 23.1.3.1 Map.prototype.clear ( )
- CreateMethodProperty(Map.prototype, 'clear', function clear() {
- // 1. Let M be the this value.
- var M = this;
- // 2. If Type(M) is not Object, throw a TypeError exception.
- if (Type(M) !== 'object') {
- throw new TypeError('Method Map.prototype.clear called on incompatible receiver ' + Object.prototype.toString.call(M));
- }
- // 3. If M does not have a [[MapData]] internal slot, throw a TypeError exception.
- if (M._es6Map !== true) {
- throw new TypeError('Method Map.prototype.clear called on incompatible receiver ' + Object.prototype.toString.call(M));
+ // handle descriptor.get
+ if (getterType) {
+ if (getterType !== 'function') {
+ throw new TypeError('Getter must be a function');
}
- // 4. Let entries be the List that is M.[[MapData]].
- var entries = M._keys;
- // 5. For each Record {[[Key]], [[Value]]} p that is an element of entries, do
- for (var i = 0; i < entries.length; i++) {
- // 5.a. Set p.[[Key]] to empty.
- M._keys[i] = undefMarker;
- // 5.b. Set p.[[Value]] to empty.
- M._values[i] = undefMarker;
+ if (!supportsAccessors) {
+ throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
}
- this._size = 0;
- if (!supportsGetters) {
- this.size = this._size;
+ if (hasValueOrWritable) {
+ throw new TypeError(ERR_VALUE_ACCESSORS);
}
- // 6. Return undefined.
- return undefined;
+ Object.__defineGetter__.call(object, propertyString, descriptor.get);
+ } else {
+ object[propertyString] = descriptor.value;
}
- );
- // 23.1.3.2. Map.prototype.constructor
- CreateMethodProperty(Map.prototype, 'constructor', Map);
-
- // 23.1.3.3. Map.prototype.delete ( key )
- CreateMethodProperty(Map.prototype, 'delete', function (key) {
- // 1. Let M be the this value.
- var M = this;
- // 2. If Type(M) is not Object, throw a TypeError exception.
- if (Type(M) !== 'object') {
- throw new TypeError('Method Map.prototype.clear called on incompatible receiver ' + Object.prototype.toString.call(M));
+ // handle descriptor.set
+ if (setterType) {
+ if (setterType !== 'function') {
+ throw new TypeError('Setter must be a function');
}
- // 3. If M does not have a [[MapData]] internal slot, throw a TypeError exception.
- if (M._es6Map !== true) {
- throw new TypeError('Method Map.prototype.clear called on incompatible receiver ' + Object.prototype.toString.call(M));
+ if (!supportsAccessors) {
+ throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
}
- // 4. Let entries be the List that is M.[[MapData]].
- var entries = M._keys;
- // 5. For each Record {[[Key]], [[Value]]} p that is an element of entries, do
- for (var i = 0; i < entries.length; i++) {
- // a. If p.[[Key]] is not empty and SameValueZero(p.[[Key]], key) is true, then
- if (M._keys[i] !== undefMarker && SameValueZero(M._keys[i], key)) {
- // i. Set p.[[Key]] to empty.
- this._keys[i] = undefMarker;
- // ii. Set p.[[Value]] to empty.
- this._values[i] = undefMarker;
- this._size = --this._size;
- if (!supportsGetters) {
- this.size = this._size;
- }
- // iii. Return true.
- return true;
- }
+ if (hasValueOrWritable) {
+ throw new TypeError(ERR_VALUE_ACCESSORS);
}
- // 6. Return false.
- return false;
+ Object.__defineSetter__.call(object, propertyString, descriptor.set);
}
- );
- // 23.1.3.4. Map.prototype.entries ( )
- CreateMethodProperty(Map.prototype, 'entries', function entries () {
- // 1. Let M be the this value.
- var M = this;
- // 2. Return ? CreateMapIterator(M, "key+value").
- return CreateMapIterator(M, 'key+value');
- }
- );
+ // OK to define value unconditionally - if a getter has been specified as well, an error would be thrown above
+ if ('value' in descriptor) {
+ object[propertyString] = descriptor.value;
+ }
+
+ return object;
+ };
+}(Object.defineProperty));
+
+}
+
+
+// _ESAbstract.CreateDataProperty
+// 7.3.4. CreateDataProperty ( O, P, V )
+// NOTE
+// This abstract operation creates a property whose attributes are set to the same defaults used for properties created by the ECMAScript language assignment operator.
+// 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.
+function CreateDataProperty(O, P, V) { // eslint-disable-line no-unused-vars
+ // 1. Assert: Type(O) is Object.
+ // 2. Assert: IsPropertyKey(P) is true.
+ // 3. Let newDesc be the PropertyDescriptor{ [[Value]]: V, [[Writable]]: true, [[Enumerable]]: true, [[Configurable]]: true }.
+ var newDesc = {
+ value: V,
+ writable: true,
+ enumerable: true,
+ configurable: true
+ };
+ // 4. Return ? O.[[DefineOwnProperty]](P, newDesc).
+ try {
+ Object.defineProperty(O, P, newDesc);
+ return true;
+ } catch (e) {
+ return false;
+ }
+}
+
+// _ESAbstract.CreateDataPropertyOrThrow
+/* global CreateDataProperty */
+// 7.3.6. CreateDataPropertyOrThrow ( O, P, V )
+function CreateDataPropertyOrThrow(O, P, V) { // eslint-disable-line no-unused-vars
+ // 1. Assert: Type(O) is Object.
+ // 2. Assert: IsPropertyKey(P) is true.
+ // 3. Let success be ? CreateDataProperty(O, P, V).
+ var success = CreateDataProperty(O, P, V);
+ // 4. If success is false, throw a TypeError exception.
+ if (!success) {
+ 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) + '`');
+ }
+ // 5. Return success.
+ return success;
+}
+
+// _ESAbstract.CreateIterResultObject
+/* global Type, CreateDataProperty */
+// 7.4.7. CreateIterResultObject ( value, done )
+function CreateIterResultObject(value, done) { // eslint-disable-line no-unused-vars
+ // 1. Assert: Type(done) is Boolean.
+ if (Type(done) !== 'boolean') {
+ throw new Error();
+ }
+ // 2. Let obj be ObjectCreate(%ObjectPrototype%).
+ var obj = {};
+ // 3. Perform CreateDataProperty(obj, "value", value).
+ CreateDataProperty(obj, "value", value);
+ // 4. Perform CreateDataProperty(obj, "done", done).
+ CreateDataProperty(obj, "done", done);
+ // 5. Return obj.
+ return obj;
+}
+
+// _ESAbstract.CreateMethodProperty
+// 7.3.5. CreateMethodProperty ( O, P, V )
+function CreateMethodProperty(O, P, V) { // eslint-disable-line no-unused-vars
+ // 1. Assert: Type(O) is Object.
+ // 2. Assert: IsPropertyKey(P) is true.
+ // 3. Let newDesc be the PropertyDescriptor{[[Value]]: V, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true}.
+ var newDesc = {
+ value: V,
+ writable: true,
+ enumerable: false,
+ configurable: true
+ };
+ // 4. Return ? O.[[DefineOwnProperty]](P, newDesc).
+ Object.defineProperty(O, P, newDesc);
+}
+if (!("isArray"in Array
+)) {
+
+// Array.isArray
+/* global CreateMethodProperty, IsArray */
+// 22.1.2.2. Array.isArray ( arg )
+CreateMethodProperty(Array, 'isArray', function isArray(arg) {
+ // 1. Return ? IsArray(arg).
+ return IsArray(arg);
+});
- // 23.1.3.5. Map.prototype.forEach ( callbackfn [ , thisArg ] )
- CreateMethodProperty(Map.prototype, 'forEach', function (callbackFn) {
- // 1. Let M be the this value.
- var M = this;
- // 2. If Type(M) is not Object, throw a TypeError exception.
- if (Type(M) !== 'object') {
- throw new TypeError('Method Map.prototype.forEach called on incompatible receiver ' + Object.prototype.toString.call(M));
- }
- // 3. If M does not have a [[MapData]] internal slot, throw a TypeError exception.
- if (M._es6Map !== true) {
- throw new TypeError('Method Map.prototype.forEach called on incompatible receiver ' + Object.prototype.toString.call(M));
- }
- // 4. If IsCallable(callbackfn) is false, throw a TypeError exception.
- if (!IsCallable(callbackFn)) {
- throw new TypeError(Object.prototype.toString.call(callbackFn) + ' is not a function.');
- }
- // 5. If thisArg is present, let T be thisArg; else let T be undefined.
- if (arguments[1]) {
- var T = arguments[1];
- }
- // 6. Let entries be the List that is M.[[MapData]].
- var entries = M._keys;
- // 7. For each Record {[[Key]], [[Value]]} e that is an element of entries, in original key insertion order, do
- for (var i = 0; i < entries.length; i++) {
- // a. If e.[[Key]] is not empty, then
- if (M._keys[i] !== undefMarker && M._values[i] !== undefMarker ) {
- // i. Perform ? Call(callbackfn, T, « e.[[Value]], e.[[Key]], M »).
- callbackFn.call(T, M._values[i], M._keys[i], M);
- }
- }
- // 8. Return undefined.
- return undefined;
- }
- );
+}
- // 23.1.3.6. Map.prototype.get ( key )
- CreateMethodProperty(Map.prototype, 'get', function get(key) {
- // 1. Let M be the this value.
- var M = this;
- // 2. If Type(M) is not Object, throw a TypeError exception.
- if (Type(M) !== 'object') {
- throw new TypeError('Method Map.prototype.get called on incompatible receiver ' + Object.prototype.toString.call(M));
- }
- // 3. If M does not have a [[MapData]] internal slot, throw a TypeError exception.
- if (M._es6Map !== true) {
- throw new TypeError('Method Map.prototype.get called on incompatible receiver ' + Object.prototype.toString.call(M));
- }
- // 4. Let entries be the List that is M.[[MapData]].
- var entries = M._keys;
- // 5. For each Record {[[Key]], [[Value]]} p that is an element of entries, do
- for (var i = 0; i < entries.length; i++) {
- // a. If p.[[Key]] is not empty and SameValueZero(p.[[Key]], key) is true, return p.[[Value]].
- if (M._keys[i] !== undefMarker && SameValueZero(M._keys[i], key)) {
- return M._values[i];
- }
- }
- // 6. Return undefined.
- return undefined;
- });
+if (!("copyWithin"in Array.prototype&&function(){try{var t=function n(){}
+t.prototype[0]="foo"
+var o=new t
+o[1]=1,o[2]=2,o.length=3
+var r=Array.prototype.copyWithin.call(o,1,0)
+return!(!r[0]||Object.prototype.hasOwnProperty.call(r,"0")||!Object.prototype.hasOwnProperty.call(r,"1")||"foo"!==r[0]||"foo"!==r[1]||1!==r[2]||3!==r.length)}catch(e){return!1}}()
+)) {
- // 23.1.3.7. Map.prototype.has ( key )
- CreateMethodProperty(Map.prototype, 'has', function has (key) {
- // 1. Let M be the this value.
- var M = this;
- // 2. If Type(M) is not Object, throw a TypeError exception.
- if (typeof M !== 'object') {
- throw new TypeError('Method Map.prototype.has called on incompatible receiver ' + Object.prototype.toString.call(M));
- }
- // 3. If M does not have a [[MapData]] internal slot, throw a TypeError exception.
- if (M._es6Map !== true) {
- throw new TypeError('Method Map.prototype.has called on incompatible receiver ' + Object.prototype.toString.call(M));
- }
- // 4. Let entries be the List that is M.[[MapData]].
- var entries = M._keys;
- // 5. For each Record {[[Key]], [[Value]]} p that is an element of entries, do
- for (var i = 0; i < entries.length; i++) {
- // a. If p.[[Key]] is not empty and SameValueZero(p.[[Key]], key) is true, return true.
- if (M._keys[i] !== undefMarker && SameValueZero(M._keys[i], key)) {
- return true;
- }
- }
- // 6. Return false.
- return false;
- });
+// Array.prototype.copyWithin
+/* global CreateMethodProperty, HasProperty, ToInteger */
+// 22.1.3.3 Array.prototype.copyWithin ( target, start [ , end ] )
+CreateMethodProperty(Array.prototype, 'copyWithin', function copyWithin(target, start /* [ , end ] */ ) {
+ 'use strict';
+ var end = arguments[2];
- // 23.1.3.8. Map.prototype.keys ( )
- CreateMethodProperty(Map.prototype, 'keys', function keys () {
- // 1. Let M be the this value.
- var M = this;
- // 2. Return ? CreateMapIterator(M, "key").
- return CreateMapIterator(M, "key");
- });
+ // 22.1.3.3.1 Let O be ? ToObject(this value).
+ if (this === null || this === undefined) {
+ throw new TypeError('Cannot call method on ' + this);
+ }
- // 23.1.3.9. Map.prototype.set ( key, value )
- CreateMethodProperty(Map.prototype, 'set', function set(key, value) {
- // 1. Let M be the this value.
- var M = this;
- // 2. If Type(M) is not Object, throw a TypeError exception.
- if (Type(M) !== 'object') {
- throw new TypeError('Method Map.prototype.set called on incompatible receiver ' + Object.prototype.toString.call(M));
- }
- // 3. If M does not have a [[MapData]] internal slot, throw a TypeError exception.
- if (M._es6Map !== true) {
- throw new TypeError('Method Map.prototype.set called on incompatible receiver ' + Object.prototype.toString.call(M));
- }
- // 4. Let entries be the List that is M.[[MapData]].
- var entries = M._keys;
- // 5. For each Record {[[Key]], [[Value]]} p that is an element of entries, do
- for (var i = 0; i < entries.length; i++) {
- // a. If p.[[Key]] is not empty and SameValueZero(p.[[Key]], key) is true, then
- if (M._keys[i] !== undefMarker && SameValueZero(M._keys[i], key)) {
- // i. Set p.[[Value]] to value.
- M._values[i] = value;
- // Return M.
- return M;
- }
- }
- // 6. If key is -0, let key be +0.
- if (1/key === -Infinity) {
- key = 0;
- }
- // 7. Let p be the Record {[[Key]]: key, [[Value]]: value}.
- var p = {};
- p['[[Key]]'] = key;
- p['[[Value]]'] = value;
- // 8. Append p as the last element of entries.
- M._keys.push(p['[[Key]]']);
- M._values.push(p['[[Value]]']);
- ++M._size;
- if (!supportsGetters) {
- M.size = M._size;
- }
- // 9. Return M.
- return M;
- });
+ var o = Object(this);
- // 23.1.3.10. get Map.prototype.size
- if (supportsGetters) {
- Object.defineProperty(Map.prototype, 'size', {
- configurable: true,
- enumerable: false,
- get: function () {
- // 1. Let M be the this value.
- var M = this;
- // 2. If Type(M) is not Object, throw a TypeError exception.
- if (Type(M) !== 'object') {
- throw new TypeError('Method Map.prototype.size called on incompatible receiver ' + Object.prototype.toString.call(M));
- }
- // 3. If M does not have a [[MapData]] internal slot, throw a TypeError exception.
- if (M._es6Map !== true) {
- throw new TypeError('Method Map.prototype.size called on incompatible receiver ' + Object.prototype.toString.call(M));
- }
- // 4. Let entries be the List that is M.[[MapData]].
- var entries = M._keys;
- // 5. Let count be 0.
- var count = 0;
- // 6. For each Record {[[Key]], [[Value]]} p that is an element of entries, do
- for (var i = 0; i < entries.length; i++) {
- // a. If p.[[Key]] is not empty, set count to count+1.
- if (M._keys[i] !== undefMarker) {
- count = count + 1;
- }
- }
- // 7. Return count.
- return count;
- },
- set: undefined
- });
+ // 22.1.3.3.2 Let len be ? ToLength(? Get(O, "length")).
+ var len = ToInteger(o.length);
+ if (len <= 0) {
+ len = 0;
+ }
+ if (len === Infinity) {
+ len = Math.pow(2, 53) - 1;
+ } else {
+ len = Math.min(len, Math.pow(2, 53) - 1);
}
+ len = Math.max(len, 0);
- // 23.1.3.11. Map.prototype.values ( )
- CreateMethodProperty(Map.prototype, 'values', function values () {
- // 1. Let M be the this value.
- var M = this;
- // 2. Return ? CreateMapIterator(M, "value").
- return CreateMapIterator(M, 'value');
- }
- );
+ // 22.1.3.3.3 Let relativeTarget be ? ToInteger(target).
+ var relativeTarget = ToInteger(target);
- // 23.1.3.12. Map.prototype [ @@iterator ] ( )
- // The initial value of the @@iterator property is the same function object as the initial value of the entries property.
- CreateMethodProperty(Map.prototype, Symbol.iterator, Map.prototype.entries);
+ // 22.1.3.3.4 If relativeTarget < 0, let to be max((len + relativeTarget), 0); else let to be min(relativeTarget, len).
+ var to;
+ if (relativeTarget < 0) {
+ to = Math.max(len + relativeTarget, 0);
+ } else {
+ to = Math.min(relativeTarget, len);
+ }
- // 23.1.3.13. Map.prototype [ @@toStringTag ]
- // The initial value of the @@toStringTag property is the String value "Map".
- // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
+ // 22.1.3.3.5 Let relativeStart be ? ToInteger(start).
+ var relativeStart = ToInteger(start);
- // Polyfill.io - Safari 8 implements Map.name but as a non-configurable property, which means it would throw an error if we try and configure it here.
- if (!('name' in Map)) {
- // 19.2.4.2 name
- Object.defineProperty(Map, 'name', {
- &nb