es-abstract
Advanced tools
Comparing version 1.13.0 to 1.14.1
@@ -0,1 +1,42 @@ | ||
1.14.1 / 2019-09-03 | ||
================= | ||
* [meta] republish with some extra files removed | ||
1.14.0 / 2019-09-02 | ||
================= | ||
* [New] add ES2019 | ||
* [New] `ES2017+`: add `IterableToList` | ||
* [New] `ES2016`: add `IterableToArrayLike` | ||
* [New] `ES2015+`: add `ArrayCreate`, `ArraySetLength`, `OrdinaryDefineOwnProperty`, `OrdinaryGetOwnProperty`, `OrdinaryHasProperty`, `CreateHTML`, `GetOwnPropertyKeys`, `InstanceofOperator`, `SymbolDescriptiveString`, `GetSubstitution`, `ValidateAndApplyPropertyDescriptor`, `IsPromise`, `OrdinaryHasInstance`, `TestIntegrityLevel`, `SetIntegrityLevel` | ||
* [New] add `callBind` helper, and use it | ||
* [New] add helpers: `isPropertyDescriptor`, `every` | ||
* [New] ES5+: add `Abstract Relational Comparison` | ||
* [New] ES5+: add `Abstract Equality Comparison`, `Strict Equality Comparison` | ||
* [Fix] `ES2015+`: `GetIterator`: only require native Symbols when `method` is omitted | ||
* [Fix] `ES2015`: `Call`: error message now properly displays Symbols using `object-inspect` | ||
* [Fix] `ES2015+`: `ValidateAndApplyPropertyDescriptor`: use ES2017 logic to bypass spec bugs | ||
* [Fix] `ES2015+`: `CreateDataProperty`, `DefinePropertyOrThrow`, `ValidateAndApplyPropertyDescriptor`: add fallbacks for ES3 | ||
* [Fix] `ES2015+`: `FromPropertyDescriptor`: no longer requires a fully complete Property Descriptor | ||
* [Fix] `ES5`: `IsPropertyDescriptor`: call into `IsDataDescriptor` and `IsAccessorDescriptor` | ||
* [Refactor] use `has-symbols` for Symbol detection | ||
* [Fix] `helpers/assertRecord`: remove `console.log` | ||
* [Deps] update `object-keys` | ||
* [readme] add security note | ||
* [meta] change http URLs to https | ||
* [meta] linter cleanup | ||
* [meta] fix getOps script | ||
* [meta] add FUNDING.yml | ||
* [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `safe-publish-latest`, `semver`, `replace`, `cheerio`, `tape` | ||
* [Tests] up to `node` `v12.9`, `v11.15`, `v10.16`, `v8.16`, `v6.17` | ||
* [Tests] temporarily allow node 0.6 to fail; segfaulting in travis | ||
* [Tests] use the values helper more in es5 tests | ||
* [Tests] fix linting to apply to all files | ||
* [Tests] run `npx aud` only on prod deps | ||
* [Tests] add v.descriptors helpers | ||
* [Tests] use `npx aud` instead of `npm audit` with hoops | ||
* [Tests] use `eclint` instead of `editorconfig-tools` | ||
* [Tests] some intrinsic cleanup | ||
* [Tests] migrate es5 tests to use values helper | ||
* [Tests] add some missing ES2015 ops | ||
1.13.0 / 2019-01-02 | ||
@@ -2,0 +43,0 @@ ================= |
678
es2015.js
@@ -6,2 +6,3 @@ 'use strict'; | ||
var keys = require('object-keys'); | ||
var inspect = require('object-inspect'); | ||
@@ -11,4 +12,6 @@ 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%'); | ||
@@ -19,4 +22,6 @@ var $Object = GetIntrinsic('%Object%'); | ||
var $RegExp = GetIntrinsic('%RegExp%'); | ||
var $Promise = GetIntrinsic('%Promise%', true); | ||
var $preventExtensions = $Object.preventExtensions; | ||
var hasSymbols = !!$Symbol; | ||
var hasSymbols = require('has-symbols')(); | ||
@@ -26,2 +31,3 @@ var assertRecord = require('./helpers/assertRecord'); | ||
var $isFinite = require('./helpers/isFinite'); | ||
var MAX_ARRAY_LENGTH = Math.pow(2, 32) - 1; | ||
var MAX_SAFE_INTEGER = $Number.MAX_SAFE_INTEGER || Math.pow(2, 53) - 1; | ||
@@ -33,22 +39,30 @@ | ||
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 callBind = require('./helpers/callBind'); | ||
var $PromiseThen = $Promise ? callBind(GetIntrinsic('%PromiseProto_then%')) : null; | ||
var arraySlice = callBind($Array.prototype.slice); | ||
var strSlice = callBind($String.prototype.slice); | ||
var isBinary = callBind($RegExp.prototype.test, /^0b[01]+$/i); | ||
var isOctal = callBind($RegExp.prototype.test, /^0o[0-7]+$/i); | ||
var isDigit = callBind($RegExp.prototype.test, /^[0-9]$/); | ||
var regexExec = callBind($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 hasNonWS = callBind($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 isInvalidHexLiteral = callBind($RegExp.prototype.test, invalidHexLiteral); | ||
var $charCodeAt = callBind($String.prototype.charCodeAt); | ||
var $isEnumerable = callBind($Object.prototype.propertyIsEnumerable); | ||
var toStr = bind.call(Function.call, Object.prototype.toString); | ||
var toStr = callBind($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 = callBind(GetIntrinsic('%NumberPrototype%').valueOf); | ||
var $BooleanValueOf = callBind(GetIntrinsic('%BooleanPrototype%').valueOf); | ||
var $StringValueOf = callBind(GetIntrinsic('%StringPrototype%').valueOf); | ||
var $DateValueOf = callBind(GetIntrinsic('%DatePrototype%').valueOf); | ||
var $SymbolToString = hasSymbols && callBind(GetIntrinsic('%SymbolPrototype%').toString); | ||
@@ -58,10 +72,44 @@ var $floor = Math.floor; | ||
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 = Object.setPrototypeOf || ( | ||
// eslint-disable-next-line no-proto, no-negated-condition | ||
[].__proto__ !== Array.prototype | ||
? null | ||
: function (O, proto) { | ||
O.__proto__ = proto; // eslint-disable-line no-proto | ||
return O; | ||
} | ||
); | ||
// 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 | ||
@@ -74,5 +122,5 @@ var ws = [ | ||
var trimRegex = new RegExp('(^[' + ws + ']+)|([' + ws + ']+$)', 'g'); | ||
var replace = bind.call(Function.call, $String.prototype.replace); | ||
var $replace = callBind($String.prototype.replace); | ||
var trim = function (value) { | ||
return replace(value, trimRegex, ''); | ||
return $replace(value, trimRegex, ''); | ||
}; | ||
@@ -91,3 +139,3 @@ | ||
if (!this.IsCallable(F)) { | ||
throw new $TypeError(F + ' is not a function'); | ||
throw new $TypeError(inspect(F) + ' is not a function'); | ||
} | ||
@@ -226,3 +274,3 @@ return F.apply(V, args); | ||
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-isextensible-o | ||
IsExtensible: Object.preventExtensions | ||
IsExtensible: $preventExtensions | ||
? function IsExtensible(obj) { | ||
@@ -337,3 +385,3 @@ if (isPrimitive(obj)) { | ||
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)); | ||
} | ||
@@ -373,2 +421,32 @@ // 7.3.1.3 | ||
// 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 | ||
@@ -473,8 +551,7 @@ CompletePropertyDescriptor: function CompletePropertyDescriptor(Desc) { | ||
GetIterator: function GetIterator(obj, method) { | ||
if (!hasSymbols) { | ||
throw new SyntaxError('ES.GetIterator depends on native iterator support.'); | ||
} | ||
var actualMethod = method; | ||
if (arguments.length < 2) { | ||
if (!hasSymbols) { | ||
throw new SyntaxError('GetIterator depends on native Symbol support when `method` is not passed'); | ||
} | ||
actualMethod = this.GetMethod(obj, $Symbol.iterator); | ||
@@ -630,3 +707,3 @@ } | ||
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); | ||
@@ -636,10 +713,8 @@ if (immutable || !extensible) { | ||
} | ||
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 | ||
}); | ||
}, | ||
@@ -722,8 +797,8 @@ | ||
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); | ||
}, | ||
@@ -741,3 +816,8 @@ | ||
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); | ||
}, | ||
@@ -801,2 +881,514 @@ | ||
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 (!$Promise) { // 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; | ||
} | ||
@@ -803,0 +1395,0 @@ }); |
'use strict'; | ||
var GetIntrinsic = require('./GetIntrinsic'); | ||
var $Array = GetIntrinsic('%Array%'); | ||
var hasSymbols = require('has-symbols')(); | ||
var ES2015 = require('./es2015'); | ||
var assign = require('./helpers/assign'); | ||
var callBind = require('./helpers/callBind'); | ||
var $arrayPush = callBind($Array.prototype.push); | ||
var ES2016 = assign(assign({}, ES2015), { | ||
// https://github.com/tc39/ecma262/pull/60 | ||
// https://www.ecma-international.org/ecma-262/7.0/#sec-samevaluenonnumber | ||
SameValueNonNumber: function SameValueNonNumber(x, y) { | ||
@@ -13,2 +22,41 @@ if (typeof x === 'number' || typeof x !== typeof y) { | ||
return this.SameValue(x, y); | ||
}, | ||
// https://www.ecma-international.org/ecma-262/7.0/#sec-iterabletoarraylike | ||
IterableToArrayLike: function IterableToArrayLike(items) { | ||
var usingIterator; | ||
if (hasSymbols) { | ||
usingIterator = this.GetMethod(items, Symbol.iterator); | ||
} else if (this.IsArray(items)) { | ||
usingIterator = function () { | ||
var i = -1; | ||
var arr = this; // eslint-disable-line no-invalid-this | ||
return { | ||
next: function () { | ||
i += 1; | ||
return { | ||
done: i >= arr.length, | ||
value: arr[i] | ||
}; | ||
} | ||
}; | ||
}; | ||
} else if (this.Type(items) === 'String') { | ||
// fallback for strings | ||
} | ||
if (typeof usingIterator !== 'undefined') { | ||
var iterator = this.GetIterator(items, usingIterator); | ||
var values = []; | ||
var next = true; | ||
while (next) { | ||
next = this.IteratorStep(iterator); | ||
if (next) { | ||
var nextValue = this.IteratorValue(next); | ||
$arrayPush(values, nextValue); | ||
} | ||
} | ||
return values; | ||
} | ||
return this.ToObject(items); | ||
} | ||
@@ -15,0 +63,0 @@ }); |
'use strict'; | ||
var bind = require('function-bind'); | ||
var GetIntrinsic = require('./GetIntrinsic'); | ||
@@ -8,8 +8,9 @@ var ES2016 = require('./es2016'); | ||
var forEach = require('./helpers/forEach'); | ||
var callBind = require('./helpers/callBind'); | ||
var GetIntrinsic = require('./GetIntrinsic'); | ||
var $TypeError = GetIntrinsic('%TypeError%'); | ||
var $isEnumerable = bind.call(Function.call, GetIntrinsic('%ObjectPrototype%').propertyIsEnumerable); | ||
var $pushApply = bind.call(Function.apply, GetIntrinsic('%ArrayPrototype%').push); | ||
var $Array = GetIntrinsic('%Array%'); | ||
var $isEnumerable = callBind(GetIntrinsic('%ObjectPrototype%').propertyIsEnumerable); | ||
var $pushApply = callBind.apply(GetIntrinsic('%ArrayPrototype%').push); | ||
var $arrayPush = callBind($Array.prototype.push); | ||
@@ -50,2 +51,17 @@ var ES2017 = assign(assign({}, ES2016), { | ||
throw new $TypeError('Assertion failed: "kind" is not "key", "value", or "key+value": ' + kind); | ||
}, | ||
// https://www.ecma-international.org/ecma-262/8.0/#sec-iterabletolist | ||
IterableToList: function IterableToList(items, method) { | ||
var iterator = this.GetIterator(items, method); | ||
var values = []; | ||
var next = true; | ||
while (next) { | ||
next = this.IteratorStep(iterator); | ||
if (next) { | ||
var nextValue = this.IteratorValue(next); | ||
$arrayPush(values, nextValue); | ||
} | ||
} | ||
return values; | ||
} | ||
@@ -55,3 +71,4 @@ }); | ||
delete ES2017.EnumerableOwnNames; // replaced with EnumerableOwnProperties | ||
delete ES2017.IterableToArrayLike; // replaced with IterableToList | ||
module.exports = ES2017; |
122
es2018.js
'use strict'; | ||
var bind = require('function-bind'); | ||
var GetIntrinsic = require('./GetIntrinsic'); | ||
var keys = require('object-keys'); | ||
var inspect = require('object-inspect'); | ||
@@ -9,18 +11,24 @@ var ES2017 = require('./es2017'); | ||
var forEach = require('./helpers/forEach'); | ||
var callBind = require('./helpers/callBind'); | ||
var every = require('./helpers/every'); | ||
var GetIntrinsic = require('./GetIntrinsic'); | ||
var $String = GetIntrinsic('%String%'); | ||
var $Object = GetIntrinsic('%Object%'); | ||
var $TypeError = GetIntrinsic('%TypeError%'); | ||
var $RegExp = GetIntrinsic('%RegExp%'); | ||
var $SymbolProto = GetIntrinsic('%SymbolPrototype%', true); | ||
var $SymbolValueOf = $SymbolProto ? bind.call(Function.call, $SymbolProto.valueOf) : null; | ||
var $SymbolValueOf = $SymbolProto ? callBind($SymbolProto.valueOf) : null; | ||
var $StringProto = GetIntrinsic('%StringPrototype%'); | ||
var $charAt = bind.call(Function.call, $StringProto.charAt); | ||
var $charAt = callBind($StringProto.charAt); | ||
var strSlice = callBind($StringProto.slice); | ||
var $indexOf = callBind($StringProto.indexOf); | ||
var $parseInt = parseInt; | ||
var isDigit = callBind($RegExp.prototype.test, /^[0-9]$/); | ||
var $PromiseResolveOrig = GetIntrinsic('%Promise_resolve%', true); | ||
var $PromiseResolve = $PromiseResolveOrig ? bind.call(Function.call, $PromiseResolveOrig) : null; | ||
var $PromiseResolve = $PromiseResolveOrig ? callBind($PromiseResolveOrig) : null; | ||
var $isEnumerable = bind.call(Function.call, GetIntrinsic('%ObjectPrototype%').propertyIsEnumerable); | ||
var $pushApply = bind.call(Function.apply, GetIntrinsic('%ArrayPrototype%').push); | ||
var $isEnumerable = callBind(GetIntrinsic('%ObjectPrototype%').propertyIsEnumerable); | ||
var $pushApply = callBind.apply(GetIntrinsic('%ArrayPrototype%').push); | ||
var $gOPS = $SymbolValueOf ? $Object.getOwnPropertySymbols : null; | ||
@@ -143,2 +151,100 @@ | ||
return $PromiseResolve(C, x); | ||
}, | ||
// http://www.ecma-international.org/ecma-262/9.0/#sec-getsubstitution | ||
// eslint-disable-next-line max-statements, max-params, max-lines-per-function | ||
GetSubstitution: function GetSubstitution(matched, str, position, captures, namedCaptures, 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; | ||
if (this.Type(namedCaptures) !== 'Undefined') { | ||
namedCaptures = this.ToObject(namedCaptures); // eslint-disable-line no-param-reassign | ||
} | ||
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 = $parseInt(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 = $parseInt(nn, 10) - 1; | ||
// if nn === '00' or nn > m, impl-defined | ||
result += (nn <= m && this.Type(captures[nnI]) === 'Undefined') ? '' : captures[nnI]; | ||
i += 2; | ||
} else if (next === '<') { | ||
// eslint-disable-next-line max-depth | ||
if (this.Type(namedCaptures) === 'Undefined') { | ||
result += '$<'; | ||
i += 2; | ||
} else { | ||
var endIndex = $indexOf(replacement, '>', i); | ||
// eslint-disable-next-line max-depth | ||
if (endIndex > -1) { | ||
var groupName = strSlice(replacement, i, endIndex); | ||
var capture = this.Get(namedCaptures, groupName); | ||
// eslint-disable-next-line max-depth | ||
if (this.Type(capture) !== 'Undefined') { | ||
result += this.ToString(capture); | ||
} | ||
i += '$<' + groupName + '>'.length; | ||
} | ||
} | ||
} else { | ||
result += '$'; | ||
} | ||
} | ||
} else { | ||
// the final $, or else not a $ | ||
result += replacement[i]; | ||
} | ||
} | ||
return result; | ||
} | ||
@@ -145,0 +251,0 @@ }); |
135
es5.js
@@ -8,4 +8,6 @@ 'use strict'; | ||
var $String = GetIntrinsic('%String%'); | ||
var $Number = GetIntrinsic('%Number%'); | ||
var assertRecord = require('./helpers/assertRecord'); | ||
var isPropertyDescriptor = require('./helpers/isPropertyDescriptor'); | ||
var $isNaN = require('./helpers/isNaN'); | ||
@@ -22,2 +24,15 @@ var $isFinite = require('./helpers/isFinite'); | ||
var callBind = require('./helpers/callBind'); | ||
var strSlice = callBind($String.prototype.slice); | ||
var isPrefixOf = function isPrefixOf(prefix, string) { | ||
if (prefix === string) { | ||
return true; | ||
} | ||
if (prefix.length > string.length) { | ||
return false; | ||
} | ||
return strSlice(string, 0, prefix.length) === prefix; | ||
}; | ||
// https://es5.github.io/#x9 | ||
@@ -98,26 +113,3 @@ var ES5 = { | ||
IsPropertyDescriptor: function IsPropertyDescriptor(Desc) { | ||
if (this.Type(Desc) !== 'Object') { | ||
return false; | ||
} | ||
var allowed = { | ||
'[[Configurable]]': true, | ||
'[[Enumerable]]': true, | ||
'[[Get]]': true, | ||
'[[Set]]': true, | ||
'[[Value]]': true, | ||
'[[Writable]]': true | ||
}; | ||
for (var key in Desc) { // eslint-disable-line | ||
if (has(Desc, key) && !allowed[key]) { | ||
return false; | ||
} | ||
} | ||
var isData = has(Desc, '[[Value]]'); | ||
var IsAccessor = has(Desc, '[[Get]]') || has(Desc, '[[Set]]'); | ||
if (isData && IsAccessor) { | ||
throw new $TypeError('Property Descriptors may not be both accessor and data descriptors'); | ||
} | ||
return true; | ||
return isPropertyDescriptor(this, Desc); | ||
}, | ||
@@ -235,2 +227,97 @@ | ||
return desc; | ||
}, | ||
// https://www.ecma-international.org/ecma-262/5.1/#sec-11.9.3 | ||
'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') && yType === 'Object') { | ||
return this['Abstract Equality Comparison'](x, this.ToPrimitive(y)); | ||
} | ||
if (xType === 'Object' && (yType === 'String' || yType === 'Number')) { | ||
return this['Abstract Equality Comparison'](this.ToPrimitive(x), y); | ||
} | ||
return false; | ||
}, | ||
// https://www.ecma-international.org/ecma-262/5.1/#sec-11.9.6 | ||
'Strict Equality Comparison': function StrictEqualityComparison(x, y) { | ||
var xType = this.Type(x); | ||
var yType = this.Type(y); | ||
if (xType !== yType) { | ||
return false; | ||
} | ||
if (xType === 'Undefined' || xType === 'Null') { | ||
return true; | ||
} | ||
return x === y; // shortcut for steps 4-7 | ||
}, | ||
// https://www.ecma-international.org/ecma-262/5.1/#sec-11.8.5 | ||
// eslint-disable-next-line max-statements | ||
'Abstract Relational Comparison': function AbstractRelationalComparison(x, y, LeftFirst) { | ||
if (this.Type(LeftFirst) !== 'Boolean') { | ||
throw new $TypeError('Assertion failed: LeftFirst argument must be a Boolean'); | ||
} | ||
var px; | ||
var py; | ||
if (LeftFirst) { | ||
px = this.ToPrimitive(x, $Number); | ||
py = this.ToPrimitive(y, $Number); | ||
} else { | ||
py = this.ToPrimitive(y, $Number); | ||
px = this.ToPrimitive(x, $Number); | ||
} | ||
var bothStrings = this.Type(px) === 'String' && this.Type(py) === 'String'; | ||
if (!bothStrings) { | ||
var nx = this.ToNumber(px); | ||
var ny = this.ToNumber(py); | ||
if ($isNaN(nx) || $isNaN(ny)) { | ||
return undefined; | ||
} | ||
if ($isFinite(nx) && $isFinite(ny) && nx === ny) { | ||
return false; | ||
} | ||
if (nx === 0 && ny === 0) { | ||
return false; | ||
} | ||
if (nx === Infinity) { | ||
return false; | ||
} | ||
if (ny === Infinity) { | ||
return true; | ||
} | ||
if (ny === -Infinity) { | ||
return false; | ||
} | ||
if (nx === -Infinity) { | ||
return true; | ||
} | ||
return nx < ny; // by now, these are both nonzero, finite, and not equal | ||
} | ||
if (isPrefixOf(py, px)) { | ||
return false; | ||
} | ||
if (isPrefixOf(px, py)) { | ||
return true; | ||
} | ||
return px < py; // both strings, neither a prefix of the other. shortcut for steps c-f | ||
} | ||
@@ -237,0 +324,0 @@ }; |
'use strict'; | ||
/* globals | ||
Set, | ||
Map, | ||
WeakSet, | ||
WeakMap, | ||
Promise, | ||
Symbol, | ||
Proxy, | ||
Atomics, | ||
SharedArrayBuffer, | ||
ArrayBuffer, | ||
DataView, | ||
Uint8Array, | ||
Float32Array, | ||
Float64Array, | ||
Int8Array, | ||
Int16Array, | ||
Int32Array, | ||
Uint8ClampedArray, | ||
Uint16Array, | ||
Uint32Array, | ||
*/ | ||
@@ -29,0 +7,0 @@ |
@@ -11,40 +11,39 @@ 'use strict'; | ||
var predicates = { | ||
// https://ecma-international.org/ecma-262/6.0/#sec-property-descriptor-specification-type | ||
'Property Descriptor': function isPropertyDescriptor(ES, Desc) { | ||
if (ES.Type(Desc) !== 'Object') { | ||
return false; | ||
} | ||
var allowed = { | ||
'[[Configurable]]': true, | ||
'[[Enumerable]]': true, | ||
'[[Get]]': true, | ||
'[[Set]]': true, | ||
'[[Value]]': true, | ||
'[[Writable]]': true | ||
}; | ||
// https://ecma-international.org/ecma-262/6.0/#sec-property-descriptor-specification-type | ||
'Property Descriptor': function isPropertyDescriptor(ES, Desc) { | ||
if (ES.Type(Desc) !== 'Object') { | ||
return false; | ||
} | ||
var allowed = { | ||
'[[Configurable]]': true, | ||
'[[Enumerable]]': true, | ||
'[[Get]]': true, | ||
'[[Set]]': true, | ||
'[[Value]]': true, | ||
'[[Writable]]': true | ||
}; | ||
for (var key in Desc) { // eslint-disable-line | ||
if (has(Desc, key) && !allowed[key]) { | ||
return false; | ||
} | ||
} | ||
for (var key in Desc) { // eslint-disable-line | ||
if (has(Desc, key) && !allowed[key]) { | ||
return false; | ||
} | ||
} | ||
var isData = has(Desc, '[[Value]]'); | ||
var IsAccessor = has(Desc, '[[Get]]') || has(Desc, '[[Set]]'); | ||
if (isData && IsAccessor) { | ||
throw new $TypeError('Property Descriptors may not be both accessor and data descriptors'); | ||
} | ||
return true; | ||
} | ||
var isData = has(Desc, '[[Value]]'); | ||
var IsAccessor = has(Desc, '[[Get]]') || has(Desc, '[[Set]]'); | ||
if (isData && IsAccessor) { | ||
throw new $TypeError('Property Descriptors may not be both accessor and data descriptors'); | ||
} | ||
return true; | ||
} | ||
}; | ||
module.exports = function assertRecord(ES, recordType, argumentName, value) { | ||
var predicate = predicates[recordType]; | ||
if (typeof predicate !== 'function') { | ||
throw new $SyntaxError('unknown record type: ' + recordType); | ||
} | ||
if (!predicate(ES, value)) { | ||
throw new $TypeError(argumentName + ' must be a ' + recordType); | ||
} | ||
console.log(predicate(ES, value), value); | ||
var predicate = predicates[recordType]; | ||
if (typeof predicate !== 'function') { | ||
throw new $SyntaxError('unknown record type: ' + recordType); | ||
} | ||
if (!predicate(ES, value)) { | ||
throw new $TypeError(argumentName + ' must be a ' + recordType); | ||
} | ||
}; |
@@ -1,6 +0,9 @@ | ||
var bind = require('function-bind'); | ||
var has = bind.call(Function.call, Object.prototype.hasOwnProperty); | ||
'use strict'; | ||
var $assign = Object.assign; | ||
var GetIntrinsic = require('../GetIntrinsic'); | ||
var has = require('has'); | ||
var $assign = GetIntrinsic('%Object%').assign; | ||
module.exports = function assign(target, source) { | ||
@@ -11,2 +14,3 @@ if ($assign) { | ||
// eslint-disable-next-line no-restricted-syntax | ||
for (var key in source) { | ||
@@ -13,0 +17,0 @@ if (has(source, key)) { |
@@ -5,4 +5,4 @@ 'use strict'; | ||
for (var i = 0; i < array.length; i += 1) { | ||
callback(array[i], i, array); | ||
callback(array[i], i, array); // eslint-disable-line callback-return | ||
} | ||
}; |
@@ -0,3 +1,5 @@ | ||
'use strict'; | ||
var $isNaN = Number.isNaN || function (a) { return a !== a; }; | ||
module.exports = Number.isFinite || function (x) { return typeof x === 'number' && !$isNaN(x) && x !== Infinity && x !== -Infinity; }; |
@@ -0,3 +1,5 @@ | ||
'use strict'; | ||
module.exports = Number.isNaN || function isNaN(a) { | ||
return a !== a; | ||
}; |
@@ -0,3 +1,5 @@ | ||
'use strict'; | ||
module.exports = function isPrimitive(value) { | ||
return value === null || (typeof value !== 'function' && typeof value !== 'object'); | ||
}; |
@@ -0,1 +1,3 @@ | ||
'use strict'; | ||
module.exports = function mod(number, modulo) { | ||
@@ -2,0 +4,0 @@ var remain = number % modulo; |
@@ -0,3 +1,5 @@ | ||
'use strict'; | ||
module.exports = function sign(number) { | ||
return number >= 0 ? 1 : -1; | ||
}; |
@@ -10,2 +10,3 @@ 'use strict'; | ||
var ES2018 = require('./es2018'); | ||
var ES2019 = require('./es2019'); | ||
@@ -19,3 +20,4 @@ var ES = { | ||
ES2017: ES2017, | ||
ES2018: ES2018 | ||
ES2018: ES2018, | ||
ES2019: ES2019 | ||
}; | ||
@@ -22,0 +24,0 @@ assign(ES, ES5); |
'use strict'; | ||
module.exports = { | ||
IsPropertyDescriptor: 'https://ecma-international.org/ecma-262/6.0/#sec-property-descriptor-specification-type', | ||
'Abstract Equality Comparison': 'https://www.ecma-international.org/ecma-262/6.0/#sec-abstract-equality-comparison', | ||
'Abstract Relational Comparison': 'https://www.ecma-international.org/ecma-262/6.0/#sec-abstract-relational-comparison', | ||
'Strict Equality Comparison': 'https://www.ecma-international.org/ecma-262/6.0/#sec-strict-equality-comparison', | ||
AdvanceStringIndex: 'https://ecma-international.org/ecma-262/6.0/#sec-advancestringindex', | ||
ArrayCreate: 'https://www.ecma-international.org/ecma-262/6.0/#sec-arraycreate', | ||
ArraySetLength: 'https://www.ecma-international.org/ecma-262/6.0/#sec-arraysetlength', | ||
ArraySpeciesCreate: 'https://ecma-international.org/ecma-262/6.0/#sec-arrayspeciescreate', | ||
Call: 'https://ecma-international.org/ecma-262/6.0/#sec-call', | ||
CanonicalNumericIndexString: 'https://ecma-international.org/ecma-262/6.0/#sec-canonicalnumericindexstring', | ||
CompletePropertyDescriptor: 'https://ecma-international.org/ecma-262/6.0/#sec-completepropertydescriptor', | ||
Construct: 'https://ecma-international.org/ecma-262/6.0/#sec-construct', | ||
CreateArrayFromList: 'https://ecma-international.org/ecma-262/6.0/#sec-createarrayfromlist', | ||
CreateDataProperty: 'https://ecma-international.org/ecma-262/6.0/#sec-createdataproperty', | ||
CreateDataPropertyOrThrow: 'https://ecma-international.org/ecma-262/6.0/#sec-createdatapropertyorthrow', | ||
CreateHTML: 'https://www.ecma-international.org/ecma-262/6.0/#sec-createhtml', | ||
CreateIterResultObject: 'https://ecma-international.org/ecma-262/6.0/#sec-createiterresultobject', | ||
CreateListFromArrayLike: 'https://ecma-international.org/ecma-262/6.0/#sec-createlistfromarraylike', | ||
CreateListIterator: 'https://ecma-international.org/ecma-262/6.0/#sec-createlistiterator', | ||
CreateMethodProperty: 'https://ecma-international.org/ecma-262/6.0/#sec-createmethodproperty', | ||
DefinePropertyOrThrow: 'https://ecma-international.org/ecma-262/6.0/#sec-definepropertyorthrow', | ||
DeletePropertyOrThrow: 'https://ecma-international.org/ecma-262/6.0/#sec-deletepropertyorthrow', | ||
EnumerableOwnNames: 'https://ecma-international.org/ecma-262/6.0/#sec-enumerableownnames', | ||
FromPropertyDescriptor: 'https://ecma-international.org/ecma-262/6.0/#sec-frompropertydescriptor', | ||
Get: 'https://ecma-international.org/ecma-262/6.0/#sec-get-o-p', | ||
GetIterator: 'https://ecma-international.org/ecma-262/6.0/#sec-getiterator', | ||
GetMethod: 'https://ecma-international.org/ecma-262/6.0/#sec-getmethod', | ||
GetOwnPropertyKeys: 'https://www.ecma-international.org/ecma-262/6.0/#sec-getownpropertykeys', | ||
GetSubstitution: 'https://www.ecma-international.org/ecma-262/6.0/#sec-getsubstitution', | ||
GetV: 'https://ecma-international.org/ecma-262/6.0/#sec-getv', | ||
HasOwnProperty: 'https://ecma-international.org/ecma-262/6.0/#sec-hasownproperty', | ||
HasProperty: 'https://ecma-international.org/ecma-262/6.0/#sec-hasproperty', | ||
InstanceofOperator: 'https://www.ecma-international.org/ecma-262/6.0/#sec-instanceofoperator', | ||
Invoke: 'https://ecma-international.org/ecma-262/6.0/#sec-invoke', | ||
IsAccessorDescriptor: 'https://ecma-international.org/ecma-262/6.0/#sec-isaccessordescriptor', | ||
IsDataDescriptor: 'https://ecma-international.org/ecma-262/6.0/#sec-isdatadescriptor', | ||
IsGenericDescriptor: 'https://ecma-international.org/ecma-262/6.0/#sec-isgenericdescriptor', | ||
FromPropertyDescriptor: 'https://ecma-international.org/ecma-262/6.0/#sec-frompropertydescriptor', | ||
ToPropertyDescriptor: 'https://ecma-international.org/ecma-262/6.0/#sec-topropertydescriptor', | ||
CompletePropertyDescriptor: 'https://ecma-international.org/ecma-262/6.0/#sec-completepropertydescriptor', | ||
ToPrimitive: 'https://ecma-international.org/ecma-262/6.0/#sec-toprimitive', | ||
ToBoolean: 'https://ecma-international.org/ecma-262/6.0/#sec-toboolean', | ||
ToNumber: 'https://ecma-international.org/ecma-262/6.0/#sec-tonumber', | ||
ToInteger: 'https://ecma-international.org/ecma-262/6.0/#sec-tointeger', | ||
ToInt32: 'https://ecma-international.org/ecma-262/6.0/#sec-toint32', | ||
ToUint32: 'https://ecma-international.org/ecma-262/6.0/#sec-touint32', | ||
ToInt16: 'https://ecma-international.org/ecma-262/6.0/#sec-toint16', | ||
ToUint16: 'https://ecma-international.org/ecma-262/6.0/#sec-touint16', | ||
ToInt8: 'https://ecma-international.org/ecma-262/6.0/#sec-toint8', | ||
ToUint8: 'https://ecma-international.org/ecma-262/6.0/#sec-touint8', | ||
ToUint8Clamp: 'https://ecma-international.org/ecma-262/6.0/#sec-touint8clamp', | ||
ToString: 'https://ecma-international.org/ecma-262/6.0/#sec-tostring', | ||
ToObject: 'https://ecma-international.org/ecma-262/6.0/#sec-toobject', | ||
ToPropertyKey: 'https://ecma-international.org/ecma-262/6.0/#sec-topropertykey', | ||
ToLength: 'https://ecma-international.org/ecma-262/6.0/#sec-tolength', | ||
CanonicalNumericIndexString: 'https://ecma-international.org/ecma-262/6.0/#sec-canonicalnumericindexstring', | ||
RequireObjectCoercible: 'https://ecma-international.org/ecma-262/6.0/#sec-requireobjectcoercible', | ||
IsArray: 'https://ecma-international.org/ecma-262/6.0/#sec-isarray', | ||
IsCallable: 'https://ecma-international.org/ecma-262/6.0/#sec-iscallable', | ||
IsConcatSpreadable: 'https://ecma-international.org/ecma-262/6.0/#sec-isconcatspreadable', | ||
IsConstructor: 'https://ecma-international.org/ecma-262/6.0/#sec-isconstructor', | ||
IsDataDescriptor: 'https://ecma-international.org/ecma-262/6.0/#sec-isdatadescriptor', | ||
IsExtensible: 'https://ecma-international.org/ecma-262/6.0/#sec-isextensible-o', | ||
IsGenericDescriptor: 'https://ecma-international.org/ecma-262/6.0/#sec-isgenericdescriptor', | ||
IsInteger: 'https://ecma-international.org/ecma-262/6.0/#sec-isinteger', | ||
IsPromise: 'https://ecma-international.org/ecma-262/6.0/#sec-ispromise', | ||
IsPropertyDescriptor: 'https://ecma-international.org/ecma-262/6.0/#sec-property-descriptor-specification-type', | ||
IsPropertyKey: 'https://ecma-international.org/ecma-262/6.0/#sec-ispropertykey', | ||
IsRegExp: 'https://ecma-international.org/ecma-262/6.0/#sec-isregexp', | ||
IteratorClose: 'https://ecma-international.org/ecma-262/6.0/#sec-iteratorclose', | ||
IteratorComplete: 'https://ecma-international.org/ecma-262/6.0/#sec-iteratorcomplete', | ||
IteratorNext: 'https://ecma-international.org/ecma-262/6.0/#sec-iteratornext', | ||
IteratorStep: 'https://ecma-international.org/ecma-262/6.0/#sec-iteratorstep', | ||
IteratorValue: 'https://ecma-international.org/ecma-262/6.0/#sec-iteratorvalue', | ||
NormalCompletion: 'https://ecma-international.org/ecma-262/6.0/#sec-normalcompletion', | ||
ObjectCreate: 'https://ecma-international.org/ecma-262/6.0/#sec-objectcreate', | ||
OrdinaryDefineOwnProperty: 'https://www.ecma-international.org/ecma-262/6.0/#sec-ordinarydefineownproperty', | ||
OrdinaryGetOwnProperty: 'https://www.ecma-international.org/ecma-262/6.0/#sec-ordinarygetownproperty', | ||
OrdinaryHasInstance: 'https://ecma-international.org/ecma-262/6.0/#sec-ordinaryhasinstance', | ||
OrdinaryHasProperty: 'https://www.ecma-international.org/ecma-262/6.0/#sec-ordinaryhasproperty', | ||
RegExpBuiltinExec: 'https://ecma-international.org/ecma-262/6.0/#sec-regexpbuiltinexec', | ||
RegExpExec: 'https://ecma-international.org/ecma-262/6.0/#sec-regexpexec', | ||
RequireObjectCoercible: 'https://ecma-international.org/ecma-262/6.0/#sec-requireobjectcoercible', | ||
SameValue: 'https://ecma-international.org/ecma-262/6.0/#sec-samevalue', | ||
SameValueZero: 'https://ecma-international.org/ecma-262/6.0/#sec-samevaluezero', | ||
Get: 'https://ecma-international.org/ecma-262/6.0/#sec-get-o-p', | ||
GetV: 'https://ecma-international.org/ecma-262/6.0/#sec-getv', | ||
Set: 'https://ecma-international.org/ecma-262/6.0/#sec-set-o-p-v-throw', | ||
CreateDataProperty: 'https://ecma-international.org/ecma-262/6.0/#sec-createdataproperty', | ||
CreateMethodProperty: 'https://ecma-international.org/ecma-262/6.0/#sec-createmethodproperty', | ||
CreateDataPropertyOrThrow: 'https://ecma-international.org/ecma-262/6.0/#sec-createdatapropertyorthrow', | ||
DefinePropertyOrThrow: 'https://ecma-international.org/ecma-262/6.0/#sec-definepropertyorthrow', | ||
DeletePropertyOrThrow: 'https://ecma-international.org/ecma-262/6.0/#sec-deletepropertyorthrow', | ||
GetMethod: 'https://ecma-international.org/ecma-262/6.0/#sec-getmethod', | ||
HasProperty: 'https://ecma-international.org/ecma-262/6.0/#sec-hasproperty', | ||
HasOwnProperty: 'https://ecma-international.org/ecma-262/6.0/#sec-hasownproperty', | ||
Call: 'https://ecma-international.org/ecma-262/6.0/#sec-call', | ||
Construct: 'https://ecma-international.org/ecma-262/6.0/#sec-construct', | ||
SetIntegrityLevel: 'https://ecma-international.org/ecma-262/6.0/#sec-setintegritylevel', | ||
SpeciesConstructor: 'https://ecma-international.org/ecma-262/6.0/#sec-speciesconstructor', | ||
SymbolDescriptiveString: 'https://www.ecma-international.org/ecma-262/6.0/#sec-symboldescriptivestring', | ||
TestIntegrityLevel: 'https://ecma-international.org/ecma-262/6.0/#sec-testintegritylevel', | ||
CreateArrayFromList: 'https://ecma-international.org/ecma-262/6.0/#sec-createarrayfromlist', | ||
CreateListFromArrayLike: 'https://ecma-international.org/ecma-262/6.0/#sec-createlistfromarraylike', | ||
Invoke: 'https://ecma-international.org/ecma-262/6.0/#sec-invoke', | ||
OrdinaryHasInstance: 'https://ecma-international.org/ecma-262/6.0/#sec-ordinaryhasinstance', | ||
SpeciesConstructor: 'https://ecma-international.org/ecma-262/6.0/#sec-speciesconstructor', | ||
EnumerableOwnNames: 'https://ecma-international.org/ecma-262/6.0/#sec-enumerableownnames', | ||
GetIterator: 'https://ecma-international.org/ecma-262/6.0/#sec-getiterator', | ||
IteratorNext: 'https://ecma-international.org/ecma-262/6.0/#sec-iteratornext', | ||
IteratorComplete: 'https://ecma-international.org/ecma-262/6.0/#sec-iteratorcomplete', | ||
IteratorValue: 'https://ecma-international.org/ecma-262/6.0/#sec-iteratorvalue', | ||
IteratorStep: 'https://ecma-international.org/ecma-262/6.0/#sec-iteratorstep', | ||
IteratorClose: 'https://ecma-international.org/ecma-262/6.0/#sec-iteratorclose', | ||
CreateIterResultObject: 'https://ecma-international.org/ecma-262/6.0/#sec-createiterresultobject', | ||
CreateListIterator: 'https://ecma-international.org/ecma-262/6.0/#sec-createlistiterator', | ||
Type: 'https://ecma-international.org/ecma-262/6.0/#sec-ecmascript-language-types', | ||
thisBooleanValue: 'https://ecma-international.org/ecma-262/6.0/#sec-properties-of-the-boolean-prototype-object', | ||
thisNumberValue: 'https://ecma-international.org/ecma-262/6.0/#sec-properties-of-the-number-prototype-object', | ||
thisStringValue: 'https://ecma-international.org/ecma-262/6.0/#sec-properties-of-the-string-prototype-object', | ||
thisTimeValue: 'https://ecma-international.org/ecma-262/6.0/#sec-properties-of-the-date-prototype-object', | ||
thisStringValue: 'https://ecma-international.org/ecma-262/6.0/#sec-properties-of-the-string-prototype-object', | ||
RegExpExec: 'https://ecma-international.org/ecma-262/6.0/#sec-regexpexec', | ||
RegExpBuiltinExec: 'https://ecma-international.org/ecma-262/6.0/#sec-regexpbuiltinexec', | ||
IsConcatSpreadable: 'https://ecma-international.org/ecma-262/6.0/#sec-isconcatspreadable', | ||
IsPromise: 'https://ecma-international.org/ecma-262/6.0/#sec-ispromise', | ||
ArraySpeciesCreate: 'https://ecma-international.org/ecma-262/6.0/#sec-arrayspeciescreate', | ||
ObjectCreate: 'https://ecma-international.org/ecma-262/6.0/#sec-objectcreate', | ||
AdvanceStringIndex: 'https://ecma-international.org/ecma-262/6.0/#sec-advancestringindex', | ||
NormalCompletion: 'https://ecma-international.org/ecma-262/6.0/#sec-normalcompletion' | ||
ToBoolean: 'https://ecma-international.org/ecma-262/6.0/#sec-toboolean', | ||
ToInt16: 'https://ecma-international.org/ecma-262/6.0/#sec-toint16', | ||
ToInt32: 'https://ecma-international.org/ecma-262/6.0/#sec-toint32', | ||
ToInt8: 'https://ecma-international.org/ecma-262/6.0/#sec-toint8', | ||
ToInteger: 'https://ecma-international.org/ecma-262/6.0/#sec-tointeger', | ||
ToLength: 'https://ecma-international.org/ecma-262/6.0/#sec-tolength', | ||
ToNumber: 'https://ecma-international.org/ecma-262/6.0/#sec-tonumber', | ||
ToObject: 'https://ecma-international.org/ecma-262/6.0/#sec-toobject', | ||
ToPrimitive: 'https://ecma-international.org/ecma-262/6.0/#sec-toprimitive', | ||
ToPropertyDescriptor: 'https://ecma-international.org/ecma-262/6.0/#sec-topropertydescriptor', | ||
ToPropertyKey: 'https://ecma-international.org/ecma-262/6.0/#sec-topropertykey', | ||
ToString: 'https://ecma-international.org/ecma-262/6.0/#sec-tostring', | ||
ToUint16: 'https://ecma-international.org/ecma-262/6.0/#sec-touint16', | ||
ToUint32: 'https://ecma-international.org/ecma-262/6.0/#sec-touint32', | ||
ToUint8: 'https://ecma-international.org/ecma-262/6.0/#sec-touint8', | ||
ToUint8Clamp: 'https://ecma-international.org/ecma-262/6.0/#sec-touint8clamp', | ||
Type: 'https://ecma-international.org/ecma-262/6.0/#sec-ecmascript-language-types', | ||
ValidateAndApplyPropertyDescriptor: 'https://www.ecma-international.org/ecma-262/6.0/#sec-validateandapplypropertydescriptor' | ||
}; |
#!/usr/bin/env node | ||
'use strict'; | ||
var fs = require('fs'); | ||
@@ -13,3 +15,3 @@ var path = require('path'); | ||
} | ||
var year = parseInt(process.argv[2]); | ||
var year = parseInt(process.argv[2], 10); | ||
if (year < 2016) { | ||
@@ -22,3 +24,3 @@ throw new RangeError('ES2016+ only'); | ||
var specHTML = String(execSync('curl --silent ' + specHTMLurl)); | ||
var specHTML = String(execSync('curl -q --silent ' + specHTMLurl, { maxBuffer: Infinity })); | ||
@@ -32,23 +34,23 @@ var root = $(specHTML); | ||
var entries = aOps.toArray().map(function (x) { | ||
var op = $(x); | ||
var aoid = op.attr('aoid'); | ||
var id = op.attr('id'); | ||
var op = $(x); | ||
var aoid = op.attr('aoid'); | ||
var id = op.attr('id'); | ||
if (!id) { | ||
id = op.closest('[id]').attr('id'); | ||
} | ||
if (!id) { | ||
id = op.closest('[id]').attr('id'); | ||
} | ||
if (!id) { | ||
missings.push(aoid); | ||
} | ||
if (!id) { | ||
missings.push(aoid); | ||
} | ||
return [ | ||
aoid, | ||
'https://ecma-international.org/ecma-262/' + edition + '.0/#' + id | ||
]; | ||
return [ | ||
aoid, | ||
'https://ecma-international.org/ecma-262/' + edition + '.0/#' + id | ||
]; | ||
}); | ||
if (missings.length > 0) { | ||
console.error('Missing URLs:', missings); | ||
process.exit(1); | ||
console.error('Missing URLs:', missings); | ||
process.exit(1); | ||
} | ||
@@ -61,5 +63,5 @@ | ||
var outputPath = path.join('operations', year + '.js'); | ||
fs.writeFileSync(outputPath, '\'use strict\';\n\nmodule.exports = ' + JSON.stringify(obj, null, '\t')+ ';\n'); | ||
fs.writeFileSync(outputPath, '\'use strict\';\n\nmodule.exports = ' + JSON.stringify(obj, null, '\t') + ';\n'); | ||
console.log('npx eslint --quiet --fix ' + outputPath); | ||
execSync('npx eslint --quiet --fix ' + outputPath); |
{ | ||
"name": "es-abstract", | ||
"version": "1.13.0", | ||
"version": "1.14.1", | ||
"author": { | ||
@@ -23,11 +23,8 @@ "name": "Jordan Harband", | ||
"test": "npm run tests-only", | ||
"posttest": "npm run audit", | ||
"posttest": "npx aud --production", | ||
"tests-only": "node test", | ||
"coverage": "nyc npm run --silent tests-only >/dev/null", | ||
"postcoverage": "nyc report", | ||
"lint": "eslint test/*.js *.js", | ||
"eccheck": "editorconfig-tools check *.js **/*.js > /dev/null", | ||
"preaudit": "npm install --package-lock --package-lock-only", | ||
"audit": "npm audit", | ||
"postaudit": "rm package-lock.json" | ||
"lint": "eslint .", | ||
"eccheck": "eclint check *.js **/*.js > /dev/null" | ||
}, | ||
@@ -53,21 +50,24 @@ "repository": { | ||
"has": "^1.0.3", | ||
"has-symbols": "^1.0.0", | ||
"is-callable": "^1.1.4", | ||
"is-regex": "^1.0.4", | ||
"object-keys": "^1.0.12" | ||
"object-inspect": "^1.6.0", | ||
"object-keys": "^1.1.1", | ||
"string.prototype.trimleft": "^2.0.0", | ||
"string.prototype.trimright": "^2.0.0" | ||
}, | ||
"devDependencies": { | ||
"@ljharb/eslint-config": "^13.1.1", | ||
"cheerio": "^1.0.0-rc.2", | ||
"editorconfig-tools": "^0.1.1", | ||
"eslint": "^5.11.1", | ||
"@ljharb/eslint-config": "^14.1.0", | ||
"cheerio": "^1.0.0-rc.3", | ||
"eclint": "^2.8.1", | ||
"eslint": "^6.3.0", | ||
"foreach": "^2.0.5", | ||
"nyc": "^10.3.2", | ||
"object-inspect": "^1.6.0", | ||
"object-is": "^1.0.1", | ||
"object.assign": "^4.1.0", | ||
"object.fromentries": "^2.0.0", | ||
"replace": "^1.0.1", | ||
"safe-publish-latest": "^1.1.2", | ||
"semver": "^5.6.0", | ||
"tape": "^4.9.2" | ||
"replace": "^1.1.1", | ||
"safe-publish-latest": "^1.1.3", | ||
"semver": "^6.3.0", | ||
"tape": "^4.11.0" | ||
}, | ||
@@ -74,0 +74,0 @@ "testling": { |
@@ -15,3 +15,3 @@ # es-abstract <sup>[![Version Badge][npm-version-svg]][package-url]</sup> | ||
When different versions of the spec conflict, the default export will be the latest version of the abstract operation. | ||
All abstract operations will also be available under an `es5`/`es2015`/`es2016`/`es2017`/`es2018` entry point, and exported property, if you require a specific version. | ||
All abstract operations will also be available under an `es5`/`es2015`/`es2016`/`es2017`/`es2018`/`es2019` entry point, and exported property, if you require a specific version. | ||
@@ -31,2 +31,6 @@ ## Example | ||
## Security | ||
Please email [@ljharb](https://github.com/ljharb) or see https://tidelift.com/security if you have a potential security vulnerability to report. | ||
[package-url]: https://npmjs.org/package/es-abstract | ||
@@ -33,0 +37,0 @@ [npm-version-svg]: http://versionbadg.es/ljharb/es-abstract.svg |
@@ -7,4 +7,4 @@ 'use strict'; | ||
var expectedMissing = ['Construct', 'SetIntegrityLevel', 'TestIntegrityLevel', 'CreateArrayFromList', 'CreateListFromArrayLike', 'OrdinaryHasInstance', 'CreateListIterator', 'RegExpBuiltinExec', 'IsPromise', 'NormalCompletion']; | ||
var expectedMissing = ['Construct', 'CreateArrayFromList', 'CreateListFromArrayLike', 'CreateListIterator', 'NormalCompletion', 'RegExpBuiltinExec']; | ||
require('./tests').es2015(ES, ops, expectedMissing); |
@@ -7,4 +7,4 @@ 'use strict'; | ||
var expectedMissing = ['Abstract Equality Comparison', 'Abstract Relational Comparison', 'AddRestrictedFunctionProperties', 'AllocateArrayBuffer', 'AllocateTypedArray', 'AllocateTypedArrayBuffer', 'ArrayCreate', 'ArraySetLength', 'BlockDeclarationInstantiation', 'BoundFunctionCreate', 'Canonicalize', 'CharacterRange', 'CharacterRangeOrUnion', 'CharacterSetMatcher', 'CloneArrayBuffer', 'Completion', 'Construct', 'CopyDataBlockBytes', 'CreateArrayFromList', 'CreateArrayIterator', 'CreateBuiltinFunction', 'CreateByteDataBlock', 'CreateDynamicFunction', 'CreateHTML', 'CreateIntrinsics', 'CreateListFromArrayLike', 'CreateListIterator', 'CreateMapIterator', 'CreateMappedArgumentsObject', 'CreatePerIterationEnvironment', 'CreateRealm', 'CreateResolvingFunctions', 'CreateSetIterator', 'CreateStringIterator', 'CreateUnmappedArgumentsObject', 'DateFromTime', 'Day', 'DayFromYear', 'DayWithinYear', 'DaysInYear', 'Decode', 'DetachArrayBuffer', 'Encode', 'EnqueueJob', 'EnumerateObjectProperties', 'EscapeRegExpPattern', 'EvalDeclarationInstantiation', 'EvaluateCall', 'EvaluateDirectCall', 'EvaluateNew', 'ForBodyEvaluation', 'ForIn/OfBodyEvaluation', 'ForIn/OfHeadEvaluation', 'FulfillPromise', 'FunctionAllocate', 'FunctionCreate', 'FunctionDeclarationInstantiation', 'FunctionInitialize', 'GeneratorFunctionCreate', 'GeneratorResume', 'GeneratorResumeAbrupt', 'GeneratorStart', 'GeneratorValidate', 'GeneratorYield', 'GetActiveScriptOrModule', 'GetFunctionRealm', 'GetGlobalObject', 'GetIdentifierReference', 'GetModuleNamespace', 'GetNewTarget', 'GetOwnPropertyKeys', 'GetPrototypeFromConstructor', 'GetSubstitution', 'GetSuperConstructor', 'GetTemplateObject', 'GetThisEnvironment', 'GetThisValue', 'GetValue', 'GetValueFromBuffer', 'GetViewValue', 'GlobalDeclarationInstantiation', 'HostPromiseRejectionTracker', 'HostReportErrors', 'HostResolveImportedModule', 'HourFromTime', 'HoursPerDay', 'IfAbruptRejectPromise', 'ImportedLocalNames', 'InLeapYear', 'InitializeBoundName', 'InitializeHostDefinedRealm', 'InitializeReferencedBinding', 'InstanceofOperator', 'IntegerIndexedElementGet', 'IntegerIndexedElementSet', 'IntegerIndexedObjectCreate', 'InternalizeJSONProperty', 'IsAnonymousFunctionDefinition', 'IsCompatiblePropertyDescriptor', 'IsDetachedBuffer', 'IsInTailPosition', 'IsLabelledFunction', 'IsPromise', 'IsWordChar', 'IterableToArrayLike', 'LocalTime', 'LoopContinues', 'MakeArgGetter', 'MakeArgSetter', 'MakeClassConstructor', 'MakeConstructor', 'MakeDate', 'MakeDay', 'MakeMethod', 'MakeSuperPropertyReference', 'MakeTime', 'MinFromTime', 'MinutesPerHour', 'ModuleNamespaceCreate', 'MonthFromTime', 'NewDeclarativeEnvironment', 'NewFunctionEnvironment', 'NewGlobalEnvironment', 'NewModuleEnvironment', 'NewObjectEnvironment', 'NewPromiseCapability', 'NextJob', 'NormalCompletion', 'ObjectDefineProperties', 'OrdinaryCallBindThis', 'OrdinaryCallEvaluateBody', 'OrdinaryCreateFromConstructor', 'OrdinaryDefineOwnProperty', 'OrdinaryDelete', 'OrdinaryGet', 'OrdinaryGetOwnProperty', 'OrdinaryGetPrototypeOf', 'OrdinaryHasInstance', 'OrdinaryHasProperty', 'OrdinaryIsExtensible', 'OrdinaryOwnPropertyKeys', 'OrdinaryPreventExtensions', 'OrdinarySet', 'OrdinarySetPrototypeOf', 'ParseModule', 'ParseScript', 'PerformEval', 'PerformPromiseAll', 'PerformPromiseRace', 'PerformPromiseThen', 'PrepareForOrdinaryCall', 'PrepareForTailCall', 'PromiseReactionJob', 'PromiseResolveThenableJob', 'ProxyCreate', 'PutValue', 'QuoteJSONString', 'RegExpAlloc', 'RegExpBuiltinExec', 'RegExpCreate', 'RegExpInitialize', 'RejectPromise', 'RepeatMatcher', 'ResolveBinding', 'ResolveThisBinding', 'ReturnIfAbrupt', 'ScriptEvaluation', 'ScriptEvaluationJob', 'SecFromTime', 'SecondsPerMinute', 'SerializeJSONArray', 'SerializeJSONObject', 'SerializeJSONProperty', 'SetDefaultGlobalBindings', 'SetFunctionName', 'SetIntegrityLevel', 'SetRealmGlobalObject', 'SetValueInBuffer', 'SetViewValue', 'SortCompare', 'SplitMatch', 'Strict Equality Comparison', 'StringCreate', 'SymbolDescriptiveString', 'TestIntegrityLevel', 'TimeClip', 'TimeFromYear', 'TimeWithinDay', 'ToDateString', 'ToString Applied to the Number Type', 'TopLevelModuleEvaluationJob', 'TriggerPromiseReactions', 'TypedArrayCreate', 'TypedArraySpeciesCreate', 'UTC', 'UTF16Decode', 'UTF16Encoding', 'UpdateEmpty', 'ValidateAndApplyPropertyDescriptor', 'ValidateTypedArray', 'WeekDay', 'YearFromTime', 'abs', 'floor', 'max', 'min', 'modulo', 'msFromTime', 'msPerDay', 'msPerHour', 'msPerMinute', 'msPerSecond']; | ||
var expectedMissing = ['AddRestrictedFunctionProperties', 'AllocateArrayBuffer', 'AllocateTypedArray', 'AllocateTypedArrayBuffer', 'BlockDeclarationInstantiation', 'BoundFunctionCreate', 'Canonicalize', 'CharacterRange', 'CharacterRangeOrUnion', 'CharacterSetMatcher', 'CloneArrayBuffer', 'Completion', 'Construct', 'CopyDataBlockBytes', 'CreateArrayFromList', 'CreateArrayIterator', 'CreateBuiltinFunction', 'CreateByteDataBlock', 'CreateDynamicFunction', 'CreateIntrinsics', 'CreateListFromArrayLike', 'CreateListIterator', 'CreateMapIterator', 'CreateMappedArgumentsObject', 'CreatePerIterationEnvironment', 'CreateRealm', 'CreateResolvingFunctions', 'CreateSetIterator', 'CreateStringIterator', 'CreateUnmappedArgumentsObject', 'DateFromTime', 'Day', 'DayFromYear', 'DayWithinYear', 'DaysInYear', 'Decode', 'DetachArrayBuffer', 'Encode', 'EnqueueJob', 'EnumerateObjectProperties', 'EscapeRegExpPattern', 'EvalDeclarationInstantiation', 'EvaluateCall', 'EvaluateDirectCall', 'EvaluateNew', 'ForBodyEvaluation', 'ForIn/OfBodyEvaluation', 'ForIn/OfHeadEvaluation', 'FulfillPromise', 'FunctionAllocate', 'FunctionCreate', 'FunctionDeclarationInstantiation', 'FunctionInitialize', 'GeneratorFunctionCreate', 'GeneratorResume', 'GeneratorResumeAbrupt', 'GeneratorStart', 'GeneratorValidate', 'GeneratorYield', 'GetActiveScriptOrModule', 'GetFunctionRealm', 'GetGlobalObject', 'GetIdentifierReference', 'GetModuleNamespace', 'GetNewTarget', 'GetPrototypeFromConstructor', 'GetSuperConstructor', 'GetTemplateObject', 'GetThisEnvironment', 'GetThisValue', 'GetValue', 'GetValueFromBuffer', 'GetViewValue', 'GlobalDeclarationInstantiation', 'HostPromiseRejectionTracker', 'HostReportErrors', 'HostResolveImportedModule', 'HourFromTime', 'HoursPerDay', 'IfAbruptRejectPromise', 'ImportedLocalNames', 'InLeapYear', 'InitializeBoundName', 'InitializeHostDefinedRealm', 'InitializeReferencedBinding', 'IntegerIndexedElementGet', 'IntegerIndexedElementSet', 'IntegerIndexedObjectCreate', 'InternalizeJSONProperty', 'IsAnonymousFunctionDefinition', 'IsCompatiblePropertyDescriptor', 'IsDetachedBuffer', 'IsInTailPosition', 'IsLabelledFunction', 'IsWordChar', 'LocalTime', 'LoopContinues', 'MakeArgGetter', 'MakeArgSetter', 'MakeClassConstructor', 'MakeConstructor', 'MakeDate', 'MakeDay', 'MakeMethod', 'MakeSuperPropertyReference', 'MakeTime', 'MinFromTime', 'MinutesPerHour', 'ModuleNamespaceCreate', 'MonthFromTime', 'NewDeclarativeEnvironment', 'NewFunctionEnvironment', 'NewGlobalEnvironment', 'NewModuleEnvironment', 'NewObjectEnvironment', 'NewPromiseCapability', 'NextJob', 'NormalCompletion', 'ObjectDefineProperties', 'OrdinaryCallBindThis', 'OrdinaryCallEvaluateBody', 'OrdinaryCreateFromConstructor', 'OrdinaryDelete', 'OrdinaryGet', 'OrdinaryGetPrototypeOf', 'OrdinaryIsExtensible', 'OrdinaryOwnPropertyKeys', 'OrdinaryPreventExtensions', 'OrdinarySet', 'OrdinarySetPrototypeOf', 'ParseModule', 'ParseScript', 'PerformEval', 'PerformPromiseAll', 'PerformPromiseRace', 'PerformPromiseThen', 'PrepareForOrdinaryCall', 'PrepareForTailCall', 'PromiseReactionJob', 'PromiseResolveThenableJob', 'ProxyCreate', 'PutValue', 'QuoteJSONString', 'RegExpAlloc', 'RegExpBuiltinExec', 'RegExpCreate', 'RegExpInitialize', 'RejectPromise', 'RepeatMatcher', 'ResolveBinding', 'ResolveThisBinding', 'ReturnIfAbrupt', 'ScriptEvaluation', 'ScriptEvaluationJob', 'SecFromTime', 'SecondsPerMinute', 'SerializeJSONArray', 'SerializeJSONObject', 'SerializeJSONProperty', 'SetDefaultGlobalBindings', 'SetFunctionName', 'SetRealmGlobalObject', 'SetValueInBuffer', 'SetViewValue', 'SortCompare', 'SplitMatch', 'StringCreate', 'TimeClip', 'TimeFromYear', 'TimeWithinDay', 'ToDateString', 'ToString Applied to the Number Type', 'TopLevelModuleEvaluationJob', 'TriggerPromiseReactions', 'TypedArrayCreate', 'TypedArraySpeciesCreate', 'UTC', 'UTF16Decode', 'UTF16Encoding', 'UpdateEmpty', 'ValidateTypedArray', 'WeekDay', 'YearFromTime', 'abs', 'floor', 'max', 'min', 'modulo', 'msFromTime', 'msPerDay', 'msPerHour', 'msPerMinute', 'msPerSecond']; | ||
require('./tests').es2016(ES, ops, expectedMissing); |
@@ -7,4 +7,4 @@ 'use strict'; | ||
var expectedMissing = ['Abstract Equality Comparison', 'Abstract Relational Comparison', 'AddRestrictedFunctionProperties', 'AddWaiter', 'AgentCanSuspend', 'AgentSignifier', 'AllocateArrayBuffer', 'AllocateSharedArrayBuffer', 'AllocateTypedArray', 'AllocateTypedArrayBuffer', 'ArrayCreate', 'ArraySetLength', 'AsyncFunctionAwait', 'AsyncFunctionCreate', 'AsyncFunctionStart', 'AtomicLoad', 'AtomicReadModifyWrite', 'BlockDeclarationInstantiation', 'BoundFunctionCreate', 'Canonicalize', 'CharacterRange', 'CharacterRangeOrUnion', 'CharacterSetMatcher', 'CloneArrayBuffer', 'Completion', 'ComposeWriteEventBytes', 'Construct', 'CopyDataBlockBytes', 'CreateArrayFromList', 'CreateArrayIterator', 'CreateBuiltinFunction', 'CreateByteDataBlock', 'CreateDynamicFunction', 'CreateHTML', 'CreateIntrinsics', 'CreateListFromArrayLike', 'CreateListIterator', 'CreateMapIterator', 'CreateMappedArgumentsObject', 'CreatePerIterationEnvironment', 'CreateRealm', 'CreateResolvingFunctions', 'CreateSetIterator', 'CreateSharedByteDataBlock', 'CreateStringIterator', 'CreateUnmappedArgumentsObject', 'DateFromTime', 'Day', 'DayFromYear', 'DayWithinYear', 'DaysInYear', 'Decode', 'DetachArrayBuffer', 'Encode', 'EnqueueJob', 'EnterCriticalSection', 'EnumerateObjectProperties', 'EscapeRegExpPattern', 'EvalDeclarationInstantiation', 'EvaluateCall', 'EvaluateDirectCall', 'EvaluateNew', 'EventSet', 'ForBodyEvaluation', 'ForIn/OfBodyEvaluation', 'ForIn/OfHeadEvaluation', 'FulfillPromise', 'FunctionAllocate', 'FunctionCreate', 'FunctionDeclarationInstantiation', 'FunctionInitialize', 'GeneratorFunctionCreate', 'GeneratorResume', 'GeneratorResumeAbrupt', 'GeneratorStart', 'GeneratorValidate', 'GeneratorYield', 'GetActiveScriptOrModule', 'GetBase', 'GetFunctionRealm', 'GetGlobalObject', 'GetIdentifierReference', 'GetModifySetValueInBuffer', 'GetModuleNamespace', 'GetNewTarget', 'GetOwnPropertyKeys', 'GetPrototypeFromConstructor', 'GetReferencedName', 'GetSubstitution', 'GetSuperConstructor', 'GetTemplateObject', 'GetThisEnvironment', 'GetThisValue', 'GetValue', 'GetValueFromBuffer', 'GetViewValue', 'GetWaiterList', 'GlobalDeclarationInstantiation', 'HasPrimitiveBase', 'HostEnsureCanCompileStrings', 'HostEventSet', 'HostPromiseRejectionTracker', 'HostReportErrors', 'HostResolveImportedModule', 'HourFromTime', 'HoursPerDay', 'IfAbruptRejectPromise', 'ImportedLocalNames', 'InLeapYear', 'InitializeBoundName', 'InitializeHostDefinedRealm', 'InitializeReferencedBinding', 'InstanceofOperator', 'IntegerIndexedElementGet', 'IntegerIndexedElementSet', 'IntegerIndexedObjectCreate', 'InternalizeJSONProperty', 'IsAnonymousFunctionDefinition', 'IsCompatiblePropertyDescriptor', 'IsDetachedBuffer', 'IsInTailPosition', 'IsLabelledFunction', 'IsPromise', 'IsPropertyReference', 'IsSharedArrayBuffer', 'IsStrictReference', 'IsSuperReference', 'IsUnresolvableReference', 'IsWordChar', 'IterableToList', 'LeaveCriticalSection', 'LocalTime', 'LoopContinues', 'MakeArgGetter', 'MakeArgSetter', 'MakeClassConstructor', 'MakeConstructor', 'MakeDate', 'MakeDay', 'MakeMethod', 'MakeSuperPropertyReference', 'MakeTime', 'MinFromTime', 'MinutesPerHour', 'ModuleNamespaceCreate', 'MonthFromTime', 'NewDeclarativeEnvironment', 'NewFunctionEnvironment', 'NewGlobalEnvironment', 'NewModuleEnvironment', 'NewObjectEnvironment', 'NewPromiseCapability', 'NormalCompletion', 'NumberToRawBytes', 'ObjectDefineProperties', 'OrdinaryCallBindThis', 'OrdinaryCallEvaluateBody', 'OrdinaryCreateFromConstructor', 'OrdinaryDefineOwnProperty', 'OrdinaryDelete', 'OrdinaryGet', 'OrdinaryGetOwnProperty', 'OrdinaryGetPrototypeOf', 'OrdinaryHasInstance', 'OrdinaryHasProperty', 'OrdinaryIsExtensible', 'OrdinaryOwnPropertyKeys', 'OrdinaryPreventExtensions', 'OrdinarySet', 'OrdinarySetPrototypeOf', 'OrdinaryToPrimitive', 'ParseModule', 'ParseScript', 'PerformEval', 'PerformPromiseAll', 'PerformPromiseRace', 'PerformPromiseThen', 'PrepareForOrdinaryCall', 'PrepareForTailCall', 'PromiseReactionJob', 'PromiseResolveThenableJob', 'ProxyCreate', 'PutValue', 'QuoteJSONString', 'RawBytesToNumber', 'RegExpAlloc', 'RegExpBuiltinExec', 'RegExpCreate', 'RegExpInitialize', 'RejectPromise', 'RemoveWaiter', 'RemoveWaiters', 'RepeatMatcher', 'ResolveBinding', 'ResolveThisBinding', 'ReturnIfAbrupt', 'RunJobs', 'ScriptEvaluation', 'ScriptEvaluationJob', 'SecFromTime', 'SecondsPerMinute', 'SerializeJSONArray', 'SerializeJSONObject', 'SerializeJSONProperty', 'SetDefaultGlobalBindings', 'SetFunctionName', 'SetImmutablePrototype', 'SetIntegrityLevel', 'SetRealmGlobalObject', 'SetValueInBuffer', 'SetViewValue', 'SharedDataBlockEventSet', 'SortCompare', 'SplitMatch', 'Strict Equality Comparison', 'StringCreate', 'StringGetOwnProperty', 'Suspend', 'SymbolDescriptiveString', 'TestIntegrityLevel', 'TimeClip', 'TimeFromYear', 'TimeWithinDay', 'ToDateString', 'ToString Applied to the Number Type', 'TopLevelModuleEvaluationJob', 'TriggerPromiseReactions', 'TypedArrayCreate', 'TypedArraySpeciesCreate', 'UTC', 'UTF16Decode', 'UTF16Encoding', 'UpdateEmpty', 'ValidateAndApplyPropertyDescriptor', 'ValidateAtomicAccess', 'ValidateSharedIntegerTypedArray', 'ValidateTypedArray', 'ValueOfReadEvent', 'WakeWaiter', 'WeekDay', 'WordCharacters', 'YearFromTime', 'abs', 'agent-order', 'floor', 'happens-before', 'host-synchronizes-with', 'max', 'memory-order', 'min', 'modulo', 'msFromTime', 'msPerDay', 'msPerHour', 'msPerMinute', 'msPerSecond', 'reads-bytes-from', 'reads-from', 'synchronizes-with']; | ||
var expectedMissing = ['AddRestrictedFunctionProperties', 'AddWaiter', 'AgentCanSuspend', 'AgentSignifier', 'AllocateArrayBuffer', 'AllocateSharedArrayBuffer', 'AllocateTypedArray', 'AllocateTypedArrayBuffer', 'AsyncFunctionAwait', 'AsyncFunctionCreate', 'AsyncFunctionStart', 'AtomicLoad', 'AtomicReadModifyWrite', 'BlockDeclarationInstantiation', 'BoundFunctionCreate', 'Canonicalize', 'CharacterRange', 'CharacterRangeOrUnion', 'CharacterSetMatcher', 'CloneArrayBuffer', 'Completion', 'ComposeWriteEventBytes', 'Construct', 'CopyDataBlockBytes', 'CreateArrayFromList', 'CreateArrayIterator', 'CreateBuiltinFunction', 'CreateByteDataBlock', 'CreateDynamicFunction', 'CreateIntrinsics', 'CreateListFromArrayLike', 'CreateListIterator', 'CreateMapIterator', 'CreateMappedArgumentsObject', 'CreatePerIterationEnvironment', 'CreateRealm', 'CreateResolvingFunctions', 'CreateSetIterator', 'CreateSharedByteDataBlock', 'CreateStringIterator', 'CreateUnmappedArgumentsObject', 'DateFromTime', 'Day', 'DayFromYear', 'DayWithinYear', 'DaysInYear', 'Decode', 'DetachArrayBuffer', 'Encode', 'EnqueueJob', 'EnterCriticalSection', 'EnumerateObjectProperties', 'EscapeRegExpPattern', 'EvalDeclarationInstantiation', 'EvaluateCall', 'EvaluateDirectCall', 'EvaluateNew', 'EventSet', 'ForBodyEvaluation', 'ForIn/OfBodyEvaluation', 'ForIn/OfHeadEvaluation', 'FulfillPromise', 'FunctionAllocate', 'FunctionCreate', 'FunctionDeclarationInstantiation', 'FunctionInitialize', 'GeneratorFunctionCreate', 'GeneratorResume', 'GeneratorResumeAbrupt', 'GeneratorStart', 'GeneratorValidate', 'GeneratorYield', 'GetActiveScriptOrModule', 'GetBase', 'GetFunctionRealm', 'GetGlobalObject', 'GetIdentifierReference', 'GetModifySetValueInBuffer', 'GetModuleNamespace', 'GetNewTarget', 'GetPrototypeFromConstructor', 'GetReferencedName', 'GetSuperConstructor', 'GetTemplateObject', 'GetThisEnvironment', 'GetThisValue', 'GetValue', 'GetValueFromBuffer', 'GetViewValue', 'GetWaiterList', 'GlobalDeclarationInstantiation', 'HasPrimitiveBase', 'HostEnsureCanCompileStrings', 'HostEventSet', 'HostPromiseRejectionTracker', 'HostReportErrors', 'HostResolveImportedModule', 'HourFromTime', 'HoursPerDay', 'IfAbruptRejectPromise', 'ImportedLocalNames', 'InLeapYear', 'InitializeBoundName', 'InitializeHostDefinedRealm', 'InitializeReferencedBinding', 'IntegerIndexedElementGet', 'IntegerIndexedElementSet', 'IntegerIndexedObjectCreate', 'InternalizeJSONProperty', 'IsAnonymousFunctionDefinition', 'IsCompatiblePropertyDescriptor', 'IsDetachedBuffer', 'IsInTailPosition', 'IsLabelledFunction', 'IsPropertyReference', 'IsSharedArrayBuffer', 'IsStrictReference', 'IsSuperReference', 'IsUnresolvableReference', 'IsWordChar', 'LeaveCriticalSection', 'LocalTime', 'LoopContinues', 'MakeArgGetter', 'MakeArgSetter', 'MakeClassConstructor', 'MakeConstructor', 'MakeDate', 'MakeDay', 'MakeMethod', 'MakeSuperPropertyReference', 'MakeTime', 'MinFromTime', 'MinutesPerHour', 'ModuleNamespaceCreate', 'MonthFromTime', 'NewDeclarativeEnvironment', 'NewFunctionEnvironment', 'NewGlobalEnvironment', 'NewModuleEnvironment', 'NewObjectEnvironment', 'NewPromiseCapability', 'NormalCompletion', 'NumberToRawBytes', 'ObjectDefineProperties', 'OrdinaryCallBindThis', 'OrdinaryCallEvaluateBody', 'OrdinaryCreateFromConstructor', 'OrdinaryDelete', 'OrdinaryGet', 'OrdinaryGetPrototypeOf', 'OrdinaryIsExtensible', 'OrdinaryOwnPropertyKeys', 'OrdinaryPreventExtensions', 'OrdinarySet', 'OrdinarySetPrototypeOf', 'OrdinaryToPrimitive', 'ParseModule', 'ParseScript', 'PerformEval', 'PerformPromiseAll', 'PerformPromiseRace', 'PerformPromiseThen', 'PrepareForOrdinaryCall', 'PrepareForTailCall', 'PromiseReactionJob', 'PromiseResolveThenableJob', 'ProxyCreate', 'PutValue', 'QuoteJSONString', 'RawBytesToNumber', 'RegExpAlloc', 'RegExpBuiltinExec', 'RegExpCreate', 'RegExpInitialize', 'RejectPromise', 'RemoveWaiter', 'RemoveWaiters', 'RepeatMatcher', 'ResolveBinding', 'ResolveThisBinding', 'ReturnIfAbrupt', 'RunJobs', 'ScriptEvaluation', 'ScriptEvaluationJob', 'SecFromTime', 'SecondsPerMinute', 'SerializeJSONArray', 'SerializeJSONObject', 'SerializeJSONProperty', 'SetDefaultGlobalBindings', 'SetFunctionName', 'SetImmutablePrototype', 'SetRealmGlobalObject', 'SetValueInBuffer', 'SetViewValue', 'SharedDataBlockEventSet', 'SortCompare', 'SplitMatch', 'StringCreate', 'StringGetOwnProperty', 'Suspend', 'TimeClip', 'TimeFromYear', 'TimeWithinDay', 'ToDateString', 'ToString Applied to the Number Type', 'TopLevelModuleEvaluationJob', 'TriggerPromiseReactions', 'TypedArrayCreate', 'TypedArraySpeciesCreate', 'UTC', 'UTF16Decode', 'UTF16Encoding', 'UpdateEmpty', 'ValidateAtomicAccess', 'ValidateSharedIntegerTypedArray', 'ValidateTypedArray', 'ValueOfReadEvent', 'WakeWaiter', 'WeekDay', 'WordCharacters', 'YearFromTime', 'abs', 'agent-order', 'floor', 'happens-before', 'host-synchronizes-with', 'max', 'memory-order', 'min', 'modulo', 'msFromTime', 'msPerDay', 'msPerHour', 'msPerMinute', 'msPerSecond', 'reads-bytes-from', 'reads-from', 'synchronizes-with']; | ||
require('./tests').es2017(ES, ops, expectedMissing); |
@@ -7,4 +7,4 @@ 'use strict'; | ||
var expectedMissing = ['abs', 'Abstract Equality Comparison', 'Abstract Relational Comparison', 'AddRestrictedFunctionProperties', 'AddWaiter', 'agent-order', 'AgentCanSuspend', 'AgentSignifier', 'AllocateArrayBuffer', 'AllocateSharedArrayBuffer', 'AllocateTypedArray', 'AllocateTypedArrayBuffer', 'ArrayCreate', 'ArraySetLength', 'AsyncFunctionStart', 'AsyncGeneratorEnqueue', 'AsyncGeneratorReject', 'AsyncGeneratorResolve', 'AsyncGeneratorResumeNext', 'AsyncGeneratorStart', 'AsyncGeneratorYield', 'AtomicLoad', 'AtomicReadModifyWrite', 'Await', 'BlockDeclarationInstantiation', 'BoundFunctionCreate', 'Canonicalize', 'CaseClauseIsSelected', 'CharacterRange', 'CharacterRangeOrUnion', 'CharacterSetMatcher', 'CloneArrayBuffer', 'Completion', 'ComposeWriteEventBytes', 'CopyDataBlockBytes', 'CreateArrayIterator', 'CreateAsyncFromSyncIterator', 'CreateBuiltinFunction', 'CreateByteDataBlock', 'CreateDynamicFunction', 'CreateHTML', 'CreateIntrinsics', 'CreateMapIterator', 'CreateMappedArgumentsObject', 'CreatePerIterationEnvironment', 'CreateRealm', 'CreateResolvingFunctions', 'CreateSetIterator', 'CreateSharedByteDataBlock', 'CreateStringIterator', 'CreateUnmappedArgumentsObject', 'DateFromTime', 'Day', 'DayFromYear', 'DaysInYear', 'DayWithinYear', 'Decode', 'DetachArrayBuffer', 'Encode', 'EnqueueJob', 'EnterCriticalSection', 'EnumerateObjectProperties', 'EscapeRegExpPattern', 'EvalDeclarationInstantiation', 'EvaluateCall', 'EvaluateNew', 'EventSet', 'floor', 'ForBodyEvaluation', 'ForIn/OfBodyEvaluation', 'ForIn/OfHeadEvaluation', 'FulfillPromise', 'FunctionAllocate', 'FunctionCreate', 'FunctionDeclarationInstantiation', 'FunctionInitialize', 'GeneratorFunctionCreate', 'GeneratorResume', 'GeneratorResumeAbrupt', 'GeneratorStart', 'GeneratorValidate', 'GeneratorYield', 'GetActiveScriptOrModule', 'GetBase', 'GetFunctionRealm', 'GetGeneratorKind', 'GetGlobalObject', 'GetIdentifierReference', 'GetModifySetValueInBuffer', 'GetModuleNamespace', 'GetNewTarget', 'GetOwnPropertyKeys', 'GetPrototypeFromConstructor', 'GetReferencedName', 'GetSubstitution', 'GetSuperConstructor', 'GetTemplateObject', 'GetThisEnvironment', 'GetThisValue', 'GetValue', 'GetValueFromBuffer', 'GetViewValue', 'GetWaiterList', 'GlobalDeclarationInstantiation', 'happens-before', 'HasPrimitiveBase', 'host-synchronizes-with', 'HostEnsureCanCompileStrings', 'HostEventSet', 'HostPromiseRejectionTracker', 'HostReportErrors', 'HostResolveImportedModule', 'HourFromTime', 'HoursPerDay', 'IfAbruptRejectPromise', 'ImportedLocalNames', 'InitializeBoundName', 'InitializeHostDefinedRealm', 'InitializeReferencedBinding', 'InLeapYear', 'InnerModuleEvaluation', 'InnerModuleInstantiation', 'InstanceofOperator', 'IntegerIndexedElementGet', 'IntegerIndexedElementSet', 'IntegerIndexedObjectCreate', 'InternalizeJSONProperty', 'IsAnonymousFunctionDefinition', 'IsCompatiblePropertyDescriptor', 'IsDetachedBuffer', 'IsInTailPosition', 'IsLabelledFunction', 'IsPropertyReference', 'IsSharedArrayBuffer', 'IsStrictReference', 'IsSuperReference', 'IsUnresolvableReference', 'IsWordChar', 'IterableToList', 'LeaveCriticalSection', 'LocalTime', 'LoopContinues', 'MakeArgGetter', 'MakeArgSetter', 'MakeClassConstructor', 'MakeConstructor', 'MakeDate', 'MakeDay', 'MakeMethod', 'MakeSuperPropertyReference', 'MakeTime', 'max', 'memory-order', 'min', 'MinFromTime', 'MinutesPerHour', 'ModuleDeclarationEnvironmentSetup', 'ModuleExecution', 'ModuleNamespaceCreate', 'modulo', 'MonthFromTime', 'msFromTime', 'msPerDay', 'msPerHour', 'msPerMinute', 'msPerSecond', 'NewDeclarativeEnvironment', 'NewFunctionEnvironment', 'NewGlobalEnvironment', 'NewModuleEnvironment', 'NewObjectEnvironment', 'NewPromiseCapability', 'NumberToRawBytes', 'ObjectDefineProperties', 'OrdinaryCallBindThis', 'OrdinaryCallEvaluateBody', 'OrdinaryCreateFromConstructor', 'OrdinaryDefineOwnProperty', 'OrdinaryDelete', 'OrdinaryGet', 'OrdinaryGetOwnProperty', 'OrdinaryGetPrototypeOf', 'OrdinaryHasProperty', 'OrdinaryIsExtensible', 'OrdinaryOwnPropertyKeys', 'OrdinaryPreventExtensions', 'OrdinarySetPrototypeOf', 'OrdinaryToPrimitive', 'ParseModule', 'ParseScript', 'PerformEval', 'PerformPromiseAll', 'PerformPromiseRace', 'PerformPromiseThen', 'PrepareForOrdinaryCall', 'PrepareForTailCall', 'PromiseReactionJob', 'PromiseResolveThenableJob', 'ProxyCreate', 'PutValue', 'QuoteJSONString', 'RawBytesToNumber', 'reads-bytes-from', 'reads-from', 'RegExpAlloc', 'RegExpCreate', 'RegExpInitialize', 'RejectPromise', 'RemoveWaiter', 'RemoveWaiters', 'RepeatMatcher', 'ResolveBinding', 'ResolveThisBinding', 'ReturnIfAbrupt', 'RunJobs', 'ScriptEvaluation', 'ScriptEvaluationJob', 'SecFromTime', 'SecondsPerMinute', 'SerializeJSONArray', 'SerializeJSONObject', 'SerializeJSONProperty', 'SetDefaultGlobalBindings', 'SetFunctionName', 'SetImmutablePrototype', 'SetRealmGlobalObject', 'SetValueInBuffer', 'SetViewValue', 'SharedDataBlockEventSet', 'SortCompare', 'SplitMatch', 'Strict Equality Comparison', 'StringCreate', 'StringGetOwnProperty', 'Suspend', 'SymbolDescriptiveString', 'synchronizes-with', 'TimeClip', 'TimeFromYear', 'TimeWithinDay', 'TimeZoneString', 'TopLevelModuleEvaluationJob', 'TriggerPromiseReactions', 'TypedArrayCreate', 'TypedArraySpeciesCreate', 'UnicodeEscape', 'UpdateEmpty', 'UTC', 'UTF16Decode', 'UTF16Encoding', 'ValidateAndApplyPropertyDescriptor', 'ValidateAtomicAccess', 'ValidateSharedIntegerTypedArray', 'ValidateTypedArray', 'ValueOfReadEvent', 'WakeWaiter', 'WeekDay', 'WordCharacters', 'YearFromTime', 'AsyncFunctionCreate', 'AsyncGeneratorFunctionCreate', 'AsyncIteratorClose', 'BackreferenceMatcher', 'Construct', 'CreateArrayFromList', 'CreateListFromArrayLike', 'CreateListIteratorRecord', 'DateString', 'IsPromise', 'NormalCompletion', 'OrdinaryHasInstance', 'OrdinarySet', 'OrdinarySetWithOwnDescriptor', 'RegExpBuiltinExec', 'SetFunctionLength', 'SetIntegrityLevel', 'TestIntegrityLevel', 'ThrowCompletion', 'TimeString', 'ToDateString', 'UnicodeMatchProperty', 'UnicodeMatchPropertyValue']; | ||
var expectedMissing = ['abs', 'AddRestrictedFunctionProperties', 'AddWaiter', 'agent-order', 'AgentCanSuspend', 'AgentSignifier', 'AllocateArrayBuffer', 'AllocateSharedArrayBuffer', 'AllocateTypedArray', 'AllocateTypedArrayBuffer', 'AsyncFunctionStart', 'AsyncGeneratorEnqueue', 'AsyncGeneratorReject', 'AsyncGeneratorResolve', 'AsyncGeneratorResumeNext', 'AsyncGeneratorStart', 'AsyncGeneratorYield', 'AtomicLoad', 'AtomicReadModifyWrite', 'Await', 'BlockDeclarationInstantiation', 'BoundFunctionCreate', 'Canonicalize', 'CaseClauseIsSelected', 'CharacterRange', 'CharacterRangeOrUnion', 'CharacterSetMatcher', 'CloneArrayBuffer', 'Completion', 'ComposeWriteEventBytes', 'CopyDataBlockBytes', 'CreateArrayIterator', 'CreateAsyncFromSyncIterator', 'CreateBuiltinFunction', 'CreateByteDataBlock', 'CreateDynamicFunction', 'CreateIntrinsics', 'CreateMapIterator', 'CreateMappedArgumentsObject', 'CreatePerIterationEnvironment', 'CreateRealm', 'CreateResolvingFunctions', 'CreateSetIterator', 'CreateSharedByteDataBlock', 'CreateStringIterator', 'CreateUnmappedArgumentsObject', 'DateFromTime', 'Day', 'DayFromYear', 'DaysInYear', 'DayWithinYear', 'Decode', 'DetachArrayBuffer', 'Encode', 'EnqueueJob', 'EnterCriticalSection', 'EnumerateObjectProperties', 'EscapeRegExpPattern', 'EvalDeclarationInstantiation', 'EvaluateCall', 'EvaluateNew', 'EventSet', 'floor', 'ForBodyEvaluation', 'ForIn/OfBodyEvaluation', 'ForIn/OfHeadEvaluation', 'FulfillPromise', 'FunctionAllocate', 'FunctionCreate', 'FunctionDeclarationInstantiation', 'FunctionInitialize', 'GeneratorFunctionCreate', 'GeneratorResume', 'GeneratorResumeAbrupt', 'GeneratorStart', 'GeneratorValidate', 'GeneratorYield', 'GetActiveScriptOrModule', 'GetBase', 'GetFunctionRealm', 'GetGeneratorKind', 'GetGlobalObject', 'GetIdentifierReference', 'GetModifySetValueInBuffer', 'GetModuleNamespace', 'GetNewTarget', 'GetPrototypeFromConstructor', 'GetReferencedName', 'GetSuperConstructor', 'GetTemplateObject', 'GetThisEnvironment', 'GetThisValue', 'GetValue', 'GetValueFromBuffer', 'GetViewValue', 'GetWaiterList', 'GlobalDeclarationInstantiation', 'happens-before', 'HasPrimitiveBase', 'host-synchronizes-with', 'HostEnsureCanCompileStrings', 'HostEventSet', 'HostPromiseRejectionTracker', 'HostReportErrors', 'HostResolveImportedModule', 'HourFromTime', 'HoursPerDay', 'IfAbruptRejectPromise', 'ImportedLocalNames', 'InitializeBoundName', 'InitializeHostDefinedRealm', 'InitializeReferencedBinding', 'InLeapYear', 'InnerModuleEvaluation', 'InnerModuleInstantiation', 'IntegerIndexedElementGet', 'IntegerIndexedElementSet', 'IntegerIndexedObjectCreate', 'InternalizeJSONProperty', 'IsAnonymousFunctionDefinition', 'IsCompatiblePropertyDescriptor', 'IsDetachedBuffer', 'IsInTailPosition', 'IsLabelledFunction', 'IsPropertyReference', 'IsSharedArrayBuffer', 'IsStrictReference', 'IsSuperReference', 'IsUnresolvableReference', 'IsWordChar', 'LeaveCriticalSection', 'LocalTime', 'LoopContinues', 'MakeArgGetter', 'MakeArgSetter', 'MakeClassConstructor', 'MakeConstructor', 'MakeDate', 'MakeDay', 'MakeMethod', 'MakeSuperPropertyReference', 'MakeTime', 'max', 'memory-order', 'min', 'MinFromTime', 'MinutesPerHour', 'ModuleDeclarationEnvironmentSetup', 'ModuleExecution', 'ModuleNamespaceCreate', 'modulo', 'MonthFromTime', 'msFromTime', 'msPerDay', 'msPerHour', 'msPerMinute', 'msPerSecond', 'NewDeclarativeEnvironment', 'NewFunctionEnvironment', 'NewGlobalEnvironment', 'NewModuleEnvironment', 'NewObjectEnvironment', 'NewPromiseCapability', 'NumberToRawBytes', 'ObjectDefineProperties', 'OrdinaryCallBindThis', 'OrdinaryCallEvaluateBody', 'OrdinaryCreateFromConstructor', 'OrdinaryDelete', 'OrdinaryGet', 'OrdinaryGetPrototypeOf', 'OrdinaryIsExtensible', 'OrdinaryOwnPropertyKeys', 'OrdinaryPreventExtensions', 'OrdinarySetPrototypeOf', 'OrdinaryToPrimitive', 'ParseModule', 'ParseScript', 'PerformEval', 'PerformPromiseAll', 'PerformPromiseRace', 'PerformPromiseThen', 'PrepareForOrdinaryCall', 'PrepareForTailCall', 'PromiseReactionJob', 'PromiseResolveThenableJob', 'ProxyCreate', 'PutValue', 'QuoteJSONString', 'RawBytesToNumber', 'reads-bytes-from', 'reads-from', 'RegExpAlloc', 'RegExpCreate', 'RegExpInitialize', 'RejectPromise', 'RemoveWaiter', 'RemoveWaiters', 'RepeatMatcher', 'ResolveBinding', 'ResolveThisBinding', 'ReturnIfAbrupt', 'RunJobs', 'ScriptEvaluation', 'ScriptEvaluationJob', 'SecFromTime', 'SecondsPerMinute', 'SerializeJSONArray', 'SerializeJSONObject', 'SerializeJSONProperty', 'SetDefaultGlobalBindings', 'SetFunctionName', 'SetImmutablePrototype', 'SetRealmGlobalObject', 'SetValueInBuffer', 'SetViewValue', 'SharedDataBlockEventSet', 'SortCompare', 'SplitMatch', 'StringCreate', 'StringGetOwnProperty', 'Suspend', 'synchronizes-with', 'TimeClip', 'TimeFromYear', 'TimeWithinDay', 'TimeZoneString', 'TopLevelModuleEvaluationJob', 'TriggerPromiseReactions', 'TypedArrayCreate', 'TypedArraySpeciesCreate', 'UnicodeEscape', 'UpdateEmpty', 'UTC', 'UTF16Decode', 'UTF16Encoding', 'ValidateAtomicAccess', 'ValidateSharedIntegerTypedArray', 'ValidateTypedArray', 'ValueOfReadEvent', 'WakeWaiter', 'WeekDay', 'WordCharacters', 'YearFromTime', 'AsyncFunctionCreate', 'AsyncGeneratorFunctionCreate', 'AsyncIteratorClose', 'BackreferenceMatcher', 'Construct', 'CreateArrayFromList', 'CreateListFromArrayLike', 'CreateListIteratorRecord', 'DateString', 'NormalCompletion', 'OrdinarySet', 'OrdinarySetWithOwnDescriptor', 'RegExpBuiltinExec', 'SetFunctionLength', 'ThrowCompletion', 'TimeString', 'ToDateString', 'UnicodeMatchProperty', 'UnicodeMatchPropertyValue']; | ||
require('./tests').es2018(ES, ops, expectedMissing); |
339
test/es5.js
@@ -8,19 +8,5 @@ 'use strict'; | ||
var is = require('object-is'); | ||
var debug = require('object-inspect'); | ||
var coercibleObject = { valueOf: function () { return '3'; }, toString: function () { return 42; } }; | ||
var coercibleFnObject = { | ||
valueOf: function () { return function valueOfFn() {}; }, | ||
toString: function () { return 42; } | ||
}; | ||
var valueOfOnlyObject = { valueOf: function () { return 4; }, toString: function () { return {}; } }; | ||
var toStringOnlyObject = { valueOf: function () { return {}; }, toString: function () { return 7; } }; | ||
var uncoercibleObject = { valueOf: function () { return {}; }, toString: function () { return {}; } }; | ||
var uncoercibleFnObject = { | ||
valueOf: function () { return function valueOfFn() {}; }, | ||
toString: function () { return function toStrFn() {}; } | ||
}; | ||
var objects = [{}, coercibleObject, toStringOnlyObject, valueOfOnlyObject]; | ||
var numbers = [0, -0, Infinity, -Infinity, 42]; | ||
var nonNullPrimitives = [true, false, 'foo', ''].concat(numbers); | ||
var primitives = [undefined, null].concat(nonNullPrimitives); | ||
var v = require('./helpers/values'); | ||
@@ -30,5 +16,5 @@ test('ToPrimitive', function (t) { | ||
var testPrimitive = function (primitive) { | ||
st.ok(is(ES.ToPrimitive(primitive), primitive), primitive + ' is returned correctly'); | ||
st.ok(is(ES.ToPrimitive(primitive), primitive), debug(primitive) + ' is returned correctly'); | ||
}; | ||
forEach(primitives, testPrimitive); | ||
forEach(v.primitives, testPrimitive); | ||
st.end(); | ||
@@ -38,13 +24,13 @@ }); | ||
t.test('objects', function (st) { | ||
st.equal(ES.ToPrimitive(coercibleObject), coercibleObject.valueOf(), 'coercibleObject coerces to valueOf'); | ||
st.equal(ES.ToPrimitive(coercibleObject, Number), coercibleObject.valueOf(), 'coercibleObject with hint Number coerces to valueOf'); | ||
st.equal(ES.ToPrimitive(coercibleObject, String), coercibleObject.toString(), 'coercibleObject with hint String coerces to toString'); | ||
st.equal(ES.ToPrimitive(coercibleFnObject), coercibleFnObject.toString(), 'coercibleFnObject coerces to toString'); | ||
st.equal(ES.ToPrimitive(toStringOnlyObject), toStringOnlyObject.toString(), 'toStringOnlyObject returns toString'); | ||
st.equal(ES.ToPrimitive(valueOfOnlyObject), valueOfOnlyObject.valueOf(), 'valueOfOnlyObject returns valueOf'); | ||
st.equal(ES.ToPrimitive(v.coercibleObject), v.coercibleObject.valueOf(), 'coercibleObject coerces to valueOf'); | ||
st.equal(ES.ToPrimitive(v.coercibleObject, Number), v.coercibleObject.valueOf(), 'coercibleObject with hint Number coerces to valueOf'); | ||
st.equal(ES.ToPrimitive(v.coercibleObject, String), v.coercibleObject.toString(), 'coercibleObject with hint String coerces to toString'); | ||
st.equal(ES.ToPrimitive(v.coercibleFnObject), v.coercibleFnObject.toString(), 'coercibleFnObject coerces to toString'); | ||
st.equal(ES.ToPrimitive(v.toStringOnlyObject), v.toStringOnlyObject.toString(), 'toStringOnlyObject returns toString'); | ||
st.equal(ES.ToPrimitive(v.valueOfOnlyObject), v.valueOfOnlyObject.valueOf(), 'valueOfOnlyObject returns valueOf'); | ||
st.equal(ES.ToPrimitive({}), '[object Object]', '{} with no hint coerces to Object#toString'); | ||
st.equal(ES.ToPrimitive({}, String), '[object Object]', '{} with hint String coerces to Object#toString'); | ||
st.equal(ES.ToPrimitive({}, Number), '[object Object]', '{} with hint Number coerces to Object#toString'); | ||
st['throws'](function () { return ES.ToPrimitive(uncoercibleObject); }, TypeError, 'uncoercibleObject throws a TypeError'); | ||
st['throws'](function () { return ES.ToPrimitive(uncoercibleFnObject); }, TypeError, 'uncoercibleFnObject throws a TypeError'); | ||
st['throws'](function () { return ES.ToPrimitive(v.uncoercibleObject); }, TypeError, 'uncoercibleObject throws a TypeError'); | ||
st['throws'](function () { return ES.ToPrimitive(v.uncoercibleFnObject); }, TypeError, 'uncoercibleFnObject throws a TypeError'); | ||
st.end(); | ||
@@ -69,6 +55,6 @@ }); | ||
t.equal(true, ES.ToBoolean('foo'), 'nonempty string coerces to true'); | ||
forEach(objects, function (obj) { | ||
forEach(v.objects, function (obj) { | ||
t.equal(true, ES.ToBoolean(obj), 'object coerces to true'); | ||
}); | ||
t.equal(true, ES.ToBoolean(uncoercibleObject), 'uncoercibleObject coerces to true'); | ||
t.equal(true, ES.ToBoolean(v.uncoercibleObject), 'uncoercibleObject coerces to true'); | ||
t.end(); | ||
@@ -89,6 +75,6 @@ }); | ||
}); | ||
forEach(objects, function (object) { | ||
forEach(v.objects, function (object) { | ||
t.ok(is(ES.ToNumber(object), ES.ToNumber(ES.ToPrimitive(object))), 'object ' + object + ' coerces to same as ToPrimitive of object does'); | ||
}); | ||
t['throws'](function () { return ES.ToNumber(uncoercibleObject); }, TypeError, 'uncoercibleObject throws'); | ||
t['throws'](function () { return ES.ToNumber(v.uncoercibleObject); }, TypeError, 'uncoercibleObject throws'); | ||
t.end(); | ||
@@ -104,3 +90,3 @@ }); | ||
t.equal(3, ES.ToInteger(Math.PI), 'pi returns 3'); | ||
t['throws'](function () { return ES.ToInteger(uncoercibleObject); }, TypeError, 'uncoercibleObject throws'); | ||
t['throws'](function () { return ES.ToInteger(v.uncoercibleObject); }, TypeError, 'uncoercibleObject throws'); | ||
t.end(); | ||
@@ -115,3 +101,3 @@ }); | ||
}); | ||
t['throws'](function () { return ES.ToInt32(uncoercibleObject); }, TypeError, 'uncoercibleObject throws'); | ||
t['throws'](function () { return ES.ToInt32(v.uncoercibleObject); }, TypeError, 'uncoercibleObject throws'); | ||
t.ok(is(ES.ToInt32(0x100000000), 0), '2^32 returns +0'); | ||
@@ -134,3 +120,3 @@ t.ok(is(ES.ToInt32(0x100000000 - 1), -1), '2^32 - 1 returns -1'); | ||
}); | ||
t['throws'](function () { return ES.ToUint32(uncoercibleObject); }, TypeError, 'uncoercibleObject throws'); | ||
t['throws'](function () { return ES.ToUint32(v.uncoercibleObject); }, TypeError, 'uncoercibleObject throws'); | ||
t.ok(is(ES.ToUint32(0x100000000), 0), '2^32 returns +0'); | ||
@@ -153,3 +139,3 @@ t.ok(is(ES.ToUint32(0x100000000 - 1), 0x100000000 - 1), '2^32 - 1 returns 2^32 - 1'); | ||
}); | ||
t['throws'](function () { return ES.ToUint16(uncoercibleObject); }, TypeError, 'uncoercibleObject throws'); | ||
t['throws'](function () { return ES.ToUint16(v.uncoercibleObject); }, TypeError, 'uncoercibleObject throws'); | ||
t.ok(is(ES.ToUint16(0x100000000), 0), '2^32 returns +0'); | ||
@@ -165,3 +151,3 @@ t.ok(is(ES.ToUint16(0x100000000 - 1), 0x10000 - 1), '2^32 - 1 returns 2^16 - 1'); | ||
test('ToString', function (t) { | ||
t['throws'](function () { return ES.ToString(uncoercibleObject); }, TypeError, 'uncoercibleObject throws'); | ||
t['throws'](function () { return ES.ToString(v.uncoercibleObject); }, TypeError, 'uncoercibleObject throws'); | ||
t.end(); | ||
@@ -173,3 +159,3 @@ }); | ||
t['throws'](function () { return ES.ToObject(null); }, TypeError, 'null throws'); | ||
forEach(numbers, function (number) { | ||
forEach(v.numbers, function (number) { | ||
var obj = ES.ToObject(number); | ||
@@ -187,5 +173,5 @@ t.equal(typeof obj, 'object', 'number ' + number + ' coerces to object'); | ||
var checkCoercible = function (value) { | ||
t.doesNotThrow(function () { return ES.CheckObjectCoercible(value); }, '"' + value + '" does not throw'); | ||
t.doesNotThrow(function () { return ES.CheckObjectCoercible(value); }, debug(value) + ' does not throw'); | ||
}; | ||
forEach(objects.concat(nonNullPrimitives), checkCoercible); | ||
forEach(v.objects.concat(v.nonNullPrimitives), checkCoercible); | ||
t.end(); | ||
@@ -196,5 +182,5 @@ }); | ||
t.equal(true, ES.IsCallable(function () {}), 'function is callable'); | ||
var nonCallables = [/a/g, {}, Object.prototype, NaN].concat(primitives); | ||
var nonCallables = [/a/g, {}, Object.prototype, NaN].concat(v.primitives); | ||
forEach(nonCallables, function (nonCallable) { | ||
t.equal(false, ES.IsCallable(nonCallable), nonCallable + ' is not callable'); | ||
t.equal(false, ES.IsCallable(nonCallable), debug(nonCallable) + ' is not callable'); | ||
}); | ||
@@ -207,4 +193,4 @@ t.end(); | ||
t.equal(false, ES.SameValue(0, -0), '+0 is not SameValue as -0'); | ||
forEach(objects.concat(primitives), function (val) { | ||
t.equal(val === val, ES.SameValue(val, val), '"' + val + '" is SameValue to itself'); | ||
forEach(v.objects.concat(v.primitives), function (val) { | ||
t.equal(val === val, ES.SameValue(val, val), debug(val) + ' is SameValue to itself'); | ||
}); | ||
@@ -228,36 +214,5 @@ t.end(); | ||
var bothDescriptor = function () { | ||
return { '[[Get]]': function () {}, '[[Value]]': true }; | ||
}; | ||
var accessorDescriptor = function () { | ||
return { | ||
'[[Get]]': function () {}, | ||
'[[Enumerable]]': true, | ||
'[[Configurable]]': true | ||
}; | ||
}; | ||
var mutatorDescriptor = function () { | ||
return { | ||
'[[Set]]': function () {}, | ||
'[[Enumerable]]': true, | ||
'[[Configurable]]': true | ||
}; | ||
}; | ||
var dataDescriptor = function () { | ||
return { | ||
'[[Value]]': 42, | ||
'[[Writable]]': false, | ||
'[[Configurable]]': false | ||
}; | ||
}; | ||
var genericDescriptor = function () { | ||
return { | ||
'[[Configurable]]': true, | ||
'[[Enumerable]]': false | ||
}; | ||
}; | ||
test('IsPropertyDescriptor', function (t) { | ||
forEach(primitives, function (primitive) { | ||
t.equal(ES.IsPropertyDescriptor(primitive), false, primitive + ' is not a Property Descriptor'); | ||
forEach(v.primitives, function (primitive) { | ||
t.equal(ES.IsPropertyDescriptor(primitive), false, debug(primitive) + ' is not a Property Descriptor'); | ||
}); | ||
@@ -269,11 +224,19 @@ | ||
t.equal(ES.IsPropertyDescriptor(accessorDescriptor()), true, 'accessor descriptor is a Property Descriptor'); | ||
t.equal(ES.IsPropertyDescriptor(mutatorDescriptor()), true, 'mutator descriptor is a Property Descriptor'); | ||
t.equal(ES.IsPropertyDescriptor(dataDescriptor()), true, 'data descriptor is a Property Descriptor'); | ||
t.equal(ES.IsPropertyDescriptor(genericDescriptor()), true, 'generic descriptor is a Property Descriptor'); | ||
t.equal(ES.IsPropertyDescriptor(v.accessorDescriptor()), true, 'accessor descriptor is a Property Descriptor'); | ||
t.equal(ES.IsPropertyDescriptor(v.mutatorDescriptor()), true, 'mutator descriptor is a Property Descriptor'); | ||
t.equal(ES.IsPropertyDescriptor(v.dataDescriptor()), true, 'data descriptor is a Property Descriptor'); | ||
t.equal(ES.IsPropertyDescriptor(v.genericDescriptor()), true, 'generic descriptor is a Property Descriptor'); | ||
t['throws'](function () { | ||
ES.IsPropertyDescriptor(bothDescriptor()); | ||
}, TypeError, 'a Property Descriptor can not be both a Data and an Accessor Descriptor'); | ||
t['throws']( | ||
function () { ES.IsPropertyDescriptor(v.bothDescriptor()); }, | ||
TypeError, | ||
'a Property Descriptor can not be both a Data and an Accessor Descriptor' | ||
); | ||
t['throws']( | ||
function () { ES.IsPropertyDescriptor(v.bothDescriptorWritable()); }, | ||
TypeError, | ||
'a Property Descriptor can not be both a Data and an Accessor Descriptor' | ||
); | ||
t.end(); | ||
@@ -283,4 +246,4 @@ }); | ||
test('IsAccessorDescriptor', function (t) { | ||
forEach(nonNullPrimitives.concat(null), function (primitive) { | ||
t['throws'](function () { ES.IsAccessorDescriptor(primitive); }, TypeError, primitive + ' is not a Property Descriptor'); | ||
forEach(v.nonNullPrimitives.concat(null), function (primitive) { | ||
t['throws'](function () { ES.IsAccessorDescriptor(primitive); }, TypeError, debug(primitive) + ' is not a Property Descriptor'); | ||
}); | ||
@@ -291,6 +254,6 @@ | ||
t.equal(ES.IsAccessorDescriptor(accessorDescriptor()), true, 'accessor descriptor is an Accessor Descriptor'); | ||
t.equal(ES.IsAccessorDescriptor(mutatorDescriptor()), true, 'mutator descriptor is an Accessor Descriptor'); | ||
t.equal(ES.IsAccessorDescriptor(dataDescriptor()), false, 'data descriptor is not an Accessor Descriptor'); | ||
t.equal(ES.IsAccessorDescriptor(genericDescriptor()), false, 'generic descriptor is not an Accessor Descriptor'); | ||
t.equal(ES.IsAccessorDescriptor(v.accessorDescriptor()), true, 'accessor descriptor is an Accessor Descriptor'); | ||
t.equal(ES.IsAccessorDescriptor(v.mutatorDescriptor()), true, 'mutator descriptor is an Accessor Descriptor'); | ||
t.equal(ES.IsAccessorDescriptor(v.dataDescriptor()), false, 'data descriptor is not an Accessor Descriptor'); | ||
t.equal(ES.IsAccessorDescriptor(v.genericDescriptor()), false, 'generic descriptor is not an Accessor Descriptor'); | ||
@@ -301,4 +264,4 @@ t.end(); | ||
test('IsDataDescriptor', function (t) { | ||
forEach(nonNullPrimitives.concat(null), function (primitive) { | ||
t['throws'](function () { ES.IsDataDescriptor(primitive); }, TypeError, primitive + ' is not a Property Descriptor'); | ||
forEach(v.nonNullPrimitives.concat(null), function (primitive) { | ||
t['throws'](function () { ES.IsDataDescriptor(primitive); }, TypeError, debug(primitive) + ' is not a Property Descriptor'); | ||
}); | ||
@@ -309,6 +272,6 @@ | ||
t.equal(ES.IsDataDescriptor(accessorDescriptor()), false, 'accessor descriptor is not a Data Descriptor'); | ||
t.equal(ES.IsDataDescriptor(mutatorDescriptor()), false, 'mutator descriptor is not a Data Descriptor'); | ||
t.equal(ES.IsDataDescriptor(dataDescriptor()), true, 'data descriptor is a Data Descriptor'); | ||
t.equal(ES.IsDataDescriptor(genericDescriptor()), false, 'generic descriptor is not a Data Descriptor'); | ||
t.equal(ES.IsDataDescriptor(v.accessorDescriptor()), false, 'accessor descriptor is not a Data Descriptor'); | ||
t.equal(ES.IsDataDescriptor(v.mutatorDescriptor()), false, 'mutator descriptor is not a Data Descriptor'); | ||
t.equal(ES.IsDataDescriptor(v.dataDescriptor()), true, 'data descriptor is a Data Descriptor'); | ||
t.equal(ES.IsDataDescriptor(v.genericDescriptor()), false, 'generic descriptor is not a Data Descriptor'); | ||
@@ -319,7 +282,7 @@ t.end(); | ||
test('IsGenericDescriptor', function (t) { | ||
forEach(nonNullPrimitives.concat(null), function (primitive) { | ||
forEach(v.nonNullPrimitives.concat(null), function (primitive) { | ||
t['throws']( | ||
function () { ES.IsGenericDescriptor(primitive); }, | ||
TypeError, | ||
primitive + ' is not a Property Descriptor' | ||
debug(primitive) + ' is not a Property Descriptor' | ||
); | ||
@@ -331,7 +294,7 @@ }); | ||
t.equal(ES.IsGenericDescriptor(accessorDescriptor()), false, 'accessor descriptor is not a generic Descriptor'); | ||
t.equal(ES.IsGenericDescriptor(mutatorDescriptor()), false, 'mutator descriptor is not a generic Descriptor'); | ||
t.equal(ES.IsGenericDescriptor(dataDescriptor()), false, 'data descriptor is not a generic Descriptor'); | ||
t.equal(ES.IsGenericDescriptor(v.accessorDescriptor()), false, 'accessor descriptor is not a generic Descriptor'); | ||
t.equal(ES.IsGenericDescriptor(v.mutatorDescriptor()), false, 'mutator descriptor is not a generic Descriptor'); | ||
t.equal(ES.IsGenericDescriptor(v.dataDescriptor()), false, 'data descriptor is not a generic Descriptor'); | ||
t.equal(ES.IsGenericDescriptor(genericDescriptor()), true, 'generic descriptor is a generic Descriptor'); | ||
t.equal(ES.IsGenericDescriptor(v.genericDescriptor()), true, 'generic descriptor is a generic Descriptor'); | ||
@@ -345,11 +308,11 @@ t.end(); | ||
forEach(nonNullPrimitives.concat(null), function (primitive) { | ||
forEach(v.nonNullPrimitives.concat(null), function (primitive) { | ||
t['throws']( | ||
function () { ES.FromPropertyDescriptor(primitive); }, | ||
TypeError, | ||
primitive + ' is not a Property Descriptor' | ||
debug(primitive) + ' is not a Property Descriptor' | ||
); | ||
}); | ||
var accessor = accessorDescriptor(); | ||
var accessor = v.accessorDescriptor(); | ||
t.deepEqual(ES.FromPropertyDescriptor(accessor), { | ||
@@ -362,3 +325,3 @@ get: accessor['[[Get]]'], | ||
var mutator = mutatorDescriptor(); | ||
var mutator = v.mutatorDescriptor(); | ||
t.deepEqual(ES.FromPropertyDescriptor(mutator), { | ||
@@ -370,3 +333,3 @@ get: mutator['[[Get]]'], | ||
}); | ||
var data = dataDescriptor(); | ||
var data = v.dataDescriptor(); | ||
t.deepEqual(ES.FromPropertyDescriptor(data), { | ||
@@ -380,3 +343,3 @@ value: data['[[Value]]'], | ||
t['throws']( | ||
function () { ES.FromPropertyDescriptor(genericDescriptor()); }, | ||
function () { ES.FromPropertyDescriptor(v.genericDescriptor()); }, | ||
TypeError, | ||
@@ -390,11 +353,11 @@ 'a complete Property Descriptor is required' | ||
test('ToPropertyDescriptor', function (t) { | ||
forEach(nonNullPrimitives.concat(null), function (primitive) { | ||
forEach(v.nonNullPrimitives.concat(null), function (primitive) { | ||
t['throws']( | ||
function () { ES.ToPropertyDescriptor(primitive); }, | ||
TypeError, | ||
primitive + ' is not an Object' | ||
debug(primitive) + ' is not an Object' | ||
); | ||
}); | ||
var accessor = accessorDescriptor(); | ||
var accessor = v.accessorDescriptor(); | ||
t.deepEqual(ES.ToPropertyDescriptor({ | ||
@@ -406,3 +369,3 @@ get: accessor['[[Get]]'], | ||
var mutator = mutatorDescriptor(); | ||
var mutator = v.mutatorDescriptor(); | ||
t.deepEqual(ES.ToPropertyDescriptor({ | ||
@@ -414,3 +377,3 @@ set: mutator['[[Set]]'], | ||
var data = dataDescriptor(); | ||
var data = v.descriptors.nonConfigurable(v.dataDescriptor()); | ||
t.deepEqual(ES.ToPropertyDescriptor({ | ||
@@ -422,3 +385,3 @@ value: data['[[Value]]'], | ||
var both = bothDescriptor(); | ||
var both = v.bothDescriptor(); | ||
t['throws']( | ||
@@ -446,1 +409,153 @@ function () { | ||
}); | ||
test('Abstract Equality Comparison', function (t) { | ||
t.test('same types use ===', function (st) { | ||
forEach(v.primitives.concat(v.objects), function (value) { | ||
st.equal(ES['Abstract Equality Comparison'](value, value), value === value, debug(value) + ' is abstractly equal to itself'); | ||
}); | ||
st.end(); | ||
}); | ||
t.test('different types coerce', function (st) { | ||
var pairs = [ | ||
[null, undefined], | ||
[3, '3'], | ||
[true, '3'], | ||
[true, 3], | ||
[false, 0], | ||
[false, '0'], | ||
[3, [3]], | ||
['3', [3]], | ||
[true, [1]], | ||
[false, [0]], | ||
[String(v.coercibleObject), v.coercibleObject], | ||
[Number(String(v.coercibleObject)), v.coercibleObject], | ||
[Number(v.coercibleObject), v.coercibleObject], | ||
[String(Number(v.coercibleObject)), v.coercibleObject] | ||
]; | ||
forEach(pairs, function (pair) { | ||
var a = pair[0]; | ||
var b = pair[1]; | ||
// eslint-disable-next-line eqeqeq | ||
st.equal(ES['Abstract Equality Comparison'](a, b), a == b, debug(a) + ' == ' + debug(b)); | ||
// eslint-disable-next-line eqeqeq | ||
st.equal(ES['Abstract Equality Comparison'](b, a), b == a, debug(b) + ' == ' + debug(a)); | ||
}); | ||
st.end(); | ||
}); | ||
t.end(); | ||
}); | ||
test('Strict Equality Comparison', function (t) { | ||
t.test('same types use ===', function (st) { | ||
forEach(v.primitives.concat(v.objects), function (value) { | ||
st.equal(ES['Strict Equality Comparison'](value, value), value === value, debug(value) + ' is strictly equal to itself'); | ||
}); | ||
st.end(); | ||
}); | ||
t.test('different types are not ===', function (st) { | ||
var pairs = [ | ||
[null, undefined], | ||
[3, '3'], | ||
[true, '3'], | ||
[true, 3], | ||
[false, 0], | ||
[false, '0'], | ||
[3, [3]], | ||
['3', [3]], | ||
[true, [1]], | ||
[false, [0]], | ||
[String(v.coercibleObject), v.coercibleObject], | ||
[Number(String(v.coercibleObject)), v.coercibleObject], | ||
[Number(v.coercibleObject), v.coercibleObject], | ||
[String(Number(v.coercibleObject)), v.coercibleObject] | ||
]; | ||
forEach(pairs, function (pair) { | ||
var a = pair[0]; | ||
var b = pair[1]; | ||
st.equal(ES['Strict Equality Comparison'](a, b), a === b, debug(a) + ' === ' + debug(b)); | ||
st.equal(ES['Strict Equality Comparison'](b, a), b === a, debug(b) + ' === ' + debug(a)); | ||
}); | ||
st.end(); | ||
}); | ||
t.end(); | ||
}); | ||
test('Abstract Relational Comparison', function (t) { | ||
t.test('at least one operand is NaN', function (st) { | ||
st.equal(ES['Abstract Relational Comparison'](NaN, {}, true), undefined, 'LeftFirst: first is NaN, returns undefined'); | ||
st.equal(ES['Abstract Relational Comparison']({}, NaN, true), undefined, 'LeftFirst: second is NaN, returns undefined'); | ||
st.equal(ES['Abstract Relational Comparison'](NaN, {}, false), undefined, '!LeftFirst: first is NaN, returns undefined'); | ||
st.equal(ES['Abstract Relational Comparison']({}, NaN, false), undefined, '!LeftFirst: second is NaN, returns undefined'); | ||
st.end(); | ||
}); | ||
t.equal(ES['Abstract Relational Comparison'](3, 4, true), true, 'LeftFirst: 3 is less than 4'); | ||
t.equal(ES['Abstract Relational Comparison'](4, 3, true), false, 'LeftFirst: 3 is not less than 4'); | ||
t.equal(ES['Abstract Relational Comparison'](3, 4, false), true, '!LeftFirst: 3 is less than 4'); | ||
t.equal(ES['Abstract Relational Comparison'](4, 3, false), false, '!LeftFirst: 3 is not less than 4'); | ||
t.equal(ES['Abstract Relational Comparison']('3', '4', true), true, 'LeftFirst: "3" is less than "4"'); | ||
t.equal(ES['Abstract Relational Comparison']('4', '3', true), false, 'LeftFirst: "3" is not less than "4"'); | ||
t.equal(ES['Abstract Relational Comparison']('3', '4', false), true, '!LeftFirst: "3" is less than "4"'); | ||
t.equal(ES['Abstract Relational Comparison']('4', '3', false), false, '!LeftFirst: "3" is not less than "4"'); | ||
t.equal(ES['Abstract Relational Comparison'](v.coercibleObject, 42, true), true, 'LeftFirst: coercible object is less than 42'); | ||
t.equal(ES['Abstract Relational Comparison'](42, v.coercibleObject, true), false, 'LeftFirst: 42 is not less than coercible object'); | ||
t.equal(ES['Abstract Relational Comparison'](v.coercibleObject, 42, false), true, '!LeftFirst: coercible object is less than 42'); | ||
t.equal(ES['Abstract Relational Comparison'](42, v.coercibleObject, false), false, '!LeftFirst: 42 is not less than coercible object'); | ||
t.equal(ES['Abstract Relational Comparison'](v.coercibleObject, '3', true), false, 'LeftFirst: coercible object is not less than "3"'); | ||
t.equal(ES['Abstract Relational Comparison']('3', v.coercibleObject, true), false, 'LeftFirst: "3" is not less than coercible object'); | ||
t.equal(ES['Abstract Relational Comparison'](v.coercibleObject, '3', false), false, '!LeftFirst: coercible object is not less than "3"'); | ||
t.equal(ES['Abstract Relational Comparison']('3', v.coercibleObject, false), false, '!LeftFirst: "3" is not less than coercible object'); | ||
t.end(); | ||
}); | ||
test('FromPropertyDescriptor', function (t) { | ||
t.equal(ES.FromPropertyDescriptor(), undefined, 'no value begets undefined'); | ||
t.equal(ES.FromPropertyDescriptor(undefined), undefined, 'undefined value begets undefined'); | ||
forEach(v.nonUndefinedPrimitives, function (primitive) { | ||
t['throws']( | ||
function () { ES.FromPropertyDescriptor(primitive); }, | ||
TypeError, | ||
debug(primitive) + ' is not a Property Descriptor' | ||
); | ||
}); | ||
var accessor = v.accessorDescriptor(); | ||
t.deepEqual(ES.FromPropertyDescriptor(accessor), { | ||
get: accessor['[[Get]]'], | ||
set: accessor['[[Set]]'], | ||
enumerable: !!accessor['[[Enumerable]]'], | ||
configurable: !!accessor['[[Configurable]]'] | ||
}); | ||
var mutator = v.mutatorDescriptor(); | ||
t.deepEqual(ES.FromPropertyDescriptor(mutator), { | ||
get: mutator['[[Get]]'], | ||
set: mutator['[[Set]]'], | ||
enumerable: !!mutator['[[Enumerable]]'], | ||
configurable: !!mutator['[[Configurable]]'] | ||
}); | ||
var data = v.dataDescriptor(); | ||
t.deepEqual(ES.FromPropertyDescriptor(data), { | ||
value: data['[[Value]]'], | ||
writable: data['[[Writable]]'], | ||
enumerable: !!data['[[Enumerable]]'], | ||
configurable: !!data['[[Configurable]]'] | ||
}); | ||
t['throws']( | ||
function () { ES.FromPropertyDescriptor(v.genericDescriptor()); }, | ||
TypeError, | ||
'a complete Property Descriptor is required' | ||
); | ||
t.end(); | ||
}); |
@@ -10,52 +10,52 @@ 'use strict'; | ||
module.exports = function assertRecordTests(ES, test) { | ||
test('Property Descriptor', function (t) { | ||
var record = 'Property Descriptor'; | ||
test('Property Descriptor', function (t) { | ||
var record = 'Property Descriptor'; | ||
forEach(v.nonUndefinedPrimitives, function (primitive) { | ||
t['throws']( | ||
function () { assertRecord(ES, record, 'arg', primitive); }, | ||
TypeError, | ||
debug(primitive) + ' is not a Property Descriptor' | ||
); | ||
}); | ||
forEach(v.nonUndefinedPrimitives, function (primitive) { | ||
t['throws']( | ||
function () { assertRecord(ES, record, 'arg', primitive); }, | ||
TypeError, | ||
debug(primitive) + ' is not a Property Descriptor' | ||
); | ||
}); | ||
t['throws']( | ||
function () { assertRecord(ES, record, 'arg', { invalid: true }); }, | ||
TypeError, | ||
'invalid keys not allowed on a Property Descriptor' | ||
); | ||
t['throws']( | ||
function () { assertRecord(ES, record, 'arg', { invalid: true }); }, | ||
TypeError, | ||
'invalid keys not allowed on a Property Descriptor' | ||
); | ||
t.doesNotThrow( | ||
function () { assertRecord(ES, record, 'arg', {}); }, | ||
'empty object is an incomplete Property Descriptor' | ||
); | ||
t.doesNotThrow( | ||
function () { assertRecord(ES, record, 'arg', {}); }, | ||
'empty object is an incomplete Property Descriptor' | ||
); | ||
t.doesNotThrow( | ||
function () { assertRecord(ES, record, 'arg', v.accessorDescriptor()); }, | ||
'accessor descriptor is a Property Descriptor' | ||
); | ||
t.doesNotThrow( | ||
function () { assertRecord(ES, record, 'arg', v.accessorDescriptor()); }, | ||
'accessor descriptor is a Property Descriptor' | ||
); | ||
t.doesNotThrow( | ||
function () { assertRecord(ES, record, 'arg', v.mutatorDescriptor()); }, | ||
'mutator descriptor is a Property Descriptor' | ||
); | ||
t.doesNotThrow( | ||
function () { assertRecord(ES, record, 'arg', v.mutatorDescriptor()); }, | ||
'mutator descriptor is a Property Descriptor' | ||
); | ||
t.doesNotThrow( | ||
function () { assertRecord(ES, record, 'arg', v.dataDescriptor()); }, | ||
'data descriptor is a Property Descriptor' | ||
); | ||
t.doesNotThrow( | ||
function () { assertRecord(ES, record, 'arg', v.dataDescriptor()); }, | ||
'data descriptor is a Property Descriptor' | ||
); | ||
t.doesNotThrow( | ||
function () { assertRecord(ES, record, 'arg', v.genericDescriptor()); }, | ||
'generic descriptor is a Property Descriptor' | ||
); | ||
t.doesNotThrow( | ||
function () { assertRecord(ES, record, 'arg', v.genericDescriptor()); }, | ||
'generic descriptor is a Property Descriptor' | ||
); | ||
t['throws']( | ||
function () { assertRecord(ES, record, 'arg', v.bothDescriptor()); }, | ||
TypeError, | ||
'a Property Descriptor can not be both a Data and an Accessor Descriptor' | ||
); | ||
t['throws']( | ||
function () { assertRecord(ES, record, 'arg', v.bothDescriptor()); }, | ||
TypeError, | ||
'a Property Descriptor can not be both a Data and an Accessor Descriptor' | ||
); | ||
t.end(); | ||
}); | ||
t.end(); | ||
}); | ||
}; |
'use strict'; | ||
var hasSymbols = typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol'; | ||
var assign = require('../../helpers/assign'); | ||
var hasSymbols = require('has-symbols')(); | ||
var coercibleObject = { valueOf: function () { return 3; }, toString: function () { return 42; } }; | ||
var coercibleFnObject = { | ||
valueOf: function () { return function valueOfFn() {}; }, | ||
toString: function () { return 42; } | ||
}; | ||
var valueOfOnlyObject = { valueOf: function () { return 4; }, toString: function () { return {}; } }; | ||
var toStringOnlyObject = { valueOf: function () { return {}; }, toString: function () { return 7; } }; | ||
var uncoercibleObject = { valueOf: function () { return {}; }, toString: function () { return {}; } }; | ||
var objects = [{}, coercibleObject, toStringOnlyObject, valueOfOnlyObject]; | ||
var uncoercibleFnObject = { | ||
valueOf: function () { return function valueOfFn() {}; }, | ||
toString: function () { return function toStrFn() {}; } | ||
}; | ||
var objects = [{}, coercibleObject, coercibleFnObject, toStringOnlyObject, valueOfOnlyObject]; | ||
var nullPrimitives = [undefined, null]; | ||
@@ -28,9 +38,36 @@ var nonIntegerNumbers = [-1.3, 0.2, 1.8, 1 / 3]; | ||
var timestamps = [].concat(0, 946713600000, 1546329600000); | ||
var nonFunctions = [].concat(primitives, objects, [42]); | ||
var nonArrays = [].concat(nonFunctions); | ||
var descriptors = { | ||
configurable: function (descriptor) { | ||
return assign(assign({}, descriptor), { '[[Configurable]]': true }); | ||
}, | ||
nonConfigurable: function (descriptor) { | ||
return assign(assign({}, descriptor), { '[[Configurable]]': false }); | ||
}, | ||
enumerable: function (descriptor) { | ||
return assign(assign({}, descriptor), { '[[Enumerable]]': true }); | ||
}, | ||
nonEnumerable: function (descriptor) { | ||
return assign(assign({}, descriptor), { '[[Enumerable]]': false }); | ||
}, | ||
writable: function (descriptor) { | ||
return assign(assign({}, descriptor), { '[[Writable]]': true }); | ||
}, | ||
nonWritable: function (descriptor) { | ||
return assign(assign({}, descriptor), { '[[Writable]]': false }); | ||
} | ||
}; | ||
module.exports = { | ||
coercibleObject: coercibleObject, | ||
coercibleFnObject: coercibleFnObject, | ||
valueOfOnlyObject: valueOfOnlyObject, | ||
toStringOnlyObject: toStringOnlyObject, | ||
uncoercibleObject: uncoercibleObject, | ||
uncoercibleFnObject: uncoercibleFnObject, | ||
objects: objects, | ||
nonFunctions: nonFunctions, | ||
nonArrays: nonArrays, | ||
nullPrimitives: nullPrimitives, | ||
@@ -59,28 +96,24 @@ numbers: numbers, | ||
}, | ||
accessorDescriptor: function () { | ||
return { | ||
'[[Get]]': function () {}, | ||
'[[Enumerable]]': true, | ||
'[[Configurable]]': true | ||
}; | ||
bothDescriptorWritable: function () { | ||
return descriptors.writable({ '[[Get]]': function () {} }); | ||
}, | ||
accessorDescriptor: function (value) { | ||
return descriptors.enumerable(descriptors.configurable({ | ||
'[[Get]]': function get() { return value; } | ||
})); | ||
}, | ||
mutatorDescriptor: function () { | ||
return { | ||
'[[Set]]': function () {}, | ||
'[[Enumerable]]': true, | ||
'[[Configurable]]': true | ||
}; | ||
return descriptors.enumerable(descriptors.configurable({ | ||
'[[Set]]': function () {} | ||
})); | ||
}, | ||
dataDescriptor: function () { | ||
return { | ||
'[[Value]]': 42, | ||
'[[Writable]]': false | ||
}; | ||
dataDescriptor: function (value) { | ||
return descriptors.nonWritable({ | ||
'[[Value]]': arguments.length > 0 ? value : 42 | ||
}); | ||
}, | ||
genericDescriptor: function () { | ||
return { | ||
'[[Configurable]]': true, | ||
'[[Enumerable]]': false | ||
}; | ||
} | ||
return descriptors.configurable(descriptors.nonEnumerable()); | ||
}, | ||
descriptors: descriptors | ||
}; |
@@ -10,3 +10,3 @@ 'use strict'; | ||
test('exposed properties', function (t) { | ||
t.deepEqual(ESkeys, ES6keys.concat(['ES2018', 'ES2017', 'ES7', 'ES2016', 'ES6', 'ES2015', 'ES5']).sort(), 'main ES object keys match ES6 keys'); | ||
t.deepEqual(ESkeys, ES6keys.concat(['ES2019', 'ES2018', 'ES2017', 'ES7', 'ES2016', 'ES6', 'ES2015', 'ES5']).sort(), 'main ES object keys match ES6 keys'); | ||
t.end(); | ||
@@ -31,1 +31,2 @@ }); | ||
require('./es2018'); | ||
require('./es2019'); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
408617
13
54
7626
49
10
5
+ Addedhas-symbols@^1.0.0
+ Addedobject-inspect@^1.6.0
+ Addeddefine-properties@1.2.1(transitive)
+ Addedes-object-atoms@1.0.0(transitive)
+ Addedobject-inspect@1.13.2(transitive)
+ Addedstring.prototype.trimend@1.0.8(transitive)
+ Addedstring.prototype.trimleft@2.1.3(transitive)
+ Addedstring.prototype.trimright@2.1.3(transitive)
+ Addedstring.prototype.trimstart@1.0.8(transitive)
Updatedobject-keys@^1.1.1