mirror of
https://github.com/imranismail/setup-kustomize.git
synced 2026-06-11 00:22:48 +00:00
Update metadata
This commit is contained in:
768
node_modules/es-abstract/es2015.js
generated
vendored
768
node_modules/es-abstract/es2015.js
generated
vendored
@@ -3,61 +3,108 @@
|
||||
var has = require('has');
|
||||
var toPrimitive = require('es-to-primitive/es6');
|
||||
var keys = require('object-keys');
|
||||
var inspect = require('object-inspect');
|
||||
|
||||
var GetIntrinsic = require('./GetIntrinsic');
|
||||
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
var $RangeError = GetIntrinsic('%RangeError%');
|
||||
var $SyntaxError = GetIntrinsic('%SyntaxError%');
|
||||
var $Array = GetIntrinsic('%Array%');
|
||||
var $ArrayPrototype = $Array.prototype;
|
||||
var $String = GetIntrinsic('%String%');
|
||||
var $Object = GetIntrinsic('%Object%');
|
||||
var $Number = GetIntrinsic('%Number%');
|
||||
var $Symbol = GetIntrinsic('%Symbol%', true);
|
||||
var $RegExp = GetIntrinsic('%RegExp%');
|
||||
var $Date = GetIntrinsic('%Date%');
|
||||
var $Function = GetIntrinsic('%Function%');
|
||||
var $preventExtensions = $Object.preventExtensions;
|
||||
|
||||
var hasSymbols = !!$Symbol;
|
||||
var hasSymbols = require('has-symbols')();
|
||||
|
||||
var assertRecord = require('./helpers/assertRecord');
|
||||
var $isNaN = require('./helpers/isNaN');
|
||||
var $isFinite = require('./helpers/isFinite');
|
||||
var MAX_SAFE_INTEGER = $Number.MAX_SAFE_INTEGER || Math.pow(2, 53) - 1;
|
||||
var MAX_ARRAY_LENGTH = Math.pow(2, 32) - 1;
|
||||
var MAX_SAFE_INTEGER = require('./helpers/maxSafeInteger');
|
||||
|
||||
var assign = require('./helpers/assign');
|
||||
var sign = require('./helpers/sign');
|
||||
var mod = require('./helpers/mod');
|
||||
var isPrimitive = require('./helpers/isPrimitive');
|
||||
var forEach = require('./helpers/forEach');
|
||||
var every = require('./helpers/every');
|
||||
var isSamePropertyDescriptor = require('./helpers/isSamePropertyDescriptor');
|
||||
var isPropertyDescriptor = require('./helpers/isPropertyDescriptor');
|
||||
var parseInteger = parseInt;
|
||||
var bind = require('function-bind');
|
||||
var arraySlice = bind.call(Function.call, $Array.prototype.slice);
|
||||
var strSlice = bind.call(Function.call, $String.prototype.slice);
|
||||
var isBinary = bind.call(Function.call, $RegExp.prototype.test, /^0b[01]+$/i);
|
||||
var isOctal = bind.call(Function.call, $RegExp.prototype.test, /^0o[0-7]+$/i);
|
||||
var regexExec = bind.call(Function.call, $RegExp.prototype.exec);
|
||||
var callBound = require('./helpers/callBound');
|
||||
var regexTester = require('./helpers/regexTester');
|
||||
var getIteratorMethod = require('./helpers/getIteratorMethod');
|
||||
var getSymbolDescription = require('./helpers/getSymbolDescription');
|
||||
|
||||
var $PromiseThen = callBound('Promise.prototype.then', true);
|
||||
var arraySlice = callBound('Array.prototype.slice');
|
||||
var strSlice = callBound('String.prototype.slice');
|
||||
var $indexOf = callBound('Array.prototype.indexOf');
|
||||
var $push = callBound('Array.prototype.push');
|
||||
|
||||
var isBinary = regexTester(/^0b[01]+$/i);
|
||||
var isOctal = regexTester(/^0o[0-7]+$/i);
|
||||
var isDigit = regexTester(/^[0-9]$/);
|
||||
var regexExec = callBound('RegExp.prototype.exec');
|
||||
var nonWS = ['\u0085', '\u200b', '\ufffe'].join('');
|
||||
var nonWSregex = new $RegExp('[' + nonWS + ']', 'g');
|
||||
var hasNonWS = bind.call(Function.call, $RegExp.prototype.test, nonWSregex);
|
||||
var invalidHexLiteral = /^[-+]0x[0-9a-f]+$/i;
|
||||
var isInvalidHexLiteral = bind.call(Function.call, $RegExp.prototype.test, invalidHexLiteral);
|
||||
var $charCodeAt = bind.call(Function.call, $String.prototype.charCodeAt);
|
||||
var hasNonWS = regexTester(nonWSregex);
|
||||
var isInvalidHexLiteral = regexTester(/^[-+]0x[0-9a-f]+$/i);
|
||||
var $charCodeAt = callBound('String.prototype.charCodeAt');
|
||||
var $isEnumerable = callBound('Object.prototype.propertyIsEnumerable');
|
||||
|
||||
var toStr = bind.call(Function.call, Object.prototype.toString);
|
||||
var toStr = callBound('Object.prototype.toString');
|
||||
|
||||
var $NumberValueOf = bind.call(Function.call, GetIntrinsic('%NumberPrototype%').valueOf);
|
||||
var $BooleanValueOf = bind.call(Function.call, GetIntrinsic('%BooleanPrototype%').valueOf);
|
||||
var $StringValueOf = bind.call(Function.call, GetIntrinsic('%StringPrototype%').valueOf);
|
||||
var $DateValueOf = bind.call(Function.call, GetIntrinsic('%DatePrototype%').valueOf);
|
||||
var $NumberValueOf = callBound('Number.prototype.valueOf');
|
||||
var $BooleanValueOf = callBound('Boolean.prototype.valueOf');
|
||||
var $StringValueOf = callBound('String.prototype.valueOf');
|
||||
var $DateValueOf = callBound('Date.prototype.valueOf');
|
||||
var $SymbolToString = callBound('Symbol.prototype.toString', true);
|
||||
|
||||
var $floor = Math.floor;
|
||||
var $abs = Math.abs;
|
||||
|
||||
var $ObjectCreate = Object.create;
|
||||
var $ObjectCreate = $Object.create;
|
||||
var $gOPD = $Object.getOwnPropertyDescriptor;
|
||||
|
||||
var $gOPN = $Object.getOwnPropertyNames;
|
||||
var $gOPS = $Object.getOwnPropertySymbols;
|
||||
var $isExtensible = $Object.isExtensible;
|
||||
|
||||
var $defineProperty = $Object.defineProperty;
|
||||
var $setProto = require('./helpers/setProto');
|
||||
|
||||
// whitespace from: http://es5.github.io/#x15.5.4.20
|
||||
var DefineOwnProperty = function DefineOwnProperty(ES, O, P, desc) {
|
||||
if (!$defineProperty) {
|
||||
if (!ES.IsDataDescriptor(desc)) {
|
||||
// ES3 does not support getters/setters
|
||||
return false;
|
||||
}
|
||||
if (!desc['[[Configurable]]'] || !desc['[[Writable]]']) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// fallback for ES3
|
||||
if (P in O && $isEnumerable(O, P) !== !!desc['[[Enumerable]]']) {
|
||||
// a non-enumerable existing property
|
||||
return false;
|
||||
}
|
||||
|
||||
// property does not exist at all, or exists but is enumerable
|
||||
var V = desc['[[Value]]'];
|
||||
O[P] = V; // will use [[Define]]
|
||||
return ES.SameValue(O[P], V);
|
||||
}
|
||||
$defineProperty(O, P, ES.FromPropertyDescriptor(desc));
|
||||
return true;
|
||||
};
|
||||
|
||||
// whitespace from: https://es5.github.io/#x15.5.4.20
|
||||
// implementation from https://github.com/es-shims/es5-shim/blob/v3.4.0/es5-shim.js#L1304-L1324
|
||||
var ws = [
|
||||
'\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003',
|
||||
@@ -65,9 +112,9 @@ var ws = [
|
||||
'\u2029\uFEFF'
|
||||
].join('');
|
||||
var trimRegex = new RegExp('(^[' + ws + ']+)|([' + ws + ']+$)', 'g');
|
||||
var replace = bind.call(Function.call, $String.prototype.replace);
|
||||
var $replace = callBound('String.prototype.replace');
|
||||
var trim = function (value) {
|
||||
return replace(value, trimRegex, '');
|
||||
return $replace(value, trimRegex, '');
|
||||
};
|
||||
|
||||
var ES5 = require('./es5');
|
||||
@@ -81,7 +128,7 @@ var ES6 = assign(assign({}, ES5), {
|
||||
Call: function Call(F, V) {
|
||||
var args = arguments.length > 2 ? arguments[2] : [];
|
||||
if (!this.IsCallable(F)) {
|
||||
throw new $TypeError(F + ' is not a function');
|
||||
throw new $TypeError(inspect(F) + ' is not a function');
|
||||
}
|
||||
return F.apply(V, args);
|
||||
},
|
||||
@@ -211,11 +258,11 @@ var ES6 = assign(assign({}, ES5), {
|
||||
|
||||
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-isconstructor
|
||||
IsConstructor: function IsConstructor(argument) {
|
||||
return typeof argument === 'function' && !!argument.prototype; // unfortunately there's no way to truly check this without try/catch `new argument`
|
||||
return typeof argument === 'function' && !!argument.prototype; // unfortunately there's no way to truly check this without try/catch `new argument` or Proxy
|
||||
},
|
||||
|
||||
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-isextensible-o
|
||||
IsExtensible: Object.preventExtensions
|
||||
IsExtensible: $preventExtensions
|
||||
? function IsExtensible(obj) {
|
||||
if (isPrimitive(obj)) {
|
||||
return false;
|
||||
@@ -325,7 +372,7 @@ var ES6 = assign(assign({}, ES5), {
|
||||
}
|
||||
// 7.3.1.2
|
||||
if (!this.IsPropertyKey(P)) {
|
||||
throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true');
|
||||
throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true, got ' + inspect(P));
|
||||
}
|
||||
// 7.3.1.3
|
||||
return O[P];
|
||||
@@ -360,6 +407,36 @@ var ES6 = assign(assign({}, ES5), {
|
||||
throw new $TypeError('no constructor found');
|
||||
},
|
||||
|
||||
// https://www.ecma-international.org/ecma-262/6.0/#sec-frompropertydescriptor
|
||||
FromPropertyDescriptor: function FromPropertyDescriptor(Desc) {
|
||||
if (typeof Desc === 'undefined') {
|
||||
return Desc;
|
||||
}
|
||||
|
||||
assertRecord(this, 'Property Descriptor', 'Desc', Desc);
|
||||
|
||||
var obj = {};
|
||||
if ('[[Value]]' in Desc) {
|
||||
obj.value = Desc['[[Value]]'];
|
||||
}
|
||||
if ('[[Writable]]' in Desc) {
|
||||
obj.writable = Desc['[[Writable]]'];
|
||||
}
|
||||
if ('[[Get]]' in Desc) {
|
||||
obj.get = Desc['[[Get]]'];
|
||||
}
|
||||
if ('[[Set]]' in Desc) {
|
||||
obj.set = Desc['[[Set]]'];
|
||||
}
|
||||
if ('[[Enumerable]]' in Desc) {
|
||||
obj.enumerable = Desc['[[Enumerable]]'];
|
||||
}
|
||||
if ('[[Configurable]]' in Desc) {
|
||||
obj.configurable = Desc['[[Configurable]]'];
|
||||
}
|
||||
return obj;
|
||||
},
|
||||
|
||||
// https://ecma-international.org/ecma-262/6.0/#sec-completepropertydescriptor
|
||||
CompletePropertyDescriptor: function CompletePropertyDescriptor(Desc) {
|
||||
assertRecord(this, 'Property Descriptor', 'Desc', Desc);
|
||||
@@ -459,13 +536,9 @@ var ES6 = assign(assign({}, ES5), {
|
||||
|
||||
// https://ecma-international.org/ecma-262/6.0/#sec-getiterator
|
||||
GetIterator: function GetIterator(obj, method) {
|
||||
if (!hasSymbols) {
|
||||
throw new SyntaxError('ES.GetIterator depends on native iterator support.');
|
||||
}
|
||||
|
||||
var actualMethod = method;
|
||||
if (arguments.length < 2) {
|
||||
actualMethod = this.GetMethod(obj, $Symbol.iterator);
|
||||
actualMethod = getIteratorMethod(this, obj);
|
||||
}
|
||||
var iterator = this.Call(actualMethod, obj);
|
||||
if (this.Type(iterator) !== 'Object') {
|
||||
@@ -615,19 +688,17 @@ var ES6 = assign(assign({}, ES5), {
|
||||
throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true');
|
||||
}
|
||||
var oldDesc = $gOPD(O, P);
|
||||
var extensible = oldDesc || (typeof $isExtensible !== 'function' || $isExtensible(O));
|
||||
var extensible = oldDesc || this.IsExtensible(O);
|
||||
var immutable = oldDesc && (!oldDesc.writable || !oldDesc.configurable);
|
||||
if (immutable || !extensible) {
|
||||
return false;
|
||||
}
|
||||
var newDesc = {
|
||||
configurable: true,
|
||||
enumerable: true,
|
||||
value: V,
|
||||
writable: true
|
||||
};
|
||||
$defineProperty(O, P, newDesc);
|
||||
return true;
|
||||
return DefineOwnProperty(this, O, P, {
|
||||
'[[Configurable]]': true,
|
||||
'[[Enumerable]]': true,
|
||||
'[[Value]]': V,
|
||||
'[[Writable]]': true
|
||||
});
|
||||
},
|
||||
|
||||
// https://ecma-international.org/ecma-262/6.0/#sec-createdatapropertyorthrow
|
||||
@@ -705,12 +776,12 @@ var ES6 = assign(assign({}, ES5), {
|
||||
}
|
||||
|
||||
var newDesc = {
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
value: V,
|
||||
writable: true
|
||||
'[[Configurable]]': true,
|
||||
'[[Enumerable]]': false,
|
||||
'[[Value]]': V,
|
||||
'[[Writable]]': true
|
||||
};
|
||||
return !!$defineProperty(O, P, newDesc);
|
||||
return DefineOwnProperty(this, O, P, newDesc);
|
||||
},
|
||||
|
||||
// https://www.ecma-international.org/ecma-262/6.0/#sec-definepropertyorthrow
|
||||
@@ -723,7 +794,12 @@ var ES6 = assign(assign({}, ES5), {
|
||||
throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true');
|
||||
}
|
||||
|
||||
return !!$defineProperty(O, P, desc);
|
||||
var Desc = isPropertyDescriptor(this, desc) ? desc : this.ToPropertyDescriptor(desc);
|
||||
if (!isPropertyDescriptor(this, Desc)) {
|
||||
throw new $TypeError('Assertion failed: Desc is not a valid Property Descriptor');
|
||||
}
|
||||
|
||||
return DefineOwnProperty(this, O, P, Desc);
|
||||
},
|
||||
|
||||
// https://www.ecma-international.org/ecma-262/6.0/#sec-deletepropertyorthrow
|
||||
@@ -782,6 +858,604 @@ var ES6 = assign(assign({}, ES5), {
|
||||
// https://ecma-international.org/ecma-262/6.0/#sec-properties-of-the-date-prototype-object
|
||||
thisTimeValue: function thisTimeValue(value) {
|
||||
return $DateValueOf(value);
|
||||
},
|
||||
|
||||
// https://www.ecma-international.org/ecma-262/6.0/#sec-setintegritylevel
|
||||
SetIntegrityLevel: function SetIntegrityLevel(O, level) {
|
||||
if (this.Type(O) !== 'Object') {
|
||||
throw new $TypeError('Assertion failed: Type(O) is not Object');
|
||||
}
|
||||
if (level !== 'sealed' && level !== 'frozen') {
|
||||
throw new $TypeError('Assertion failed: `level` must be `"sealed"` or `"frozen"`');
|
||||
}
|
||||
if (!$preventExtensions) {
|
||||
throw new $SyntaxError('SetIntegrityLevel requires native `Object.preventExtensions` support');
|
||||
}
|
||||
var status = $preventExtensions(O);
|
||||
if (!status) {
|
||||
return false;
|
||||
}
|
||||
if (!$gOPN) {
|
||||
throw new $SyntaxError('SetIntegrityLevel requires native `Object.getOwnPropertyNames` support');
|
||||
}
|
||||
var theKeys = $gOPN(O);
|
||||
var ES = this;
|
||||
if (level === 'sealed') {
|
||||
forEach(theKeys, function (k) {
|
||||
ES.DefinePropertyOrThrow(O, k, { configurable: false });
|
||||
});
|
||||
} else if (level === 'frozen') {
|
||||
forEach(theKeys, function (k) {
|
||||
var currentDesc = $gOPD(O, k);
|
||||
if (typeof currentDesc !== 'undefined') {
|
||||
var desc;
|
||||
if (ES.IsAccessorDescriptor(ES.ToPropertyDescriptor(currentDesc))) {
|
||||
desc = { configurable: false };
|
||||
} else {
|
||||
desc = { configurable: false, writable: false };
|
||||
}
|
||||
ES.DefinePropertyOrThrow(O, k, desc);
|
||||
}
|
||||
});
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
||||
// https://www.ecma-international.org/ecma-262/6.0/#sec-testintegritylevel
|
||||
TestIntegrityLevel: function TestIntegrityLevel(O, level) {
|
||||
if (this.Type(O) !== 'Object') {
|
||||
throw new $TypeError('Assertion failed: Type(O) is not Object');
|
||||
}
|
||||
if (level !== 'sealed' && level !== 'frozen') {
|
||||
throw new $TypeError('Assertion failed: `level` must be `"sealed"` or `"frozen"`');
|
||||
}
|
||||
var status = this.IsExtensible(O);
|
||||
if (status) {
|
||||
return false;
|
||||
}
|
||||
var theKeys = $gOPN(O);
|
||||
var ES = this;
|
||||
return theKeys.length === 0 || every(theKeys, function (k) {
|
||||
var currentDesc = $gOPD(O, k);
|
||||
if (typeof currentDesc !== 'undefined') {
|
||||
if (currentDesc.configurable) {
|
||||
return false;
|
||||
}
|
||||
if (level === 'frozen' && ES.IsDataDescriptor(ES.ToPropertyDescriptor(currentDesc)) && currentDesc.writable) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
},
|
||||
|
||||
// https://www.ecma-international.org/ecma-262/6.0/#sec-ordinaryhasinstance
|
||||
OrdinaryHasInstance: function OrdinaryHasInstance(C, O) {
|
||||
if (this.IsCallable(C) === false) {
|
||||
return false;
|
||||
}
|
||||
if (this.Type(O) !== 'Object') {
|
||||
return false;
|
||||
}
|
||||
var P = this.Get(C, 'prototype');
|
||||
if (this.Type(P) !== 'Object') {
|
||||
throw new $TypeError('OrdinaryHasInstance called on an object with an invalid prototype property.');
|
||||
}
|
||||
return O instanceof C;
|
||||
},
|
||||
|
||||
// https://www.ecma-international.org/ecma-262/6.0/#sec-ordinaryhasproperty
|
||||
OrdinaryHasProperty: function OrdinaryHasProperty(O, P) {
|
||||
if (this.Type(O) !== 'Object') {
|
||||
throw new $TypeError('Assertion failed: Type(O) is not Object');
|
||||
}
|
||||
if (!this.IsPropertyKey(P)) {
|
||||
throw new $TypeError('Assertion failed: P must be a Property Key');
|
||||
}
|
||||
return P in O;
|
||||
},
|
||||
|
||||
// https://www.ecma-international.org/ecma-262/6.0/#sec-instanceofoperator
|
||||
InstanceofOperator: function InstanceofOperator(O, C) {
|
||||
if (this.Type(O) !== 'Object') {
|
||||
throw new $TypeError('Assertion failed: Type(O) is not Object');
|
||||
}
|
||||
var instOfHandler = hasSymbols && $Symbol.hasInstance ? this.GetMethod(C, $Symbol.hasInstance) : void 0;
|
||||
if (typeof instOfHandler !== 'undefined') {
|
||||
return this.ToBoolean(this.Call(instOfHandler, C, [O]));
|
||||
}
|
||||
if (!this.IsCallable(C)) {
|
||||
throw new $TypeError('`C` is not Callable');
|
||||
}
|
||||
return this.OrdinaryHasInstance(C, O);
|
||||
},
|
||||
|
||||
// https://www.ecma-international.org/ecma-262/6.0/#sec-ispromise
|
||||
IsPromise: function IsPromise(x) {
|
||||
if (this.Type(x) !== 'Object') {
|
||||
return false;
|
||||
}
|
||||
if (!$PromiseThen) { // Promises are not supported
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
$PromiseThen(x); // throws if not a promise
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
||||
// https://www.ecma-international.org/ecma-262/6.0/#sec-abstract-equality-comparison
|
||||
'Abstract Equality Comparison': function AbstractEqualityComparison(x, y) {
|
||||
var xType = this.Type(x);
|
||||
var yType = this.Type(y);
|
||||
if (xType === yType) {
|
||||
return x === y; // ES6+ specified this shortcut anyways.
|
||||
}
|
||||
if (x == null && y == null) {
|
||||
return true;
|
||||
}
|
||||
if (xType === 'Number' && yType === 'String') {
|
||||
return this['Abstract Equality Comparison'](x, this.ToNumber(y));
|
||||
}
|
||||
if (xType === 'String' && yType === 'Number') {
|
||||
return this['Abstract Equality Comparison'](this.ToNumber(x), y);
|
||||
}
|
||||
if (xType === 'Boolean') {
|
||||
return this['Abstract Equality Comparison'](this.ToNumber(x), y);
|
||||
}
|
||||
if (yType === 'Boolean') {
|
||||
return this['Abstract Equality Comparison'](x, this.ToNumber(y));
|
||||
}
|
||||
if ((xType === 'String' || xType === 'Number' || xType === 'Symbol') && yType === 'Object') {
|
||||
return this['Abstract Equality Comparison'](x, this.ToPrimitive(y));
|
||||
}
|
||||
if (xType === 'Object' && (yType === 'String' || yType === 'Number' || yType === 'Symbol')) {
|
||||
return this['Abstract Equality Comparison'](this.ToPrimitive(x), y);
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
// eslint-disable-next-line max-lines-per-function, max-statements, id-length, max-params
|
||||
ValidateAndApplyPropertyDescriptor: function ValidateAndApplyPropertyDescriptor(O, P, extensible, Desc, current) {
|
||||
// this uses the ES2017+ logic, since it fixes a number of bugs in the ES2015 logic.
|
||||
var oType = this.Type(O);
|
||||
if (oType !== 'Undefined' && oType !== 'Object') {
|
||||
throw new $TypeError('Assertion failed: O must be undefined or an Object');
|
||||
}
|
||||
if (this.Type(extensible) !== 'Boolean') {
|
||||
throw new $TypeError('Assertion failed: extensible must be a Boolean');
|
||||
}
|
||||
if (!isPropertyDescriptor(this, Desc)) {
|
||||
throw new $TypeError('Assertion failed: Desc must be a Property Descriptor');
|
||||
}
|
||||
if (this.Type(current) !== 'Undefined' && !isPropertyDescriptor(this, current)) {
|
||||
throw new $TypeError('Assertion failed: current must be a Property Descriptor, or undefined');
|
||||
}
|
||||
if (oType !== 'Undefined' && !this.IsPropertyKey(P)) {
|
||||
throw new $TypeError('Assertion failed: if O is not undefined, P must be a Property Key');
|
||||
}
|
||||
if (this.Type(current) === 'Undefined') {
|
||||
if (!extensible) {
|
||||
return false;
|
||||
}
|
||||
if (this.IsGenericDescriptor(Desc) || this.IsDataDescriptor(Desc)) {
|
||||
if (oType !== 'Undefined') {
|
||||
DefineOwnProperty(this, O, P, {
|
||||
'[[Configurable]]': Desc['[[Configurable]]'],
|
||||
'[[Enumerable]]': Desc['[[Enumerable]]'],
|
||||
'[[Value]]': Desc['[[Value]]'],
|
||||
'[[Writable]]': Desc['[[Writable]]']
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if (!this.IsAccessorDescriptor(Desc)) {
|
||||
throw new $TypeError('Assertion failed: Desc is not an accessor descriptor');
|
||||
}
|
||||
if (oType !== 'Undefined') {
|
||||
return DefineOwnProperty(this, O, P, Desc);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (this.IsGenericDescriptor(Desc) && !('[[Configurable]]' in Desc) && !('[[Enumerable]]' in Desc)) {
|
||||
return true;
|
||||
}
|
||||
if (isSamePropertyDescriptor(this, Desc, current)) {
|
||||
return true; // removed by ES2017, but should still be correct
|
||||
}
|
||||
// "if every field in Desc is absent, return true" can't really match the assertion that it's a Property Descriptor
|
||||
if (!current['[[Configurable]]']) {
|
||||
if (Desc['[[Configurable]]']) {
|
||||
return false;
|
||||
}
|
||||
if ('[[Enumerable]]' in Desc && !Desc['[[Enumerable]]'] === !!current['[[Enumerable]]']) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (this.IsGenericDescriptor(Desc)) {
|
||||
// no further validation is required.
|
||||
} else if (this.IsDataDescriptor(current) !== this.IsDataDescriptor(Desc)) {
|
||||
if (!current['[[Configurable]]']) {
|
||||
return false;
|
||||
}
|
||||
if (this.IsDataDescriptor(current)) {
|
||||
if (oType !== 'Undefined') {
|
||||
DefineOwnProperty(this, O, P, {
|
||||
'[[Configurable]]': current['[[Configurable]]'],
|
||||
'[[Enumerable]]': current['[[Enumerable]]'],
|
||||
'[[Get]]': undefined
|
||||
});
|
||||
}
|
||||
} else if (oType !== 'Undefined') {
|
||||
DefineOwnProperty(this, O, P, {
|
||||
'[[Configurable]]': current['[[Configurable]]'],
|
||||
'[[Enumerable]]': current['[[Enumerable]]'],
|
||||
'[[Value]]': undefined
|
||||
});
|
||||
}
|
||||
} else if (this.IsDataDescriptor(current) && this.IsDataDescriptor(Desc)) {
|
||||
if (!current['[[Configurable]]'] && !current['[[Writable]]']) {
|
||||
if ('[[Writable]]' in Desc && Desc['[[Writable]]']) {
|
||||
return false;
|
||||
}
|
||||
if ('[[Value]]' in Desc && !this.SameValue(Desc['[[Value]]'], current['[[Value]]'])) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} else if (this.IsAccessorDescriptor(current) && this.IsAccessorDescriptor(Desc)) {
|
||||
if (!current['[[Configurable]]']) {
|
||||
if ('[[Set]]' in Desc && !this.SameValue(Desc['[[Set]]'], current['[[Set]]'])) {
|
||||
return false;
|
||||
}
|
||||
if ('[[Get]]' in Desc && !this.SameValue(Desc['[[Get]]'], current['[[Get]]'])) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
throw new $TypeError('Assertion failed: current and Desc are not both data, both accessors, or one accessor and one data.');
|
||||
}
|
||||
if (oType !== 'Undefined') {
|
||||
return DefineOwnProperty(this, O, P, Desc);
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
||||
// https://www.ecma-international.org/ecma-262/6.0/#sec-ordinarydefineownproperty
|
||||
OrdinaryDefineOwnProperty: function OrdinaryDefineOwnProperty(O, P, Desc) {
|
||||
if (this.Type(O) !== 'Object') {
|
||||
throw new $TypeError('Assertion failed: O must be an Object');
|
||||
}
|
||||
if (!this.IsPropertyKey(P)) {
|
||||
throw new $TypeError('Assertion failed: P must be a Property Key');
|
||||
}
|
||||
if (!isPropertyDescriptor(this, Desc)) {
|
||||
throw new $TypeError('Assertion failed: Desc must be a Property Descriptor');
|
||||
}
|
||||
var desc = $gOPD(O, P);
|
||||
var current = desc && this.ToPropertyDescriptor(desc);
|
||||
var extensible = this.IsExtensible(O);
|
||||
return this.ValidateAndApplyPropertyDescriptor(O, P, extensible, Desc, current);
|
||||
},
|
||||
|
||||
// https://www.ecma-international.org/ecma-262/6.0/#sec-ordinarygetownproperty
|
||||
OrdinaryGetOwnProperty: function OrdinaryGetOwnProperty(O, P) {
|
||||
if (this.Type(O) !== 'Object') {
|
||||
throw new $TypeError('Assertion failed: O must be an Object');
|
||||
}
|
||||
if (!this.IsPropertyKey(P)) {
|
||||
throw new $TypeError('Assertion failed: P must be a Property Key');
|
||||
}
|
||||
if (!has(O, P)) {
|
||||
return void 0;
|
||||
}
|
||||
if (!$gOPD) {
|
||||
// ES3 fallback
|
||||
var arrayLength = this.IsArray(O) && P === 'length';
|
||||
var regexLastIndex = this.IsRegExp(O) && P === 'lastIndex';
|
||||
return {
|
||||
'[[Configurable]]': !(arrayLength || regexLastIndex),
|
||||
'[[Enumerable]]': $isEnumerable(O, P),
|
||||
'[[Value]]': O[P],
|
||||
'[[Writable]]': true
|
||||
};
|
||||
}
|
||||
return this.ToPropertyDescriptor($gOPD(O, P));
|
||||
},
|
||||
|
||||
// https://www.ecma-international.org/ecma-262/6.0/#sec-arraycreate
|
||||
ArrayCreate: function ArrayCreate(length) {
|
||||
if (!this.IsInteger(length) || length < 0) {
|
||||
throw new $TypeError('Assertion failed: `length` must be an integer Number >= 0');
|
||||
}
|
||||
if (length > MAX_ARRAY_LENGTH) {
|
||||
throw new $RangeError('length is greater than (2**32 - 1)');
|
||||
}
|
||||
var proto = arguments.length > 1 ? arguments[1] : $ArrayPrototype;
|
||||
var A = []; // steps 5 - 7, and 9
|
||||
if (proto !== $ArrayPrototype) { // step 8
|
||||
if (!$setProto) {
|
||||
throw new $SyntaxError('ArrayCreate: a `proto` argument that is not `Array.prototype` is not supported in an environment that does not support setting the [[Prototype]]');
|
||||
}
|
||||
$setProto(A, proto);
|
||||
}
|
||||
if (length !== 0) { // bypasses the need for step 2
|
||||
A.length = length;
|
||||
}
|
||||
/* step 10, the above as a shortcut for the below
|
||||
this.OrdinaryDefineOwnProperty(A, 'length', {
|
||||
'[[Configurable]]': false,
|
||||
'[[Enumerable]]': false,
|
||||
'[[Value]]': length,
|
||||
'[[Writable]]': true
|
||||
});
|
||||
*/
|
||||
return A;
|
||||
},
|
||||
|
||||
// eslint-disable-next-line max-statements, max-lines-per-function
|
||||
ArraySetLength: function ArraySetLength(A, Desc) {
|
||||
if (!this.IsArray(A)) {
|
||||
throw new $TypeError('Assertion failed: A must be an Array');
|
||||
}
|
||||
if (!isPropertyDescriptor(this, Desc)) {
|
||||
throw new $TypeError('Assertion failed: Desc must be a Property Descriptor');
|
||||
}
|
||||
if (!('[[Value]]' in Desc)) {
|
||||
return this.OrdinaryDefineOwnProperty(A, 'length', Desc);
|
||||
}
|
||||
var newLenDesc = assign({}, Desc);
|
||||
var newLen = this.ToUint32(Desc['[[Value]]']);
|
||||
var numberLen = this.ToNumber(Desc['[[Value]]']);
|
||||
if (newLen !== numberLen) {
|
||||
throw new $RangeError('Invalid array length');
|
||||
}
|
||||
newLenDesc['[[Value]]'] = newLen;
|
||||
var oldLenDesc = this.OrdinaryGetOwnProperty(A, 'length');
|
||||
if (!this.IsDataDescriptor(oldLenDesc)) {
|
||||
throw new $TypeError('Assertion failed: an array had a non-data descriptor on `length`');
|
||||
}
|
||||
var oldLen = oldLenDesc['[[Value]]'];
|
||||
if (newLen >= oldLen) {
|
||||
return this.OrdinaryDefineOwnProperty(A, 'length', newLenDesc);
|
||||
}
|
||||
if (!oldLenDesc['[[Writable]]']) {
|
||||
return false;
|
||||
}
|
||||
var newWritable;
|
||||
if (!('[[Writable]]' in newLenDesc) || newLenDesc['[[Writable]]']) {
|
||||
newWritable = true;
|
||||
} else {
|
||||
newWritable = false;
|
||||
newLenDesc['[[Writable]]'] = true;
|
||||
}
|
||||
var succeeded = this.OrdinaryDefineOwnProperty(A, 'length', newLenDesc);
|
||||
if (!succeeded) {
|
||||
return false;
|
||||
}
|
||||
while (newLen < oldLen) {
|
||||
oldLen -= 1;
|
||||
var deleteSucceeded = delete A[this.ToString(oldLen)];
|
||||
if (!deleteSucceeded) {
|
||||
newLenDesc['[[Value]]'] = oldLen + 1;
|
||||
if (!newWritable) {
|
||||
newLenDesc['[[Writable]]'] = false;
|
||||
this.OrdinaryDefineOwnProperty(A, 'length', newLenDesc);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!newWritable) {
|
||||
return this.OrdinaryDefineOwnProperty(A, 'length', { '[[Writable]]': false });
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
||||
// https://www.ecma-international.org/ecma-262/6.0/#sec-createhtml
|
||||
CreateHTML: function CreateHTML(string, tag, attribute, value) {
|
||||
if (this.Type(tag) !== 'String' || this.Type(attribute) !== 'String') {
|
||||
throw new $TypeError('Assertion failed: `tag` and `attribute` must be strings');
|
||||
}
|
||||
var str = this.RequireObjectCoercible(string);
|
||||
var S = this.ToString(str);
|
||||
var p1 = '<' + tag;
|
||||
if (attribute !== '') {
|
||||
var V = this.ToString(value);
|
||||
var escapedV = $replace(V, /\x22/g, '"');
|
||||
p1 += '\x20' + attribute + '\x3D\x22' + escapedV + '\x22';
|
||||
}
|
||||
return p1 + '>' + S + '</' + tag + '>';
|
||||
},
|
||||
|
||||
// https://www.ecma-international.org/ecma-262/6.0/#sec-getownpropertykeys
|
||||
GetOwnPropertyKeys: function GetOwnPropertyKeys(O, Type) {
|
||||
if (this.Type(O) !== 'Object') {
|
||||
throw new $TypeError('Assertion failed: Type(O) is not Object');
|
||||
}
|
||||
if (Type === 'Symbol') {
|
||||
return hasSymbols && $gOPS ? $gOPS(O) : [];
|
||||
}
|
||||
if (Type === 'String') {
|
||||
if (!$gOPN) {
|
||||
return keys(O);
|
||||
}
|
||||
return $gOPN(O);
|
||||
}
|
||||
throw new $TypeError('Assertion failed: `Type` must be `"String"` or `"Symbol"`');
|
||||
},
|
||||
|
||||
// https://www.ecma-international.org/ecma-262/6.0/#sec-symboldescriptivestring
|
||||
SymbolDescriptiveString: function SymbolDescriptiveString(sym) {
|
||||
if (this.Type(sym) !== 'Symbol') {
|
||||
throw new $TypeError('Assertion failed: `sym` must be a Symbol');
|
||||
}
|
||||
return $SymbolToString(sym);
|
||||
},
|
||||
|
||||
// https://www.ecma-international.org/ecma-262/6.0/#sec-getsubstitution
|
||||
// eslint-disable-next-line max-statements, max-params, max-lines-per-function
|
||||
GetSubstitution: function GetSubstitution(matched, str, position, captures, replacement) {
|
||||
if (this.Type(matched) !== 'String') {
|
||||
throw new $TypeError('Assertion failed: `matched` must be a String');
|
||||
}
|
||||
var matchLength = matched.length;
|
||||
|
||||
if (this.Type(str) !== 'String') {
|
||||
throw new $TypeError('Assertion failed: `str` must be a String');
|
||||
}
|
||||
var stringLength = str.length;
|
||||
|
||||
if (!this.IsInteger(position) || position < 0 || position > stringLength) {
|
||||
throw new $TypeError('Assertion failed: `position` must be a nonnegative integer, and less than or equal to the length of `string`, got ' + inspect(position));
|
||||
}
|
||||
|
||||
var ES = this;
|
||||
var isStringOrHole = function (capture, index, arr) { return ES.Type(capture) === 'String' || !(index in arr); };
|
||||
if (!this.IsArray(captures) || !every(captures, isStringOrHole)) {
|
||||
throw new $TypeError('Assertion failed: `captures` must be a List of Strings, got ' + inspect(captures));
|
||||
}
|
||||
|
||||
if (this.Type(replacement) !== 'String') {
|
||||
throw new $TypeError('Assertion failed: `replacement` must be a String');
|
||||
}
|
||||
|
||||
var tailPos = position + matchLength;
|
||||
var m = captures.length;
|
||||
|
||||
var result = '';
|
||||
for (var i = 0; i < replacement.length; i += 1) {
|
||||
// if this is a $, and it's not the end of the replacement
|
||||
var current = replacement[i];
|
||||
var isLast = (i + 1) >= replacement.length;
|
||||
var nextIsLast = (i + 2) >= replacement.length;
|
||||
if (current === '$' && !isLast) {
|
||||
var next = replacement[i + 1];
|
||||
if (next === '$') {
|
||||
result += '$';
|
||||
i += 1;
|
||||
} else if (next === '&') {
|
||||
result += matched;
|
||||
i += 1;
|
||||
} else if (next === '`') {
|
||||
result += position === 0 ? '' : strSlice(str, 0, position - 1);
|
||||
i += 1;
|
||||
} else if (next === "'") {
|
||||
result += tailPos >= stringLength ? '' : strSlice(str, tailPos);
|
||||
i += 1;
|
||||
} else {
|
||||
var nextNext = nextIsLast ? null : replacement[i + 2];
|
||||
if (isDigit(next) && next !== '0' && (nextIsLast || !isDigit(nextNext))) {
|
||||
// $1 through $9, and not followed by a digit
|
||||
var n = parseInteger(next, 10);
|
||||
// if (n > m, impl-defined)
|
||||
result += (n <= m && this.Type(captures[n - 1]) === 'Undefined') ? '' : captures[n - 1];
|
||||
i += 1;
|
||||
} else if (isDigit(next) && (nextIsLast || isDigit(nextNext))) {
|
||||
// $00 through $99
|
||||
var nn = next + nextNext;
|
||||
var nnI = parseInteger(nn, 10) - 1;
|
||||
// if nn === '00' or nn > m, impl-defined
|
||||
result += (nn <= m && this.Type(captures[nnI]) === 'Undefined') ? '' : captures[nnI];
|
||||
i += 2;
|
||||
} else {
|
||||
result += '$';
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// the final $, or else not a $
|
||||
result += replacement[i];
|
||||
}
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
// https://ecma-international.org/ecma-262/6.0/#sec-todatestring
|
||||
ToDateString: function ToDateString(tv) {
|
||||
if (this.Type(tv) !== 'Number') {
|
||||
throw new $TypeError('Assertion failed: `tv` must be a Number');
|
||||
}
|
||||
if ($isNaN(tv)) {
|
||||
return 'Invalid Date';
|
||||
}
|
||||
return $Date(tv);
|
||||
},
|
||||
|
||||
// https://ecma-international.org/ecma-262/6.0/#sec-createlistfromarraylike
|
||||
CreateListFromArrayLike: function CreateListFromArrayLike(obj) {
|
||||
var elementTypes = arguments.length > 1
|
||||
? arguments[1]
|
||||
: ['Undefined', 'Null', 'Boolean', 'String', 'Symbol', 'Number', 'Object'];
|
||||
|
||||
if (this.Type(obj) !== 'Object') {
|
||||
throw new $TypeError('Assertion failed: `obj` must be an Object');
|
||||
}
|
||||
if (!this.IsArray(elementTypes)) {
|
||||
throw new $TypeError('Assertion failed: `elementTypes`, if provided, must be an array');
|
||||
}
|
||||
var len = this.ToLength(this.Get(obj, 'length'));
|
||||
var list = [];
|
||||
var index = 0;
|
||||
while (index < len) {
|
||||
var indexName = this.ToString(index);
|
||||
var next = this.Get(obj, indexName);
|
||||
var nextType = this.Type(next);
|
||||
if ($indexOf(elementTypes, nextType) < 0) {
|
||||
throw new $TypeError('item type ' + nextType + ' is not a valid elementType');
|
||||
}
|
||||
$push(list, next);
|
||||
index += 1;
|
||||
}
|
||||
return list;
|
||||
},
|
||||
|
||||
// https://ecma-international.org/ecma-262/6.0/#sec-getprototypefromconstructor
|
||||
GetPrototypeFromConstructor: function GetPrototypeFromConstructor(constructor, intrinsicDefaultProto) {
|
||||
var intrinsic = GetIntrinsic(intrinsicDefaultProto); // throws if not a valid intrinsic
|
||||
if (!this.IsConstructor(constructor)) {
|
||||
throw new $TypeError('Assertion failed: `constructor` must be a constructor');
|
||||
}
|
||||
var proto = this.Get(constructor, 'prototype');
|
||||
if (this.Type(proto) !== 'Object') {
|
||||
if (!(constructor instanceof $Function)) {
|
||||
// ignore other realms, for now
|
||||
throw new $TypeError('cross-realm constructors not currently supported');
|
||||
}
|
||||
proto = intrinsic;
|
||||
}
|
||||
return proto;
|
||||
},
|
||||
|
||||
// https://ecma-international.org/ecma-262/6.0/#sec-setfunctionname
|
||||
SetFunctionName: function SetFunctionName(F, name) {
|
||||
if (typeof F !== 'function') {
|
||||
throw new $TypeError('Assertion failed: `F` must be a function');
|
||||
}
|
||||
if (!this.IsExtensible(F) || has(F, 'name')) {
|
||||
throw new $TypeError('Assertion failed: `F` must be extensible, and must not have a `name` own property');
|
||||
}
|
||||
var nameType = this.Type(name);
|
||||
if (nameType !== 'Symbol' && nameType !== 'String') {
|
||||
throw new $TypeError('Assertion failed: `name` must be a Symbol or a String');
|
||||
}
|
||||
if (nameType === 'Symbol') {
|
||||
var description = getSymbolDescription(name);
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
name = typeof description === 'undefined' ? '' : '[' + description + ']';
|
||||
}
|
||||
if (arguments.length > 2) {
|
||||
var prefix = arguments[2];
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
name = prefix + ' ' + name;
|
||||
}
|
||||
return this.DefinePropertyOrThrow(F, 'name', {
|
||||
'[[Value]]': name,
|
||||
'[[Writable]]': false,
|
||||
'[[Enumerable]]': false,
|
||||
'[[Configurable]]': true
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user