diff --git a/node_modules/es-abstract/2019/DayFromYear.js b/node_modules/es-abstract/2019/DayFromYear.js new file mode 100644 index 0000000000000000000000000000000000000000..341bf22a6c19352ec6225944fb49adeed22983e8 --- /dev/null +++ b/node_modules/es-abstract/2019/DayFromYear.js @@ -0,0 +1,10 @@ +'use strict'; + +var floor = require('./floor'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.3 + +module.exports = function DayFromYear(y) { + return (365 * (y - 1970)) + floor((y - 1969) / 4) - floor((y - 1901) / 100) + floor((y - 1601) / 400); +}; + diff --git a/node_modules/es-abstract/2019/DayWithinYear.js b/node_modules/es-abstract/2019/DayWithinYear.js new file mode 100644 index 0000000000000000000000000000000000000000..4c580940a58c58dcc3f7c2f96c5bca8e8237ebfc --- /dev/null +++ b/node_modules/es-abstract/2019/DayWithinYear.js @@ -0,0 +1,11 @@ +'use strict'; + +var Day = require('./Day'); +var DayFromYear = require('./DayFromYear'); +var YearFromTime = require('./YearFromTime'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.4 + +module.exports = function DayWithinYear(t) { + return Day(t) - DayFromYear(YearFromTime(t)); +}; diff --git a/node_modules/es-abstract/2019/DaysInYear.js b/node_modules/es-abstract/2019/DaysInYear.js new file mode 100644 index 0000000000000000000000000000000000000000..7116c69027022323e41130f384db7cc3d35709f9 --- /dev/null +++ b/node_modules/es-abstract/2019/DaysInYear.js @@ -0,0 +1,18 @@ +'use strict'; + +var modulo = require('./modulo'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.3 + +module.exports = function DaysInYear(y) { + if (modulo(y, 4) !== 0) { + return 365; + } + if (modulo(y, 100) !== 0) { + return 366; + } + if (modulo(y, 400) !== 0) { + return 365; + } + return 366; +}; diff --git a/node_modules/es-abstract/2019/DefinePropertyOrThrow.js b/node_modules/es-abstract/2019/DefinePropertyOrThrow.js new file mode 100644 index 0000000000000000000000000000000000000000..ff6683c3dc954ec27c072032bfcc0cfd70936587 --- /dev/null +++ b/node_modules/es-abstract/2019/DefinePropertyOrThrow.js @@ -0,0 +1,39 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var isPropertyDescriptor = require('../helpers/records/property-descriptor'); +var DefineOwnProperty = require('../helpers/DefineOwnProperty'); + +var FromPropertyDescriptor = require('./FromPropertyDescriptor'); +var IsDataDescriptor = require('./IsDataDescriptor'); +var isPropertyKey = require('../helpers/isPropertyKey'); +var SameValue = require('./SameValue'); +var ToPropertyDescriptor = require('./ToPropertyDescriptor'); + +// https://262.ecma-international.org/6.0/#sec-definepropertyorthrow + +module.exports = function DefinePropertyOrThrow(O, P, desc) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: P is not a Property Key'); + } + + var Desc = isPropertyDescriptor(desc) ? desc : ToPropertyDescriptor(desc); + if (!isPropertyDescriptor(Desc)) { + throw new $TypeError('Assertion failed: Desc is not a valid Property Descriptor'); + } + + return DefineOwnProperty( + IsDataDescriptor, + SameValue, + FromPropertyDescriptor, + O, + P, + Desc + ); +}; diff --git a/node_modules/es-abstract/2019/DeletePropertyOrThrow.js b/node_modules/es-abstract/2019/DeletePropertyOrThrow.js new file mode 100644 index 0000000000000000000000000000000000000000..8841fda81f7663673367bdfc1af99794fb0ef747 --- /dev/null +++ b/node_modules/es-abstract/2019/DeletePropertyOrThrow.js @@ -0,0 +1,25 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var isPropertyKey = require('../helpers/isPropertyKey'); + +// https://262.ecma-international.org/6.0/#sec-deletepropertyorthrow + +module.exports = function DeletePropertyOrThrow(O, P) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: P is not a Property Key'); + } + + // eslint-disable-next-line no-param-reassign + var success = delete O[P]; + if (!success) { + throw new $TypeError('Attempt to delete property failed.'); + } + return success; +}; diff --git a/node_modules/es-abstract/2019/DetachArrayBuffer.js b/node_modules/es-abstract/2019/DetachArrayBuffer.js new file mode 100644 index 0000000000000000000000000000000000000000..6ded9de5652c4483ba14060ba82380eb3e63d92a --- /dev/null +++ b/node_modules/es-abstract/2019/DetachArrayBuffer.js @@ -0,0 +1,46 @@ +'use strict'; + +var $SyntaxError = require('es-errors/syntax'); +var $TypeError = require('es-errors/type'); + +var IsDetachedBuffer = require('./IsDetachedBuffer'); + +var isArrayBuffer = require('is-array-buffer'); +var isSharedArrayBuffer = require('is-shared-array-buffer'); + +var MessageChannel; +try { + // eslint-disable-next-line global-require + MessageChannel = require('worker_threads').MessageChannel; +} catch (e) { /**/ } + +// https://262.ecma-international.org/9.0/#sec-detacharraybuffer + +/* globals postMessage */ + +module.exports = function DetachArrayBuffer(arrayBuffer) { + if (!isArrayBuffer(arrayBuffer) || isSharedArrayBuffer(arrayBuffer)) { + throw new $TypeError('Assertion failed: `arrayBuffer` must be an Object with an [[ArrayBufferData]] internal slot, and not a Shared Array Buffer'); + } + + // commented out since there's no way to set or access this key + // var key = arguments.length > 1 ? arguments[1] : void undefined; + + // if (!SameValue(arrayBuffer[[ArrayBufferDetachKey]], key)) { + // throw new $TypeError('Assertion failed: `key` must be the value of the [[ArrayBufferDetachKey]] internal slot of `arrayBuffer`'); + // } + + if (!IsDetachedBuffer(arrayBuffer)) { // node v21.0.0+ throws when you structuredClone a detached buffer + if (typeof structuredClone === 'function') { + structuredClone(arrayBuffer, { transfer: [arrayBuffer] }); + } else if (typeof postMessage === 'function') { + postMessage('', '/', [arrayBuffer]); // TODO: see if this might trigger listeners + } else if (MessageChannel) { + (new MessageChannel()).port1.postMessage(null, [arrayBuffer]); + } else { + throw new $SyntaxError('DetachArrayBuffer is not supported in this environment'); + } + } + + return null; +}; diff --git a/node_modules/es-abstract/2019/EnumerableOwnPropertyNames.js b/node_modules/es-abstract/2019/EnumerableOwnPropertyNames.js new file mode 100644 index 0000000000000000000000000000000000000000..f08d846e95148ddd0b96f0475ea6d1ae3554e704 --- /dev/null +++ b/node_modules/es-abstract/2019/EnumerableOwnPropertyNames.js @@ -0,0 +1,37 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var objectKeys = require('object-keys'); +var safePushApply = require('safe-push-apply'); +var callBound = require('call-bound'); + +var $isEnumerable = callBound('Object.prototype.propertyIsEnumerable'); + +var forEach = require('../helpers/forEach'); + +// https://262.ecma-international.org/8.0/#sec-enumerableownproperties + +module.exports = function EnumerableOwnPropertyNames(O, kind) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + var keys = objectKeys(O); + if (kind === 'key') { + return keys; + } + if (kind === 'value' || kind === 'key+value') { + var results = []; + forEach(keys, function (key) { + if ($isEnumerable(O, key)) { + safePushApply(results, [ + kind === 'value' ? O[key] : [key, O[key]] + ]); + } + }); + return results; + } + throw new $TypeError('Assertion failed: "kind" is not "key", "value", or "key+value": ' + kind); +}; diff --git a/node_modules/es-abstract/2019/FlattenIntoArray.js b/node_modules/es-abstract/2019/FlattenIntoArray.js new file mode 100644 index 0000000000000000000000000000000000000000..90e01434e6936f5476e6d0936932c01af9a71b88 --- /dev/null +++ b/node_modules/es-abstract/2019/FlattenIntoArray.js @@ -0,0 +1,55 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var MAX_SAFE_INTEGER = require('math-intrinsics/constants/maxSafeInteger'); + +var Call = require('./Call'); +var CreateDataPropertyOrThrow = require('./CreateDataPropertyOrThrow'); +var Get = require('./Get'); +var HasProperty = require('./HasProperty'); +var IsArray = require('./IsArray'); +var ToLength = require('./ToLength'); +var ToString = require('./ToString'); + +// https://262.ecma-international.org/10.0/#sec-flattenintoarray + +module.exports = function FlattenIntoArray(target, source, sourceLen, start, depth) { + var mapperFunction; + if (arguments.length > 5) { + mapperFunction = arguments[5]; + } + + var targetIndex = start; + var sourceIndex = 0; + while (sourceIndex < sourceLen) { + var P = ToString(sourceIndex); + var exists = HasProperty(source, P); + if (exists === true) { + var element = Get(source, P); + if (typeof mapperFunction !== 'undefined') { + if (arguments.length <= 6) { + throw new $TypeError('Assertion failed: thisArg is required when mapperFunction is provided'); + } + element = Call(mapperFunction, arguments[6], [element, sourceIndex, source]); + } + var shouldFlatten = false; + if (depth > 0) { + shouldFlatten = IsArray(element); + } + if (shouldFlatten) { + var elementLen = ToLength(Get(element, 'length')); + targetIndex = FlattenIntoArray(target, element, elementLen, targetIndex, depth - 1); + } else { + if (targetIndex >= MAX_SAFE_INTEGER) { + throw new $TypeError('index too large'); + } + CreateDataPropertyOrThrow(target, ToString(targetIndex), element); + targetIndex += 1; + } + } + sourceIndex += 1; + } + + return targetIndex; +}; diff --git a/node_modules/es-abstract/2019/FromPropertyDescriptor.js b/node_modules/es-abstract/2019/FromPropertyDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..45b6379f1214c415e1e43b855db01f18b3566cba --- /dev/null +++ b/node_modules/es-abstract/2019/FromPropertyDescriptor.js @@ -0,0 +1,16 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var isPropertyDescriptor = require('../helpers/records/property-descriptor'); +var fromPropertyDescriptor = require('../helpers/fromPropertyDescriptor'); + +// https://262.ecma-international.org/6.0/#sec-frompropertydescriptor + +module.exports = function FromPropertyDescriptor(Desc) { + if (typeof Desc !== 'undefined' && !isPropertyDescriptor(Desc)) { + throw new $TypeError('Assertion failed: `Desc` must be a Property Descriptor'); + } + + return fromPropertyDescriptor(Desc); +}; diff --git a/node_modules/es-abstract/2019/Get.js b/node_modules/es-abstract/2019/Get.js new file mode 100644 index 0000000000000000000000000000000000000000..42f7a14d853e05735d4166708590df2743cfa74c --- /dev/null +++ b/node_modules/es-abstract/2019/Get.js @@ -0,0 +1,24 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var inspect = require('object-inspect'); + +var isPropertyKey = require('../helpers/isPropertyKey'); + +var isObject = require('es-object-atoms/isObject'); + +// https://262.ecma-international.org/6.0/#sec-get-o-p + +module.exports = function Get(O, P) { + // 7.3.1.1 + if (!isObject(O)) { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + // 7.3.1.2 + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: P is not a Property Key, got ' + inspect(P)); + } + // 7.3.1.3 + return O[P]; +}; diff --git a/node_modules/es-abstract/2019/GetGlobalObject.js b/node_modules/es-abstract/2019/GetGlobalObject.js new file mode 100644 index 0000000000000000000000000000000000000000..0541ede0c48889fefe9a137e0e37a2e13573c091 --- /dev/null +++ b/node_modules/es-abstract/2019/GetGlobalObject.js @@ -0,0 +1,9 @@ +'use strict'; + +var getGlobal = require('globalthis/polyfill'); + +// https://262.ecma-international.org/6.0/#sec-getglobalobject + +module.exports = function GetGlobalObject() { + return getGlobal(); +}; diff --git a/node_modules/es-abstract/2019/GetIterator.js b/node_modules/es-abstract/2019/GetIterator.js new file mode 100644 index 0000000000000000000000000000000000000000..1a8d49a686fdb4ae3b9edb87f3dce6a9815565ab --- /dev/null +++ b/node_modules/es-abstract/2019/GetIterator.js @@ -0,0 +1,30 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var getIteratorMethod = require('../helpers/getIteratorMethod'); +var AdvanceStringIndex = require('./AdvanceStringIndex'); +var Call = require('./Call'); +var GetMethod = require('./GetMethod'); + +var isObject = require('es-object-atoms/isObject'); + +var ES = { + AdvanceStringIndex: AdvanceStringIndex, + GetMethod: GetMethod +}; + +// https://262.ecma-international.org/6.0/#sec-getiterator + +module.exports = function GetIterator(obj, method) { + var actualMethod = method; + if (arguments.length < 2) { + actualMethod = getIteratorMethod(ES, obj); + } + var iterator = Call(actualMethod, obj); + if (!isObject(iterator)) { + throw new $TypeError('iterator must return an object'); + } + + return iterator; +}; diff --git a/node_modules/es-abstract/2019/GetMethod.js b/node_modules/es-abstract/2019/GetMethod.js new file mode 100644 index 0000000000000000000000000000000000000000..e28bb1501fc8e4d4a67250c5110cba73bbcba385 --- /dev/null +++ b/node_modules/es-abstract/2019/GetMethod.js @@ -0,0 +1,34 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var GetV = require('./GetV'); +var IsCallable = require('./IsCallable'); +var isPropertyKey = require('../helpers/isPropertyKey'); + +var inspect = require('object-inspect'); + +// https://262.ecma-international.org/6.0/#sec-getmethod + +module.exports = function GetMethod(O, P) { + // 7.3.9.1 + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: P is not a Property Key'); + } + + // 7.3.9.2 + var func = GetV(O, P); + + // 7.3.9.4 + if (func == null) { + return void 0; + } + + // 7.3.9.5 + if (!IsCallable(func)) { + throw new $TypeError(inspect(P) + ' is not a function: ' + inspect(func)); + } + + // 7.3.9.6 + return func; +}; diff --git a/node_modules/es-abstract/2019/GetOwnPropertyKeys.js b/node_modules/es-abstract/2019/GetOwnPropertyKeys.js new file mode 100644 index 0000000000000000000000000000000000000000..e9b50d744a5fdf42221ad18e6674e777fa3b0a47 --- /dev/null +++ b/node_modules/es-abstract/2019/GetOwnPropertyKeys.js @@ -0,0 +1,30 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var hasSymbols = require('has-symbols')(); + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var $gOPN = GetIntrinsic('%Object.getOwnPropertyNames%', true); +var $gOPS = hasSymbols && GetIntrinsic('%Object.getOwnPropertySymbols%', true); +var keys = require('object-keys'); + +// https://262.ecma-international.org/6.0/#sec-getownpropertykeys + +module.exports = function GetOwnPropertyKeys(O, Type) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + if (Type === 'Symbol') { + return $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"`'); +}; diff --git a/node_modules/es-abstract/2019/GetPrototypeFromConstructor.js b/node_modules/es-abstract/2019/GetPrototypeFromConstructor.js new file mode 100644 index 0000000000000000000000000000000000000000..687f6ef200fb11a3dc97a27533d15430c305fb3b --- /dev/null +++ b/node_modules/es-abstract/2019/GetPrototypeFromConstructor.js @@ -0,0 +1,33 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $Function = GetIntrinsic('%Function%'); +var $TypeError = require('es-errors/type'); +var $SyntaxError = require('es-errors/syntax'); + +var Get = require('./Get'); +var IsConstructor = require('./IsConstructor'); + +var isObject = require('es-object-atoms/isObject'); + +// https://262.ecma-international.org/6.0/#sec-getprototypefromconstructor + +module.exports = function GetPrototypeFromConstructor(constructor, intrinsicDefaultProto) { + var intrinsic = GetIntrinsic(intrinsicDefaultProto); // throws if not a valid intrinsic + if (!isObject(intrinsic)) { + throw new $TypeError('intrinsicDefaultProto must be an object'); + } + if (!IsConstructor(constructor)) { + throw new $TypeError('Assertion failed: `constructor` must be a constructor'); + } + var proto = Get(constructor, 'prototype'); + if (!isObject(proto)) { + if (!(constructor instanceof $Function)) { + // ignore other realms, for now + throw new $SyntaxError('cross-realm constructors not currently supported'); + } + proto = intrinsic; + } + return proto; +}; diff --git a/node_modules/es-abstract/2019/GetSubstitution.js b/node_modules/es-abstract/2019/GetSubstitution.js new file mode 100644 index 0000000000000000000000000000000000000000..76789559b6e227b489787819e96bd1eb7dd0dc99 --- /dev/null +++ b/node_modules/es-abstract/2019/GetSubstitution.js @@ -0,0 +1,120 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var callBound = require('call-bound'); +var regexTester = require('safe-regex-test'); +var every = require('../helpers/every'); + +var $charAt = callBound('String.prototype.charAt'); +var $strSlice = callBound('String.prototype.slice'); +var $indexOf = callBound('String.prototype.indexOf'); +var $parseInt = parseInt; + +var isDigit = regexTester(/^[0-9]$/); + +var inspect = require('object-inspect'); +var isInteger = require('math-intrinsics/isInteger'); + +var Get = require('./Get'); +var IsArray = require('./IsArray'); +var ToObject = require('./ToObject'); +var ToString = require('./ToString'); + +var isStringOrUndefined = require('../helpers/isStringOrUndefined'); + +// http://262.ecma-international.org/9.0/#sec-getsubstitution + +// eslint-disable-next-line max-statements, max-params, max-lines-per-function +module.exports = function GetSubstitution(matched, str, position, captures, namedCaptures, replacement) { + if (typeof matched !== 'string') { + throw new $TypeError('Assertion failed: `matched` must be a String'); + } + var matchLength = matched.length; + + if (typeof str !== 'string') { + throw new $TypeError('Assertion failed: `str` must be a String'); + } + var stringLength = str.length; + + if (!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)); + } + + if (!IsArray(captures) || !every(captures, isStringOrUndefined)) { + throw new $TypeError('Assertion failed: `captures` must be a List of Strings or `undefined`, got ' + inspect(captures)); + } + + if (typeof replacement !== 'string') { + throw new $TypeError('Assertion failed: `replacement` must be a String'); + } + + var tailPos = position + matchLength; + var m = captures.length; + if (typeof namedCaptures !== 'undefined') { + namedCaptures = 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 = $charAt(replacement, i); + var isLast = (i + 1) >= replacement.length; + var nextIsLast = (i + 2) >= replacement.length; + if (current === '$' && !isLast) { + var next = $charAt(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 : $charAt(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 && typeof 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 && typeof captures[nnI] === 'undefined' ? '' : captures[nnI]; + i += 2; + } else if (next === '<') { + if (typeof namedCaptures === 'undefined') { + result += '$<'; + i += 2; + } else { + var endIndex = $indexOf(replacement, '>', i); + + if (endIndex > -1) { + var groupName = $strSlice(replacement, i + '$<'.length, endIndex); + var capture = Get(namedCaptures, groupName); + + if (typeof capture !== 'undefined') { + result += ToString(capture); + } + i += ('<' + groupName + '>').length; + } + } + } else { + result += '$'; + } + } + } else { + // the final $, or else not a $ + result += $charAt(replacement, i); + } + } + return result; +}; diff --git a/node_modules/es-abstract/2019/GetV.js b/node_modules/es-abstract/2019/GetV.js new file mode 100644 index 0000000000000000000000000000000000000000..920dec3c4a4eac8aa63678c2afa5683e79e3337f --- /dev/null +++ b/node_modules/es-abstract/2019/GetV.js @@ -0,0 +1,23 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var inspect = require('object-inspect'); + +var isPropertyKey = require('../helpers/isPropertyKey'); +// var ToObject = require('./ToObject'); + +// https://262.ecma-international.org/6.0/#sec-getv + +module.exports = function GetV(V, P) { + // 7.3.2.1 + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: P is not a Property Key, got ' + inspect(P)); + } + + // 7.3.2.2-3 + // var O = ToObject(V); + + // 7.3.2.4 + return V[P]; +}; diff --git a/node_modules/es-abstract/2019/GetValueFromBuffer.js b/node_modules/es-abstract/2019/GetValueFromBuffer.js new file mode 100644 index 0000000000000000000000000000000000000000..8d5a8e79b47d8f0b532a4739dc77c770ad716981 --- /dev/null +++ b/node_modules/es-abstract/2019/GetValueFromBuffer.js @@ -0,0 +1,94 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = require('es-errors/type'); +var $Uint8Array = GetIntrinsic('%Uint8Array%', true); +var isInteger = require('math-intrinsics/isInteger'); + +var callBound = require('call-bound'); + +var $slice = callBound('Array.prototype.slice'); + +var IsDetachedBuffer = require('./IsDetachedBuffer'); +var RawBytesToNumber = require('./RawBytesToNumber'); + +var isArrayBuffer = require('is-array-buffer'); +var isSharedArrayBuffer = require('is-shared-array-buffer'); +var safeConcat = require('safe-array-concat'); + +var tableTAO = require('./tables/typed-array-objects'); + +var defaultEndianness = require('../helpers/defaultEndianness'); + +// https://262.ecma-international.org/10.0/#sec-getvaluefrombuffer + +module.exports = function GetValueFromBuffer(arrayBuffer, byteIndex, type, isTypedArray, order) { + var isSAB = isSharedArrayBuffer(arrayBuffer); + if (!isArrayBuffer(arrayBuffer) && !isSAB) { + throw new $TypeError('Assertion failed: `arrayBuffer` must be an ArrayBuffer or a SharedArrayBuffer'); + } + + if (!isInteger(byteIndex)) { + throw new $TypeError('Assertion failed: `byteIndex` must be an integer'); + } + + if (typeof type !== 'string') { + throw new $TypeError('Assertion failed: `type` must be a string'); + } + + if (typeof isTypedArray !== 'boolean') { + throw new $TypeError('Assertion failed: `isTypedArray` must be a boolean'); + } + + if (typeof order !== 'string') { + throw new $TypeError('Assertion failed: `order` must be a string'); + } + + if (arguments.length > 5 && typeof arguments[5] !== 'boolean') { + throw new $TypeError('Assertion failed: `isLittleEndian` must be a boolean, if present'); + } + + if (IsDetachedBuffer(arrayBuffer)) { + throw new $TypeError('Assertion failed: `arrayBuffer` is detached'); // step 1 + } + + // 2. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type. + + if (byteIndex < 0) { + throw new $TypeError('Assertion failed: `byteIndex` must be non-negative'); // step 3 + } + + // 4. Let block be arrayBuffer.[[ArrayBufferData]]. + + var elementSize = tableTAO.size['$' + type]; // step 5 + if (!elementSize) { + throw new $TypeError('Assertion failed: `type` must be one of ' + tableTAO.choices); + } + + var rawValue; + if (isSAB) { // step 6 + /* + a. Let execution be the [[CandidateExecution]] field of the surrounding agent's Agent Record. + b. Let eventList be the [[EventList]] field of the element in execution.[[EventsRecords]] whose [[AgentSignifier]] is AgentSignifier(). + c. If isTypedArray is true and type is "Int8", "Uint8", "Int16", "Uint16", "Int32", or "Uint32", let noTear be true; otherwise let noTear be false. + d. Let rawValue be a List of length elementSize of nondeterministically chosen byte values. + e. NOTE: In implementations, rawValue is the result of a non-atomic or atomic read instruction on the underlying hardware. The nondeterminism is a semantic prescription of the memory model to describe observable behaviour of hardware with weak consistency. + f. Let readEvent be ReadSharedMemory{ [[Order]]: order, [[NoTear]]: noTear, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize }. + g. Append readEvent to eventList. + h. Append Chosen Value Record { [[Event]]: readEvent, [[ChosenValue]]: rawValue } to execution.[[ChosenValues]]. + */ + } else { + // 7. Let rawValue be a List of elementSize containing, in order, the elementSize sequence of bytes starting with block[byteIndex]. + rawValue = $slice(new $Uint8Array(arrayBuffer, byteIndex), 0, elementSize); // step 6 + } + + // 8. If isLittleEndian is not present, set isLittleEndian to either true or false. The choice is implementation dependent and should be the alternative that is most efficient for the implementation. An implementation must use the same value each time this step is executed and the same value must be used for the corresponding step in the SetValueInBuffer abstract operation. + var isLittleEndian = arguments.length > 5 ? arguments[5] : defaultEndianness === 'little'; // step 8 + + var bytes = isLittleEndian + ? $slice(safeConcat([0, 0, 0, 0, 0, 0, 0, 0], rawValue), -elementSize) + : $slice(safeConcat(rawValue, [0, 0, 0, 0, 0, 0, 0, 0]), 0, elementSize); + + return RawBytesToNumber(type, bytes, isLittleEndian); +}; diff --git a/node_modules/es-abstract/2019/HasOwnProperty.js b/node_modules/es-abstract/2019/HasOwnProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..617f0b856e81f2518d2c03bf72b367eea50eb6ef --- /dev/null +++ b/node_modules/es-abstract/2019/HasOwnProperty.js @@ -0,0 +1,20 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var hasOwn = require('hasown'); +var isObject = require('es-object-atoms/isObject'); + +var isPropertyKey = require('../helpers/isPropertyKey'); + +// https://262.ecma-international.org/6.0/#sec-hasownproperty + +module.exports = function HasOwnProperty(O, P) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: `O` must be an Object'); + } + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: `P` must be a Property Key'); + } + return hasOwn(O, P); +}; diff --git a/node_modules/es-abstract/2019/HasProperty.js b/node_modules/es-abstract/2019/HasProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..eb66ca9853ec09c092d87f10333fcdb19a882c83 --- /dev/null +++ b/node_modules/es-abstract/2019/HasProperty.js @@ -0,0 +1,18 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var isPropertyKey = require('../helpers/isPropertyKey'); + +// https://262.ecma-international.org/6.0/#sec-hasproperty + +module.exports = function HasProperty(O, P) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: `O` must be an Object'); + } + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: `P` must be a Property Key'); + } + return P in O; +}; diff --git a/node_modules/es-abstract/2019/HourFromTime.js b/node_modules/es-abstract/2019/HourFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..f963bfb68540ba21f46be00b623cb89db98d63f5 --- /dev/null +++ b/node_modules/es-abstract/2019/HourFromTime.js @@ -0,0 +1,14 @@ +'use strict'; + +var floor = require('./floor'); +var modulo = require('./modulo'); + +var timeConstants = require('../helpers/timeConstants'); +var msPerHour = timeConstants.msPerHour; +var HoursPerDay = timeConstants.HoursPerDay; + +// https://262.ecma-international.org/5.1/#sec-15.9.1.10 + +module.exports = function HourFromTime(t) { + return modulo(floor(t / msPerHour), HoursPerDay); +}; diff --git a/node_modules/es-abstract/2019/InLeapYear.js b/node_modules/es-abstract/2019/InLeapYear.js new file mode 100644 index 0000000000000000000000000000000000000000..4a283a4b6097f4b2c4e872b0cc775024ff517b77 --- /dev/null +++ b/node_modules/es-abstract/2019/InLeapYear.js @@ -0,0 +1,19 @@ +'use strict'; + +var $EvalError = require('es-errors/eval'); + +var DaysInYear = require('./DaysInYear'); +var YearFromTime = require('./YearFromTime'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.3 + +module.exports = function InLeapYear(t) { + var days = DaysInYear(YearFromTime(t)); + if (days === 365) { + return 0; + } + if (days === 366) { + return 1; + } + throw new $EvalError('Assertion failed: there are not 365 or 366 days in a year, got: ' + days); +}; diff --git a/node_modules/es-abstract/2019/InstanceofOperator.js b/node_modules/es-abstract/2019/InstanceofOperator.js new file mode 100644 index 0000000000000000000000000000000000000000..5dd7d04a4c16b423b1613070585b864e22b2dc9e --- /dev/null +++ b/node_modules/es-abstract/2019/InstanceofOperator.js @@ -0,0 +1,30 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var $hasInstance = GetIntrinsic('%Symbol.hasInstance%', true); + +var Call = require('./Call'); +var GetMethod = require('./GetMethod'); +var IsCallable = require('./IsCallable'); +var OrdinaryHasInstance = require('./OrdinaryHasInstance'); +var ToBoolean = require('./ToBoolean'); + +// https://262.ecma-international.org/6.0/#sec-instanceofoperator + +module.exports = function InstanceofOperator(O, C) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + var instOfHandler = $hasInstance ? GetMethod(C, $hasInstance) : void 0; + if (typeof instOfHandler !== 'undefined') { + return ToBoolean(Call(instOfHandler, C, [O])); + } + if (!IsCallable(C)) { + throw new $TypeError('`C` is not Callable'); + } + return OrdinaryHasInstance(C, O); +}; diff --git a/node_modules/es-abstract/2019/IntegerIndexedElementGet.js b/node_modules/es-abstract/2019/IntegerIndexedElementGet.js new file mode 100644 index 0000000000000000000000000000000000000000..b651db950ac5b4edb3e5fa6b5dc55a3823380a40 --- /dev/null +++ b/node_modules/es-abstract/2019/IntegerIndexedElementGet.js @@ -0,0 +1,58 @@ +'use strict'; + +var $SyntaxError = require('es-errors/syntax'); +var $TypeError = require('es-errors/type'); + +var GetValueFromBuffer = require('./GetValueFromBuffer'); +var IsDetachedBuffer = require('./IsDetachedBuffer'); +var IsInteger = require('./IsInteger'); + +var isNegativeZero = require('math-intrinsics/isNegativeZero'); + +var typedArrayLength = require('typed-array-length'); +var typedArrayBuffer = require('typed-array-buffer'); +var typedArrayByteOffset = require('typed-array-byte-offset'); +var whichTypedArray = require('which-typed-array'); + +var tableTAO = require('./tables/typed-array-objects'); + +// https://262.ecma-international.org/8.0/#sec-integerindexedelementget + +module.exports = function IntegerIndexedElementGet(O, index) { + if (typeof index !== 'number') { + throw new $TypeError('`index` must be a Number'); // step 1 + } + var arrayTypeName = whichTypedArray(O); // step 10 + if (!arrayTypeName) { + throw new $TypeError('`O` must be a TypedArray'); // step 2 + } + if (arrayTypeName === 'BigInt64Array' || arrayTypeName === 'BigUint64Array') { + throw new $SyntaxError('BigInt64Array and BigUint64Array do not exist until ES2020'); + } + + var buffer = typedArrayBuffer(O); // step 3 + + if (IsDetachedBuffer(buffer)) { + throw new $TypeError('`O` has a detached buffer'); // step 4 + } + + if (!IsInteger(index) || isNegativeZero(index)) { + return void undefined; // steps 5 - 6 + } + + var length = typedArrayLength(O); // step 7 + + if (index < 0 || index >= length) { + return void undefined; // step 8 + } + + var offset = typedArrayByteOffset(O); // step 9 + + var elementType = tableTAO.name['$' + arrayTypeName]; // step 13 + + var elementSize = tableTAO.size['$' + elementType]; // step 11 + + var indexedPosition = (index * elementSize) + offset; // step 12 + + return GetValueFromBuffer(buffer, indexedPosition, elementType, true, 'Unordered'); // step 14 +}; diff --git a/node_modules/es-abstract/2019/IntegerIndexedElementSet.js b/node_modules/es-abstract/2019/IntegerIndexedElementSet.js new file mode 100644 index 0000000000000000000000000000000000000000..a4405a456bcfd3db0c31ff19d614ac4af461fe1f --- /dev/null +++ b/node_modules/es-abstract/2019/IntegerIndexedElementSet.js @@ -0,0 +1,62 @@ +'use strict'; + +var $SyntaxError = require('es-errors/syntax'); +var $TypeError = require('es-errors/type'); + +var IsDetachedBuffer = require('./IsDetachedBuffer'); +var IsInteger = require('./IsInteger'); +var SetValueInBuffer = require('./SetValueInBuffer'); +var ToNumber = require('./ToNumber'); + +var isNegativeZero = require('math-intrinsics/isNegativeZero'); +var typedArrayBuffer = require('typed-array-buffer'); +var typedArrayByteOffset = require('typed-array-byte-offset'); +var typedArrayLength = require('typed-array-length'); +var whichTypedArray = require('which-typed-array'); + +var tableTAO = require('./tables/typed-array-objects'); + +// https://262.ecma-international.org/8.0/#sec-integerindexedelementset + +module.exports = function IntegerIndexedElementSet(O, index, value) { + if (typeof index !== 'number') { + throw new $TypeError('`index` must be a Number'); // step 1 + } + var arrayTypeName = whichTypedArray(O); // step 12 + if (!arrayTypeName) { + throw new $TypeError('`O` must be a TypedArray'); // step 2 + } + if (arrayTypeName === 'BigInt64Array' || arrayTypeName === 'BigUint64Array') { + throw new $SyntaxError('BigInt64Array and BigUint64Array do not exist until ES2020'); // step 2 + } + + var numValue = ToNumber(value); // step 3 + + var buffer = typedArrayBuffer(O); // step 5 + + if (IsDetachedBuffer(buffer)) { + throw new $TypeError('`O` has a detached buffer'); // step 6 + } + + if (!IsInteger(index) || isNegativeZero(index)) { + return false; // steps 7 - 8 + } + + var length = typedArrayLength(O); // step 9 + + if (index < 0 || index >= length) { + return false; // step 10 + } + + var offset = typedArrayByteOffset(O); // step 11 + + var elementType = tableTAO.name['$' + arrayTypeName]; // step 15 + + var elementSize = tableTAO.size['$' + elementType]; // step 13 + + var indexedPosition = (index * elementSize) + offset; // step 14 + + SetValueInBuffer(buffer, indexedPosition, elementType, numValue, true, 'Unordered'); // step 16 + + return true; // step 17 +}; diff --git a/node_modules/es-abstract/2019/InternalizeJSONProperty.js b/node_modules/es-abstract/2019/InternalizeJSONProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..1043d27d316c71b63c6bfd2ef49a829658957af0 --- /dev/null +++ b/node_modules/es-abstract/2019/InternalizeJSONProperty.js @@ -0,0 +1,68 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var Call = require('./Call'); +var CreateDataProperty = require('./CreateDataProperty'); +var EnumerableOwnPropertyNames = require('./EnumerableOwnPropertyNames'); +var Get = require('./Get'); +var IsArray = require('./IsArray'); +var ToLength = require('./ToLength'); +var ToString = require('./ToString'); + +var forEach = require('../helpers/forEach'); + +// https://262.ecma-international.org/9.0/#sec-internalizejsonproperty + +// note: `reviver` was implicitly closed-over until ES2020, where it becomes a third argument + +module.exports = function InternalizeJSONProperty(holder, name, reviver) { + if (!isObject(holder)) { + throw new $TypeError('Assertion failed: `holder` is not an Object'); + } + if (typeof name !== 'string') { + throw new $TypeError('Assertion failed: `name` is not a String'); + } + if (typeof reviver !== 'function') { + throw new $TypeError('Assertion failed: `reviver` is not a Function'); + } + + var val = Get(holder, name); // step 1 + + if (isObject(val)) { // step 2 + var isArray = IsArray(val); // step 2.a + if (isArray) { // step 2.b + var I = 0; // step 2.b.i + + var len = ToLength(Get(val, 'length')); // step 2.b.ii + + while (I < len) { // step 2.b.iii + var newElement = InternalizeJSONProperty(val, ToString(I), reviver); // step 2.b.iv.1 + + if (typeof newElement === 'undefined') { // step 2.b.iii.2 + delete val[ToString(I)]; // step 2.b.iii.2.a + } else { // step 2.b.iii.3 + CreateDataProperty(val, ToString(I), newElement); // step 2.b.iii.3.a + } + + I += 1; // step 2.b.iii.4 + } + } else { // step 2.c + var keys = EnumerableOwnPropertyNames(val, 'key'); // step 2.c.i + + forEach(keys, function (P) { // step 2.c.ii + // eslint-disable-next-line no-shadow + var newElement = InternalizeJSONProperty(val, P, reviver); // step 2.c.ii.1 + + if (typeof newElement === 'undefined') { // step 2.c.ii.2 + delete val[P]; // step 2.c.ii.2.a + } else { // step 2.c.ii.3 + CreateDataProperty(val, P, newElement); // step 2.c.ii.3.a + } + }); + } + } + + return Call(reviver, holder, [name, val]); // step 3 +}; diff --git a/node_modules/es-abstract/2019/Invoke.js b/node_modules/es-abstract/2019/Invoke.js new file mode 100644 index 0000000000000000000000000000000000000000..57bca8ebc3dcb6172949cb3bef6f134dacabbf4b --- /dev/null +++ b/node_modules/es-abstract/2019/Invoke.js @@ -0,0 +1,22 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var Call = require('./Call'); +var IsArray = require('./IsArray'); +var GetV = require('./GetV'); +var isPropertyKey = require('../helpers/isPropertyKey'); + +// https://262.ecma-international.org/6.0/#sec-invoke + +module.exports = function Invoke(O, P) { + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: P must be a Property Key'); + } + var argumentsList = arguments.length > 2 ? arguments[2] : []; + if (!IsArray(argumentsList)) { + throw new $TypeError('Assertion failed: optional `argumentsList`, if provided, must be a List'); + } + var func = GetV(O, P); + return Call(func, O, argumentsList); +}; diff --git a/node_modules/es-abstract/2019/IsAccessorDescriptor.js b/node_modules/es-abstract/2019/IsAccessorDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..f7bf73afb1c1617b04596a6e2af6d1617857bf1e --- /dev/null +++ b/node_modules/es-abstract/2019/IsAccessorDescriptor.js @@ -0,0 +1,25 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var hasOwn = require('hasown'); + +var isPropertyDescriptor = require('../helpers/records/property-descriptor'); + +// https://262.ecma-international.org/5.1/#sec-8.10.1 + +module.exports = function IsAccessorDescriptor(Desc) { + if (typeof Desc === 'undefined') { + return false; + } + + if (!isPropertyDescriptor(Desc)) { + throw new $TypeError('Assertion failed: `Desc` must be a Property Descriptor'); + } + + if (!hasOwn(Desc, '[[Get]]') && !hasOwn(Desc, '[[Set]]')) { + return false; + } + + return true; +}; diff --git a/node_modules/es-abstract/2019/IsArray.js b/node_modules/es-abstract/2019/IsArray.js new file mode 100644 index 0000000000000000000000000000000000000000..c2c48c1f233c058c691d45d7587f1b58d3de5eb2 --- /dev/null +++ b/node_modules/es-abstract/2019/IsArray.js @@ -0,0 +1,4 @@ +'use strict'; + +// https://262.ecma-international.org/6.0/#sec-isarray +module.exports = require('../helpers/IsArray'); diff --git a/node_modules/es-abstract/2019/IsCallable.js b/node_modules/es-abstract/2019/IsCallable.js new file mode 100644 index 0000000000000000000000000000000000000000..3a69b19267dff33491a84421b667a0d82cba21f9 --- /dev/null +++ b/node_modules/es-abstract/2019/IsCallable.js @@ -0,0 +1,5 @@ +'use strict'; + +// http://262.ecma-international.org/5.1/#sec-9.11 + +module.exports = require('is-callable'); diff --git a/node_modules/es-abstract/2019/IsCompatiblePropertyDescriptor.js b/node_modules/es-abstract/2019/IsCompatiblePropertyDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..8bdaf3eb45d24407a2a416cc5aadab4f4eb1c7da --- /dev/null +++ b/node_modules/es-abstract/2019/IsCompatiblePropertyDescriptor.js @@ -0,0 +1,9 @@ +'use strict'; + +var ValidateAndApplyPropertyDescriptor = require('./ValidateAndApplyPropertyDescriptor'); + +// https://262.ecma-international.org/6.0/#sec-iscompatiblepropertydescriptor + +module.exports = function IsCompatiblePropertyDescriptor(Extensible, Desc, Current) { + return ValidateAndApplyPropertyDescriptor(undefined, undefined, Extensible, Desc, Current); +}; diff --git a/node_modules/es-abstract/2019/IsConcatSpreadable.js b/node_modules/es-abstract/2019/IsConcatSpreadable.js new file mode 100644 index 0000000000000000000000000000000000000000..ace2695309292c91b185505f63da3cc942534bd2 --- /dev/null +++ b/node_modules/es-abstract/2019/IsConcatSpreadable.js @@ -0,0 +1,26 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $isConcatSpreadable = GetIntrinsic('%Symbol.isConcatSpreadable%', true); + +var Get = require('./Get'); +var IsArray = require('./IsArray'); +var ToBoolean = require('./ToBoolean'); + +var isObject = require('es-object-atoms/isObject'); + +// https://262.ecma-international.org/6.0/#sec-isconcatspreadable + +module.exports = function IsConcatSpreadable(O) { + if (!isObject(O)) { + return false; + } + if ($isConcatSpreadable) { + var spreadable = Get(O, $isConcatSpreadable); + if (typeof spreadable !== 'undefined') { + return ToBoolean(spreadable); + } + } + return IsArray(O); +}; diff --git a/node_modules/es-abstract/2019/IsConstructor.js b/node_modules/es-abstract/2019/IsConstructor.js new file mode 100644 index 0000000000000000000000000000000000000000..62ac47f6a3d262927a9b147ee0057dfba9664b24 --- /dev/null +++ b/node_modules/es-abstract/2019/IsConstructor.js @@ -0,0 +1,40 @@ +'use strict'; + +var GetIntrinsic = require('../GetIntrinsic.js'); + +var $construct = GetIntrinsic('%Reflect.construct%', true); + +var DefinePropertyOrThrow = require('./DefinePropertyOrThrow'); +try { + DefinePropertyOrThrow({}, '', { '[[Get]]': function () {} }); +} catch (e) { + // Accessor properties aren't supported + DefinePropertyOrThrow = null; +} + +// https://262.ecma-international.org/6.0/#sec-isconstructor + +if (DefinePropertyOrThrow && $construct) { + var isConstructorMarker = {}; + var badArrayLike = {}; + DefinePropertyOrThrow(badArrayLike, 'length', { + '[[Get]]': function () { + throw isConstructorMarker; + }, + '[[Enumerable]]': true + }); + + module.exports = function IsConstructor(argument) { + try { + // `Reflect.construct` invokes `IsConstructor(target)` before `Get(args, 'length')`: + $construct(argument, badArrayLike); + } catch (err) { + return err === isConstructorMarker; + } + }; +} else { + module.exports = function IsConstructor(argument) { + // unfortunately there's no way to truly check this without try/catch `new argument` in old environments + return typeof argument === 'function' && !!argument.prototype; + }; +} diff --git a/node_modules/es-abstract/2019/IsDataDescriptor.js b/node_modules/es-abstract/2019/IsDataDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..d56bd36d4294369f6486f6dfc5d60dada2cc410a --- /dev/null +++ b/node_modules/es-abstract/2019/IsDataDescriptor.js @@ -0,0 +1,25 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var hasOwn = require('hasown'); + +var isPropertyDescriptor = require('../helpers/records/property-descriptor'); + +// https://262.ecma-international.org/5.1/#sec-8.10.2 + +module.exports = function IsDataDescriptor(Desc) { + if (typeof Desc === 'undefined') { + return false; + } + + if (!isPropertyDescriptor(Desc)) { + throw new $TypeError('Assertion failed: `Desc` must be a Property Descriptor'); + } + + if (!hasOwn(Desc, '[[Value]]') && !hasOwn(Desc, '[[Writable]]')) { + return false; + } + + return true; +}; diff --git a/node_modules/es-abstract/2019/IsDetachedBuffer.js b/node_modules/es-abstract/2019/IsDetachedBuffer.js new file mode 100644 index 0000000000000000000000000000000000000000..71c4f6be8d20b02a92a6721c7ae2833adf21150e --- /dev/null +++ b/node_modules/es-abstract/2019/IsDetachedBuffer.js @@ -0,0 +1,28 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var $byteLength = require('array-buffer-byte-length'); +var availableTypedArrays = require('available-typed-arrays')(); +var callBound = require('call-bound'); +var isArrayBuffer = require('is-array-buffer'); +var isSharedArrayBuffer = require('is-shared-array-buffer'); + +var $sabByteLength = callBound('SharedArrayBuffer.prototype.byteLength', true); + +// https://262.ecma-international.org/8.0/#sec-isdetachedbuffer + +module.exports = function IsDetachedBuffer(arrayBuffer) { + var isSAB = isSharedArrayBuffer(arrayBuffer); + if (!isArrayBuffer(arrayBuffer) && !isSAB) { + throw new $TypeError('Assertion failed: `arrayBuffer` must be an Object with an [[ArrayBufferData]] internal slot'); + } + if ((isSAB ? $sabByteLength : $byteLength)(arrayBuffer) === 0) { + try { + new global[availableTypedArrays[0]](arrayBuffer); // eslint-disable-line no-new + } catch (error) { + return !!error && error.name === 'TypeError'; + } + } + return false; +}; diff --git a/node_modules/es-abstract/2019/IsExtensible.js b/node_modules/es-abstract/2019/IsExtensible.js new file mode 100644 index 0000000000000000000000000000000000000000..aa19b914c2d3dc31c1215e2b203dc3ffbb78746c --- /dev/null +++ b/node_modules/es-abstract/2019/IsExtensible.js @@ -0,0 +1,18 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $preventExtensions = GetIntrinsic('%Object.preventExtensions%', true); +var $isExtensible = GetIntrinsic('%Object.isExtensible%', true); + +var isPrimitive = require('../helpers/isPrimitive'); + +// https://262.ecma-international.org/6.0/#sec-isextensible-o + +module.exports = $preventExtensions + ? function IsExtensible(obj) { + return !isPrimitive(obj) && $isExtensible(obj); + } + : function IsExtensible(obj) { + return !isPrimitive(obj); + }; diff --git a/node_modules/es-abstract/2019/IsGenericDescriptor.js b/node_modules/es-abstract/2019/IsGenericDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..9f6ef045ee44e9eaea4506a234f0e41e0bd1bac9 --- /dev/null +++ b/node_modules/es-abstract/2019/IsGenericDescriptor.js @@ -0,0 +1,26 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var IsAccessorDescriptor = require('./IsAccessorDescriptor'); +var IsDataDescriptor = require('./IsDataDescriptor'); + +var isPropertyDescriptor = require('../helpers/records/property-descriptor'); + +// https://262.ecma-international.org/6.0/#sec-isgenericdescriptor + +module.exports = function IsGenericDescriptor(Desc) { + if (typeof Desc === 'undefined') { + return false; + } + + if (!isPropertyDescriptor(Desc)) { + throw new $TypeError('Assertion failed: `Desc` must be a Property Descriptor'); + } + + if (!IsAccessorDescriptor(Desc) && !IsDataDescriptor(Desc)) { + return true; + } + + return false; +}; diff --git a/node_modules/es-abstract/2019/IsInteger.js b/node_modules/es-abstract/2019/IsInteger.js new file mode 100644 index 0000000000000000000000000000000000000000..9acd7638f5933240e9211a985556ed27df4e82ad --- /dev/null +++ b/node_modules/es-abstract/2019/IsInteger.js @@ -0,0 +1,9 @@ +'use strict'; + +var isInteger = require('math-intrinsics/isInteger'); + +// https://262.ecma-international.org/6.0/#sec-isinteger + +module.exports = function IsInteger(argument) { + return isInteger(argument); +}; diff --git a/node_modules/es-abstract/2019/IsPromise.js b/node_modules/es-abstract/2019/IsPromise.js new file mode 100644 index 0000000000000000000000000000000000000000..f3d67b1c7045d7657ec74a6d084dc088aadb5ff4 --- /dev/null +++ b/node_modules/es-abstract/2019/IsPromise.js @@ -0,0 +1,24 @@ +'use strict'; + +var callBound = require('call-bound'); + +var $PromiseThen = callBound('Promise.prototype.then', true); + +var isObject = require('es-object-atoms/isObject'); + +// https://262.ecma-international.org/6.0/#sec-ispromise + +module.exports = function IsPromise(x) { + if (!isObject(x)) { + return false; + } + if (!$PromiseThen) { // Promises are not supported + return false; + } + try { + $PromiseThen(x); // throws if not a promise + } catch (e) { + return false; + } + return true; +}; diff --git a/node_modules/es-abstract/2019/IsPropertyKey.js b/node_modules/es-abstract/2019/IsPropertyKey.js new file mode 100644 index 0000000000000000000000000000000000000000..4b1c9c71461ca474f34b517c0bc04e5d700280f2 --- /dev/null +++ b/node_modules/es-abstract/2019/IsPropertyKey.js @@ -0,0 +1,9 @@ +'use strict'; + +var isPropertyKey = require('../helpers/isPropertyKey'); + +// https://262.ecma-international.org/6.0/#sec-ispropertykey + +module.exports = function IsPropertyKey(argument) { + return isPropertyKey(argument); +}; diff --git a/node_modules/es-abstract/2019/IsRegExp.js b/node_modules/es-abstract/2019/IsRegExp.js new file mode 100644 index 0000000000000000000000000000000000000000..8855492d58ded3c061b84be35e962fe32c8de53e --- /dev/null +++ b/node_modules/es-abstract/2019/IsRegExp.js @@ -0,0 +1,25 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $match = GetIntrinsic('%Symbol.match%', true); + +var hasRegExpMatcher = require('is-regex'); +var isObject = require('es-object-atoms/isObject'); + +var ToBoolean = require('./ToBoolean'); + +// https://262.ecma-international.org/6.0/#sec-isregexp + +module.exports = function IsRegExp(argument) { + if (!isObject(argument)) { + return false; + } + if ($match) { + var isRegExp = argument[$match]; + if (typeof isRegExp !== 'undefined') { + return ToBoolean(isRegExp); + } + } + return hasRegExpMatcher(argument); +}; diff --git a/node_modules/es-abstract/2019/IsSharedArrayBuffer.js b/node_modules/es-abstract/2019/IsSharedArrayBuffer.js new file mode 100644 index 0000000000000000000000000000000000000000..41d61b116db4b3aabf7dde87e6b46cc5aa378d99 --- /dev/null +++ b/node_modules/es-abstract/2019/IsSharedArrayBuffer.js @@ -0,0 +1,16 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var isSharedArrayBuffer = require('is-shared-array-buffer'); + +// https://262.ecma-international.org/8.0/#sec-issharedarraybuffer + +module.exports = function IsSharedArrayBuffer(obj) { + if (!isObject(obj)) { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + return isSharedArrayBuffer(obj); +}; diff --git a/node_modules/es-abstract/2019/IsStringPrefix.js b/node_modules/es-abstract/2019/IsStringPrefix.js new file mode 100644 index 0000000000000000000000000000000000000000..507f9fc1f397d6382a878d4c1d6d18da2feb21a5 --- /dev/null +++ b/node_modules/es-abstract/2019/IsStringPrefix.js @@ -0,0 +1,43 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var isPrefixOf = require('../helpers/isPrefixOf'); + +// var callBound = require('call-bound'); + +// var $charAt = callBound('String.prototype.charAt'); + +// https://262.ecma-international.org/9.0/#sec-isstringprefix + +module.exports = function IsStringPrefix(p, q) { + if (typeof p !== 'string') { + throw new $TypeError('Assertion failed: "p" must be a String'); + } + + if (typeof q !== 'string') { + throw new $TypeError('Assertion failed: "q" must be a String'); + } + + return isPrefixOf(p, q); + /* + if (p === q || p === '') { + return true; + } + + var pLength = p.length; + var qLength = q.length; + if (pLength >= qLength) { + return false; + } + + // assert: pLength < qLength + + for (var i = 0; i < pLength; i += 1) { + if ($charAt(p, i) !== $charAt(q, i)) { + return false; + } + } + return true; + */ +}; diff --git a/node_modules/es-abstract/2019/IsWordChar.js b/node_modules/es-abstract/2019/IsWordChar.js new file mode 100644 index 0000000000000000000000000000000000000000..df2541d1c3bc13a6c89e01e6cfe04193bdf282f5 --- /dev/null +++ b/node_modules/es-abstract/2019/IsWordChar.js @@ -0,0 +1,45 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var callBound = require('call-bound'); + +var $indexOf = callBound('String.prototype.indexOf'); + +var IsArray = require('./IsArray'); +var IsInteger = require('./IsInteger'); +var WordCharacters = require('./WordCharacters'); + +var every = require('../helpers/every'); + +var isChar = function isChar(c) { + return typeof c === 'string'; +}; + +// https://262.ecma-international.org/8.0/#sec-runtime-semantics-iswordchar-abstract-operation + +// note: prior to ES2023, this AO erroneously omitted the latter of its arguments. +module.exports = function IsWordChar(e, InputLength, Input, IgnoreCase, Unicode) { + if (!IsInteger(e)) { + throw new $TypeError('Assertion failed: `e` must be an integer'); + } + if (!IsInteger(InputLength)) { + throw new $TypeError('Assertion failed: `InputLength` must be an integer'); + } + if (!IsArray(Input) || !every(Input, isChar)) { + throw new $TypeError('Assertion failed: `Input` must be a List of characters'); + } + if (typeof IgnoreCase !== 'boolean' || typeof Unicode !== 'boolean') { + throw new $TypeError('Assertion failed: `IgnoreCase` and `Unicode` must be booleans'); + } + + if (e === -1 || e === InputLength) { + return false; // step 1 + } + + var c = Input[e]; // step 2 + + var wordChars = WordCharacters(IgnoreCase, Unicode); + + return $indexOf(wordChars, c) > -1; // steps 3-4 +}; diff --git a/node_modules/es-abstract/2019/IterableToList.js b/node_modules/es-abstract/2019/IterableToList.js new file mode 100644 index 0000000000000000000000000000000000000000..7cf32c18d72f78e2120a9d81ad1ab5ae1dc9619d --- /dev/null +++ b/node_modules/es-abstract/2019/IterableToList.js @@ -0,0 +1,21 @@ +'use strict'; + +var GetIterator = require('./GetIterator'); +var IteratorStep = require('./IteratorStep'); +var IteratorValue = require('./IteratorValue'); + +// https://262.ecma-international.org/8.0/#sec-iterabletolist + +module.exports = function IterableToList(items, method) { + var iterator = GetIterator(items, method); + var values = []; + var next = true; + while (next) { + next = IteratorStep(iterator); + if (next) { + var nextValue = IteratorValue(next); + values[values.length] = nextValue; + } + } + return values; +}; diff --git a/node_modules/es-abstract/2019/IteratorClose.js b/node_modules/es-abstract/2019/IteratorClose.js new file mode 100644 index 0000000000000000000000000000000000000000..c28373b5df19807503f12da511643f30b72ad786 --- /dev/null +++ b/node_modules/es-abstract/2019/IteratorClose.js @@ -0,0 +1,51 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var Call = require('./Call'); +var CompletionRecord = require('./CompletionRecord'); +var GetMethod = require('./GetMethod'); +var IsCallable = require('./IsCallable'); + +// https://262.ecma-international.org/6.0/#sec-iteratorclose + +module.exports = function IteratorClose(iterator, completion) { + if (!isObject(iterator)) { + throw new $TypeError('Assertion failed: Type(iterator) is not Object'); + } + if (!IsCallable(completion) && !(completion instanceof CompletionRecord)) { + throw new $TypeError('Assertion failed: completion is not a thunk representing a Completion Record, nor a Completion Record instance'); + } + var completionThunk = completion instanceof CompletionRecord ? function () { return completion['?'](); } : completion; + + var iteratorReturn = GetMethod(iterator, 'return'); + + if (typeof iteratorReturn === 'undefined') { + return completionThunk(); + } + + var completionRecord; + try { + var innerResult = Call(iteratorReturn, iterator, []); + } catch (e) { + // if we hit here, then "e" is the innerResult completion that needs re-throwing + + // if the completion is of type "throw", this will throw. + completionThunk(); + // eslint-disable-next-line no-useless-assignment + completionThunk = null; // ensure it's not called twice. + + // if not, then return the innerResult completion + throw e; + } + completionRecord = completionThunk(); // if innerResult worked, then throw if the completion does + // eslint-disable-next-line no-useless-assignment + completionThunk = null; // ensure it's not called twice. + + if (!isObject(innerResult)) { + throw new $TypeError('iterator .return must return an object'); + } + + return completionRecord; +}; diff --git a/node_modules/es-abstract/2019/IteratorComplete.js b/node_modules/es-abstract/2019/IteratorComplete.js new file mode 100644 index 0000000000000000000000000000000000000000..c8a0d67c244bbec3d032bb8a4cc5597b7419d97b --- /dev/null +++ b/node_modules/es-abstract/2019/IteratorComplete.js @@ -0,0 +1,16 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var Get = require('./Get'); +var ToBoolean = require('./ToBoolean'); + +// https://262.ecma-international.org/6.0/#sec-iteratorcomplete + +module.exports = function IteratorComplete(iterResult) { + if (!isObject(iterResult)) { + throw new $TypeError('Assertion failed: Type(iterResult) is not Object'); + } + return ToBoolean(Get(iterResult, 'done')); +}; diff --git a/node_modules/es-abstract/2019/IteratorNext.js b/node_modules/es-abstract/2019/IteratorNext.js new file mode 100644 index 0000000000000000000000000000000000000000..b6bd71c68fca61d152bbf420aa5fdfb2feeab854 --- /dev/null +++ b/node_modules/es-abstract/2019/IteratorNext.js @@ -0,0 +1,16 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var Invoke = require('./Invoke'); + +// https://262.ecma-international.org/6.0/#sec-iteratornext + +module.exports = function IteratorNext(iterator, value) { + var result = Invoke(iterator, 'next', arguments.length < 2 ? [] : [value]); + if (!isObject(result)) { + throw new $TypeError('iterator next must return an object'); + } + return result; +}; diff --git a/node_modules/es-abstract/2019/IteratorStep.js b/node_modules/es-abstract/2019/IteratorStep.js new file mode 100644 index 0000000000000000000000000000000000000000..85bcd95c0410f7efd79ae16b91b0a513d404a64a --- /dev/null +++ b/node_modules/es-abstract/2019/IteratorStep.js @@ -0,0 +1,13 @@ +'use strict'; + +var IteratorComplete = require('./IteratorComplete'); +var IteratorNext = require('./IteratorNext'); + +// https://262.ecma-international.org/6.0/#sec-iteratorstep + +module.exports = function IteratorStep(iterator) { + var result = IteratorNext(iterator); + var done = IteratorComplete(result); + return done === true ? false : result; +}; + diff --git a/node_modules/es-abstract/2019/IteratorValue.js b/node_modules/es-abstract/2019/IteratorValue.js new file mode 100644 index 0000000000000000000000000000000000000000..016ddfbd4f01381dd13487740d6806003449d4b1 --- /dev/null +++ b/node_modules/es-abstract/2019/IteratorValue.js @@ -0,0 +1,16 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var Get = require('./Get'); + +// https://262.ecma-international.org/6.0/#sec-iteratorvalue + +module.exports = function IteratorValue(iterResult) { + if (!isObject(iterResult)) { + throw new $TypeError('Assertion failed: Type(iterResult) is not Object'); + } + return Get(iterResult, 'value'); +}; + diff --git a/node_modules/es-abstract/2019/MakeDate.js b/node_modules/es-abstract/2019/MakeDate.js new file mode 100644 index 0000000000000000000000000000000000000000..3256ae1092afd21a469f4ca086dc028a73ecaa52 --- /dev/null +++ b/node_modules/es-abstract/2019/MakeDate.js @@ -0,0 +1,14 @@ +'use strict'; + +var $isFinite = require('math-intrinsics/isFinite'); + +var msPerDay = require('../helpers/timeConstants').msPerDay; + +// https://262.ecma-international.org/5.1/#sec-15.9.1.13 + +module.exports = function MakeDate(day, time) { + if (!$isFinite(day) || !$isFinite(time)) { + return NaN; + } + return (day * msPerDay) + time; +}; diff --git a/node_modules/es-abstract/2019/MakeDay.js b/node_modules/es-abstract/2019/MakeDay.js new file mode 100644 index 0000000000000000000000000000000000000000..d03d683855826fe3e3889b737b06a08c34ff4442 --- /dev/null +++ b/node_modules/es-abstract/2019/MakeDay.js @@ -0,0 +1,33 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $DateUTC = GetIntrinsic('%Date.UTC%'); + +var $isFinite = require('math-intrinsics/isFinite'); + +var DateFromTime = require('./DateFromTime'); +var Day = require('./Day'); +var floor = require('./floor'); +var modulo = require('./modulo'); +var MonthFromTime = require('./MonthFromTime'); +var ToInteger = require('./ToInteger'); +var YearFromTime = require('./YearFromTime'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.12 + +module.exports = function MakeDay(year, month, date) { + if (!$isFinite(year) || !$isFinite(month) || !$isFinite(date)) { + return NaN; + } + var y = ToInteger(year); + var m = ToInteger(month); + var dt = ToInteger(date); + var ym = y + floor(m / 12); + var mn = modulo(m, 12); + var t = $DateUTC(ym, mn, 1); + if (YearFromTime(t) !== ym || MonthFromTime(t) !== mn || DateFromTime(t) !== 1) { + return NaN; + } + return Day(t) + dt - 1; +}; diff --git a/node_modules/es-abstract/2019/MakeTime.js b/node_modules/es-abstract/2019/MakeTime.js new file mode 100644 index 0000000000000000000000000000000000000000..94096d6d4ec8833fa6df121cdef28a8da19c150a --- /dev/null +++ b/node_modules/es-abstract/2019/MakeTime.js @@ -0,0 +1,24 @@ +'use strict'; + +var $isFinite = require('math-intrinsics/isFinite'); + +var timeConstants = require('../helpers/timeConstants'); +var msPerSecond = timeConstants.msPerSecond; +var msPerMinute = timeConstants.msPerMinute; +var msPerHour = timeConstants.msPerHour; + +var ToInteger = require('./ToInteger'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.11 + +module.exports = function MakeTime(hour, min, sec, ms) { + if (!$isFinite(hour) || !$isFinite(min) || !$isFinite(sec) || !$isFinite(ms)) { + return NaN; + } + var h = ToInteger(hour); + var m = ToInteger(min); + var s = ToInteger(sec); + var milli = ToInteger(ms); + var t = (h * msPerHour) + (m * msPerMinute) + (s * msPerSecond) + milli; + return t; +}; diff --git a/node_modules/es-abstract/2019/MinFromTime.js b/node_modules/es-abstract/2019/MinFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..a0c631d4cc56cb21e15712def6008d5623edd0f9 --- /dev/null +++ b/node_modules/es-abstract/2019/MinFromTime.js @@ -0,0 +1,14 @@ +'use strict'; + +var floor = require('./floor'); +var modulo = require('./modulo'); + +var timeConstants = require('../helpers/timeConstants'); +var msPerMinute = timeConstants.msPerMinute; +var MinutesPerHour = timeConstants.MinutesPerHour; + +// https://262.ecma-international.org/5.1/#sec-15.9.1.10 + +module.exports = function MinFromTime(t) { + return modulo(floor(t / msPerMinute), MinutesPerHour); +}; diff --git a/node_modules/es-abstract/2019/MonthFromTime.js b/node_modules/es-abstract/2019/MonthFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..e551ee2be6da5cc49c7da94be78095c0803c53d9 --- /dev/null +++ b/node_modules/es-abstract/2019/MonthFromTime.js @@ -0,0 +1,51 @@ +'use strict'; + +var $RangeError = require('es-errors/range'); + +var DayWithinYear = require('./DayWithinYear'); +var InLeapYear = require('./InLeapYear'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.4 + +module.exports = function MonthFromTime(t) { + var day = DayWithinYear(t); + if (0 <= day && day < 31) { + return 0; + } + var leap = InLeapYear(t); + if (31 <= day && day < (59 + leap)) { + return 1; + } + if ((59 + leap) <= day && day < (90 + leap)) { + return 2; + } + if ((90 + leap) <= day && day < (120 + leap)) { + return 3; + } + if ((120 + leap) <= day && day < (151 + leap)) { + return 4; + } + if ((151 + leap) <= day && day < (181 + leap)) { + return 5; + } + if ((181 + leap) <= day && day < (212 + leap)) { + return 6; + } + if ((212 + leap) <= day && day < (243 + leap)) { + return 7; + } + if ((243 + leap) <= day && day < (273 + leap)) { + return 8; + } + if ((273 + leap) <= day && day < (304 + leap)) { + return 9; + } + if ((304 + leap) <= day && day < (334 + leap)) { + return 10; + } + if ((334 + leap) <= day && day < (365 + leap)) { + return 11; + } + + throw new $RangeError('Assertion failed: `day` is out of range'); +}; diff --git a/node_modules/es-abstract/2019/NewPromiseCapability.js b/node_modules/es-abstract/2019/NewPromiseCapability.js new file mode 100644 index 0000000000000000000000000000000000000000..893266fe9f8da7b032d6fc835750a07c30086179 --- /dev/null +++ b/node_modules/es-abstract/2019/NewPromiseCapability.js @@ -0,0 +1,34 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var IsCallable = require('./IsCallable'); +var IsConstructor = require('./IsConstructor'); + +// https://262.ecma-international.org/6.0/#sec-newpromisecapability + +module.exports = function NewPromiseCapability(C) { + if (!IsConstructor(C)) { + throw new $TypeError('C must be a constructor'); // step 1 + } + + var resolvingFunctions = { '[[Resolve]]': void undefined, '[[Reject]]': void undefined }; // step 3 + + var promise = new C(function (resolve, reject) { // steps 4-5 + if (typeof resolvingFunctions['[[Resolve]]'] !== 'undefined' || typeof resolvingFunctions['[[Reject]]'] !== 'undefined') { + throw new $TypeError('executor has already been called'); // step 4.a, 4.b + } + resolvingFunctions['[[Resolve]]'] = resolve; // step 4.c + resolvingFunctions['[[Reject]]'] = reject; // step 4.d + }); // step 4-6 + + if (!IsCallable(resolvingFunctions['[[Resolve]]']) || !IsCallable(resolvingFunctions['[[Reject]]'])) { + throw new $TypeError('executor must provide valid resolve and reject functions'); // steps 7-8 + } + + return { + '[[Promise]]': promise, + '[[Resolve]]': resolvingFunctions['[[Resolve]]'], + '[[Reject]]': resolvingFunctions['[[Reject]]'] + }; // step 9 +}; diff --git a/node_modules/es-abstract/2019/NormalCompletion.js b/node_modules/es-abstract/2019/NormalCompletion.js new file mode 100644 index 0000000000000000000000000000000000000000..1e429dd65cfaded0bd09155819605198a45c628d --- /dev/null +++ b/node_modules/es-abstract/2019/NormalCompletion.js @@ -0,0 +1,9 @@ +'use strict'; + +var CompletionRecord = require('./CompletionRecord'); + +// https://262.ecma-international.org/6.0/#sec-normalcompletion + +module.exports = function NormalCompletion(value) { + return new CompletionRecord('normal', value); +}; diff --git a/node_modules/es-abstract/2019/NumberToRawBytes.js b/node_modules/es-abstract/2019/NumberToRawBytes.js new file mode 100644 index 0000000000000000000000000000000000000000..6b9a303337bf679a5d2c24b22daae687e6644cd7 --- /dev/null +++ b/node_modules/es-abstract/2019/NumberToRawBytes.js @@ -0,0 +1,59 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var hasOwnProperty = require('./HasOwnProperty'); +var ToInt16 = require('./ToInt16'); +var ToInt32 = require('./ToInt32'); +var ToInt8 = require('./ToInt8'); +var ToUint16 = require('./ToUint16'); +var ToUint32 = require('./ToUint32'); +var ToUint8 = require('./ToUint8'); +var ToUint8Clamp = require('./ToUint8Clamp'); + +var valueToFloat32Bytes = require('../helpers/valueToFloat32Bytes'); +var valueToFloat64Bytes = require('../helpers/valueToFloat64Bytes'); +var integerToNBytes = require('../helpers/integerToNBytes'); + +var tableTAO = require('./tables/typed-array-objects'); + +// https://262.ecma-international.org/8.0/#table-50 + +var TypeToAO = { + __proto__: null, + $Int8: ToInt8, + $Uint8: ToUint8, + $Uint8C: ToUint8Clamp, + $Int16: ToInt16, + $Uint16: ToUint16, + $Int32: ToInt32, + $Uint32: ToUint32 +}; + +// https://262.ecma-international.org/8.0/#sec-numbertorawbytes + +module.exports = function NumberToRawBytes(type, value, isLittleEndian) { + if (typeof type !== 'string' || !hasOwnProperty(tableTAO.size, '$' + type)) { + throw new $TypeError('Assertion failed: `type` must be a TypedArray element type'); + } + if (typeof value !== 'number') { + throw new $TypeError('Assertion failed: `value` must be a Number'); + } + if (typeof isLittleEndian !== 'boolean') { + throw new $TypeError('Assertion failed: `isLittleEndian` must be a Boolean'); + } + + if (type === 'Float32') { // step 1 + return valueToFloat32Bytes(value, isLittleEndian); + } else if (type === 'Float64') { // step 2 + return valueToFloat64Bytes(value, isLittleEndian); + } // step 3 + + var n = tableTAO.size['$' + type]; // step 3.a + + var convOp = TypeToAO['$' + type]; // step 3.b + + var intValue = convOp(value); // step 3.c + + return integerToNBytes(intValue, n, isLittleEndian); // step 3.d, 3.e, 4 +}; diff --git a/node_modules/es-abstract/2019/NumberToString.js b/node_modules/es-abstract/2019/NumberToString.js new file mode 100644 index 0000000000000000000000000000000000000000..a932d00029cd0b10c30f05e492805919b8cfad24 --- /dev/null +++ b/node_modules/es-abstract/2019/NumberToString.js @@ -0,0 +1,17 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $String = GetIntrinsic('%String%'); +var $TypeError = require('es-errors/type'); + +// https://262.ecma-international.org/9.0/#sec-tostring-applied-to-the-number-type + +module.exports = function NumberToString(m) { + if (typeof m !== 'number') { + throw new $TypeError('Assertion failed: "m" must be a String'); + } + + return $String(m); +}; + diff --git a/node_modules/es-abstract/2019/ObjectCreate.js b/node_modules/es-abstract/2019/ObjectCreate.js new file mode 100644 index 0000000000000000000000000000000000000000..c2ef47578051e1b9f051c3daef6a9e0e88055032 --- /dev/null +++ b/node_modules/es-abstract/2019/ObjectCreate.js @@ -0,0 +1,50 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $ObjectCreate = GetIntrinsic('%Object.create%', true); +var $TypeError = require('es-errors/type'); +var $SyntaxError = require('es-errors/syntax'); +var isObject = require('es-object-atoms/isObject'); + +var IsArray = require('./IsArray'); + +var forEach = require('../helpers/forEach'); + +var SLOT = require('internal-slot'); + +var hasProto = require('has-proto')(); + +// https://262.ecma-international.org/6.0/#sec-objectcreate + +module.exports = function ObjectCreate(proto, internalSlotsList) { + if (proto !== null && !isObject(proto)) { + throw new $TypeError('Assertion failed: `proto` must be null or an object'); + } + var slots = arguments.length < 2 ? [] : internalSlotsList; // step 1 + if (arguments.length >= 2 && !IsArray(slots)) { + throw new $TypeError('Assertion failed: `internalSlotsList` must be an Array'); + } + + var O; + if (hasProto) { + O = { __proto__: proto }; + } else if ($ObjectCreate) { + O = $ObjectCreate(proto); + } else { + if (proto === null) { + throw new $SyntaxError('native Object.create support is required to create null objects'); + } + var T = function T() {}; + T.prototype = proto; + O = new T(); + } + + if (slots.length > 0) { + forEach(slots, function (slot) { + SLOT.set(O, slot, void undefined); + }); + } + + return O; // step 6 +}; diff --git a/node_modules/es-abstract/2019/ObjectDefineProperties.js b/node_modules/es-abstract/2019/ObjectDefineProperties.js new file mode 100644 index 0000000000000000000000000000000000000000..0d41322bcc146b95dea2f81dbb533ed69495414a --- /dev/null +++ b/node_modules/es-abstract/2019/ObjectDefineProperties.js @@ -0,0 +1,37 @@ +'use strict'; + +var DefinePropertyOrThrow = require('./DefinePropertyOrThrow'); +var Get = require('./Get'); +var OrdinaryGetOwnProperty = require('./OrdinaryGetOwnProperty'); +var ToObject = require('./ToObject'); +var ToPropertyDescriptor = require('./ToPropertyDescriptor'); + +var forEach = require('../helpers/forEach'); +var OwnPropertyKeys = require('own-keys'); + +// https://262.ecma-international.org/6.0/#sec-objectdefineproperties + +/** @type { = {}>(O: T, Properties: object) => T} */ +module.exports = function ObjectDefineProperties(O, Properties) { + var props = ToObject(Properties); // step 1 + var keys = OwnPropertyKeys(props); // step 2 + /** @type {[string | symbol, import('../types').Descriptor][]} */ + var descriptors = []; // step 3 + + forEach(keys, function (nextKey) { // step 4 + var propDesc = OrdinaryGetOwnProperty(props, nextKey); // ToPropertyDescriptor(getOwnPropertyDescriptor(props, nextKey)); // step 4.a + if (typeof propDesc !== 'undefined' && propDesc['[[Enumerable]]']) { // step 4.b + var descObj = Get(props, nextKey); // step 4.b.i + var desc = ToPropertyDescriptor(descObj); // step 4.b.ii + descriptors[descriptors.length] = [nextKey, desc]; // step 4.b.iii + } + }); + + forEach(descriptors, function (pair) { // step 5 + var P = pair[0]; // step 5.a + var desc = pair[1]; // step 5.b + DefinePropertyOrThrow(O, P, desc); // step 5.c + }); + + return O; // step 6 +}; diff --git a/node_modules/es-abstract/2019/OrdinaryCreateFromConstructor.js b/node_modules/es-abstract/2019/OrdinaryCreateFromConstructor.js new file mode 100644 index 0000000000000000000000000000000000000000..f84b410439c2e3534ec9b5fa619766962cd4264a --- /dev/null +++ b/node_modules/es-abstract/2019/OrdinaryCreateFromConstructor.js @@ -0,0 +1,20 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); +var $TypeError = require('es-errors/type'); + +var GetPrototypeFromConstructor = require('./GetPrototypeFromConstructor'); +var IsArray = require('./IsArray'); +var ObjectCreate = require('./ObjectCreate'); + +// https://262.ecma-international.org/6.0/#sec-ordinarycreatefromconstructor + +module.exports = function OrdinaryCreateFromConstructor(constructor, intrinsicDefaultProto) { + GetIntrinsic(intrinsicDefaultProto); // throws if not a valid intrinsic + var proto = GetPrototypeFromConstructor(constructor, intrinsicDefaultProto); + var slots = arguments.length < 3 ? [] : arguments[2]; + if (!IsArray(slots)) { + throw new $TypeError('Assertion failed: if provided, `internalSlotsList` must be a List'); + } + return ObjectCreate(proto, slots); +}; diff --git a/node_modules/es-abstract/2019/OrdinaryDefineOwnProperty.js b/node_modules/es-abstract/2019/OrdinaryDefineOwnProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..1a61488c6311f778620cdccb377e0b377040b055 --- /dev/null +++ b/node_modules/es-abstract/2019/OrdinaryDefineOwnProperty.js @@ -0,0 +1,54 @@ +'use strict'; + +var $gOPD = require('gopd'); +var $SyntaxError = require('es-errors/syntax'); +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var isPropertyDescriptor = require('../helpers/records/property-descriptor'); + +var IsAccessorDescriptor = require('./IsAccessorDescriptor'); +var IsExtensible = require('./IsExtensible'); +var isPropertyKey = require('../helpers/isPropertyKey'); +var ToPropertyDescriptor = require('./ToPropertyDescriptor'); +var SameValue = require('./SameValue'); +var ValidateAndApplyPropertyDescriptor = require('./ValidateAndApplyPropertyDescriptor'); + +// https://262.ecma-international.org/6.0/#sec-ordinarydefineownproperty + +module.exports = function OrdinaryDefineOwnProperty(O, P, Desc) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: O must be an Object'); + } + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: P must be a Property Key'); + } + if (!isPropertyDescriptor(Desc)) { + throw new $TypeError('Assertion failed: Desc must be a Property Descriptor'); + } + if (!$gOPD) { + // ES3/IE 8 fallback + if (IsAccessorDescriptor(Desc)) { + throw new $SyntaxError('This environment does not support accessor property descriptors.'); + } + var creatingNormalDataProperty = !(P in O) + && Desc['[[Writable]]'] + && Desc['[[Enumerable]]'] + && Desc['[[Configurable]]'] + && '[[Value]]' in Desc; + var settingExistingDataProperty = (P in O) + && (!('[[Configurable]]' in Desc) || Desc['[[Configurable]]']) + && (!('[[Enumerable]]' in Desc) || Desc['[[Enumerable]]']) + && (!('[[Writable]]' in Desc) || Desc['[[Writable]]']) + && '[[Value]]' in Desc; + if (creatingNormalDataProperty || settingExistingDataProperty) { + O[P] = Desc['[[Value]]']; // eslint-disable-line no-param-reassign + return SameValue(O[P], Desc['[[Value]]']); + } + throw new $SyntaxError('This environment does not support defining non-writable, non-enumerable, or non-configurable properties'); + } + var desc = $gOPD(O, P); + var current = desc && ToPropertyDescriptor(desc); + var extensible = IsExtensible(O); + return ValidateAndApplyPropertyDescriptor(O, P, extensible, Desc, current); +}; diff --git a/node_modules/es-abstract/2019/OrdinaryGetOwnProperty.js b/node_modules/es-abstract/2019/OrdinaryGetOwnProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..fdf6cc0cad72a7d2af37ee6eb9db36cffde6b822 --- /dev/null +++ b/node_modules/es-abstract/2019/OrdinaryGetOwnProperty.js @@ -0,0 +1,40 @@ +'use strict'; + +var $gOPD = require('gopd'); +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); +var hasOwn = require('hasown'); +var callBound = require('call-bound'); + +var $isEnumerable = callBound('Object.prototype.propertyIsEnumerable'); + +var IsArray = require('./IsArray'); +var isPropertyKey = require('../helpers/isPropertyKey'); +var IsRegExp = require('./IsRegExp'); +var ToPropertyDescriptor = require('./ToPropertyDescriptor'); + +// https://262.ecma-international.org/6.0/#sec-ordinarygetownproperty + +module.exports = function OrdinaryGetOwnProperty(O, P) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: O must be an Object'); + } + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: P must be a Property Key'); + } + if (!hasOwn(O, P)) { + return void 0; + } + if (!$gOPD) { + // ES3 / IE 8 fallback + var arrayLength = IsArray(O) && P === 'length'; + var regexLastIndex = IsRegExp(O) && P === 'lastIndex'; + return { + '[[Configurable]]': !(arrayLength || regexLastIndex), + '[[Enumerable]]': $isEnumerable(O, P), + '[[Value]]': O[P], + '[[Writable]]': true + }; + } + return ToPropertyDescriptor($gOPD(O, P)); +}; diff --git a/node_modules/es-abstract/2019/OrdinaryGetPrototypeOf.js b/node_modules/es-abstract/2019/OrdinaryGetPrototypeOf.js new file mode 100644 index 0000000000000000000000000000000000000000..7ef8bee34617c4ecaa2bd4b55cf1eb6a6665fe50 --- /dev/null +++ b/node_modules/es-abstract/2019/OrdinaryGetPrototypeOf.js @@ -0,0 +1,18 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var $getProto = require('get-proto'); + +// https://262.ecma-international.org/7.0/#sec-ordinarygetprototypeof + +module.exports = function OrdinaryGetPrototypeOf(O) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: O must be an Object'); + } + if (!$getProto) { + throw new $TypeError('This environment does not support fetching prototypes.'); + } + return $getProto(O); +}; diff --git a/node_modules/es-abstract/2019/OrdinaryHasInstance.js b/node_modules/es-abstract/2019/OrdinaryHasInstance.js new file mode 100644 index 0000000000000000000000000000000000000000..a0a83e6733a49e898d0f9db5df20a54028ad69e3 --- /dev/null +++ b/node_modules/es-abstract/2019/OrdinaryHasInstance.js @@ -0,0 +1,23 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var Get = require('./Get'); +var IsCallable = require('./IsCallable'); + +// https://262.ecma-international.org/6.0/#sec-ordinaryhasinstance + +module.exports = function OrdinaryHasInstance(C, O) { + if (!IsCallable(C)) { + return false; + } + if (!isObject(O)) { + return false; + } + var P = Get(C, 'prototype'); + if (!isObject(P)) { + throw new $TypeError('OrdinaryHasInstance called on an object with an invalid prototype property.'); + } + return O instanceof C; +}; diff --git a/node_modules/es-abstract/2019/OrdinaryHasProperty.js b/node_modules/es-abstract/2019/OrdinaryHasProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..c6c5c11961374a2c3c4beb751aca52a9973093d6 --- /dev/null +++ b/node_modules/es-abstract/2019/OrdinaryHasProperty.js @@ -0,0 +1,18 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var isPropertyKey = require('../helpers/isPropertyKey'); + +// https://262.ecma-international.org/6.0/#sec-ordinaryhasproperty + +module.exports = function OrdinaryHasProperty(O, P) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: P must be a Property Key'); + } + return P in O; +}; diff --git a/node_modules/es-abstract/2019/OrdinarySetPrototypeOf.js b/node_modules/es-abstract/2019/OrdinarySetPrototypeOf.js new file mode 100644 index 0000000000000000000000000000000000000000..b493a442ddd22b125fde2ed40eeebddf2d080a2d --- /dev/null +++ b/node_modules/es-abstract/2019/OrdinarySetPrototypeOf.js @@ -0,0 +1,50 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var $setProto = require('set-proto'); +var isObject = require('es-object-atoms/isObject'); + +var OrdinaryGetPrototypeOf = require('./OrdinaryGetPrototypeOf'); + +// https://262.ecma-international.org/7.0/#sec-ordinarysetprototypeof + +module.exports = function OrdinarySetPrototypeOf(O, V) { + if (V !== null && !isObject(V)) { + throw new $TypeError('Assertion failed: V must be Object or Null'); + } + /* + var extensible = IsExtensible(O); + var current = OrdinaryGetPrototypeOf(O); + if (SameValue(V, current)) { + return true; + } + if (!extensible) { + return false; + } + */ + try { + $setProto(O, V); + } catch (e) { + return false; + } + return OrdinaryGetPrototypeOf(O) === V; + /* + var p = V; + var done = false; + while (!done) { + if (p === null) { + done = true; + } else if (SameValue(p, O)) { + return false; + } else { + if (wat) { + done = true; + } else { + p = p.[[Prototype]]; + } + } + } + O.[[Prototype]] = V; + return true; + */ +}; diff --git a/node_modules/es-abstract/2019/OrdinaryToPrimitive.js b/node_modules/es-abstract/2019/OrdinaryToPrimitive.js new file mode 100644 index 0000000000000000000000000000000000000000..5feb5694e8aba94591eac365aa6bd8a6b985f305 --- /dev/null +++ b/node_modules/es-abstract/2019/OrdinaryToPrimitive.js @@ -0,0 +1,36 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var Call = require('./Call'); +var Get = require('./Get'); +var IsCallable = require('./IsCallable'); + +var inspect = require('object-inspect'); + +// https://262.ecma-international.org/8.0/#sec-ordinarytoprimitive + +module.exports = function OrdinaryToPrimitive(O, hint) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + if (/* typeof hint !== 'string' || */ hint !== 'string' && hint !== 'number') { + throw new $TypeError('Assertion failed: `hint` must be "string" or "number"'); + } + + var methodNames = hint === 'string' ? ['toString', 'valueOf'] : ['valueOf', 'toString']; + + for (var i = 0; i < methodNames.length; i += 1) { + var name = methodNames[i]; + var method = Get(O, name); + if (IsCallable(method)) { + var result = Call(method, O); + if (!isObject(result)) { + return result; + } + } + } + + throw new $TypeError('No primitive value for ' + inspect(O)); +}; diff --git a/node_modules/es-abstract/2019/PromiseResolve.js b/node_modules/es-abstract/2019/PromiseResolve.js new file mode 100644 index 0000000000000000000000000000000000000000..dfb7d82fd2e9a378da3188a73ff006a06ce14463 --- /dev/null +++ b/node_modules/es-abstract/2019/PromiseResolve.js @@ -0,0 +1,18 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); +var callBind = require('call-bind'); +var $SyntaxError = require('es-errors/syntax'); + +var $resolve = GetIntrinsic('%Promise.resolve%', true); +var $PromiseResolve = $resolve && callBind($resolve); + +// https://262.ecma-international.org/9.0/#sec-promise-resolve + +module.exports = function PromiseResolve(C, x) { + if (!$PromiseResolve) { + throw new $SyntaxError('This environment does not support Promises.'); + } + return $PromiseResolve(C, x); +}; + diff --git a/node_modules/es-abstract/2019/QuoteJSONString.js b/node_modules/es-abstract/2019/QuoteJSONString.js new file mode 100644 index 0000000000000000000000000000000000000000..9fedfaa93aac071f0ae7be1bc1575e8c3e1274c8 --- /dev/null +++ b/node_modules/es-abstract/2019/QuoteJSONString.js @@ -0,0 +1,51 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var callBound = require('call-bound'); +var forEach = require('../helpers/forEach'); +var isLeadingSurrogate = require('../helpers/isLeadingSurrogate'); +var isTrailingSurrogate = require('../helpers/isTrailingSurrogate'); + +var $charCodeAt = callBound('String.prototype.charCodeAt'); +var $strSplit = callBound('String.prototype.split'); + +var UnicodeEscape = require('./UnicodeEscape'); +var UTF16Encoding = require('./UTF16Encoding'); + +var hasOwn = require('hasown'); + +// https://262.ecma-international.org/10.0/#sec-quotejsonstring + +var escapes = { + '\u0008': '\\b', + '\u0009': '\\t', + '\u000A': '\\n', + '\u000C': '\\f', + '\u000D': '\\r', + '\u0022': '\\"', + '\u005c': '\\\\' +}; + +module.exports = function QuoteJSONString(value) { + if (typeof value !== 'string') { + throw new $TypeError('Assertion failed: `value` must be a String'); + } + var product = '"'; + if (value) { + forEach($strSplit(value, ''), function (C) { + if (hasOwn(escapes, C)) { + product += escapes[C]; + } else { + var cCharCode = $charCodeAt(C, 0); + if (cCharCode < 0x20 || isLeadingSurrogate(cCharCode) || isTrailingSurrogate(cCharCode)) { + product += UnicodeEscape(C); + } else { + product += UTF16Encoding(cCharCode); + } + } + }); + } + product += '"'; + return product; +}; diff --git a/node_modules/es-abstract/2019/RawBytesToNumber.js b/node_modules/es-abstract/2019/RawBytesToNumber.js new file mode 100644 index 0000000000000000000000000000000000000000..db0a1e9c9c19ecbdf4b27973f6a0e84fb60ad729 --- /dev/null +++ b/node_modules/es-abstract/2019/RawBytesToNumber.js @@ -0,0 +1,58 @@ +'use strict'; + +var callBound = require('call-bound'); + +var $RangeError = require('es-errors/range'); +var $TypeError = require('es-errors/type'); + +var $charAt = callBound('String.prototype.charAt'); +var $reverse = callBound('Array.prototype.reverse'); +var $slice = callBound('Array.prototype.slice'); + +var hasOwnProperty = require('./HasOwnProperty'); +var IsArray = require('./IsArray'); + +var bytesAsFloat32 = require('../helpers/bytesAsFloat32'); +var bytesAsFloat64 = require('../helpers/bytesAsFloat64'); +var bytesAsInteger = require('../helpers/bytesAsInteger'); +var every = require('../helpers/every'); +var isByteValue = require('../helpers/isByteValue'); + +var tableTAO = require('./tables/typed-array-objects'); + +// https://262.ecma-international.org/8.0/#sec-rawbytestonumber + +module.exports = function RawBytesToNumber(type, rawBytes, isLittleEndian) { + if (typeof type !== 'string' || !hasOwnProperty(tableTAO.size, '$' + type)) { + throw new $TypeError('Assertion failed: `type` must be a TypedArray element type'); + } + if (!IsArray(rawBytes) || !every(rawBytes, isByteValue)) { + throw new $TypeError('Assertion failed: `rawBytes` must be an Array of bytes'); + } + if (typeof isLittleEndian !== 'boolean') { + throw new $TypeError('Assertion failed: `isLittleEndian` must be a Boolean'); + } + + var elementSize = tableTAO.size['$' + type]; // step 1 + + if (rawBytes.length !== elementSize) { + // this assertion is not in the spec, but it'd be an editorial error if it were ever violated + throw new $RangeError('Assertion failed: `rawBytes` must have a length of ' + elementSize + ' for type ' + type); + } + + // eslint-disable-next-line no-param-reassign + rawBytes = $slice(rawBytes, 0, elementSize); + if (!isLittleEndian) { + $reverse(rawBytes); // step 2 + } + + if (type === 'Float32') { // step 3 + return bytesAsFloat32(rawBytes); + } + + if (type === 'Float64') { // step 4 + return bytesAsFloat64(rawBytes); + } + + return bytesAsInteger(rawBytes, elementSize, $charAt(type, 0) === 'U', false); +}; diff --git a/node_modules/es-abstract/2019/RegExpCreate.js b/node_modules/es-abstract/2019/RegExpCreate.js new file mode 100644 index 0000000000000000000000000000000000000000..68e31605ed1764b9e1addddc5b910e9c9d73fba2 --- /dev/null +++ b/node_modules/es-abstract/2019/RegExpCreate.js @@ -0,0 +1,21 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $RegExp = GetIntrinsic('%RegExp%'); + +// var RegExpAlloc = require('./RegExpAlloc'); +// var RegExpInitialize = require('./RegExpInitialize'); +var ToString = require('./ToString'); + +// https://262.ecma-international.org/6.0/#sec-regexpcreate + +module.exports = function RegExpCreate(P, F) { + // var obj = RegExpAlloc($RegExp); + // return RegExpInitialize(obj, P, F); + + // covers spec mechanics; bypass regex brand checking + var pattern = typeof P === 'undefined' ? '' : ToString(P); + var flags = typeof F === 'undefined' ? '' : ToString(F); + return new $RegExp(pattern, flags); +}; diff --git a/node_modules/es-abstract/2019/RegExpExec.js b/node_modules/es-abstract/2019/RegExpExec.js new file mode 100644 index 0000000000000000000000000000000000000000..15762b8343aa380c2c90257eef552a87c56745ae --- /dev/null +++ b/node_modules/es-abstract/2019/RegExpExec.js @@ -0,0 +1,29 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); +var regexExec = require('call-bound')('RegExp.prototype.exec'); + +var Call = require('./Call'); +var Get = require('./Get'); +var IsCallable = require('./IsCallable'); + +// https://262.ecma-international.org/6.0/#sec-regexpexec + +module.exports = function RegExpExec(R, S) { + if (!isObject(R)) { + throw new $TypeError('Assertion failed: `R` must be an Object'); + } + if (typeof S !== 'string') { + throw new $TypeError('Assertion failed: `S` must be a String'); + } + var exec = Get(R, 'exec'); + if (IsCallable(exec)) { + var result = Call(exec, R, [S]); + if (result === null || isObject(result)) { + return result; + } + throw new $TypeError('"exec" method must return `null` or an Object'); + } + return regexExec(R, S); +}; diff --git a/node_modules/es-abstract/2019/RequireObjectCoercible.js b/node_modules/es-abstract/2019/RequireObjectCoercible.js new file mode 100644 index 0000000000000000000000000000000000000000..b816d1f34b01a80352e783672836a17c49cc06f0 --- /dev/null +++ b/node_modules/es-abstract/2019/RequireObjectCoercible.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('es-object-atoms/RequireObjectCoercible'); diff --git a/node_modules/es-abstract/2019/SameValue.js b/node_modules/es-abstract/2019/SameValue.js new file mode 100644 index 0000000000000000000000000000000000000000..d07bbb8a8f3fec5ad22ffdfb617245331fcff412 --- /dev/null +++ b/node_modules/es-abstract/2019/SameValue.js @@ -0,0 +1,13 @@ +'use strict'; + +var $isNaN = require('math-intrinsics/isNaN'); + +// http://262.ecma-international.org/5.1/#sec-9.12 + +module.exports = function SameValue(x, y) { + if (x === y) { // 0 === -0, but they are not identical. + if (x === 0) { return 1 / x === 1 / y; } + return true; + } + return $isNaN(x) && $isNaN(y); +}; diff --git a/node_modules/es-abstract/2019/SameValueNonNumber.js b/node_modules/es-abstract/2019/SameValueNonNumber.js new file mode 100644 index 0000000000000000000000000000000000000000..2d3b3de5c7a1ec0126d4e2b65e36aaa92b994309 --- /dev/null +++ b/node_modules/es-abstract/2019/SameValueNonNumber.js @@ -0,0 +1,14 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var SameValue = require('./SameValue'); + +// https://262.ecma-international.org/7.0/#sec-samevaluenonnumber + +module.exports = function SameValueNonNumber(x, y) { + if (typeof x === 'number' || typeof x !== typeof y) { + throw new $TypeError('SameValueNonNumber requires two non-number values of the same type.'); + } + return SameValue(x, y); +}; diff --git a/node_modules/es-abstract/2019/SameValueZero.js b/node_modules/es-abstract/2019/SameValueZero.js new file mode 100644 index 0000000000000000000000000000000000000000..8880e915941eeae2d890f2bdeb1bd057516e3d50 --- /dev/null +++ b/node_modules/es-abstract/2019/SameValueZero.js @@ -0,0 +1,9 @@ +'use strict'; + +var $isNaN = require('math-intrinsics/isNaN'); + +// https://262.ecma-international.org/6.0/#sec-samevaluezero + +module.exports = function SameValueZero(x, y) { + return (x === y) || ($isNaN(x) && $isNaN(y)); +}; diff --git a/node_modules/es-abstract/2019/SecFromTime.js b/node_modules/es-abstract/2019/SecFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..fc2e44560240f134cf345e63ab69d5f8a2d8cec1 --- /dev/null +++ b/node_modules/es-abstract/2019/SecFromTime.js @@ -0,0 +1,14 @@ +'use strict'; + +var floor = require('./floor'); +var modulo = require('./modulo'); + +var timeConstants = require('../helpers/timeConstants'); +var msPerSecond = timeConstants.msPerSecond; +var SecondsPerMinute = timeConstants.SecondsPerMinute; + +// https://262.ecma-international.org/5.1/#sec-15.9.1.10 + +module.exports = function SecFromTime(t) { + return modulo(floor(t / msPerSecond), SecondsPerMinute); +}; diff --git a/node_modules/es-abstract/2019/Set.js b/node_modules/es-abstract/2019/Set.js new file mode 100644 index 0000000000000000000000000000000000000000..f814076a8fb813648eb16093fe86a46182c0fccf --- /dev/null +++ b/node_modules/es-abstract/2019/Set.js @@ -0,0 +1,45 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var isPropertyKey = require('../helpers/isPropertyKey'); +var SameValue = require('./SameValue'); + +// IE 9 does not throw in strict mode when writability/configurability/extensibility is violated +var noThrowOnStrictViolation = (function () { + try { + delete [].length; + return true; + } catch (e) { + return false; + } +}()); + +// https://262.ecma-international.org/6.0/#sec-set-o-p-v-throw + +module.exports = function Set(O, P, V, Throw) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: `O` must be an Object'); + } + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: `P` must be a Property Key'); + } + if (typeof Throw !== 'boolean') { + throw new $TypeError('Assertion failed: `Throw` must be a Boolean'); + } + if (Throw) { + O[P] = V; // eslint-disable-line no-param-reassign + if (noThrowOnStrictViolation && !SameValue(O[P], V)) { + throw new $TypeError('Attempted to assign to readonly property.'); + } + return true; + } + try { + O[P] = V; // eslint-disable-line no-param-reassign + return noThrowOnStrictViolation ? SameValue(O[P], V) : true; + } catch (e) { + return false; + } + +}; diff --git a/node_modules/es-abstract/2019/SetFunctionLength.js b/node_modules/es-abstract/2019/SetFunctionLength.js new file mode 100644 index 0000000000000000000000000000000000000000..6ad93fb7574f60fdd4d1bac2f477ad99352c6a15 --- /dev/null +++ b/node_modules/es-abstract/2019/SetFunctionLength.js @@ -0,0 +1,28 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isInteger = require('math-intrinsics/isInteger'); + +var DefinePropertyOrThrow = require('./DefinePropertyOrThrow'); +var HasOwnProperty = require('./HasOwnProperty'); +var IsExtensible = require('./IsExtensible'); + +// https://262.ecma-international.org/9.0/#sec-setfunctionlength + +module.exports = function SetFunctionLength(F, length) { + if (typeof F !== 'function' || !IsExtensible(F) || HasOwnProperty(F, 'length')) { + throw new $TypeError('Assertion failed: `F` must be an extensible function and lack an own `length` property'); + } + if (typeof length !== 'number') { + throw new $TypeError('Assertion failed: `length` must be a Number'); + } + if (length < 0 || !isInteger(length)) { + throw new $TypeError('Assertion failed: `length` must be an integer >= 0'); + } + return DefinePropertyOrThrow(F, 'length', { + '[[Configurable]]': true, + '[[Enumerable]]': false, + '[[Value]]': length, + '[[Writable]]': false + }); +}; diff --git a/node_modules/es-abstract/2019/SetFunctionName.js b/node_modules/es-abstract/2019/SetFunctionName.js new file mode 100644 index 0000000000000000000000000000000000000000..9e8511fd46bc115d0459cc66f44bb6560ba2bc3a --- /dev/null +++ b/node_modules/es-abstract/2019/SetFunctionName.js @@ -0,0 +1,40 @@ +'use strict'; + +var hasOwn = require('hasown'); + +var $TypeError = require('es-errors/type'); + +var getSymbolDescription = require('get-symbol-description'); + +var DefinePropertyOrThrow = require('./DefinePropertyOrThrow'); +var IsExtensible = require('./IsExtensible'); + +// https://262.ecma-international.org/6.0/#sec-setfunctionname + +module.exports = function SetFunctionName(F, name) { + if (typeof F !== 'function') { + throw new $TypeError('Assertion failed: `F` must be a function'); + } + if (!IsExtensible(F) || hasOwn(F, 'name')) { + throw new $TypeError('Assertion failed: `F` must be extensible, and must not have a `name` own property'); + } + if (typeof name !== 'symbol' && typeof name !== 'string') { + throw new $TypeError('Assertion failed: `name` must be a Symbol or a String'); + } + if (typeof name === 'symbol') { + var description = getSymbolDescription(name); + // eslint-disable-next-line no-param-reassign + name = typeof description === 'undefined' ? '' : '[' + description + ']'; + } + if (arguments.length > 2) { + var prefix = arguments[2]; + // eslint-disable-next-line no-param-reassign + name = prefix + ' ' + name; + } + return DefinePropertyOrThrow(F, 'name', { + '[[Value]]': name, + '[[Writable]]': false, + '[[Enumerable]]': false, + '[[Configurable]]': true + }); +}; diff --git a/node_modules/es-abstract/2019/SetIntegrityLevel.js b/node_modules/es-abstract/2019/SetIntegrityLevel.js new file mode 100644 index 0000000000000000000000000000000000000000..ad92fb99b004f2b05e23fa0b2ef45dfc3775025e --- /dev/null +++ b/node_modules/es-abstract/2019/SetIntegrityLevel.js @@ -0,0 +1,57 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $SyntaxError = require('es-errors/syntax'); +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); +var $gOPD = require('gopd'); +var $preventExtensions = GetIntrinsic('%Object.preventExtensions%', true); +var $gOPN = GetIntrinsic('%Object.getOwnPropertyNames%', true); + +var forEach = require('../helpers/forEach'); + +var DefinePropertyOrThrow = require('./DefinePropertyOrThrow'); +var IsAccessorDescriptor = require('./IsAccessorDescriptor'); +var ToPropertyDescriptor = require('./ToPropertyDescriptor'); + +// https://262.ecma-international.org/6.0/#sec-setintegritylevel + +module.exports = function SetIntegrityLevel(O, level) { + if (!isObject(O)) { + 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); + if (level === 'sealed') { + forEach(theKeys, function (k) { + 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 (IsAccessorDescriptor(ToPropertyDescriptor(currentDesc))) { + desc = { configurable: false }; + } else { + desc = { configurable: false, writable: false }; + } + DefinePropertyOrThrow(O, k, desc); + } + }); + } + return true; +}; diff --git a/node_modules/es-abstract/2019/SetValueInBuffer.js b/node_modules/es-abstract/2019/SetValueInBuffer.js new file mode 100644 index 0000000000000000000000000000000000000000..4755fd10312915d12505a7f20332f9a5387438ef --- /dev/null +++ b/node_modules/es-abstract/2019/SetValueInBuffer.js @@ -0,0 +1,94 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $SyntaxError = require('es-errors/syntax'); +var $TypeError = require('es-errors/type'); +var $Uint8Array = GetIntrinsic('%Uint8Array%', true); + +var isInteger = require('math-intrinsics/isInteger'); + +var IsDetachedBuffer = require('./IsDetachedBuffer'); +var NumberToRawBytes = require('./NumberToRawBytes'); + +var isArrayBuffer = require('is-array-buffer'); +var isSharedArrayBuffer = require('is-shared-array-buffer'); +var hasOwn = require('hasown'); + +var tableTAO = require('./tables/typed-array-objects'); + +var defaultEndianness = require('../helpers/defaultEndianness'); +var forEach = require('../helpers/forEach'); + +// https://262.ecma-international.org/8.0/#sec-setvalueinbuffer + +/* eslint max-params: 0 */ + +module.exports = function SetValueInBuffer(arrayBuffer, byteIndex, type, value, isTypedArray, order) { + var isSAB = isSharedArrayBuffer(arrayBuffer); + if (!isArrayBuffer(arrayBuffer) && !isSAB) { + throw new $TypeError('Assertion failed: `arrayBuffer` must be an ArrayBuffer or a SharedArrayBuffer'); + } + + if (!isInteger(byteIndex)) { + throw new $TypeError('Assertion failed: `byteIndex` must be an integer'); + } + + if (typeof type !== 'string' || !hasOwn(tableTAO.size, '$' + type)) { + throw new $TypeError('Assertion failed: `type` must be one of ' + tableTAO.choices); + } + + if (typeof value !== 'number') { + throw new $TypeError('Assertion failed: `value` must be a number'); + } + + if (typeof isTypedArray !== 'boolean') { + throw new $TypeError('Assertion failed: `isTypedArray` must be a boolean'); + } + if (order !== 'SeqCst' && order !== 'Unordered' && order !== 'Init') { + throw new $TypeError('Assertion failed: `order` must be `"SeqCst"`, `"Unordered"`, or `"Init"`'); + } + + if (arguments.length > 6 && typeof arguments[6] !== 'boolean') { + throw new $TypeError('Assertion failed: `isLittleEndian` must be a boolean, if present'); + } + + if (IsDetachedBuffer(arrayBuffer)) { + throw new $TypeError('Assertion failed: ArrayBuffer is detached'); // step 1 + } + + // 2. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type. + + if (byteIndex < 0) { + throw new $TypeError('Assertion failed: `byteIndex` must be non-negative'); // step 3 + } + + // 4. Assert: Type(value) is Number. + + // 5. Let block be arrayBuffer.[[ArrayBufferData]]. + + var elementSize = tableTAO.size['$' + type]; // step 6 + + // 7. If isLittleEndian is not present, set isLittleEndian to to the value of the [[LittleEndian]] field of the surrounding agent's Agent Record. + var isLittleEndian = arguments.length > 6 ? arguments[6] : defaultEndianness === 'little'; // step 8 + + var rawBytes = NumberToRawBytes(type, value, isLittleEndian); // step 8 + + if (isSAB) { // step 9 + /* + Let execution be the [[CandidateExecution]] field of the surrounding agent's Agent Record. + Let eventList be the [[EventList]] field of the element in execution.[[EventsRecords]] whose [[AgentSignifier]] is AgentSignifier(). + If isTypedArray is true and IsNoTearConfiguration(type, order) is true, let noTear be true; otherwise let noTear be false. + Append WriteSharedMemory { [[Order]]: order, [[NoTear]]: noTear, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize, [[Payload]]: rawBytes } to eventList. + */ + throw new $SyntaxError('SharedArrayBuffer is not supported by this implementation'); + } else { + // 10. Store the individual bytes of rawBytes into block, in order, starting at block[byteIndex]. + var arr = new $Uint8Array(arrayBuffer, byteIndex, elementSize); + forEach(rawBytes, function (rawByte, i) { + arr[i] = rawByte; + }); + } + + // 11. Return NormalCompletion(undefined). +}; diff --git a/node_modules/es-abstract/2019/SpeciesConstructor.js b/node_modules/es-abstract/2019/SpeciesConstructor.js new file mode 100644 index 0000000000000000000000000000000000000000..23e32b443ef3655f56639920d5cf58474500bf67 --- /dev/null +++ b/node_modules/es-abstract/2019/SpeciesConstructor.js @@ -0,0 +1,32 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $species = GetIntrinsic('%Symbol.species%', true); +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var IsConstructor = require('./IsConstructor'); + +// https://262.ecma-international.org/6.0/#sec-speciesconstructor + +module.exports = function SpeciesConstructor(O, defaultConstructor) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + var C = O.constructor; + if (typeof C === 'undefined') { + return defaultConstructor; + } + if (!isObject(C)) { + throw new $TypeError('O.constructor is not an Object'); + } + var S = $species ? C[$species] : void 0; + if (S == null) { + return defaultConstructor; + } + if (IsConstructor(S)) { + return S; + } + throw new $TypeError('no constructor found'); +}; diff --git a/node_modules/es-abstract/2019/SplitMatch.js b/node_modules/es-abstract/2019/SplitMatch.js new file mode 100644 index 0000000000000000000000000000000000000000..c04fa7f63c6884e6d40b21689784dae891ceb655 --- /dev/null +++ b/node_modules/es-abstract/2019/SplitMatch.js @@ -0,0 +1,35 @@ +'use strict'; + +var callBound = require('call-bound'); + +var $TypeError = require('es-errors/type'); +var isInteger = require('math-intrinsics/isInteger'); + +var $charAt = callBound('String.prototype.charAt'); + +// https://262.ecma-international.org/6.0/#sec-splitmatch + +module.exports = function SplitMatch(S, q, R) { + if (typeof S !== 'string') { + throw new $TypeError('Assertion failed: `S` must be a String'); + } + if (!isInteger(q)) { + throw new $TypeError('Assertion failed: `q` must be an integer'); + } + if (typeof R !== 'string') { + throw new $TypeError('Assertion failed: `R` must be a String'); + } + var r = R.length; + var s = S.length; + if (q + r > s) { + return false; + } + + for (var i = 0; i < r; i += 1) { + if ($charAt(S, q + i) !== $charAt(R, i)) { + return false; + } + } + + return q + r; +}; diff --git a/node_modules/es-abstract/2019/StrictEqualityComparison.js b/node_modules/es-abstract/2019/StrictEqualityComparison.js new file mode 100644 index 0000000000000000000000000000000000000000..d056c44e79a546022718908720ab19cd27e7415e --- /dev/null +++ b/node_modules/es-abstract/2019/StrictEqualityComparison.js @@ -0,0 +1,15 @@ +'use strict'; + +var Type = require('./Type'); + +// https://262.ecma-international.org/5.1/#sec-11.9.6 + +module.exports = function StrictEqualityComparison(x, y) { + if (Type(x) !== Type(y)) { + return false; + } + if (typeof x === 'undefined' || x === null) { + return true; + } + return x === y; // shortcut for steps 4-7 +}; diff --git a/node_modules/es-abstract/2019/StringCreate.js b/node_modules/es-abstract/2019/StringCreate.js new file mode 100644 index 0000000000000000000000000000000000000000..3e2aa43c50d8aa6317c0eef7eaf0b87e32916d4d --- /dev/null +++ b/node_modules/es-abstract/2019/StringCreate.js @@ -0,0 +1,38 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $Object = require('es-object-atoms'); +var $StringPrototype = GetIntrinsic('%String.prototype%'); +var $SyntaxError = require('es-errors/syntax'); +var $TypeError = require('es-errors/type'); +var setProto = require('set-proto'); + +var DefinePropertyOrThrow = require('./DefinePropertyOrThrow'); + +// https://262.ecma-international.org/6.0/#sec-stringcreate + +module.exports = function StringCreate(value, prototype) { + if (typeof value !== 'string') { + throw new $TypeError('Assertion failed: `S` must be a String'); + } + + var S = $Object(value); + if (prototype !== $StringPrototype) { + if (setProto) { + setProto(S, prototype); + } else { + throw new $SyntaxError('StringCreate: a `proto` argument that is not `String.prototype` is not supported in an environment that does not support setting the [[Prototype]]'); + } + } + + var length = value.length; + DefinePropertyOrThrow(S, 'length', { + '[[Configurable]]': false, + '[[Enumerable]]': false, + '[[Value]]': length, + '[[Writable]]': false + }); + + return S; +}; diff --git a/node_modules/es-abstract/2019/StringGetOwnProperty.js b/node_modules/es-abstract/2019/StringGetOwnProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..60a94ddc36368c245f5f54a807ea74e49bf663aa --- /dev/null +++ b/node_modules/es-abstract/2019/StringGetOwnProperty.js @@ -0,0 +1,47 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var callBound = require('call-bound'); +var $charAt = callBound('String.prototype.charAt'); +var $stringToString = callBound('String.prototype.toString'); + +var CanonicalNumericIndexString = require('./CanonicalNumericIndexString'); +var IsInteger = require('./IsInteger'); + +var isPropertyKey = require('../helpers/isPropertyKey'); + +var isNegativeZero = require('math-intrinsics/isNegativeZero'); + +// https://262.ecma-international.org/8.0/#sec-stringgetownproperty + +module.exports = function StringGetOwnProperty(S, P) { + var str; + if (isObject(S)) { + try { + str = $stringToString(S); + } catch (e) { /**/ } + } + if (typeof str !== 'string') { + throw new $TypeError('Assertion failed: `S` must be a boxed string object'); + } + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: P is not a Property Key'); + } + if (typeof P !== 'string') { + return void undefined; + } + var index = CanonicalNumericIndexString(P); + var len = str.length; + if (typeof index === 'undefined' || !IsInteger(index) || isNegativeZero(index) || index < 0 || len <= index) { + return void undefined; + } + var resultStr = $charAt(S, index); + return { + '[[Configurable]]': false, + '[[Enumerable]]': true, + '[[Value]]': resultStr, + '[[Writable]]': false + }; +}; diff --git a/node_modules/es-abstract/2019/SymbolDescriptiveString.js b/node_modules/es-abstract/2019/SymbolDescriptiveString.js new file mode 100644 index 0000000000000000000000000000000000000000..444e3f70004626a3053f672a290e5e81b0f5cf51 --- /dev/null +++ b/node_modules/es-abstract/2019/SymbolDescriptiveString.js @@ -0,0 +1,16 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var callBound = require('call-bound'); + +var $SymbolToString = callBound('Symbol.prototype.toString', true); + +// https://262.ecma-international.org/6.0/#sec-symboldescriptivestring + +module.exports = function SymbolDescriptiveString(sym) { + if (typeof sym !== 'symbol') { + throw new $TypeError('Assertion failed: `sym` must be a Symbol'); + } + return $SymbolToString(sym); +}; diff --git a/node_modules/es-abstract/2019/TestIntegrityLevel.js b/node_modules/es-abstract/2019/TestIntegrityLevel.js new file mode 100644 index 0000000000000000000000000000000000000000..0e802f42786f89bac378b6a58e6009c9620be721 --- /dev/null +++ b/node_modules/es-abstract/2019/TestIntegrityLevel.js @@ -0,0 +1,40 @@ +'use strict'; + +var $gOPD = require('gopd'); +var $TypeError = require('es-errors/type'); + +var every = require('../helpers/every'); +var OwnPropertyKeys = require('own-keys'); +var isObject = require('es-object-atoms/isObject'); + +var IsDataDescriptor = require('./IsDataDescriptor'); +var IsExtensible = require('./IsExtensible'); +var ToPropertyDescriptor = require('./ToPropertyDescriptor'); + +// https://262.ecma-international.org/6.0/#sec-testintegritylevel + +module.exports = function TestIntegrityLevel(O, level) { + if (!isObject(O)) { + 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 = IsExtensible(O); + if (status || !$gOPD) { + return false; + } + var theKeys = OwnPropertyKeys(O); + 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' && IsDataDescriptor(ToPropertyDescriptor(currentDesc)) && currentDesc.writable) { + return false; + } + } + return true; + }); +}; diff --git a/node_modules/es-abstract/2019/ThrowCompletion.js b/node_modules/es-abstract/2019/ThrowCompletion.js new file mode 100644 index 0000000000000000000000000000000000000000..b7d388a35292e2a9faf88d4808b74e2c4878bbe7 --- /dev/null +++ b/node_modules/es-abstract/2019/ThrowCompletion.js @@ -0,0 +1,9 @@ +'use strict'; + +var CompletionRecord = require('./CompletionRecord'); + +// https://262.ecma-international.org/9.0/#sec-throwcompletion + +module.exports = function ThrowCompletion(argument) { + return new CompletionRecord('throw', argument); +}; diff --git a/node_modules/es-abstract/2019/TimeClip.js b/node_modules/es-abstract/2019/TimeClip.js new file mode 100644 index 0000000000000000000000000000000000000000..77c8dd4226c4765855024b1784b842f869fa5bfe --- /dev/null +++ b/node_modules/es-abstract/2019/TimeClip.js @@ -0,0 +1,20 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $Date = GetIntrinsic('%Date%'); + +var $isFinite = require('math-intrinsics/isFinite'); +var abs = require('math-intrinsics/abs'); + +var ToNumber = require('./ToNumber'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.14 + +module.exports = function TimeClip(time) { + if (!$isFinite(time) || abs(time) > 8.64e15) { + return NaN; + } + return +new $Date(ToNumber(time)); +}; + diff --git a/node_modules/es-abstract/2019/TimeFromYear.js b/node_modules/es-abstract/2019/TimeFromYear.js new file mode 100644 index 0000000000000000000000000000000000000000..f3518a41a19146c9ba59e1362c3fb33f800daaa1 --- /dev/null +++ b/node_modules/es-abstract/2019/TimeFromYear.js @@ -0,0 +1,11 @@ +'use strict'; + +var msPerDay = require('../helpers/timeConstants').msPerDay; + +var DayFromYear = require('./DayFromYear'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.3 + +module.exports = function TimeFromYear(y) { + return msPerDay * DayFromYear(y); +}; diff --git a/node_modules/es-abstract/2019/TimeString.js b/node_modules/es-abstract/2019/TimeString.js new file mode 100644 index 0000000000000000000000000000000000000000..f79080d6c3523a6d272d53f45a1e1501b655ae75 --- /dev/null +++ b/node_modules/es-abstract/2019/TimeString.js @@ -0,0 +1,22 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var $isNaN = require('math-intrinsics/isNaN'); +var padTimeComponent = require('../helpers/padTimeComponent'); + +var HourFromTime = require('./HourFromTime'); +var MinFromTime = require('./MinFromTime'); +var SecFromTime = require('./SecFromTime'); + +// https://262.ecma-international.org/9.0/#sec-timestring + +module.exports = function TimeString(tv) { + if (typeof tv !== 'number' || $isNaN(tv)) { + throw new $TypeError('Assertion failed: `tv` must be a non-NaN Number'); + } + var hour = HourFromTime(tv); + var minute = MinFromTime(tv); + var second = SecFromTime(tv); + return padTimeComponent(hour) + ':' + padTimeComponent(minute) + ':' + padTimeComponent(second) + '\x20GMT'; +}; diff --git a/node_modules/es-abstract/2019/TimeWithinDay.js b/node_modules/es-abstract/2019/TimeWithinDay.js new file mode 100644 index 0000000000000000000000000000000000000000..2bba83386c141873d3b603ed19d0f37069d1016a --- /dev/null +++ b/node_modules/es-abstract/2019/TimeWithinDay.js @@ -0,0 +1,12 @@ +'use strict'; + +var modulo = require('./modulo'); + +var msPerDay = require('../helpers/timeConstants').msPerDay; + +// https://262.ecma-international.org/5.1/#sec-15.9.1.2 + +module.exports = function TimeWithinDay(t) { + return modulo(t, msPerDay); +}; + diff --git a/node_modules/es-abstract/2019/TimeZoneString.js b/node_modules/es-abstract/2019/TimeZoneString.js new file mode 100644 index 0000000000000000000000000000000000000000..aa4d5b1cdea32a13bc20fb9526f7a76b89194431 --- /dev/null +++ b/node_modules/es-abstract/2019/TimeZoneString.js @@ -0,0 +1,33 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $Date = GetIntrinsic('%Date%'); +var $TypeError = require('es-errors/type'); + +var isNaN = require('math-intrinsics/isNaN'); + +var callBound = require('call-bound'); + +var $indexOf = callBound('String.prototype.indexOf'); +var $slice = callBound('String.prototype.slice'); +var $toTimeString = callBound('Date.prototype.toTimeString'); + +// https://262.ecma-international.org/9.0/#sec-timezoneestring + +module.exports = function TimeZoneString(tv) { + if (typeof tv !== 'number' || isNaN(tv)) { + throw new $TypeError('Assertion failed: `tv` must be a non-NaN Number'); // steps 1 - 2 + } + + // 3. Let offset be LocalTZA(tv, true). + // 4. If offset ≥ 0, let offsetSign be "+"; otherwise, let offsetSign be "-". + // 5. Let offsetMin be the String representation of MinFromTime(abs(offset)), formatted as a two-digit decimal number, padded to the left with a zero if necessary. + // 6. Let offsetHour be the String representation of HourFromTime(abs(offset)), formatted as a two-digit decimal number, padded to the left with a zero if necessary. + // 7. Let tzName be an implementation-defined string that is either the empty string or the string-concatenation of the code unit 0x0020 (SPACE), the code unit 0x0028 (LEFT PARENTHESIS), an implementation-dependent timezone name, and the code unit 0x0029 (RIGHT PARENTHESIS). + // 8. Return the string-concatenation of offsetSign, offsetHour, offsetMin, and tzName. + + // hack until LocalTZA, and "implementation-defined string" are available + var ts = $toTimeString(new $Date(tv)); + return $slice(ts, $indexOf(ts, '(') + 1, $indexOf(ts, ')')); +}; diff --git a/node_modules/es-abstract/2019/ToBoolean.js b/node_modules/es-abstract/2019/ToBoolean.js new file mode 100644 index 0000000000000000000000000000000000000000..466404bf9992f0ba636249264c620d6c56215d6a --- /dev/null +++ b/node_modules/es-abstract/2019/ToBoolean.js @@ -0,0 +1,5 @@ +'use strict'; + +// http://262.ecma-international.org/5.1/#sec-9.2 + +module.exports = function ToBoolean(value) { return !!value; }; diff --git a/node_modules/es-abstract/2019/ToDateString.js b/node_modules/es-abstract/2019/ToDateString.js new file mode 100644 index 0000000000000000000000000000000000000000..d9bb434185ca0adfa055d91bf592efdce3ed1d94 --- /dev/null +++ b/node_modules/es-abstract/2019/ToDateString.js @@ -0,0 +1,21 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = require('es-errors/type'); +var $Date = GetIntrinsic('%Date%'); +var $String = GetIntrinsic('%String%'); + +var $isNaN = require('math-intrinsics/isNaN'); + +// https://262.ecma-international.org/6.0/#sec-todatestring + +module.exports = function ToDateString(tv) { + if (typeof tv !== 'number') { + throw new $TypeError('Assertion failed: `tv` must be a Number'); + } + if ($isNaN(tv)) { + return 'Invalid Date'; + } + return $String(new $Date(tv)); +}; diff --git a/node_modules/es-abstract/2019/ToIndex.js b/node_modules/es-abstract/2019/ToIndex.js new file mode 100644 index 0000000000000000000000000000000000000000..2dd00981cfdd7fb1130d729ce635ab088afb3f32 --- /dev/null +++ b/node_modules/es-abstract/2019/ToIndex.js @@ -0,0 +1,24 @@ +'use strict'; + +var $RangeError = require('es-errors/range'); + +var ToInteger = require('./ToInteger'); +var ToLength = require('./ToLength'); +var SameValueZero = require('./SameValueZero'); + +// https://262.ecma-international.org/8.0/#sec-toindex + +module.exports = function ToIndex(value) { + if (typeof value === 'undefined') { + return 0; + } + var integerIndex = ToInteger(value); + if (integerIndex < 0) { + throw new $RangeError('index must be >= 0'); + } + var index = ToLength(integerIndex); + if (!SameValueZero(integerIndex, index)) { + throw new $RangeError('index must be >= 0 and < 2 ** 53 - 1'); + } + return index; +}; diff --git a/node_modules/es-abstract/2019/ToInt16.js b/node_modules/es-abstract/2019/ToInt16.js new file mode 100644 index 0000000000000000000000000000000000000000..21694bdeb923cd78791c7c01e242d892b4833af0 --- /dev/null +++ b/node_modules/es-abstract/2019/ToInt16.js @@ -0,0 +1,10 @@ +'use strict'; + +var ToUint16 = require('./ToUint16'); + +// https://262.ecma-international.org/6.0/#sec-toint16 + +module.exports = function ToInt16(argument) { + var int16bit = ToUint16(argument); + return int16bit >= 0x8000 ? int16bit - 0x10000 : int16bit; +}; diff --git a/node_modules/es-abstract/2019/ToInt32.js b/node_modules/es-abstract/2019/ToInt32.js new file mode 100644 index 0000000000000000000000000000000000000000..b879ccc479e039097fa2d1017299579a2d8a8162 --- /dev/null +++ b/node_modules/es-abstract/2019/ToInt32.js @@ -0,0 +1,9 @@ +'use strict'; + +var ToNumber = require('./ToNumber'); + +// http://262.ecma-international.org/5.1/#sec-9.5 + +module.exports = function ToInt32(x) { + return ToNumber(x) >> 0; +}; diff --git a/node_modules/es-abstract/2019/ToInt8.js b/node_modules/es-abstract/2019/ToInt8.js new file mode 100644 index 0000000000000000000000000000000000000000..e223b6c1d352a3432da2d272d0f7e66bbfa818b4 --- /dev/null +++ b/node_modules/es-abstract/2019/ToInt8.js @@ -0,0 +1,10 @@ +'use strict'; + +var ToUint8 = require('./ToUint8'); + +// https://262.ecma-international.org/6.0/#sec-toint8 + +module.exports = function ToInt8(argument) { + var int8bit = ToUint8(argument); + return int8bit >= 0x80 ? int8bit - 0x100 : int8bit; +}; diff --git a/node_modules/es-abstract/2019/ToInteger.js b/node_modules/es-abstract/2019/ToInteger.js new file mode 100644 index 0000000000000000000000000000000000000000..f6625796ebd22a688826a1bd5d36e20dfe6ebcc7 --- /dev/null +++ b/node_modules/es-abstract/2019/ToInteger.js @@ -0,0 +1,12 @@ +'use strict'; + +var ES5ToInteger = require('../5/ToInteger'); + +var ToNumber = require('./ToNumber'); + +// https://262.ecma-international.org/6.0/#sec-tointeger + +module.exports = function ToInteger(value) { + var number = ToNumber(value); + return ES5ToInteger(number); +}; diff --git a/node_modules/es-abstract/2019/ToLength.js b/node_modules/es-abstract/2019/ToLength.js new file mode 100644 index 0000000000000000000000000000000000000000..afa8fb5576c98149d8b6e3327fde8370cd34794c --- /dev/null +++ b/node_modules/es-abstract/2019/ToLength.js @@ -0,0 +1,14 @@ +'use strict'; + +var MAX_SAFE_INTEGER = require('math-intrinsics/constants/maxSafeInteger'); + +var ToInteger = require('./ToInteger'); + +// https://262.ecma-international.org/6.0/#sec-tolength + +module.exports = function ToLength(argument) { + var len = ToInteger(argument); + if (len <= 0) { return 0; } // includes converting -0 to +0 + if (len > MAX_SAFE_INTEGER) { return MAX_SAFE_INTEGER; } + return len; +}; diff --git a/node_modules/es-abstract/2019/ToNumber.js b/node_modules/es-abstract/2019/ToNumber.js new file mode 100644 index 0000000000000000000000000000000000000000..c3d95a5fa51d6d66ec39b339e9d7839266c192ff --- /dev/null +++ b/node_modules/es-abstract/2019/ToNumber.js @@ -0,0 +1,48 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = require('es-errors/type'); +var $Number = GetIntrinsic('%Number%'); +var $RegExp = GetIntrinsic('%RegExp%'); +var $parseInteger = GetIntrinsic('%parseInt%'); + +var callBound = require('call-bound'); +var regexTester = require('safe-regex-test'); +var isPrimitive = require('../helpers/isPrimitive'); + +var $strSlice = callBound('String.prototype.slice'); +var isBinary = regexTester(/^0b[01]+$/i); +var isOctal = regexTester(/^0o[0-7]+$/i); +var isInvalidHexLiteral = regexTester(/^[-+]0x[0-9a-f]+$/i); +var nonWS = ['\u0085', '\u200b', '\ufffe'].join(''); +var nonWSregex = new $RegExp('[' + nonWS + ']', 'g'); +var hasNonWS = regexTester(nonWSregex); + +var $trim = require('string.prototype.trim'); + +var ToPrimitive = require('./ToPrimitive'); + +// https://262.ecma-international.org/6.0/#sec-tonumber + +module.exports = function ToNumber(argument) { + var value = isPrimitive(argument) ? argument : ToPrimitive(argument, $Number); + if (typeof value === 'symbol') { + throw new $TypeError('Cannot convert a Symbol value to a number'); + } + if (typeof value === 'string') { + if (isBinary(value)) { + return ToNumber($parseInteger($strSlice(value, 2), 2)); + } else if (isOctal(value)) { + return ToNumber($parseInteger($strSlice(value, 2), 8)); + } else if (hasNonWS(value) || isInvalidHexLiteral(value)) { + return NaN; + } + var trimmed = $trim(value); + if (trimmed !== value) { + return ToNumber(trimmed); + } + + } + return +value; +}; diff --git a/node_modules/es-abstract/2019/ToObject.js b/node_modules/es-abstract/2019/ToObject.js new file mode 100644 index 0000000000000000000000000000000000000000..70226aaa331e7fd7aa487e680d4aca6bb6874f5b --- /dev/null +++ b/node_modules/es-abstract/2019/ToObject.js @@ -0,0 +1,5 @@ +'use strict'; + +// https://262.ecma-international.org/6.0/#sec-toobject + +module.exports = require('es-object-atoms/ToObject'); diff --git a/node_modules/es-abstract/2019/ToPrimitive.js b/node_modules/es-abstract/2019/ToPrimitive.js new file mode 100644 index 0000000000000000000000000000000000000000..56bcf1aa9eb269d753119497686556384800b092 --- /dev/null +++ b/node_modules/es-abstract/2019/ToPrimitive.js @@ -0,0 +1,12 @@ +'use strict'; + +var toPrimitive = require('es-to-primitive/es2015'); + +// https://262.ecma-international.org/6.0/#sec-toprimitive + +module.exports = function ToPrimitive(input) { + if (arguments.length > 1) { + return toPrimitive(input, arguments[1]); + } + return toPrimitive(input); +}; diff --git a/node_modules/es-abstract/2019/ToPropertyDescriptor.js b/node_modules/es-abstract/2019/ToPropertyDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..017350d593b202573a928ccefeacc7472c803a5e --- /dev/null +++ b/node_modules/es-abstract/2019/ToPropertyDescriptor.js @@ -0,0 +1,50 @@ +'use strict'; + +var hasOwn = require('hasown'); + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var IsCallable = require('./IsCallable'); +var ToBoolean = require('./ToBoolean'); + +// https://262.ecma-international.org/5.1/#sec-8.10.5 + +module.exports = function ToPropertyDescriptor(Obj) { + if (!isObject(Obj)) { + throw new $TypeError('ToPropertyDescriptor requires an object'); + } + + var desc = {}; + if (hasOwn(Obj, 'enumerable')) { + desc['[[Enumerable]]'] = ToBoolean(Obj.enumerable); + } + if (hasOwn(Obj, 'configurable')) { + desc['[[Configurable]]'] = ToBoolean(Obj.configurable); + } + if (hasOwn(Obj, 'value')) { + desc['[[Value]]'] = Obj.value; + } + if (hasOwn(Obj, 'writable')) { + desc['[[Writable]]'] = ToBoolean(Obj.writable); + } + if (hasOwn(Obj, 'get')) { + var getter = Obj.get; + if (typeof getter !== 'undefined' && !IsCallable(getter)) { + throw new $TypeError('getter must be a function'); + } + desc['[[Get]]'] = getter; + } + if (hasOwn(Obj, 'set')) { + var setter = Obj.set; + if (typeof setter !== 'undefined' && !IsCallable(setter)) { + throw new $TypeError('setter must be a function'); + } + desc['[[Set]]'] = setter; + } + + if ((hasOwn(desc, '[[Get]]') || hasOwn(desc, '[[Set]]')) && (hasOwn(desc, '[[Value]]') || hasOwn(desc, '[[Writable]]'))) { + throw new $TypeError('Invalid property descriptor. Cannot both specify accessors and a value or writable attribute'); + } + return desc; +}; diff --git a/node_modules/es-abstract/2019/ToPropertyKey.js b/node_modules/es-abstract/2019/ToPropertyKey.js new file mode 100644 index 0000000000000000000000000000000000000000..e363cd93b1722ddcff99896fb5667079bb95c932 --- /dev/null +++ b/node_modules/es-abstract/2019/ToPropertyKey.js @@ -0,0 +1,15 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $String = GetIntrinsic('%String%'); + +var ToPrimitive = require('./ToPrimitive'); +var ToString = require('./ToString'); + +// https://262.ecma-international.org/6.0/#sec-topropertykey + +module.exports = function ToPropertyKey(argument) { + var key = ToPrimitive(argument, $String); + return typeof key === 'symbol' ? key : ToString(key); +}; diff --git a/node_modules/es-abstract/2019/ToString.js b/node_modules/es-abstract/2019/ToString.js new file mode 100644 index 0000000000000000000000000000000000000000..16b4ccf893640ee9162ff07ad484038311e6210d --- /dev/null +++ b/node_modules/es-abstract/2019/ToString.js @@ -0,0 +1,15 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $String = GetIntrinsic('%String%'); +var $TypeError = require('es-errors/type'); + +// https://262.ecma-international.org/6.0/#sec-tostring + +module.exports = function ToString(argument) { + if (typeof argument === 'symbol') { + throw new $TypeError('Cannot convert a Symbol value to a string'); + } + return $String(argument); +}; diff --git a/node_modules/es-abstract/2019/ToUint16.js b/node_modules/es-abstract/2019/ToUint16.js new file mode 100644 index 0000000000000000000000000000000000000000..117485e616437b348b9b74dddc3fc5e7af9f9ed0 --- /dev/null +++ b/node_modules/es-abstract/2019/ToUint16.js @@ -0,0 +1,19 @@ +'use strict'; + +var modulo = require('./modulo'); +var ToNumber = require('./ToNumber'); + +var abs = require('math-intrinsics/abs'); +var floor = require('math-intrinsics/floor'); +var $isNaN = require('math-intrinsics/isNaN'); +var $isFinite = require('math-intrinsics/isFinite'); +var $sign = require('math-intrinsics/sign'); + +// http://262.ecma-international.org/5.1/#sec-9.7 + +module.exports = function ToUint16(value) { + var number = ToNumber(value); + if ($isNaN(number) || number === 0 || !$isFinite(number)) { return 0; } + var posInt = $sign(number) * floor(abs(number)); + return modulo(posInt, 0x10000); +}; diff --git a/node_modules/es-abstract/2019/ToUint32.js b/node_modules/es-abstract/2019/ToUint32.js new file mode 100644 index 0000000000000000000000000000000000000000..2a8e9dd6a3794a0940b6bae175a99f00c0e2d25d --- /dev/null +++ b/node_modules/es-abstract/2019/ToUint32.js @@ -0,0 +1,9 @@ +'use strict'; + +var ToNumber = require('./ToNumber'); + +// http://262.ecma-international.org/5.1/#sec-9.6 + +module.exports = function ToUint32(x) { + return ToNumber(x) >>> 0; +}; diff --git a/node_modules/es-abstract/2019/ToUint8.js b/node_modules/es-abstract/2019/ToUint8.js new file mode 100644 index 0000000000000000000000000000000000000000..e3af8ede13a7ef1e5e3eb8833701d6497f8611e0 --- /dev/null +++ b/node_modules/es-abstract/2019/ToUint8.js @@ -0,0 +1,19 @@ +'use strict'; + +var ToNumber = require('./ToNumber'); + +var $isNaN = require('math-intrinsics/isNaN'); +var $isFinite = require('math-intrinsics/isFinite'); +var $sign = require('math-intrinsics/sign'); +var abs = require('math-intrinsics/abs'); +var floor = require('math-intrinsics/floor'); +var modulo = require('math-intrinsics/mod'); + +// https://262.ecma-international.org/6.0/#sec-touint8 + +module.exports = function ToUint8(argument) { + var number = ToNumber(argument); + if ($isNaN(number) || number === 0 || !$isFinite(number)) { return 0; } + var posInt = $sign(number) * floor(abs(number)); + return modulo(posInt, 0x100); +}; diff --git a/node_modules/es-abstract/2019/ToUint8Clamp.js b/node_modules/es-abstract/2019/ToUint8Clamp.js new file mode 100644 index 0000000000000000000000000000000000000000..ac1b06e461ba4d562700971000c2d30a9b9dfca4 --- /dev/null +++ b/node_modules/es-abstract/2019/ToUint8Clamp.js @@ -0,0 +1,19 @@ +'use strict'; + +var ToNumber = require('./ToNumber'); +var floor = require('./floor'); + +var $isNaN = require('math-intrinsics/isNaN'); + +// https://262.ecma-international.org/6.0/#sec-touint8clamp + +module.exports = function ToUint8Clamp(argument) { + var number = ToNumber(argument); + if ($isNaN(number) || number <= 0) { return 0; } + if (number >= 0xFF) { return 0xFF; } + var f = floor(number); + if (f + 0.5 < number) { return f + 1; } + if (number < f + 0.5) { return f; } + if (f % 2 !== 0) { return f + 1; } + return f; +}; diff --git a/node_modules/es-abstract/2019/TrimString.js b/node_modules/es-abstract/2019/TrimString.js new file mode 100644 index 0000000000000000000000000000000000000000..516ef254819cc6b4d11788176a2e90b7ca18b7e4 --- /dev/null +++ b/node_modules/es-abstract/2019/TrimString.js @@ -0,0 +1,27 @@ +'use strict'; + +var trimStart = require('string.prototype.trimstart'); +var trimEnd = require('string.prototype.trimend'); + +var $TypeError = require('es-errors/type'); + +var RequireObjectCoercible = require('./RequireObjectCoercible'); +var ToString = require('./ToString'); + +// https://262.ecma-international.org/10.0/#sec-trimstring + +module.exports = function TrimString(string, where) { + var str = RequireObjectCoercible(string); + var S = ToString(str); + var T; + if (where === 'start') { + T = trimStart(S); + } else if (where === 'end') { + T = trimEnd(S); + } else if (where === 'start+end') { + T = trimStart(trimEnd(S)); + } else { + throw new $TypeError('Assertion failed: invalid `where` value; must be "start", "end", or "start+end"'); + } + return T; +}; diff --git a/node_modules/es-abstract/2019/Type.js b/node_modules/es-abstract/2019/Type.js new file mode 100644 index 0000000000000000000000000000000000000000..da5cb762508f187a91583bfc2d509036d492aa66 --- /dev/null +++ b/node_modules/es-abstract/2019/Type.js @@ -0,0 +1,12 @@ +'use strict'; + +var ES5Type = require('../5/Type'); + +// https://262.ecma-international.org/6.0/#sec-ecmascript-data-types-and-values + +module.exports = function Type(x) { + if (typeof x === 'symbol') { + return 'Symbol'; + } + return ES5Type(x); +}; diff --git a/node_modules/es-abstract/2019/TypedArrayCreate.js b/node_modules/es-abstract/2019/TypedArrayCreate.js new file mode 100644 index 0000000000000000000000000000000000000000..c598dfff9fe1d42461198227a6004e0fe4512226 --- /dev/null +++ b/node_modules/es-abstract/2019/TypedArrayCreate.js @@ -0,0 +1,47 @@ +'use strict'; + +var $SyntaxError = require('es-errors/syntax'); +var $TypeError = require('es-errors/type'); + +var IsArray = require('./IsArray'); +var IsConstructor = require('./IsConstructor'); +var ValidateTypedArray = require('./ValidateTypedArray'); + +var availableTypedArrays = require('available-typed-arrays')(); +var typedArrayLength = require('typed-array-length'); + +// https://262.ecma-international.org/7.0/#typedarray-create + +module.exports = function TypedArrayCreate(constructor, argumentList) { + if (!IsConstructor(constructor)) { + throw new $TypeError('Assertion failed: `constructor` must be a constructor'); + } + if (!IsArray(argumentList)) { + throw new $TypeError('Assertion failed: `argumentList` must be a List'); + } + if (availableTypedArrays.length === 0) { + throw new $SyntaxError('Assertion failed: Typed Arrays are not supported in this environment'); + } + + // var newTypedArray = Construct(constructor, argumentList); // step 1 + var newTypedArray; + if (argumentList.length === 0) { + newTypedArray = new constructor(); + } else if (argumentList.length === 1) { + newTypedArray = new constructor(argumentList[0]); + } else if (argumentList.length === 2) { + newTypedArray = new constructor(argumentList[0], argumentList[1]); + } else { + newTypedArray = new constructor(argumentList[0], argumentList[1], argumentList[2]); + } + + ValidateTypedArray(newTypedArray); // step 2 + + if (argumentList.length === 1 && typeof argumentList[0] === 'number') { // step 3 + if (typedArrayLength(newTypedArray) < argumentList[0]) { + throw new $TypeError('Assertion failed: `argumentList[0]` must be <= `newTypedArray.length`'); // step 3.a + } + } + + return newTypedArray; // step 4 +}; diff --git a/node_modules/es-abstract/2019/TypedArraySpeciesCreate.js b/node_modules/es-abstract/2019/TypedArraySpeciesCreate.js new file mode 100644 index 0000000000000000000000000000000000000000..6c71498a052bbfc121b4887e2aa3fff5572510b2 --- /dev/null +++ b/node_modules/es-abstract/2019/TypedArraySpeciesCreate.js @@ -0,0 +1,37 @@ +'use strict'; + +var $SyntaxError = require('es-errors/syntax'); +var $TypeError = require('es-errors/type'); + +var whichTypedArray = require('which-typed-array'); +var availableTypedArrays = require('available-typed-arrays')(); + +var IsArray = require('./IsArray'); +var SpeciesConstructor = require('./SpeciesConstructor'); +var TypedArrayCreate = require('./TypedArrayCreate'); + +var getConstructor = require('../helpers/typedArrayConstructors'); + +// https://262.ecma-international.org/7.0/#typedarray-species-create + +module.exports = function TypedArraySpeciesCreate(exemplar, argumentList) { + if (availableTypedArrays.length === 0) { + throw new $SyntaxError('Assertion failed: Typed Arrays are not supported in this environment'); + } + + var kind = whichTypedArray(exemplar); + if (!kind) { + throw new $TypeError('Assertion failed: exemplar must be a TypedArray'); // step 1 + } + if (!IsArray(argumentList)) { + throw new $TypeError('Assertion failed: `argumentList` must be a List'); // step 1 + } + + var defaultConstructor = getConstructor(kind); // step 2 + if (typeof defaultConstructor !== 'function') { + throw new $SyntaxError('Assertion failed: `constructor` of `exemplar` (' + kind + ') must exist. Please report this!'); + } + var constructor = SpeciesConstructor(exemplar, defaultConstructor); // step 3 + + return TypedArrayCreate(constructor, argumentList); // step 4 +}; diff --git a/node_modules/es-abstract/2019/UTF16Decode.js b/node_modules/es-abstract/2019/UTF16Decode.js new file mode 100644 index 0000000000000000000000000000000000000000..b7dc758219e3e0aa16e6f0703584b247c71e21d5 --- /dev/null +++ b/node_modules/es-abstract/2019/UTF16Decode.js @@ -0,0 +1,21 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = require('es-errors/type'); +var $fromCharCode = GetIntrinsic('%String.fromCharCode%'); + +// https://262.ecma-international.org/7.0/#sec-utf16decode + +var isLeadingSurrogate = require('../helpers/isLeadingSurrogate'); +var isTrailingSurrogate = require('../helpers/isTrailingSurrogate'); + +// https://262.ecma-international.org/11.0/#sec-utf16decodesurrogatepair + +module.exports = function UTF16Decode(lead, trail) { + if (!isLeadingSurrogate(lead) || !isTrailingSurrogate(trail)) { + throw new $TypeError('Assertion failed: `lead` must be a leading surrogate char code, and `trail` must be a trailing surrogate char code'); + } + // var cp = (lead - 0xD800) * 0x400 + (trail - 0xDC00) + 0x10000; + return $fromCharCode(lead) + $fromCharCode(trail); +}; diff --git a/node_modules/es-abstract/2019/UTF16Encoding.js b/node_modules/es-abstract/2019/UTF16Encoding.js new file mode 100644 index 0000000000000000000000000000000000000000..81e567dc6766e5be802ce39f03d49ab930292154 --- /dev/null +++ b/node_modules/es-abstract/2019/UTF16Encoding.js @@ -0,0 +1,25 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = require('es-errors/type'); +var $fromCharCode = GetIntrinsic('%String.fromCharCode%'); + +var floor = require('./floor'); +var modulo = require('./modulo'); + +var isCodePoint = require('../helpers/isCodePoint'); + +// https://262.ecma-international.org/7.0/#sec-utf16encoding + +module.exports = function UTF16Encoding(cp) { + if (!isCodePoint(cp)) { + throw new $TypeError('Assertion failed: `cp` must be >= 0 and <= 0x10FFFF'); + } + if (cp <= 65535) { + return $fromCharCode(cp); + } + var cu1 = $fromCharCode(floor((cp - 65536) / 1024) + 0xD800); + var cu2 = $fromCharCode(modulo(cp - 65536, 1024) + 0xDC00); + return cu1 + cu2; +}; diff --git a/node_modules/es-abstract/2019/UnicodeEscape.js b/node_modules/es-abstract/2019/UnicodeEscape.js new file mode 100644 index 0000000000000000000000000000000000000000..3def927a84865e5efb0129a93b7af46936832c5d --- /dev/null +++ b/node_modules/es-abstract/2019/UnicodeEscape.js @@ -0,0 +1,24 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var callBound = require('call-bound'); + +var $charCodeAt = callBound('String.prototype.charCodeAt'); +var $numberToString = callBound('Number.prototype.toString'); +var $toLowerCase = callBound('String.prototype.toLowerCase'); +var $strSlice = callBound('String.prototype.slice'); + +// https://262.ecma-international.org/9.0/#sec-unicodeescape + +module.exports = function UnicodeEscape(C) { + if (typeof C !== 'string' || C.length !== 1) { + throw new $TypeError('Assertion failed: `C` must be a single code unit'); + } + var n = $charCodeAt(C, 0); + if (n > 0xFFFF) { + throw new $TypeError('`Assertion failed: numeric value of `C` must be <= 0xFFFF'); + } + + return '\\u' + $strSlice('0000' + $toLowerCase($numberToString(n, 16)), -4); +}; diff --git a/node_modules/es-abstract/2019/ValidateAndApplyPropertyDescriptor.js b/node_modules/es-abstract/2019/ValidateAndApplyPropertyDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..12cab5dff05ac5d79240ac4b40af54aa99c5fd5e --- /dev/null +++ b/node_modules/es-abstract/2019/ValidateAndApplyPropertyDescriptor.js @@ -0,0 +1,159 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var DefineOwnProperty = require('../helpers/DefineOwnProperty'); +var isPropertyDescriptor = require('../helpers/records/property-descriptor'); +var isSamePropertyDescriptor = require('../helpers/isSamePropertyDescriptor'); + +var FromPropertyDescriptor = require('./FromPropertyDescriptor'); +var IsAccessorDescriptor = require('./IsAccessorDescriptor'); +var IsDataDescriptor = require('./IsDataDescriptor'); +var IsGenericDescriptor = require('./IsGenericDescriptor'); +var isPropertyKey = require('../helpers/isPropertyKey'); +var SameValue = require('./SameValue'); + +// https://262.ecma-international.org/6.0/#sec-validateandapplypropertydescriptor +// https://262.ecma-international.org/8.0/#sec-validateandapplypropertydescriptor + +// eslint-disable-next-line max-lines-per-function, max-statements +module.exports = function ValidateAndApplyPropertyDescriptor(O, P, extensible, Desc, current) { + // this uses the ES2017+ logic, since it fixes a number of bugs in the ES2015 logic. + if (typeof O !== 'undefined' && !isObject(O)) { + throw new $TypeError('Assertion failed: O must be undefined or an Object'); + } + if (typeof extensible !== 'boolean') { + throw new $TypeError('Assertion failed: extensible must be a Boolean'); + } + if (!isPropertyDescriptor(Desc)) { + throw new $TypeError('Assertion failed: Desc must be a Property Descriptor'); + } + if (typeof current !== 'undefined' && !isPropertyDescriptor(current)) { + throw new $TypeError('Assertion failed: current must be a Property Descriptor, or undefined'); + } + if (typeof O !== 'undefined' && !isPropertyKey(P)) { + throw new $TypeError('Assertion failed: if O is not undefined, P must be a Property Key'); + } + if (typeof current === 'undefined') { + if (!extensible) { + return false; + } + if (IsGenericDescriptor(Desc) || IsDataDescriptor(Desc)) { + if (typeof O !== 'undefined') { + DefineOwnProperty( + IsDataDescriptor, + SameValue, + FromPropertyDescriptor, + O, + P, + { + '[[Configurable]]': Desc['[[Configurable]]'], + '[[Enumerable]]': Desc['[[Enumerable]]'], + '[[Value]]': Desc['[[Value]]'], + '[[Writable]]': Desc['[[Writable]]'] + } + ); + } + } else { + if (!IsAccessorDescriptor(Desc)) { + throw new $TypeError('Assertion failed: Desc is not an accessor descriptor'); + } + if (typeof O !== 'undefined') { + return DefineOwnProperty( + IsDataDescriptor, + SameValue, + FromPropertyDescriptor, + O, + P, + Desc + ); + } + } + return true; + } + if (IsGenericDescriptor(Desc) && !('[[Configurable]]' in Desc) && !('[[Enumerable]]' in Desc)) { + return true; + } + if (isSamePropertyDescriptor({ SameValue: SameValue }, 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 (IsGenericDescriptor(Desc)) { + // no further validation is required. + } else if (IsDataDescriptor(current) !== IsDataDescriptor(Desc)) { + if (!current['[[Configurable]]']) { + return false; + } + if (IsDataDescriptor(current)) { + if (typeof O !== 'undefined') { + DefineOwnProperty( + IsDataDescriptor, + SameValue, + FromPropertyDescriptor, + O, + P, + { + '[[Configurable]]': current['[[Configurable]]'], + '[[Enumerable]]': current['[[Enumerable]]'], + '[[Get]]': undefined + } + ); + } + } else if (typeof O !== 'undefined') { + DefineOwnProperty( + IsDataDescriptor, + SameValue, + FromPropertyDescriptor, + O, + P, + { + '[[Configurable]]': current['[[Configurable]]'], + '[[Enumerable]]': current['[[Enumerable]]'], + '[[Value]]': undefined + } + ); + } + } else if (IsDataDescriptor(current) && IsDataDescriptor(Desc)) { + if (!current['[[Configurable]]'] && !current['[[Writable]]']) { + if ('[[Writable]]' in Desc && Desc['[[Writable]]']) { + return false; + } + if ('[[Value]]' in Desc && !SameValue(Desc['[[Value]]'], current['[[Value]]'])) { + return false; + } + return true; + } + } else if (IsAccessorDescriptor(current) && IsAccessorDescriptor(Desc)) { + if (!current['[[Configurable]]']) { + if ('[[Set]]' in Desc && !SameValue(Desc['[[Set]]'], current['[[Set]]'])) { + return false; + } + if ('[[Get]]' in Desc && !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 (typeof O !== 'undefined') { + return DefineOwnProperty( + IsDataDescriptor, + SameValue, + FromPropertyDescriptor, + O, + P, + Desc + ); + } + return true; +}; diff --git a/node_modules/es-abstract/2019/ValidateAtomicAccess.js b/node_modules/es-abstract/2019/ValidateAtomicAccess.js new file mode 100644 index 0000000000000000000000000000000000000000..f902b7d18bfc3e06cba4a46dcce5099220418093 --- /dev/null +++ b/node_modules/es-abstract/2019/ValidateAtomicAccess.js @@ -0,0 +1,34 @@ +'use strict'; + +var $RangeError = require('es-errors/range'); +var $TypeError = require('es-errors/type'); + +var ToIndex = require('./ToIndex'); + +var isTypedArray = require('is-typed-array'); +var typedArrayLength = require('typed-array-length'); + +// https://262.ecma-international.org/8.0/#sec-validateatomicaccess + +module.exports = function ValidateAtomicAccess(typedArray, requestIndex) { + if (!isTypedArray(typedArray)) { + throw new $TypeError('Assertion failed: `typedArray` must be a TypedArray'); // step 1 + } + + var accessIndex = ToIndex(requestIndex); // step 2 + + var length = typedArrayLength(typedArray); // step 3 + + /* + // this assertion can never be reached + if (!(accessIndex >= 0)) { + throw new $TypeError('Assertion failed: accessIndex >= 0'); // step 4 + } + */ + + if (accessIndex >= length) { + throw new $RangeError('index out of range'); // step 5 + } + + return accessIndex; // step 6 +}; diff --git a/node_modules/es-abstract/2019/ValidateTypedArray.js b/node_modules/es-abstract/2019/ValidateTypedArray.js new file mode 100644 index 0000000000000000000000000000000000000000..87fa8d17872f4463582e77a803dc98ff0019f878 --- /dev/null +++ b/node_modules/es-abstract/2019/ValidateTypedArray.js @@ -0,0 +1,28 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var IsDetachedBuffer = require('./IsDetachedBuffer'); + +var isTypedArray = require('is-typed-array'); +var typedArrayBuffer = require('typed-array-buffer'); + +// https://262.ecma-international.org/6.0/#sec-validatetypedarray + +module.exports = function ValidateTypedArray(O) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: `O` must be an Object'); // step 1 + } + if (!isTypedArray(O)) { + throw new $TypeError('Assertion failed: `O` must be a Typed Array'); // steps 2 - 3 + } + + var buffer = typedArrayBuffer(O); // step 4 + + if (IsDetachedBuffer(buffer)) { + throw new $TypeError('`O` must be backed by a non-detached buffer'); // step 5 + } + + return buffer; // step 6 +}; diff --git a/node_modules/es-abstract/2019/WeekDay.js b/node_modules/es-abstract/2019/WeekDay.js new file mode 100644 index 0000000000000000000000000000000000000000..17cf94ca34ce0aae649c1e0236cd18f248d54e3d --- /dev/null +++ b/node_modules/es-abstract/2019/WeekDay.js @@ -0,0 +1,10 @@ +'use strict'; + +var Day = require('./Day'); +var modulo = require('./modulo'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.6 + +module.exports = function WeekDay(t) { + return modulo(Day(t) + 4, 7); +}; diff --git a/node_modules/es-abstract/2019/WordCharacters.js b/node_modules/es-abstract/2019/WordCharacters.js new file mode 100644 index 0000000000000000000000000000000000000000..36532afc9087057ccdf6fb52434e7fe523714f4d --- /dev/null +++ b/node_modules/es-abstract/2019/WordCharacters.js @@ -0,0 +1,46 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var callBound = require('call-bound'); +var $indexOf = callBound('String.prototype.indexOf'); + +var Canonicalize = require('./Canonicalize'); + +var caseFolding = require('../helpers/caseFolding.json'); +var forEach = require('../helpers/forEach'); +var OwnPropertyKeys = require('own-keys'); + +var A = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_'; // step 1 + +// https://262.ecma-international.org/8.0/#sec-runtime-semantics-wordcharacters-abstract-operation + +module.exports = function WordCharacters(IgnoreCase, Unicode) { + if (typeof IgnoreCase !== 'boolean' || typeof Unicode !== 'boolean') { + throw new $TypeError('Assertion failed: `IgnoreCase` and `Unicode` must be booleans'); + } + + var U = ''; + forEach(OwnPropertyKeys(caseFolding.C), function (c) { + if ( + $indexOf(A, c) === -1 // c not in A + && $indexOf(A, Canonicalize(c, IgnoreCase, Unicode)) > -1 // canonicalized c IS in A + ) { + U += caseFolding.C[c]; // step 3 + } + }); + forEach(OwnPropertyKeys(caseFolding.S), function (c) { + if ( + $indexOf(A, c) === -1 // c not in A + && $indexOf(A, Canonicalize(c, IgnoreCase, Unicode)) > -1 // canonicalized c IS in A + ) { + U += caseFolding.S[c]; // step 3 + } + }); + + if ((!Unicode || !IgnoreCase) && U.length > 0) { + throw new $TypeError('Assertion failed: `U` must be empty when `IgnoreCase` and `Unicode` are not both true'); // step 4 + } + + return A + U; // step 5, 6 +}; diff --git a/node_modules/es-abstract/2019/YearFromTime.js b/node_modules/es-abstract/2019/YearFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..18958182021b0ecc71645057fe8ed826ef786586 --- /dev/null +++ b/node_modules/es-abstract/2019/YearFromTime.js @@ -0,0 +1,16 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $Date = GetIntrinsic('%Date%'); + +var callBound = require('call-bound'); + +var $getUTCFullYear = callBound('Date.prototype.getUTCFullYear'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.3 + +module.exports = function YearFromTime(t) { + // largest y such that this.TimeFromYear(y) <= t + return $getUTCFullYear(new $Date(t)); +}; diff --git a/node_modules/es-abstract/2019/abs.js b/node_modules/es-abstract/2019/abs.js new file mode 100644 index 0000000000000000000000000000000000000000..342aa85c66060f7b1cf3a8773cea18b487f3f0a4 --- /dev/null +++ b/node_modules/es-abstract/2019/abs.js @@ -0,0 +1,9 @@ +'use strict'; + +var $abs = require('math-intrinsics/abs'); + +// https://262.ecma-international.org/5.1/#sec-5.2 + +module.exports = function abs(x) { + return $abs(x); +}; diff --git a/node_modules/es-abstract/2019/floor.js b/node_modules/es-abstract/2019/floor.js new file mode 100644 index 0000000000000000000000000000000000000000..cc53b951167e8f73498de0a1f0e970c52c598f80 --- /dev/null +++ b/node_modules/es-abstract/2019/floor.js @@ -0,0 +1,11 @@ +'use strict'; + +// var modulo = require('./modulo'); +var $floor = require('math-intrinsics/floor'); + +// http://262.ecma-international.org/5.1/#sec-5.2 + +module.exports = function floor(x) { + // return x - modulo(x, 1); + return $floor(x); +}; diff --git a/node_modules/es-abstract/2019/max.js b/node_modules/es-abstract/2019/max.js new file mode 100644 index 0000000000000000000000000000000000000000..f83b038a221fed3a500c72b41f5fdc31e1100827 --- /dev/null +++ b/node_modules/es-abstract/2019/max.js @@ -0,0 +1,5 @@ +'use strict'; + +// https://262.ecma-international.org/6.0/#sec-algorithm-conventions + +module.exports = require('math-intrinsics/max'); diff --git a/node_modules/es-abstract/2019/min.js b/node_modules/es-abstract/2019/min.js new file mode 100644 index 0000000000000000000000000000000000000000..3a8f50539f0a6519251299edf4169f98a6db0bd9 --- /dev/null +++ b/node_modules/es-abstract/2019/min.js @@ -0,0 +1,5 @@ +'use strict'; + +// https://262.ecma-international.org/6.0/#sec-algorithm-conventions + +module.exports = require('math-intrinsics/min'); diff --git a/node_modules/es-abstract/2019/modulo.js b/node_modules/es-abstract/2019/modulo.js new file mode 100644 index 0000000000000000000000000000000000000000..b94bb52bb3c62e45629a4b1e8f0ebba219d5e41e --- /dev/null +++ b/node_modules/es-abstract/2019/modulo.js @@ -0,0 +1,9 @@ +'use strict'; + +var mod = require('../helpers/mod'); + +// https://262.ecma-international.org/5.1/#sec-5.2 + +module.exports = function modulo(x, y) { + return mod(x, y); +}; diff --git a/node_modules/es-abstract/2019/msFromTime.js b/node_modules/es-abstract/2019/msFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..a6bae767aed31c8a467b8ea1fb2128e64860a972 --- /dev/null +++ b/node_modules/es-abstract/2019/msFromTime.js @@ -0,0 +1,11 @@ +'use strict'; + +var modulo = require('./modulo'); + +var msPerSecond = require('../helpers/timeConstants').msPerSecond; + +// https://262.ecma-international.org/5.1/#sec-15.9.1.10 + +module.exports = function msFromTime(t) { + return modulo(t, msPerSecond); +}; diff --git a/node_modules/es-abstract/2019/tables/typed-array-objects.js b/node_modules/es-abstract/2019/tables/typed-array-objects.js new file mode 100644 index 0000000000000000000000000000000000000000..629b31dc113164a392c54b8eee8ba7ebc3796435 --- /dev/null +++ b/node_modules/es-abstract/2019/tables/typed-array-objects.js @@ -0,0 +1,32 @@ +'use strict'; + +// https://262.ecma-international.org/10.0/#table-49 + +module.exports = { + __proto__: null, + name: { + __proto__: null, + $Int8Array: 'Int8', + $Uint8Array: 'Uint8', + $Uint8ClampedArray: 'Uint8C', + $Int16Array: 'Int16', + $Uint16Array: 'Uint16', + $Int32Array: 'Int32', + $Uint32Array: 'Uint32', + $Float32Array: 'Float32', + $Float64Array: 'Float64' + }, + size: { + __proto__: null, + $Int8: 1, + $Uint8: 1, + $Uint8C: 1, + $Int16: 2, + $Uint16: 2, + $Int32: 4, + $Uint32: 4, + $Float32: 4, + $Float64: 8 + }, + choices: '"Int8", "Uint8", "Uint8C", "Int16", "Uint16", "Int32", "Uint32", "Float32", or "Float64"' +}; diff --git a/node_modules/es-abstract/2019/thisBooleanValue.js b/node_modules/es-abstract/2019/thisBooleanValue.js new file mode 100644 index 0000000000000000000000000000000000000000..265fff335bed60f2a636b2fa3bf2ac113b896ff7 --- /dev/null +++ b/node_modules/es-abstract/2019/thisBooleanValue.js @@ -0,0 +1,13 @@ +'use strict'; + +var $BooleanValueOf = require('call-bound')('Boolean.prototype.valueOf'); + +// https://262.ecma-international.org/6.0/#sec-properties-of-the-boolean-prototype-object + +module.exports = function thisBooleanValue(value) { + if (typeof value === 'boolean') { + return value; + } + + return $BooleanValueOf(value); +}; diff --git a/node_modules/es-abstract/2019/thisNumberValue.js b/node_modules/es-abstract/2019/thisNumberValue.js new file mode 100644 index 0000000000000000000000000000000000000000..e2457fb3f076d4f8c500d7f5ce7b19ff4846cf2d --- /dev/null +++ b/node_modules/es-abstract/2019/thisNumberValue.js @@ -0,0 +1,16 @@ +'use strict'; + +var callBound = require('call-bound'); + +var $NumberValueOf = callBound('Number.prototype.valueOf'); + +// https://262.ecma-international.org/6.0/#sec-properties-of-the-number-prototype-object + +module.exports = function thisNumberValue(value) { + if (typeof value === 'number') { + return value; + } + + return $NumberValueOf(value); +}; + diff --git a/node_modules/es-abstract/2019/thisStringValue.js b/node_modules/es-abstract/2019/thisStringValue.js new file mode 100644 index 0000000000000000000000000000000000000000..a5c70534670cd719ca425055d597ac6b5f5994c2 --- /dev/null +++ b/node_modules/es-abstract/2019/thisStringValue.js @@ -0,0 +1,13 @@ +'use strict'; + +var $StringValueOf = require('call-bound')('String.prototype.valueOf'); + +// https://262.ecma-international.org/6.0/#sec-properties-of-the-string-prototype-object + +module.exports = function thisStringValue(value) { + if (typeof value === 'string') { + return value; + } + + return $StringValueOf(value); +}; diff --git a/node_modules/es-abstract/2019/thisSymbolValue.js b/node_modules/es-abstract/2019/thisSymbolValue.js new file mode 100644 index 0000000000000000000000000000000000000000..77342ad16a77128cddbb7c79e9eb576bbe6b126c --- /dev/null +++ b/node_modules/es-abstract/2019/thisSymbolValue.js @@ -0,0 +1,20 @@ +'use strict'; + +var $SyntaxError = require('es-errors/syntax'); +var callBound = require('call-bound'); + +var $SymbolValueOf = callBound('Symbol.prototype.valueOf', true); + +// https://262.ecma-international.org/9.0/#sec-thissymbolvalue + +module.exports = function thisSymbolValue(value) { + if (typeof value === 'symbol') { + return value; + } + + if (!$SymbolValueOf) { + throw new $SyntaxError('Symbols are not supported; thisSymbolValue requires that `value` be a Symbol or a Symbol object'); + } + + return $SymbolValueOf(value); +}; diff --git a/node_modules/es-abstract/2019/thisTimeValue.js b/node_modules/es-abstract/2019/thisTimeValue.js new file mode 100644 index 0000000000000000000000000000000000000000..f64be83fcaed6a3766a1397c1c373981c0543b1a --- /dev/null +++ b/node_modules/es-abstract/2019/thisTimeValue.js @@ -0,0 +1,9 @@ +'use strict'; + +var timeValue = require('../helpers/timeValue'); + +// https://262.ecma-international.org/6.0/#sec-properties-of-the-date-prototype-object + +module.exports = function thisTimeValue(value) { + return timeValue(value); +}; diff --git a/node_modules/es-abstract/2020/AbstractEqualityComparison.js b/node_modules/es-abstract/2020/AbstractEqualityComparison.js new file mode 100644 index 0000000000000000000000000000000000000000..dba5595b7e58d701c4a1f1baf02ae285df4ae595 --- /dev/null +++ b/node_modules/es-abstract/2020/AbstractEqualityComparison.js @@ -0,0 +1,56 @@ +'use strict'; + +var StrictEqualityComparison = require('./StrictEqualityComparison'); +var StringToBigInt = require('./StringToBigInt'); +var ToNumber = require('./ToNumber'); +var ToPrimitive = require('./ToPrimitive'); + +var isNaN = require('math-intrinsics/isNaN'); +var isObject = require('es-object-atoms/isObject'); +var isSameType = require('../helpers/isSameType'); + +// https://262.ecma-international.org/11.0/#sec-abstract-equality-comparison + +module.exports = function AbstractEqualityComparison(x, y) { + if (isSameType(x, y)) { + return StrictEqualityComparison(x, y); + } + if (x == null && y == null) { + return true; + } + if (typeof x === 'number' && typeof y === 'string') { + return AbstractEqualityComparison(x, ToNumber(y)); + } + if (typeof x === 'string' && typeof y === 'number') { + return AbstractEqualityComparison(ToNumber(x), y); + } + if (typeof x === 'bigint' && typeof y === 'string') { + var n = StringToBigInt(y); + if (isNaN(n)) { + return false; + } + return AbstractEqualityComparison(x, n); + } + if (typeof x === 'string' && typeof y === 'bigint') { + return AbstractEqualityComparison(y, x); + } + if (typeof x === 'boolean') { + return AbstractEqualityComparison(ToNumber(x), y); + } + if (typeof y === 'boolean') { + return AbstractEqualityComparison(x, ToNumber(y)); + } + if ((typeof x === 'string' || typeof x === 'number' || typeof x === 'bigint' || typeof x === 'symbol') && isObject(y)) { + return AbstractEqualityComparison(x, ToPrimitive(y)); + } + if (isObject(x) && (typeof y === 'string' || typeof y === 'number' || typeof y === 'bigint' || typeof y === 'symbol')) { + return AbstractEqualityComparison(ToPrimitive(x), y); + } + if ((typeof x === 'bigint' && typeof y === 'number') || (typeof x === 'number' && typeof y === 'bigint')) { + if (isNaN(x) || isNaN(y) || x === Infinity || y === Infinity || x === -Infinity || y === -Infinity) { + return false; + } + return x == y; // eslint-disable-line eqeqeq + } + return false; +}; diff --git a/node_modules/es-abstract/2020/AbstractRelationalComparison.js b/node_modules/es-abstract/2020/AbstractRelationalComparison.js new file mode 100644 index 0000000000000000000000000000000000000000..811c944d82e39d04a23e4f28b228b07a8655c5d3 --- /dev/null +++ b/node_modules/es-abstract/2020/AbstractRelationalComparison.js @@ -0,0 +1,80 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $Number = GetIntrinsic('%Number%'); +var $TypeError = require('es-errors/type'); + +var $isNaN = require('math-intrinsics/isNaN'); + +var IsStringPrefix = require('./IsStringPrefix'); +var StringToBigInt = require('./StringToBigInt'); +var ToNumeric = require('./ToNumeric'); +var ToPrimitive = require('./ToPrimitive'); + +var BigIntLessThan = require('./BigInt/lessThan'); +var NumberLessThan = require('./Number/lessThan'); + +var isSameType = require('../helpers/isSameType'); + +// https://262.ecma-international.org/11.0/#sec-abstract-relational-comparison + +// eslint-disable-next-line max-statements, max-lines-per-function +module.exports = function AbstractRelationalComparison(x, y, LeftFirst) { + if (typeof LeftFirst !== 'boolean') { + throw new $TypeError('Assertion failed: LeftFirst argument must be a Boolean'); + } + var px; + var py; + if (LeftFirst) { + px = ToPrimitive(x, $Number); + py = ToPrimitive(y, $Number); + } else { + py = ToPrimitive(y, $Number); + px = ToPrimitive(x, $Number); + } + if (typeof px === 'string' && typeof py === 'string') { + if (IsStringPrefix(py, px)) { + return false; + } + if (IsStringPrefix(px, py)) { + return true; + } + return px < py; // both strings, neither a prefix of the other. shortcut for steps 3 c-f + } + + var nx; + var ny; + if (typeof px === 'bigint' && typeof py === 'string') { + ny = StringToBigInt(py); + if ($isNaN(ny)) { + return void undefined; + } + return BigIntLessThan(px, ny); + } + if (typeof px === 'string' && typeof py === 'bigint') { + nx = StringToBigInt(px); + if ($isNaN(nx)) { + return void undefined; + } + return BigIntLessThan(nx, py); + } + + nx = ToNumeric(px); + ny = ToNumeric(py); + if (isSameType(nx, ny)) { + return typeof nx === 'number' ? NumberLessThan(nx, ny) : BigIntLessThan(nx, ny); + } + + if ($isNaN(nx) || $isNaN(ny)) { + return void undefined; + } + if (nx === -Infinity || ny === Infinity) { + return true; + } + if (nx === Infinity || ny === -Infinity) { + return false; + } + + return nx < ny; // by now, these are both nonzero, finite, and not equal +}; diff --git a/node_modules/es-abstract/2020/AddEntriesFromIterable.js b/node_modules/es-abstract/2020/AddEntriesFromIterable.js new file mode 100644 index 0000000000000000000000000000000000000000..8c1c1e60007d69caa21ce9bd420b5a000bcf8a24 --- /dev/null +++ b/node_modules/es-abstract/2020/AddEntriesFromIterable.js @@ -0,0 +1,44 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); +var inspect = require('object-inspect'); + +var Call = require('./Call'); +var Get = require('./Get'); +var GetIterator = require('./GetIterator'); +var IsCallable = require('./IsCallable'); +var IteratorClose = require('./IteratorClose'); +var IteratorStep = require('./IteratorStep'); +var IteratorValue = require('./IteratorValue'); +var ThrowCompletion = require('./ThrowCompletion'); + +// https://262.ecma-international.org/10.0/#sec-add-entries-from-iterable + +module.exports = function AddEntriesFromIterable(target, iterable, adder) { + if (!IsCallable(adder)) { + throw new $TypeError('Assertion failed: `adder` is not callable'); + } + if (iterable == null) { + throw new $TypeError('Assertion failed: `iterable` is present, and not nullish'); + } + var iteratorRecord = GetIterator(iterable); + while (true) { + var next = IteratorStep(iteratorRecord); + if (!next) { + return target; + } + var nextItem = IteratorValue(next); + if (!isObject(nextItem)) { + var error = ThrowCompletion(new $TypeError('iterator next must return an Object, got ' + inspect(nextItem))); + return IteratorClose(iteratorRecord, error); + } + try { + var k = Get(nextItem, '0'); + var v = Get(nextItem, '1'); + Call(adder, target, [k, v]); + } catch (e) { + return IteratorClose(iteratorRecord, ThrowCompletion(e)); + } + } +}; diff --git a/node_modules/es-abstract/2020/AdvanceStringIndex.js b/node_modules/es-abstract/2020/AdvanceStringIndex.js new file mode 100644 index 0000000000000000000000000000000000000000..5ca2b3c097c96ad428d16d52e1ca32026a3560b3 --- /dev/null +++ b/node_modules/es-abstract/2020/AdvanceStringIndex.js @@ -0,0 +1,30 @@ +'use strict'; + +var CodePointAt = require('./CodePointAt'); + +var $TypeError = require('es-errors/type'); +var isInteger = require('math-intrinsics/isInteger'); +var MAX_SAFE_INTEGER = require('math-intrinsics/constants/maxSafeInteger'); + +// https://262.ecma-international.org/11.0/#sec-advancestringindex + +module.exports = function AdvanceStringIndex(S, index, unicode) { + if (typeof S !== 'string') { + throw new $TypeError('Assertion failed: `S` must be a String'); + } + if (!isInteger(index) || index < 0 || index > MAX_SAFE_INTEGER) { + throw new $TypeError('Assertion failed: `length` must be an integer >= 0 and <= 2**53'); + } + if (typeof unicode !== 'boolean') { + throw new $TypeError('Assertion failed: `unicode` must be a Boolean'); + } + if (!unicode) { + return index + 1; + } + var length = S.length; + if ((index + 1) >= length) { + return index + 1; + } + var cp = CodePointAt(S, index); + return index + cp['[[CodeUnitCount]]']; +}; diff --git a/node_modules/es-abstract/2020/ArrayCreate.js b/node_modules/es-abstract/2020/ArrayCreate.js new file mode 100644 index 0000000000000000000000000000000000000000..8ed55aa2950b86640e487c905e4b73c543d71680 --- /dev/null +++ b/node_modules/es-abstract/2020/ArrayCreate.js @@ -0,0 +1,42 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $ArrayPrototype = GetIntrinsic('%Array.prototype%'); +var $RangeError = require('es-errors/range'); +var $SyntaxError = require('es-errors/syntax'); +var $TypeError = require('es-errors/type'); +var isInteger = require('math-intrinsics/isInteger'); +var MAX_ARRAY_LENGTH = require('math-intrinsics/constants/maxArrayLength'); +var $setProto = require('set-proto'); + +// https://262.ecma-international.org/6.0/#sec-arraycreate + +module.exports = function ArrayCreate(length) { + if (!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 + OrdinaryDefineOwnProperty(A, 'length', { + '[[Configurable]]': false, + '[[Enumerable]]': false, + '[[Value]]': length, + '[[Writable]]': true + }); + */ + return A; +}; diff --git a/node_modules/es-abstract/2020/ArraySetLength.js b/node_modules/es-abstract/2020/ArraySetLength.js new file mode 100644 index 0000000000000000000000000000000000000000..7f7a4339c2af5c8656165189f47c4212732ee1bd --- /dev/null +++ b/node_modules/es-abstract/2020/ArraySetLength.js @@ -0,0 +1,77 @@ +'use strict'; + +var $RangeError = require('es-errors/range'); +var $TypeError = require('es-errors/type'); + +var assign = require('object.assign'); + +var isPropertyDescriptor = require('../helpers/records/property-descriptor'); + +var IsArray = require('./IsArray'); +var IsDataDescriptor = require('./IsDataDescriptor'); +var OrdinaryDefineOwnProperty = require('./OrdinaryDefineOwnProperty'); +var OrdinaryGetOwnProperty = require('./OrdinaryGetOwnProperty'); +var ToNumber = require('./ToNumber'); +var ToString = require('./ToString'); +var ToUint32 = require('./ToUint32'); + +// https://262.ecma-international.org/6.0/#sec-arraysetlength + +// eslint-disable-next-line max-statements, max-lines-per-function +module.exports = function ArraySetLength(A, Desc) { + if (!IsArray(A)) { + throw new $TypeError('Assertion failed: A must be an Array'); + } + if (!isPropertyDescriptor(Desc)) { + throw new $TypeError('Assertion failed: Desc must be a Property Descriptor'); + } + if (!('[[Value]]' in Desc)) { + return OrdinaryDefineOwnProperty(A, 'length', Desc); + } + var newLenDesc = assign({}, Desc); + var newLen = ToUint32(Desc['[[Value]]']); + var numberLen = ToNumber(Desc['[[Value]]']); + if (newLen !== numberLen) { + throw new $RangeError('Invalid array length'); + } + newLenDesc['[[Value]]'] = newLen; + var oldLenDesc = OrdinaryGetOwnProperty(A, 'length'); + if (!IsDataDescriptor(oldLenDesc)) { + throw new $TypeError('Assertion failed: an array had a non-data descriptor on `length`'); + } + var oldLen = oldLenDesc['[[Value]]']; + if (newLen >= oldLen) { + return 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 = OrdinaryDefineOwnProperty(A, 'length', newLenDesc); + if (!succeeded) { + return false; + } + while (newLen < oldLen) { + oldLen -= 1; + // eslint-disable-next-line no-param-reassign + var deleteSucceeded = delete A[ToString(oldLen)]; + if (!deleteSucceeded) { + newLenDesc['[[Value]]'] = oldLen + 1; + if (!newWritable) { + newLenDesc['[[Writable]]'] = false; + OrdinaryDefineOwnProperty(A, 'length', newLenDesc); + return false; + } + } + } + if (!newWritable) { + return OrdinaryDefineOwnProperty(A, 'length', { '[[Writable]]': false }); + } + return true; +}; diff --git a/node_modules/es-abstract/2020/ArraySpeciesCreate.js b/node_modules/es-abstract/2020/ArraySpeciesCreate.js new file mode 100644 index 0000000000000000000000000000000000000000..8be185bd97d9c1d975ac93d279dd9d502790e51b --- /dev/null +++ b/node_modules/es-abstract/2020/ArraySpeciesCreate.js @@ -0,0 +1,46 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $Array = GetIntrinsic('%Array%'); +var $species = GetIntrinsic('%Symbol.species%', true); +var $TypeError = require('es-errors/type'); +var isInteger = require('math-intrinsics/isInteger'); +var isObject = require('es-object-atoms/isObject'); + +var Get = require('./Get'); +var IsArray = require('./IsArray'); +var IsConstructor = require('./IsConstructor'); + +// https://262.ecma-international.org/6.0/#sec-arrayspeciescreate + +module.exports = function ArraySpeciesCreate(originalArray, length) { + if (!isInteger(length) || length < 0) { + throw new $TypeError('Assertion failed: length must be an integer >= 0'); + } + var len = length === 0 ? 0 : length; + var C; + var isArray = IsArray(originalArray); + if (isArray) { + C = Get(originalArray, 'constructor'); + // TODO: figure out how to make a cross-realm normal Array, a same-realm Array + // if (IsConstructor(C)) { + // if C is another realm's Array, C = undefined + // Object.getPrototypeOf(Object.getPrototypeOf(Object.getPrototypeOf(Array))) === null ? + // } + if ($species && isObject(C)) { + C = Get(C, $species); + if (C === null) { + C = void 0; + } + } + } + if (typeof C === 'undefined') { + return $Array(len); + } + if (!IsConstructor(C)) { + throw new $TypeError('C must be a constructor'); + } + return new C(len); // Construct(C, len); +}; + diff --git a/node_modules/es-abstract/2020/AsyncFromSyncIteratorContinuation.js b/node_modules/es-abstract/2020/AsyncFromSyncIteratorContinuation.js new file mode 100644 index 0000000000000000000000000000000000000000..d545b6bfc70974e44350f20e4ec28812d9cbf9e2 --- /dev/null +++ b/node_modules/es-abstract/2020/AsyncFromSyncIteratorContinuation.js @@ -0,0 +1,45 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $SyntaxError = require('es-errors/syntax'); +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); +var $Promise = GetIntrinsic('%Promise%', true); + +var callBound = require('call-bound'); + +var CreateIterResultObject = require('./CreateIterResultObject'); +var IteratorComplete = require('./IteratorComplete'); +var IteratorValue = require('./IteratorValue'); +var PromiseResolve = require('./PromiseResolve'); + +var $then = callBound('Promise.prototype.then', true); + +// https://262.ecma-international.org/10.0/#sec-asyncfromsynciteratorcontinuation + +module.exports = function AsyncFromSyncIteratorContinuation(result) { + if (!isObject(result)) { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + if (arguments.length > 1) { + throw new $SyntaxError('although AsyncFromSyncIteratorContinuation should take a second argument, it is not used in this implementation'); + } + + if (!$Promise) { + throw new $SyntaxError('This environment does not support Promises.'); + } + + return new $Promise(function (resolve) { + var done = IteratorComplete(result); // step 2 + var value = IteratorValue(result); // step 4 + var valueWrapper = PromiseResolve($Promise, value); // step 6 + + // eslint-disable-next-line no-shadow + var onFulfilled = function (value) { // steps 8-9 + return CreateIterResultObject(value, done); // step 8.a + }; + resolve($then(valueWrapper, onFulfilled)); // step 11 + }); // step 12 +}; diff --git a/node_modules/es-abstract/2020/AsyncIteratorClose.js b/node_modules/es-abstract/2020/AsyncIteratorClose.js new file mode 100644 index 0000000000000000000000000000000000000000..47cbaeaf3a4974c1aab7f9f372bd826115ef6b26 --- /dev/null +++ b/node_modules/es-abstract/2020/AsyncIteratorClose.js @@ -0,0 +1,64 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $SyntaxError = require('es-errors/syntax'); +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); +var $Promise = GetIntrinsic('%Promise%', true); + +var Call = require('./Call'); +var CompletionRecord = require('./CompletionRecord'); +var GetMethod = require('./GetMethod'); + +var isIteratorRecord = require('../helpers/records/iterator-record-2023'); + +var callBound = require('call-bound'); + +var $then = callBound('Promise.prototype.then', true); + +// https://262.ecma-international.org/9.0/#sec-asynciteratorclose + +module.exports = function AsyncIteratorClose(iteratorRecord, completion) { + if (!isIteratorRecord(iteratorRecord)) { + throw new $TypeError('Assertion failed: `iteratorRecord` must be an Iterator Record'); // step 1 + } + + if (!(completion instanceof CompletionRecord)) { + throw new $TypeError('Assertion failed: completion is not a Completion Record instance'); // step 2 + } + + if (!$then) { + throw new $SyntaxError('This environment does not support Promises.'); + } + + var iterator = iteratorRecord['[[Iterator]]']; // step 3 + + return new $Promise(function (resolve) { + var ret = GetMethod(iterator, 'return'); // step 4 + + if (typeof ret === 'undefined') { + resolve(completion); // step 5 + } else { + resolve($then( + new $Promise(function (resolve2) { + // process.exit(42); + resolve2(Call(ret, iterator, [])); // step 6 + }), + function (innerResult) { + if (!isObject(innerResult)) { + throw new $TypeError('`innerResult` must be an Object'); // step 10 + } + return completion; + }, + function (e) { + if (completion.type() === 'throw') { + completion['?'](); // step 8 + } else { + throw e; // step 9 + } + } + )); + } + }); +}; diff --git a/node_modules/es-abstract/2020/BigInt/add.js b/node_modules/es-abstract/2020/BigInt/add.js new file mode 100644 index 0000000000000000000000000000000000000000..25cc9fa60f58e2433eb392a4cc0e00a0569474ba --- /dev/null +++ b/node_modules/es-abstract/2020/BigInt/add.js @@ -0,0 +1,14 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-add + +module.exports = function BigIntAdd(x, y) { + if (typeof x !== 'bigint' || typeof y !== 'bigint') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + + // shortcut for the actual spec mechanics + return x + y; +}; diff --git a/node_modules/es-abstract/2020/BigInt/bitwiseAND.js b/node_modules/es-abstract/2020/BigInt/bitwiseAND.js new file mode 100644 index 0000000000000000000000000000000000000000..106f4a273945d92cdb34715249ae5a72c1af93d8 --- /dev/null +++ b/node_modules/es-abstract/2020/BigInt/bitwiseAND.js @@ -0,0 +1,14 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var BigIntBitwiseOp = require('../BigIntBitwiseOp'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-bitwiseAND + +module.exports = function BigIntBitwiseAND(x, y) { + if (typeof x !== 'bigint' || typeof y !== 'bigint') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + return BigIntBitwiseOp('&', x, y); +}; diff --git a/node_modules/es-abstract/2020/BigInt/bitwiseNOT.js b/node_modules/es-abstract/2020/BigInt/bitwiseNOT.js new file mode 100644 index 0000000000000000000000000000000000000000..9fe67405f674c3501fe410d55c63c59874841d87 --- /dev/null +++ b/node_modules/es-abstract/2020/BigInt/bitwiseNOT.js @@ -0,0 +1,15 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $BigInt = GetIntrinsic('%BigInt%', true); +var $TypeError = require('es-errors/type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-bitwiseNOT + +module.exports = function BigIntBitwiseNOT(x) { + if (typeof x !== 'bigint') { + throw new $TypeError('Assertion failed: `x` argument must be a BigInt'); + } + return -x - $BigInt(1); +}; diff --git a/node_modules/es-abstract/2020/BigInt/bitwiseOR.js b/node_modules/es-abstract/2020/BigInt/bitwiseOR.js new file mode 100644 index 0000000000000000000000000000000000000000..b0ba812a8a321e0f92a9d446b4e5439ec898fd47 --- /dev/null +++ b/node_modules/es-abstract/2020/BigInt/bitwiseOR.js @@ -0,0 +1,14 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var BigIntBitwiseOp = require('../BigIntBitwiseOp'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-bitwiseOR + +module.exports = function BigIntBitwiseOR(x, y) { + if (typeof x !== 'bigint' || typeof y !== 'bigint') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + return BigIntBitwiseOp('|', x, y); +}; diff --git a/node_modules/es-abstract/2020/BigInt/bitwiseXOR.js b/node_modules/es-abstract/2020/BigInt/bitwiseXOR.js new file mode 100644 index 0000000000000000000000000000000000000000..79ac4a1f4568d559d69b64ba88061aabb1460c57 --- /dev/null +++ b/node_modules/es-abstract/2020/BigInt/bitwiseXOR.js @@ -0,0 +1,14 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var BigIntBitwiseOp = require('../BigIntBitwiseOp'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-bitwiseXOR + +module.exports = function BigIntBitwiseXOR(x, y) { + if (typeof x !== 'bigint' || typeof y !== 'bigint') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + return BigIntBitwiseOp('^', x, y); +}; diff --git a/node_modules/es-abstract/2020/BigInt/divide.js b/node_modules/es-abstract/2020/BigInt/divide.js new file mode 100644 index 0000000000000000000000000000000000000000..a194302eb682514dc75061f391f75fdad1f0da4e --- /dev/null +++ b/node_modules/es-abstract/2020/BigInt/divide.js @@ -0,0 +1,20 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $BigInt = GetIntrinsic('%BigInt%', true); +var $RangeError = require('es-errors/range'); +var $TypeError = require('es-errors/type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-divide + +module.exports = function BigIntDivide(x, y) { + if (typeof x !== 'bigint' || typeof y !== 'bigint') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + if (y === $BigInt(0)) { + throw new $RangeError('Division by zero'); + } + // shortcut for the actual spec mechanics + return x / y; +}; diff --git a/node_modules/es-abstract/2020/BigInt/equal.js b/node_modules/es-abstract/2020/BigInt/equal.js new file mode 100644 index 0000000000000000000000000000000000000000..d6b36a2551cb08160a812a8bab4dc3a63e751a8b --- /dev/null +++ b/node_modules/es-abstract/2020/BigInt/equal.js @@ -0,0 +1,13 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-equal + +module.exports = function BigIntEqual(x, y) { + if (typeof x !== 'bigint' || typeof y !== 'bigint') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + // shortcut for the actual spec mechanics + return x === y; +}; diff --git a/node_modules/es-abstract/2020/BigInt/exponentiate.js b/node_modules/es-abstract/2020/BigInt/exponentiate.js new file mode 100644 index 0000000000000000000000000000000000000000..f5bcdc148af1bc7658596120cbf5d72f7036c599 --- /dev/null +++ b/node_modules/es-abstract/2020/BigInt/exponentiate.js @@ -0,0 +1,29 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $BigInt = GetIntrinsic('%BigInt%', true); +var $RangeError = require('es-errors/range'); +var $TypeError = require('es-errors/type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-exponentiate + +module.exports = function BigIntExponentiate(base, exponent) { + if (typeof base !== 'bigint' || typeof exponent !== 'bigint') { + throw new $TypeError('Assertion failed: `base` and `exponent` arguments must be BigInts'); + } + if (exponent < $BigInt(0)) { + throw new $RangeError('Exponent must be positive'); + } + if (/* base === $BigInt(0) && */ exponent === $BigInt(0)) { + return $BigInt(1); + } + + var square = base; + var remaining = exponent; + while (remaining > $BigInt(0)) { + square += exponent; + --remaining; // eslint-disable-line no-plusplus + } + return square; +}; diff --git a/node_modules/es-abstract/2020/BigInt/index.js b/node_modules/es-abstract/2020/BigInt/index.js new file mode 100644 index 0000000000000000000000000000000000000000..63ec52da69e285d605f9f5db2ffe69ed4af591f2 --- /dev/null +++ b/node_modules/es-abstract/2020/BigInt/index.js @@ -0,0 +1,43 @@ +'use strict'; + +var add = require('./add'); +var bitwiseAND = require('./bitwiseAND'); +var bitwiseNOT = require('./bitwiseNOT'); +var bitwiseOR = require('./bitwiseOR'); +var bitwiseXOR = require('./bitwiseXOR'); +var divide = require('./divide'); +var equal = require('./equal'); +var exponentiate = require('./exponentiate'); +var leftShift = require('./leftShift'); +var lessThan = require('./lessThan'); +var multiply = require('./multiply'); +var remainder = require('./remainder'); +var sameValue = require('./sameValue'); +var sameValueZero = require('./sameValueZero'); +var signedRightShift = require('./signedRightShift'); +var subtract = require('./subtract'); +var toString = require('./toString'); +var unaryMinus = require('./unaryMinus'); +var unsignedRightShift = require('./unsignedRightShift'); + +module.exports = { + add: add, + bitwiseAND: bitwiseAND, + bitwiseNOT: bitwiseNOT, + bitwiseOR: bitwiseOR, + bitwiseXOR: bitwiseXOR, + divide: divide, + equal: equal, + exponentiate: exponentiate, + leftShift: leftShift, + lessThan: lessThan, + multiply: multiply, + remainder: remainder, + sameValue: sameValue, + sameValueZero: sameValueZero, + signedRightShift: signedRightShift, + subtract: subtract, + toString: toString, + unaryMinus: unaryMinus, + unsignedRightShift: unsignedRightShift +}; diff --git a/node_modules/es-abstract/2020/BigInt/leftShift.js b/node_modules/es-abstract/2020/BigInt/leftShift.js new file mode 100644 index 0000000000000000000000000000000000000000..327592ea62472441e0750d4a6e5bccc81a7a5c71 --- /dev/null +++ b/node_modules/es-abstract/2020/BigInt/leftShift.js @@ -0,0 +1,14 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-leftShift + +module.exports = function BigIntLeftShift(x, y) { + if (typeof x !== 'bigint' || typeof y !== 'bigint') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + + // shortcut for the actual spec mechanics + return x << y; +}; diff --git a/node_modules/es-abstract/2020/BigInt/lessThan.js b/node_modules/es-abstract/2020/BigInt/lessThan.js new file mode 100644 index 0000000000000000000000000000000000000000..612f2dbbc4ea4aa7e5b27781f68071baa10f8727 --- /dev/null +++ b/node_modules/es-abstract/2020/BigInt/lessThan.js @@ -0,0 +1,14 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-lessThan + +module.exports = function BigIntLessThan(x, y) { + if (typeof x !== 'bigint' || typeof y !== 'bigint') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + + // shortcut for the actual spec mechanics + return x < y; +}; diff --git a/node_modules/es-abstract/2020/BigInt/multiply.js b/node_modules/es-abstract/2020/BigInt/multiply.js new file mode 100644 index 0000000000000000000000000000000000000000..a9bfbd5936a77ce9ddaec1e442a36fc2c4eb96de --- /dev/null +++ b/node_modules/es-abstract/2020/BigInt/multiply.js @@ -0,0 +1,14 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-multiply + +module.exports = function BigIntMultiply(x, y) { + if (typeof x !== 'bigint' || typeof y !== 'bigint') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + + // shortcut for the actual spec mechanics + return x * y; +}; diff --git a/node_modules/es-abstract/2020/BigInt/remainder.js b/node_modules/es-abstract/2020/BigInt/remainder.js new file mode 100644 index 0000000000000000000000000000000000000000..60346ecdeec72fc2f63f823c80fea5a45208abab --- /dev/null +++ b/node_modules/es-abstract/2020/BigInt/remainder.js @@ -0,0 +1,28 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $BigInt = GetIntrinsic('%BigInt%', true); +var $RangeError = require('es-errors/range'); +var $TypeError = require('es-errors/type'); + +var zero = $BigInt && $BigInt(0); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-remainder + +module.exports = function BigIntRemainder(n, d) { + if (typeof n !== 'bigint' || typeof d !== 'bigint') { + throw new $TypeError('Assertion failed: `n` and `d` arguments must be BigInts'); + } + + if (d === zero) { + throw new $RangeError('Division by zero'); + } + + if (n === zero) { + return zero; + } + + // shortcut for the actual spec mechanics + return n % d; +}; diff --git a/node_modules/es-abstract/2020/BigInt/sameValue.js b/node_modules/es-abstract/2020/BigInt/sameValue.js new file mode 100644 index 0000000000000000000000000000000000000000..c4851a067c23ab5b48214b51dd6cc0744f1798ef --- /dev/null +++ b/node_modules/es-abstract/2020/BigInt/sameValue.js @@ -0,0 +1,15 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var BigIntEqual = require('./equal'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-sameValue + +module.exports = function BigIntSameValue(x, y) { + if (typeof x !== 'bigint' || typeof y !== 'bigint') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + + return BigIntEqual(x, y); +}; diff --git a/node_modules/es-abstract/2020/BigInt/sameValueZero.js b/node_modules/es-abstract/2020/BigInt/sameValueZero.js new file mode 100644 index 0000000000000000000000000000000000000000..0505ca376eb92ac77300bc70ec8c99f12bb90dc8 --- /dev/null +++ b/node_modules/es-abstract/2020/BigInt/sameValueZero.js @@ -0,0 +1,15 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var BigIntEqual = require('./equal'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-sameValueZero + +module.exports = function BigIntSameValueZero(x, y) { + if (typeof x !== 'bigint' || typeof y !== 'bigint') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + + return BigIntEqual(x, y); +}; diff --git a/node_modules/es-abstract/2020/BigInt/signedRightShift.js b/node_modules/es-abstract/2020/BigInt/signedRightShift.js new file mode 100644 index 0000000000000000000000000000000000000000..90967d66e622397fc8e7cd54ee6e1f7c5426b786 --- /dev/null +++ b/node_modules/es-abstract/2020/BigInt/signedRightShift.js @@ -0,0 +1,15 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var BigIntLeftShift = require('./leftShift'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-signedRightShift + +module.exports = function BigIntSignedRightShift(x, y) { + if (typeof x !== 'bigint' || typeof y !== 'bigint') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + + return BigIntLeftShift(x, -y); +}; diff --git a/node_modules/es-abstract/2020/BigInt/subtract.js b/node_modules/es-abstract/2020/BigInt/subtract.js new file mode 100644 index 0000000000000000000000000000000000000000..32de730a3cbea3a14df35755a24c54dcb9e5de9f --- /dev/null +++ b/node_modules/es-abstract/2020/BigInt/subtract.js @@ -0,0 +1,14 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-subtract + +module.exports = function BigIntSubtract(x, y) { + if (typeof x !== 'bigint' || typeof y !== 'bigint') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + + // shortcut for the actual spec mechanics + return x - y; +}; diff --git a/node_modules/es-abstract/2020/BigInt/toString.js b/node_modules/es-abstract/2020/BigInt/toString.js new file mode 100644 index 0000000000000000000000000000000000000000..5dc8a6a672c957e7c54eca452857436ff5794c9d --- /dev/null +++ b/node_modules/es-abstract/2020/BigInt/toString.js @@ -0,0 +1,16 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $String = GetIntrinsic('%String%'); +var $TypeError = require('es-errors/type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-tostring + +module.exports = function BigIntToString(x) { + if (typeof x !== 'bigint') { + throw new $TypeError('Assertion failed: `x` must be a BigInt'); + } + + return $String(x); +}; diff --git a/node_modules/es-abstract/2020/BigInt/unaryMinus.js b/node_modules/es-abstract/2020/BigInt/unaryMinus.js new file mode 100644 index 0000000000000000000000000000000000000000..161f02fbdba7eca7078ee2a2404f646e03b4d0be --- /dev/null +++ b/node_modules/es-abstract/2020/BigInt/unaryMinus.js @@ -0,0 +1,22 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $BigInt = GetIntrinsic('%BigInt%', true); +var $TypeError = require('es-errors/type'); + +var zero = $BigInt && $BigInt(0); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-unaryMinus + +module.exports = function BigIntUnaryMinus(x) { + if (typeof x !== 'bigint') { + throw new $TypeError('Assertion failed: `x` argument must be a BigInt'); + } + + if (x === zero) { + return zero; + } + + return -x; +}; diff --git a/node_modules/es-abstract/2020/BigInt/unsignedRightShift.js b/node_modules/es-abstract/2020/BigInt/unsignedRightShift.js new file mode 100644 index 0000000000000000000000000000000000000000..d695cb43beb3716c8015d4b83f93d6fc7307da73 --- /dev/null +++ b/node_modules/es-abstract/2020/BigInt/unsignedRightShift.js @@ -0,0 +1,13 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-unsignedRightShift + +module.exports = function BigIntUnsignedRightShift(x, y) { + if (typeof x !== 'bigint' || typeof y !== 'bigint') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + + throw new $TypeError('BigInts have no unsigned right shift, use >> instead'); +}; diff --git a/node_modules/es-abstract/2020/BigIntBitwiseOp.js b/node_modules/es-abstract/2020/BigIntBitwiseOp.js new file mode 100644 index 0000000000000000000000000000000000000000..40e1a13185c4a1b7273f3e53a48f04f9ec5161b6 --- /dev/null +++ b/node_modules/es-abstract/2020/BigIntBitwiseOp.js @@ -0,0 +1,63 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +// var $BigInt = GetIntrinsic('%BigInt%', true); +// var $pow = require('math-intrinsics/pow'); + +// var BinaryAnd = require('./BinaryAnd'); +// var BinaryOr = require('./BinaryOr'); +// var BinaryXor = require('./BinaryXor'); +// var modulo = require('./modulo'); + +// var zero = $BigInt && $BigInt(0); +// var negOne = $BigInt && $BigInt(-1); +// var two = $BigInt && $BigInt(2); + +// https://262.ecma-international.org/11.0/#sec-bigintbitwiseop + +module.exports = function BigIntBitwiseOp(op, x, y) { + if (op !== '&' && op !== '|' && op !== '^') { + throw new $TypeError('Assertion failed: `op` must be `&`, `|`, or `^`'); + } + if (typeof x !== 'bigint' || typeof y !== 'bigint') { + throw new $TypeError('`x` and `y` must be BigInts'); + } + + if (op === '&') { + return x & y; + } + if (op === '|') { + return x | y; + } + return x ^ y; + /* + var result = zero; + var shift = 0; + while (x !== zero && x !== negOne && y !== zero && y !== negOne) { + var xDigit = modulo(x, two); + var yDigit = modulo(y, two); + if (op === '&') { + result += $pow(2, shift) * BinaryAnd(xDigit, yDigit); + } else if (op === '|') { + result += $pow(2, shift) * BinaryOr(xDigit, yDigit); + } else if (op === '^') { + result += $pow(2, shift) * BinaryXor(xDigit, yDigit); + } + shift += 1; + x = (x - xDigit) / two; + y = (y - yDigit) / two; + } + var tmp; + if (op === '&') { + tmp = BinaryAnd(modulo(x, two), modulo(y, two)); + } else if (op === '|') { + tmp = BinaryAnd(modulo(x, two), modulo(y, two)); + } else { + tmp = BinaryXor(modulo(x, two), modulo(y, two)); + } + if (tmp !== 0) { + result -= $pow(2, shift); + } + return result; + */ +}; diff --git a/node_modules/es-abstract/2020/BinaryAnd.js b/node_modules/es-abstract/2020/BinaryAnd.js new file mode 100644 index 0000000000000000000000000000000000000000..bb361dea6141f1b0d447cb06b5ee18e96ea426ce --- /dev/null +++ b/node_modules/es-abstract/2020/BinaryAnd.js @@ -0,0 +1,12 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +// https://262.ecma-international.org/11.0/#sec-binaryand + +module.exports = function BinaryAnd(x, y) { + if ((x !== 0 && x !== 1) || (y !== 0 && y !== 1)) { + throw new $TypeError('Assertion failed: `x` and `y` must be either 0 or 1'); + } + return x & y; +}; diff --git a/node_modules/es-abstract/2020/BinaryOr.js b/node_modules/es-abstract/2020/BinaryOr.js new file mode 100644 index 0000000000000000000000000000000000000000..76200f8744087b5c72020f4826d5bc8f55bd3886 --- /dev/null +++ b/node_modules/es-abstract/2020/BinaryOr.js @@ -0,0 +1,12 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +// https://262.ecma-international.org/11.0/#sec-binaryor + +module.exports = function BinaryOr(x, y) { + if ((x !== 0 && x !== 1) || (y !== 0 && y !== 1)) { + throw new $TypeError('Assertion failed: `x` and `y` must be either 0 or 1'); + } + return x | y; +}; diff --git a/node_modules/es-abstract/2020/BinaryXor.js b/node_modules/es-abstract/2020/BinaryXor.js new file mode 100644 index 0000000000000000000000000000000000000000..c1da53b26c67c6379ceaa50349f7861827eb6e10 --- /dev/null +++ b/node_modules/es-abstract/2020/BinaryXor.js @@ -0,0 +1,12 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +// https://262.ecma-international.org/11.0/#sec-binaryxor + +module.exports = function BinaryXor(x, y) { + if ((x !== 0 && x !== 1) || (y !== 0 && y !== 1)) { + throw new $TypeError('Assertion failed: `x` and `y` must be either 0 or 1'); + } + return x ^ y; +}; diff --git a/node_modules/es-abstract/2020/Call.js b/node_modules/es-abstract/2020/Call.js new file mode 100644 index 0000000000000000000000000000000000000000..90b3519cb954848f531c4921eaa79ec7d37d06bd --- /dev/null +++ b/node_modules/es-abstract/2020/Call.js @@ -0,0 +1,20 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); +var callBound = require('call-bound'); + +var $TypeError = require('es-errors/type'); + +var IsArray = require('./IsArray'); + +var $apply = GetIntrinsic('%Reflect.apply%', true) || callBound('Function.prototype.apply'); + +// https://262.ecma-international.org/6.0/#sec-call + +module.exports = function Call(F, V) { + var argumentsList = arguments.length > 2 ? arguments[2] : []; + if (!IsArray(argumentsList)) { + throw new $TypeError('Assertion failed: optional `argumentsList`, if provided, must be a List'); + } + return $apply(F, V, argumentsList); +}; diff --git a/node_modules/es-abstract/2020/CanonicalNumericIndexString.js b/node_modules/es-abstract/2020/CanonicalNumericIndexString.js new file mode 100644 index 0000000000000000000000000000000000000000..74ed02f050d21c13dbfc06c80c21ae20a8e530ee --- /dev/null +++ b/node_modules/es-abstract/2020/CanonicalNumericIndexString.js @@ -0,0 +1,19 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var SameValue = require('./SameValue'); +var ToNumber = require('./ToNumber'); +var ToString = require('./ToString'); + +// https://262.ecma-international.org/6.0/#sec-canonicalnumericindexstring + +module.exports = function CanonicalNumericIndexString(argument) { + if (typeof argument !== 'string') { + throw new $TypeError('Assertion failed: `argument` must be a String'); + } + if (argument === '-0') { return -0; } + var n = ToNumber(argument); + if (SameValue(ToString(n), argument)) { return n; } + return void 0; +}; diff --git a/node_modules/es-abstract/2020/Canonicalize.js b/node_modules/es-abstract/2020/Canonicalize.js new file mode 100644 index 0000000000000000000000000000000000000000..63a58c4028e12d41fc2775615441ea23228b6719 --- /dev/null +++ b/node_modules/es-abstract/2020/Canonicalize.js @@ -0,0 +1,51 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var callBound = require('call-bound'); +var hasOwn = require('hasown'); + +var $charCodeAt = callBound('String.prototype.charCodeAt'); +var $toUpperCase = callBound('String.prototype.toUpperCase'); + +var caseFolding = require('../helpers/caseFolding.json'); + +// https://262.ecma-international.org/6.0/#sec-runtime-semantics-canonicalize-ch + +module.exports = function Canonicalize(ch, IgnoreCase, Unicode) { + if (typeof ch !== 'string') { + throw new $TypeError('Assertion failed: `ch` must be a character'); + } + + if (typeof IgnoreCase !== 'boolean' || typeof Unicode !== 'boolean') { + throw new $TypeError('Assertion failed: `IgnoreCase` and `Unicode` must be Booleans'); + } + + if (!IgnoreCase) { + return ch; // step 1 + } + + if (Unicode) { // step 2 + if (hasOwn(caseFolding.C, ch)) { + return caseFolding.C[ch]; + } + if (hasOwn(caseFolding.S, ch)) { + return caseFolding.S[ch]; + } + return ch; // step 2.b + } + + var u = $toUpperCase(ch); // step 2 + + if (u.length !== 1) { + return ch; // step 3 + } + + var cu = u; // step 4 + + if ($charCodeAt(ch, 0) >= 128 && $charCodeAt(cu, 0) < 128) { + return ch; // step 5 + } + + return cu; +}; diff --git a/node_modules/es-abstract/2020/CharacterRange.js b/node_modules/es-abstract/2020/CharacterRange.js new file mode 100644 index 0000000000000000000000000000000000000000..e41cb7870a7411344a21dfe7fbfc7cd6888b7c9e --- /dev/null +++ b/node_modules/es-abstract/2020/CharacterRange.js @@ -0,0 +1,53 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); +var callBound = require('call-bound'); + +var $fromCharCode = GetIntrinsic('%String.fromCharCode%'); +var $TypeError = require('es-errors/type'); +var $charCodeAt = callBound('String.prototype.charCodeAt'); + +var CharSet = require('../helpers/CharSet').CharSet; + +module.exports = function CharacterRange(A, B) { + var a; + var b; + + if (A instanceof CharSet || B instanceof CharSet) { + if (!(A instanceof CharSet) || !(B instanceof CharSet)) { + throw new $TypeError('Assertion failed: CharSets A and B are not both CharSets'); + } + + A.yield(function (c) { + if (typeof a !== 'undefined') { + throw new $TypeError('Assertion failed: CharSet A has more than one character'); + } + a = c; + }); + B.yield(function (c) { + if (typeof b !== 'undefined') { + throw new $TypeError('Assertion failed: CharSet B has more than one character'); + } + b = c; + }); + } else { + if (A.length !== 1 || B.length !== 1) { + throw new $TypeError('Assertion failed: CharSets A and B contain exactly one character'); + } + a = A[0]; + b = B[0]; + } + + var i = $charCodeAt(a, 0); + var j = $charCodeAt(b, 0); + + if (!(i <= j)) { + throw new $TypeError('Assertion failed: i is not <= j'); + } + + var arr = []; + for (var k = i; k <= j; k += 1) { + arr[arr.length] = $fromCharCode(k); + } + return arr; +}; diff --git a/node_modules/es-abstract/2020/CodePointAt.js b/node_modules/es-abstract/2020/CodePointAt.js new file mode 100644 index 0000000000000000000000000000000000000000..92dc860bad7992138a9e30d0a60a59c3f70e9b16 --- /dev/null +++ b/node_modules/es-abstract/2020/CodePointAt.js @@ -0,0 +1,55 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var callBound = require('call-bound'); +var isLeadingSurrogate = require('../helpers/isLeadingSurrogate'); +var isTrailingSurrogate = require('../helpers/isTrailingSurrogate'); + +var UTF16DecodeSurrogatePair = require('./UTF16DecodeSurrogatePair'); + +var $charAt = callBound('String.prototype.charAt'); +var $charCodeAt = callBound('String.prototype.charCodeAt'); + +// https://262.ecma-international.org/11.0/#sec-codepointat + +module.exports = function CodePointAt(string, position) { + if (typeof string !== 'string') { + throw new $TypeError('Assertion failed: `string` must be a String'); + } + var size = string.length; + if (position < 0 || position >= size) { + throw new $TypeError('Assertion failed: `position` must be >= 0, and < the length of `string`'); + } + var first = $charCodeAt(string, position); + var cp = $charAt(string, position); + var firstIsLeading = isLeadingSurrogate(first); + var firstIsTrailing = isTrailingSurrogate(first); + if (!firstIsLeading && !firstIsTrailing) { + return { + '[[CodePoint]]': cp, + '[[CodeUnitCount]]': 1, + '[[IsUnpairedSurrogate]]': false + }; + } + if (firstIsTrailing || (position + 1 === size)) { + return { + '[[CodePoint]]': cp, + '[[CodeUnitCount]]': 1, + '[[IsUnpairedSurrogate]]': true + }; + } + var second = $charCodeAt(string, position + 1); + if (!isTrailingSurrogate(second)) { + return { + '[[CodePoint]]': cp, + '[[CodeUnitCount]]': 1, + '[[IsUnpairedSurrogate]]': true + }; + } + + return { + '[[CodePoint]]': UTF16DecodeSurrogatePair(first, second), + '[[CodeUnitCount]]': 2, + '[[IsUnpairedSurrogate]]': false + }; +}; diff --git a/node_modules/es-abstract/2020/CompletePropertyDescriptor.js b/node_modules/es-abstract/2020/CompletePropertyDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..8c9e3f441111638a3b3c9fd69857d3da22c779ee --- /dev/null +++ b/node_modules/es-abstract/2020/CompletePropertyDescriptor.js @@ -0,0 +1,43 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var hasOwn = require('hasown'); + +var IsDataDescriptor = require('./IsDataDescriptor'); +var IsGenericDescriptor = require('./IsGenericDescriptor'); + +var isPropertyDescriptor = require('../helpers/records/property-descriptor'); + +// https://262.ecma-international.org/6.0/#sec-completepropertydescriptor + +module.exports = function CompletePropertyDescriptor(Desc) { + if (!isPropertyDescriptor(Desc)) { + throw new $TypeError('Assertion failed: `Desc` must be a Property Descriptor'); + } + + /* eslint no-param-reassign: 0 */ + + if (IsGenericDescriptor(Desc) || IsDataDescriptor(Desc)) { + if (!hasOwn(Desc, '[[Value]]')) { + Desc['[[Value]]'] = void 0; + } + if (!hasOwn(Desc, '[[Writable]]')) { + Desc['[[Writable]]'] = false; + } + } else { + if (!hasOwn(Desc, '[[Get]]')) { + Desc['[[Get]]'] = void 0; + } + if (!hasOwn(Desc, '[[Set]]')) { + Desc['[[Set]]'] = void 0; + } + } + if (!hasOwn(Desc, '[[Enumerable]]')) { + Desc['[[Enumerable]]'] = false; + } + if (!hasOwn(Desc, '[[Configurable]]')) { + Desc['[[Configurable]]'] = false; + } + return Desc; +}; diff --git a/node_modules/es-abstract/2020/CompletionRecord.js b/node_modules/es-abstract/2020/CompletionRecord.js new file mode 100644 index 0000000000000000000000000000000000000000..0a7a6817c87e69578cfbc5546901b1c4dba112a9 --- /dev/null +++ b/node_modules/es-abstract/2020/CompletionRecord.js @@ -0,0 +1,48 @@ +'use strict'; + +var $SyntaxError = require('es-errors/syntax'); + +var SLOT = require('internal-slot'); + +// https://262.ecma-international.org/7.0/#sec-completion-record-specification-type + +var CompletionRecord = function CompletionRecord(type, value) { + if (!(this instanceof CompletionRecord)) { + return new CompletionRecord(type, value); + } + if (type !== 'normal' && type !== 'break' && type !== 'continue' && type !== 'return' && type !== 'throw') { + throw new $SyntaxError('Assertion failed: `type` must be one of "normal", "break", "continue", "return", or "throw"'); + } + SLOT.set(this, '[[Type]]', type); + SLOT.set(this, '[[Value]]', value); + // [[Target]] slot? +}; + +CompletionRecord.prototype.type = function Type() { + return SLOT.get(this, '[[Type]]'); +}; + +CompletionRecord.prototype.value = function Value() { + return SLOT.get(this, '[[Value]]'); +}; + +CompletionRecord.prototype['?'] = function ReturnIfAbrupt() { + var type = SLOT.get(this, '[[Type]]'); + var value = SLOT.get(this, '[[Value]]'); + + if (type === 'throw') { + throw value; + } + return value; +}; + +CompletionRecord.prototype['!'] = function assert() { + var type = SLOT.get(this, '[[Type]]'); + + if (type !== 'normal') { + throw new $SyntaxError('Assertion failed: Completion Record is not of type "normal"'); + } + return SLOT.get(this, '[[Value]]'); +}; + +module.exports = CompletionRecord; diff --git a/node_modules/es-abstract/2020/CopyDataProperties.js b/node_modules/es-abstract/2020/CopyDataProperties.js new file mode 100644 index 0000000000000000000000000000000000000000..bdd70f1ad704eaacc5759d110238d5ea8d138e46 --- /dev/null +++ b/node_modules/es-abstract/2020/CopyDataProperties.js @@ -0,0 +1,62 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); +var callBound = require('call-bound'); +var OwnPropertyKeys = require('own-keys'); + +var every = require('../helpers/every'); +var forEach = require('../helpers/forEach'); + +var $isEnumerable = callBound('Object.prototype.propertyIsEnumerable'); + +var CreateDataPropertyOrThrow = require('./CreateDataPropertyOrThrow'); +var Get = require('./Get'); +var IsArray = require('./IsArray'); +var IsInteger = require('./IsInteger'); +var isPropertyKey = require('../helpers/isPropertyKey'); +var SameValue = require('./SameValue'); +var ToNumber = require('./ToNumber'); +var ToObject = require('./ToObject'); + +// https://262.ecma-international.org/11.0/#sec-copydataproperties + +module.exports = function CopyDataProperties(target, source, excludedItems) { + if (!isObject(target)) { + throw new $TypeError('Assertion failed: "target" must be an Object'); + } + + if (!IsArray(excludedItems) || !every(excludedItems, isPropertyKey)) { + throw new $TypeError('Assertion failed: "excludedItems" must be a List of Property Keys'); + } + + if (typeof source === 'undefined' || source === null) { + return target; + } + + var from = ToObject(source); + + var sourceKeys = OwnPropertyKeys(from); + forEach(sourceKeys, function (nextKey) { + var excluded = false; + + forEach(excludedItems, function (e) { + if (SameValue(e, nextKey) === true) { + excluded = true; + } + }); + + var enumerable = $isEnumerable(from, nextKey) || ( + // this is to handle string keys being non-enumerable in older engines + typeof source === 'string' + && nextKey >= 0 + && IsInteger(ToNumber(nextKey)) + ); + if (excluded === false && enumerable) { + var propValue = Get(from, nextKey); + CreateDataPropertyOrThrow(target, nextKey, propValue); + } + }); + + return target; +}; diff --git a/node_modules/es-abstract/2020/CreateAsyncFromSyncIterator.js b/node_modules/es-abstract/2020/CreateAsyncFromSyncIterator.js new file mode 100644 index 0000000000000000000000000000000000000000..33c02bebc80cfdf01f16758e05a21b6d1ff7720c --- /dev/null +++ b/node_modules/es-abstract/2020/CreateAsyncFromSyncIterator.js @@ -0,0 +1,137 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $SyntaxError = require('es-errors/syntax'); +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); +var $Promise = GetIntrinsic('%Promise%', true); + +var AsyncFromSyncIteratorContinuation = require('./AsyncFromSyncIteratorContinuation'); +var Call = require('./Call'); +var CreateIterResultObject = require('./CreateIterResultObject'); +var Get = require('./Get'); +var GetMethod = require('./GetMethod'); +var IteratorNext = require('./IteratorNext'); +var OrdinaryObjectCreate = require('./OrdinaryObjectCreate'); + +var isIteratorRecord = require('../helpers/records/iterator-record-2023'); + +var SLOT = require('internal-slot'); + +var $AsyncFromSyncIteratorPrototype = GetIntrinsic('%AsyncFromSyncIteratorPrototype%', true) || { + next: function next(value) { + if (!$Promise) { + throw new $SyntaxError('This environment does not support Promises.'); + } + + var O = this; // step 1 + + SLOT.assert(O, '[[SyncIteratorRecord]]'); // step 2 + + var argsLength = arguments.length; + + return new $Promise(function (resolve) { // step 3 + var syncIteratorRecord = SLOT.get(O, '[[SyncIteratorRecord]]'); // step 4 + var result; + if (argsLength > 0) { + result = IteratorNext(syncIteratorRecord['[[Iterator]]'], value); // step 5.a + } else { // step 6 + result = IteratorNext(syncIteratorRecord['[[Iterator]]']);// step 6.a + } + resolve(AsyncFromSyncIteratorContinuation(result)); // step 8 + }); + }, + 'return': function () { + if (!$Promise) { + throw new $SyntaxError('This environment does not support Promises.'); + } + + var O = this; // step 1 + + SLOT.assert(O, '[[SyncIteratorRecord]]'); // step 2 + + var valueIsPresent = arguments.length > 0; + var value = valueIsPresent ? arguments[0] : void undefined; + + return new $Promise(function (resolve, reject) { // step 3 + var syncIterator = SLOT.get(O, '[[SyncIteratorRecord]]')['[[Iterator]]']; // step 4 + var iteratorReturn = GetMethod(syncIterator, 'return'); // step 5 + + if (typeof iteratorReturn === 'undefined') { // step 7 + var iterResult = CreateIterResultObject(value, true); // step 7.a + Call(resolve, undefined, [iterResult]); // step 7.b + return; + } + var result; + if (valueIsPresent) { // step 8 + result = Call(iteratorReturn, syncIterator, [value]); // step 8.a + } else { // step 9 + result = Call(iteratorReturn, syncIterator); // step 9.a + } + if (!isObject(result)) { // step 11 + Call(reject, undefined, [new $TypeError('Iterator `return` method returned a non-object value.')]); // step 11.a + return; + } + + resolve(AsyncFromSyncIteratorContinuation(result)); // step 12 + }); + }, + 'throw': function () { + if (!$Promise) { + throw new $SyntaxError('This environment does not support Promises.'); + } + + var O = this; // step 1 + + SLOT.assert(O, '[[SyncIteratorRecord]]'); // step 2 + + var valueIsPresent = arguments.length > 0; + var value = valueIsPresent ? arguments[0] : void undefined; + + return new $Promise(function (resolve, reject) { // step 3 + var syncIterator = SLOT.get(O, '[[SyncIteratorRecord]]')['[[Iterator]]']; // step 4 + + var throwMethod = GetMethod(syncIterator, 'throw'); // step 5 + + if (typeof throwMethod === 'undefined') { // step 7 + Call(reject, undefined, [value]); // step 7.a + return; + } + + var result; + if (valueIsPresent) { // step 8 + result = Call(throwMethod, syncIterator, [value]); // step 8.a + } else { // step 9 + result = Call(throwMethod, syncIterator); // step 9.a + } + if (!isObject(result)) { // step 11 + Call(reject, undefined, [new $TypeError('Iterator `throw` method returned a non-object value.')]); // step 11.a + return; + } + + resolve(AsyncFromSyncIteratorContinuation(result/* , promiseCapability */)); // step 12 + }); + } +}; + +// https://262.ecma-international.org/11.0/#sec-createasyncfromsynciterator + +module.exports = function CreateAsyncFromSyncIterator(syncIteratorRecord) { + if (!isIteratorRecord(syncIteratorRecord)) { + throw new $TypeError('Assertion failed: `syncIteratorRecord` must be an Iterator Record'); + } + + // var asyncIterator = OrdinaryObjectCreate(%AsyncFromSyncIteratorPrototype%, « [[SyncIteratorRecord]] »); // step 1 + var asyncIterator = OrdinaryObjectCreate($AsyncFromSyncIteratorPrototype); + + SLOT.set(asyncIterator, '[[SyncIteratorRecord]]', syncIteratorRecord); // step 2 + + var nextMethod = Get(asyncIterator, 'next'); // step 3 + + return { // steps 3-4 + '[[Iterator]]': asyncIterator, + '[[NextMethod]]': nextMethod, + '[[Done]]': false + }; +}; diff --git a/node_modules/es-abstract/2020/CreateDataProperty.js b/node_modules/es-abstract/2020/CreateDataProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..897617c0ca1e0365cb55a83855b0983550e3e298 --- /dev/null +++ b/node_modules/es-abstract/2020/CreateDataProperty.js @@ -0,0 +1,25 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var isPropertyKey = require('../helpers/isPropertyKey'); +var OrdinaryDefineOwnProperty = require('./OrdinaryDefineOwnProperty'); + +// https://262.ecma-international.org/6.0/#sec-createdataproperty + +module.exports = function CreateDataProperty(O, P, V) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: P is not a Property Key'); + } + var newDesc = { + '[[Configurable]]': true, + '[[Enumerable]]': true, + '[[Value]]': V, + '[[Writable]]': true + }; + return OrdinaryDefineOwnProperty(O, P, newDesc); +}; diff --git a/node_modules/es-abstract/2020/CreateDataPropertyOrThrow.js b/node_modules/es-abstract/2020/CreateDataPropertyOrThrow.js new file mode 100644 index 0000000000000000000000000000000000000000..42327aaef58a8ffc3c320851135e886106dcbad6 --- /dev/null +++ b/node_modules/es-abstract/2020/CreateDataPropertyOrThrow.js @@ -0,0 +1,24 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var CreateDataProperty = require('./CreateDataProperty'); + +var isPropertyKey = require('../helpers/isPropertyKey'); + +// // https://262.ecma-international.org/6.0/#sec-createdatapropertyorthrow + +module.exports = function CreateDataPropertyOrThrow(O, P, V) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: P is not a Property Key'); + } + var success = CreateDataProperty(O, P, V); + if (!success) { + throw new $TypeError('unable to create data property'); + } + return success; +}; diff --git a/node_modules/es-abstract/2020/CreateHTML.js b/node_modules/es-abstract/2020/CreateHTML.js new file mode 100644 index 0000000000000000000000000000000000000000..25630f43085954792b398e93a870ac78b46e3fc4 --- /dev/null +++ b/node_modules/es-abstract/2020/CreateHTML.js @@ -0,0 +1,27 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var callBound = require('call-bound'); + +var $replace = callBound('String.prototype.replace'); + +var RequireObjectCoercible = require('./RequireObjectCoercible'); +var ToString = require('./ToString'); + +// https://262.ecma-international.org/6.0/#sec-createhtml + +module.exports = function CreateHTML(string, tag, attribute, value) { + if (typeof tag !== 'string' || typeof attribute !== 'string') { + throw new $TypeError('Assertion failed: `tag` and `attribute` must be strings'); + } + var str = RequireObjectCoercible(string); + var S = ToString(str); + var p1 = '<' + tag; + if (attribute !== '') { + var V = ToString(value); + var escapedV = $replace(V, /\x22/g, '"'); + p1 += '\x20' + attribute + '\x3D\x22' + escapedV + '\x22'; + } + return p1 + '>' + S + ''; +}; diff --git a/node_modules/es-abstract/2020/CreateIterResultObject.js b/node_modules/es-abstract/2020/CreateIterResultObject.js new file mode 100644 index 0000000000000000000000000000000000000000..679bdf00ea851b40cce0dc9e6d55526aa9d5c5d7 --- /dev/null +++ b/node_modules/es-abstract/2020/CreateIterResultObject.js @@ -0,0 +1,15 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +// https://262.ecma-international.org/6.0/#sec-createiterresultobject + +module.exports = function CreateIterResultObject(value, done) { + if (typeof done !== 'boolean') { + throw new $TypeError('Assertion failed: Type(done) is not Boolean'); + } + return { + value: value, + done: done + }; +}; diff --git a/node_modules/es-abstract/2020/CreateListFromArrayLike.js b/node_modules/es-abstract/2020/CreateListFromArrayLike.js new file mode 100644 index 0000000000000000000000000000000000000000..20290eb0bcf5f25bc36767d972398643e77efed0 --- /dev/null +++ b/node_modules/es-abstract/2020/CreateListFromArrayLike.js @@ -0,0 +1,46 @@ +'use strict'; + +var callBound = require('call-bound'); + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); +var $indexOf = callBound('Array.prototype.indexOf', true) || callBound('String.prototype.indexOf'); + +var Get = require('./Get'); +var IsArray = require('./IsArray'); +var LengthOfArrayLike = require('./LengthOfArrayLike'); +var ToString = require('./ToString'); +var Type = require('./Type'); + +var defaultElementTypes = ['Undefined', 'Null', 'Boolean', 'String', 'Symbol', 'Number', 'BigInt', 'Object']; + +// https://262.ecma-international.org/11.0/#sec-createlistfromarraylike + +/** @type {(obj: object, elementTypes?: typeof defaultElementTypes) => unknown[]} */ +module.exports = function CreateListFromArrayLike(obj) { + var elementTypes = arguments.length > 1 + ? arguments[1] + : defaultElementTypes; + + if (!isObject(obj)) { + throw new $TypeError('Assertion failed: `obj` must be an Object'); + } + if (!IsArray(elementTypes)) { + throw new $TypeError('Assertion failed: `elementTypes`, if provided, must be an array'); + } + var len = LengthOfArrayLike(obj); + /** @type {(typeof elementTypes)[]} */ + var list = []; + var index = 0; + while (index < len) { + var indexName = ToString(index); + var next = Get(obj, indexName); + var nextType = Type(next); + if ($indexOf(elementTypes, nextType) < 0) { + throw new $TypeError('item type ' + nextType + ' is not a valid elementType'); + } + list[list.length] = next; + index += 1; + } + return list; +}; diff --git a/node_modules/es-abstract/2020/CreateMethodProperty.js b/node_modules/es-abstract/2020/CreateMethodProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..4c53a40986ad2c0f6678b161465bca1ba569dd21 --- /dev/null +++ b/node_modules/es-abstract/2020/CreateMethodProperty.js @@ -0,0 +1,38 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var DefineOwnProperty = require('../helpers/DefineOwnProperty'); + +var FromPropertyDescriptor = require('./FromPropertyDescriptor'); +var IsDataDescriptor = require('./IsDataDescriptor'); +var isPropertyKey = require('../helpers/isPropertyKey'); +var SameValue = require('./SameValue'); + +// https://262.ecma-international.org/6.0/#sec-createmethodproperty + +module.exports = function CreateMethodProperty(O, P, V) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: P is not a Property Key'); + } + + var newDesc = { + '[[Configurable]]': true, + '[[Enumerable]]': false, + '[[Value]]': V, + '[[Writable]]': true + }; + return DefineOwnProperty( + IsDataDescriptor, + SameValue, + FromPropertyDescriptor, + O, + P, + newDesc + ); +}; diff --git a/node_modules/es-abstract/2020/CreateRegExpStringIterator.js b/node_modules/es-abstract/2020/CreateRegExpStringIterator.js new file mode 100644 index 0000000000000000000000000000000000000000..d7cc09963e2b8c33147bd8285d986e86d80201ea --- /dev/null +++ b/node_modules/es-abstract/2020/CreateRegExpStringIterator.js @@ -0,0 +1,100 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); +var hasSymbols = require('has-symbols')(); + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); +var IteratorPrototype = GetIntrinsic('%IteratorPrototype%', true); + +var AdvanceStringIndex = require('./AdvanceStringIndex'); +var CreateIterResultObject = require('./CreateIterResultObject'); +var CreateMethodProperty = require('./CreateMethodProperty'); +var Get = require('./Get'); +var OrdinaryObjectCreate = require('./OrdinaryObjectCreate'); +var RegExpExec = require('./RegExpExec'); +var Set = require('./Set'); +var ToLength = require('./ToLength'); +var ToString = require('./ToString'); + +var SLOT = require('internal-slot'); +var setToStringTag = require('es-set-tostringtag'); + +var RegExpStringIterator = function RegExpStringIterator(R, S, global, fullUnicode) { + if (typeof S !== 'string') { + throw new $TypeError('`S` must be a string'); + } + if (typeof global !== 'boolean') { + throw new $TypeError('`global` must be a boolean'); + } + if (typeof fullUnicode !== 'boolean') { + throw new $TypeError('`fullUnicode` must be a boolean'); + } + SLOT.set(this, '[[IteratingRegExp]]', R); + SLOT.set(this, '[[IteratedString]]', S); + SLOT.set(this, '[[Global]]', global); + SLOT.set(this, '[[Unicode]]', fullUnicode); + SLOT.set(this, '[[Done]]', false); +}; + +if (IteratorPrototype) { + RegExpStringIterator.prototype = OrdinaryObjectCreate(IteratorPrototype); +} + +var RegExpStringIteratorNext = function next() { + var O = this; + if (!isObject(O)) { + throw new $TypeError('receiver must be an object'); + } + if ( + !(O instanceof RegExpStringIterator) + || !SLOT.has(O, '[[IteratingRegExp]]') + || !SLOT.has(O, '[[IteratedString]]') + || !SLOT.has(O, '[[Global]]') + || !SLOT.has(O, '[[Unicode]]') + || !SLOT.has(O, '[[Done]]') + ) { + throw new $TypeError('"this" value must be a RegExpStringIterator instance'); + } + if (SLOT.get(O, '[[Done]]')) { + return CreateIterResultObject(undefined, true); + } + var R = SLOT.get(O, '[[IteratingRegExp]]'); + var S = SLOT.get(O, '[[IteratedString]]'); + var global = SLOT.get(O, '[[Global]]'); + var fullUnicode = SLOT.get(O, '[[Unicode]]'); + var match = RegExpExec(R, S); + if (match === null) { + SLOT.set(O, '[[Done]]', true); + return CreateIterResultObject(undefined, true); + } + if (global) { + var matchStr = ToString(Get(match, '0')); + if (matchStr === '') { + var thisIndex = ToLength(Get(R, 'lastIndex')); + var nextIndex = AdvanceStringIndex(S, thisIndex, fullUnicode); + Set(R, 'lastIndex', nextIndex, true); + } + return CreateIterResultObject(match, false); + } + SLOT.set(O, '[[Done]]', true); + return CreateIterResultObject(match, false); +}; +CreateMethodProperty(RegExpStringIterator.prototype, 'next', RegExpStringIteratorNext); + +if (hasSymbols) { + setToStringTag(RegExpStringIterator.prototype, 'RegExp String Iterator'); + + if (Symbol.iterator && typeof RegExpStringIterator.prototype[Symbol.iterator] !== 'function') { + var iteratorFn = function SymbolIterator() { + return this; + }; + CreateMethodProperty(RegExpStringIterator.prototype, Symbol.iterator, iteratorFn); + } +} + +// https://262.ecma-international.org/11.0/#sec-createregexpstringiterator +module.exports = function CreateRegExpStringIterator(R, S, global, fullUnicode) { + // assert R.global === global && R.unicode === fullUnicode? + return new RegExpStringIterator(R, S, global, fullUnicode); +}; diff --git a/node_modules/es-abstract/2020/DateFromTime.js b/node_modules/es-abstract/2020/DateFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..ec7edcd295f8bdd79eb60e44d8a17bb0b90fd80d --- /dev/null +++ b/node_modules/es-abstract/2020/DateFromTime.js @@ -0,0 +1,52 @@ +'use strict'; + +var $EvalError = require('es-errors/eval'); + +var DayWithinYear = require('./DayWithinYear'); +var InLeapYear = require('./InLeapYear'); +var MonthFromTime = require('./MonthFromTime'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.5 + +module.exports = function DateFromTime(t) { + var m = MonthFromTime(t); + var d = DayWithinYear(t); + if (m === 0) { + return d + 1; + } + if (m === 1) { + return d - 30; + } + var leap = InLeapYear(t); + if (m === 2) { + return d - 58 - leap; + } + if (m === 3) { + return d - 89 - leap; + } + if (m === 4) { + return d - 119 - leap; + } + if (m === 5) { + return d - 150 - leap; + } + if (m === 6) { + return d - 180 - leap; + } + if (m === 7) { + return d - 211 - leap; + } + if (m === 8) { + return d - 242 - leap; + } + if (m === 9) { + return d - 272 - leap; + } + if (m === 10) { + return d - 303 - leap; + } + if (m === 11) { + return d - 333 - leap; + } + throw new $EvalError('Assertion failed: MonthFromTime returned an impossible value: ' + m); +}; diff --git a/node_modules/es-abstract/2020/DateString.js b/node_modules/es-abstract/2020/DateString.js new file mode 100644 index 0000000000000000000000000000000000000000..8106127a7d9e7708279035a2488e66cd49bbd5cb --- /dev/null +++ b/node_modules/es-abstract/2020/DateString.js @@ -0,0 +1,27 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var weekdays = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']; +var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; + +var $isNaN = require('math-intrinsics/isNaN'); +var padTimeComponent = require('../helpers/padTimeComponent'); + +var DateFromTime = require('./DateFromTime'); +var MonthFromTime = require('./MonthFromTime'); +var WeekDay = require('./WeekDay'); +var YearFromTime = require('./YearFromTime'); + +// https://262.ecma-international.org/9.0/#sec-datestring + +module.exports = function DateString(tv) { + if (typeof tv !== 'number' || $isNaN(tv)) { + throw new $TypeError('Assertion failed: `tv` must be a non-NaN Number'); + } + var weekday = weekdays[WeekDay(tv)]; + var month = months[MonthFromTime(tv)]; + var day = padTimeComponent(DateFromTime(tv)); + var year = padTimeComponent(YearFromTime(tv), 4); + return weekday + '\x20' + month + '\x20' + day + '\x20' + year; +}; diff --git a/node_modules/es-abstract/2020/Day.js b/node_modules/es-abstract/2020/Day.js new file mode 100644 index 0000000000000000000000000000000000000000..51d01033c81cbd356ff4da8010c166137364237d --- /dev/null +++ b/node_modules/es-abstract/2020/Day.js @@ -0,0 +1,11 @@ +'use strict'; + +var floor = require('./floor'); + +var msPerDay = require('../helpers/timeConstants').msPerDay; + +// https://262.ecma-international.org/5.1/#sec-15.9.1.2 + +module.exports = function Day(t) { + return floor(t / msPerDay); +}; diff --git a/node_modules/es-abstract/2020/DayFromYear.js b/node_modules/es-abstract/2020/DayFromYear.js new file mode 100644 index 0000000000000000000000000000000000000000..341bf22a6c19352ec6225944fb49adeed22983e8 --- /dev/null +++ b/node_modules/es-abstract/2020/DayFromYear.js @@ -0,0 +1,10 @@ +'use strict'; + +var floor = require('./floor'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.3 + +module.exports = function DayFromYear(y) { + return (365 * (y - 1970)) + floor((y - 1969) / 4) - floor((y - 1901) / 100) + floor((y - 1601) / 400); +}; + diff --git a/node_modules/es-abstract/2020/DayWithinYear.js b/node_modules/es-abstract/2020/DayWithinYear.js new file mode 100644 index 0000000000000000000000000000000000000000..4c580940a58c58dcc3f7c2f96c5bca8e8237ebfc --- /dev/null +++ b/node_modules/es-abstract/2020/DayWithinYear.js @@ -0,0 +1,11 @@ +'use strict'; + +var Day = require('./Day'); +var DayFromYear = require('./DayFromYear'); +var YearFromTime = require('./YearFromTime'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.4 + +module.exports = function DayWithinYear(t) { + return Day(t) - DayFromYear(YearFromTime(t)); +}; diff --git a/node_modules/es-abstract/2020/DaysInYear.js b/node_modules/es-abstract/2020/DaysInYear.js new file mode 100644 index 0000000000000000000000000000000000000000..7116c69027022323e41130f384db7cc3d35709f9 --- /dev/null +++ b/node_modules/es-abstract/2020/DaysInYear.js @@ -0,0 +1,18 @@ +'use strict'; + +var modulo = require('./modulo'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.3 + +module.exports = function DaysInYear(y) { + if (modulo(y, 4) !== 0) { + return 365; + } + if (modulo(y, 100) !== 0) { + return 366; + } + if (modulo(y, 400) !== 0) { + return 365; + } + return 366; +}; diff --git a/node_modules/es-abstract/2020/DefinePropertyOrThrow.js b/node_modules/es-abstract/2020/DefinePropertyOrThrow.js new file mode 100644 index 0000000000000000000000000000000000000000..ff6683c3dc954ec27c072032bfcc0cfd70936587 --- /dev/null +++ b/node_modules/es-abstract/2020/DefinePropertyOrThrow.js @@ -0,0 +1,39 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var isPropertyDescriptor = require('../helpers/records/property-descriptor'); +var DefineOwnProperty = require('../helpers/DefineOwnProperty'); + +var FromPropertyDescriptor = require('./FromPropertyDescriptor'); +var IsDataDescriptor = require('./IsDataDescriptor'); +var isPropertyKey = require('../helpers/isPropertyKey'); +var SameValue = require('./SameValue'); +var ToPropertyDescriptor = require('./ToPropertyDescriptor'); + +// https://262.ecma-international.org/6.0/#sec-definepropertyorthrow + +module.exports = function DefinePropertyOrThrow(O, P, desc) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: P is not a Property Key'); + } + + var Desc = isPropertyDescriptor(desc) ? desc : ToPropertyDescriptor(desc); + if (!isPropertyDescriptor(Desc)) { + throw new $TypeError('Assertion failed: Desc is not a valid Property Descriptor'); + } + + return DefineOwnProperty( + IsDataDescriptor, + SameValue, + FromPropertyDescriptor, + O, + P, + Desc + ); +}; diff --git a/node_modules/es-abstract/2020/DeletePropertyOrThrow.js b/node_modules/es-abstract/2020/DeletePropertyOrThrow.js new file mode 100644 index 0000000000000000000000000000000000000000..8841fda81f7663673367bdfc1af99794fb0ef747 --- /dev/null +++ b/node_modules/es-abstract/2020/DeletePropertyOrThrow.js @@ -0,0 +1,25 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var isPropertyKey = require('../helpers/isPropertyKey'); + +// https://262.ecma-international.org/6.0/#sec-deletepropertyorthrow + +module.exports = function DeletePropertyOrThrow(O, P) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: P is not a Property Key'); + } + + // eslint-disable-next-line no-param-reassign + var success = delete O[P]; + if (!success) { + throw new $TypeError('Attempt to delete property failed.'); + } + return success; +}; diff --git a/node_modules/es-abstract/2020/DetachArrayBuffer.js b/node_modules/es-abstract/2020/DetachArrayBuffer.js new file mode 100644 index 0000000000000000000000000000000000000000..6ded9de5652c4483ba14060ba82380eb3e63d92a --- /dev/null +++ b/node_modules/es-abstract/2020/DetachArrayBuffer.js @@ -0,0 +1,46 @@ +'use strict'; + +var $SyntaxError = require('es-errors/syntax'); +var $TypeError = require('es-errors/type'); + +var IsDetachedBuffer = require('./IsDetachedBuffer'); + +var isArrayBuffer = require('is-array-buffer'); +var isSharedArrayBuffer = require('is-shared-array-buffer'); + +var MessageChannel; +try { + // eslint-disable-next-line global-require + MessageChannel = require('worker_threads').MessageChannel; +} catch (e) { /**/ } + +// https://262.ecma-international.org/9.0/#sec-detacharraybuffer + +/* globals postMessage */ + +module.exports = function DetachArrayBuffer(arrayBuffer) { + if (!isArrayBuffer(arrayBuffer) || isSharedArrayBuffer(arrayBuffer)) { + throw new $TypeError('Assertion failed: `arrayBuffer` must be an Object with an [[ArrayBufferData]] internal slot, and not a Shared Array Buffer'); + } + + // commented out since there's no way to set or access this key + // var key = arguments.length > 1 ? arguments[1] : void undefined; + + // if (!SameValue(arrayBuffer[[ArrayBufferDetachKey]], key)) { + // throw new $TypeError('Assertion failed: `key` must be the value of the [[ArrayBufferDetachKey]] internal slot of `arrayBuffer`'); + // } + + if (!IsDetachedBuffer(arrayBuffer)) { // node v21.0.0+ throws when you structuredClone a detached buffer + if (typeof structuredClone === 'function') { + structuredClone(arrayBuffer, { transfer: [arrayBuffer] }); + } else if (typeof postMessage === 'function') { + postMessage('', '/', [arrayBuffer]); // TODO: see if this might trigger listeners + } else if (MessageChannel) { + (new MessageChannel()).port1.postMessage(null, [arrayBuffer]); + } else { + throw new $SyntaxError('DetachArrayBuffer is not supported in this environment'); + } + } + + return null; +}; diff --git a/node_modules/es-abstract/2020/EnumerableOwnPropertyNames.js b/node_modules/es-abstract/2020/EnumerableOwnPropertyNames.js new file mode 100644 index 0000000000000000000000000000000000000000..f08d846e95148ddd0b96f0475ea6d1ae3554e704 --- /dev/null +++ b/node_modules/es-abstract/2020/EnumerableOwnPropertyNames.js @@ -0,0 +1,37 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var objectKeys = require('object-keys'); +var safePushApply = require('safe-push-apply'); +var callBound = require('call-bound'); + +var $isEnumerable = callBound('Object.prototype.propertyIsEnumerable'); + +var forEach = require('../helpers/forEach'); + +// https://262.ecma-international.org/8.0/#sec-enumerableownproperties + +module.exports = function EnumerableOwnPropertyNames(O, kind) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + var keys = objectKeys(O); + if (kind === 'key') { + return keys; + } + if (kind === 'value' || kind === 'key+value') { + var results = []; + forEach(keys, function (key) { + if ($isEnumerable(O, key)) { + safePushApply(results, [ + kind === 'value' ? O[key] : [key, O[key]] + ]); + } + }); + return results; + } + throw new $TypeError('Assertion failed: "kind" is not "key", "value", or "key+value": ' + kind); +}; diff --git a/node_modules/es-abstract/2020/FlattenIntoArray.js b/node_modules/es-abstract/2020/FlattenIntoArray.js new file mode 100644 index 0000000000000000000000000000000000000000..78dc57c8cc90f0c0a60adb32fc7f41c230c4a591 --- /dev/null +++ b/node_modules/es-abstract/2020/FlattenIntoArray.js @@ -0,0 +1,55 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var MAX_SAFE_INTEGER = require('math-intrinsics/constants/maxSafeInteger'); + +var Call = require('./Call'); +var CreateDataPropertyOrThrow = require('./CreateDataPropertyOrThrow'); +var Get = require('./Get'); +var HasProperty = require('./HasProperty'); +var IsArray = require('./IsArray'); +var LengthOfArrayLike = require('./LengthOfArrayLike'); +var ToString = require('./ToString'); + +// https://262.ecma-international.org/11.0/#sec-flattenintoarray + +module.exports = function FlattenIntoArray(target, source, sourceLen, start, depth) { + var mapperFunction; + if (arguments.length > 5) { + mapperFunction = arguments[5]; + } + + var targetIndex = start; + var sourceIndex = 0; + while (sourceIndex < sourceLen) { + var P = ToString(sourceIndex); + var exists = HasProperty(source, P); + if (exists === true) { + var element = Get(source, P); + if (typeof mapperFunction !== 'undefined') { + if (arguments.length <= 6) { + throw new $TypeError('Assertion failed: thisArg is required when mapperFunction is provided'); + } + element = Call(mapperFunction, arguments[6], [element, sourceIndex, source]); + } + var shouldFlatten = false; + if (depth > 0) { + shouldFlatten = IsArray(element); + } + if (shouldFlatten) { + var elementLen = LengthOfArrayLike(element); + targetIndex = FlattenIntoArray(target, element, elementLen, targetIndex, depth - 1); + } else { + if (targetIndex >= MAX_SAFE_INTEGER) { + throw new $TypeError('index too large'); + } + CreateDataPropertyOrThrow(target, ToString(targetIndex), element); + targetIndex += 1; + } + } + sourceIndex += 1; + } + + return targetIndex; +}; diff --git a/node_modules/es-abstract/2020/FromPropertyDescriptor.js b/node_modules/es-abstract/2020/FromPropertyDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..45b6379f1214c415e1e43b855db01f18b3566cba --- /dev/null +++ b/node_modules/es-abstract/2020/FromPropertyDescriptor.js @@ -0,0 +1,16 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var isPropertyDescriptor = require('../helpers/records/property-descriptor'); +var fromPropertyDescriptor = require('../helpers/fromPropertyDescriptor'); + +// https://262.ecma-international.org/6.0/#sec-frompropertydescriptor + +module.exports = function FromPropertyDescriptor(Desc) { + if (typeof Desc !== 'undefined' && !isPropertyDescriptor(Desc)) { + throw new $TypeError('Assertion failed: `Desc` must be a Property Descriptor'); + } + + return fromPropertyDescriptor(Desc); +}; diff --git a/node_modules/es-abstract/2020/Get.js b/node_modules/es-abstract/2020/Get.js new file mode 100644 index 0000000000000000000000000000000000000000..42f7a14d853e05735d4166708590df2743cfa74c --- /dev/null +++ b/node_modules/es-abstract/2020/Get.js @@ -0,0 +1,24 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var inspect = require('object-inspect'); + +var isPropertyKey = require('../helpers/isPropertyKey'); + +var isObject = require('es-object-atoms/isObject'); + +// https://262.ecma-international.org/6.0/#sec-get-o-p + +module.exports = function Get(O, P) { + // 7.3.1.1 + if (!isObject(O)) { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + // 7.3.1.2 + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: P is not a Property Key, got ' + inspect(P)); + } + // 7.3.1.3 + return O[P]; +}; diff --git a/node_modules/es-abstract/2020/GetGlobalObject.js b/node_modules/es-abstract/2020/GetGlobalObject.js new file mode 100644 index 0000000000000000000000000000000000000000..0541ede0c48889fefe9a137e0e37a2e13573c091 --- /dev/null +++ b/node_modules/es-abstract/2020/GetGlobalObject.js @@ -0,0 +1,9 @@ +'use strict'; + +var getGlobal = require('globalthis/polyfill'); + +// https://262.ecma-international.org/6.0/#sec-getglobalobject + +module.exports = function GetGlobalObject() { + return getGlobal(); +}; diff --git a/node_modules/es-abstract/2020/GetIterator.js b/node_modules/es-abstract/2020/GetIterator.js new file mode 100644 index 0000000000000000000000000000000000000000..9c7bdfce51f79e2501c0a15702476bd78458028f --- /dev/null +++ b/node_modules/es-abstract/2020/GetIterator.js @@ -0,0 +1,63 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = require('es-errors/type'); +var $SyntaxError = require('es-errors/syntax'); +var isObject = require('es-object-atoms/isObject'); +var $asyncIterator = GetIntrinsic('%Symbol.asyncIterator%', true); + +var inspect = require('object-inspect'); +var hasSymbols = require('has-symbols')(); + +var getIteratorMethod = require('../helpers/getIteratorMethod'); +var AdvanceStringIndex = require('./AdvanceStringIndex'); +var Call = require('./Call'); +var GetMethod = require('./GetMethod'); + +var ES = { + AdvanceStringIndex: AdvanceStringIndex, + GetMethod: GetMethod +}; + +// https://262.ecma-international.org/9.0/#sec-getiterator + +module.exports = function GetIterator(obj, hint, method) { + var actualHint = hint; + if (arguments.length < 2) { + actualHint = 'sync'; + } + if (actualHint !== 'sync' && actualHint !== 'async') { + throw new $TypeError("Assertion failed: `hint` must be one of 'sync' or 'async', got " + inspect(hint)); + } + + var actualMethod = method; + if (arguments.length < 3) { + if (actualHint === 'async') { + if (hasSymbols && $asyncIterator) { + actualMethod = GetMethod(obj, $asyncIterator); + } + if (actualMethod === undefined) { + throw new $SyntaxError("async from sync iterators aren't currently supported"); + } + } else { + actualMethod = getIteratorMethod(ES, obj); + } + } + var iterator = Call(actualMethod, obj); + if (!isObject(iterator)) { + throw new $TypeError('iterator must return an object'); + } + + return iterator; + + // TODO: This should return an IteratorRecord + /* + var nextMethod = GetV(iterator, 'next'); + return { + '[[Iterator]]': iterator, + '[[NextMethod]]': nextMethod, + '[[Done]]': false + }; + */ +}; diff --git a/node_modules/es-abstract/2020/GetMethod.js b/node_modules/es-abstract/2020/GetMethod.js new file mode 100644 index 0000000000000000000000000000000000000000..e28bb1501fc8e4d4a67250c5110cba73bbcba385 --- /dev/null +++ b/node_modules/es-abstract/2020/GetMethod.js @@ -0,0 +1,34 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var GetV = require('./GetV'); +var IsCallable = require('./IsCallable'); +var isPropertyKey = require('../helpers/isPropertyKey'); + +var inspect = require('object-inspect'); + +// https://262.ecma-international.org/6.0/#sec-getmethod + +module.exports = function GetMethod(O, P) { + // 7.3.9.1 + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: P is not a Property Key'); + } + + // 7.3.9.2 + var func = GetV(O, P); + + // 7.3.9.4 + if (func == null) { + return void 0; + } + + // 7.3.9.5 + if (!IsCallable(func)) { + throw new $TypeError(inspect(P) + ' is not a function: ' + inspect(func)); + } + + // 7.3.9.6 + return func; +}; diff --git a/node_modules/es-abstract/2020/GetOwnPropertyKeys.js b/node_modules/es-abstract/2020/GetOwnPropertyKeys.js new file mode 100644 index 0000000000000000000000000000000000000000..e9b50d744a5fdf42221ad18e6674e777fa3b0a47 --- /dev/null +++ b/node_modules/es-abstract/2020/GetOwnPropertyKeys.js @@ -0,0 +1,30 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var hasSymbols = require('has-symbols')(); + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var $gOPN = GetIntrinsic('%Object.getOwnPropertyNames%', true); +var $gOPS = hasSymbols && GetIntrinsic('%Object.getOwnPropertySymbols%', true); +var keys = require('object-keys'); + +// https://262.ecma-international.org/6.0/#sec-getownpropertykeys + +module.exports = function GetOwnPropertyKeys(O, Type) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + if (Type === 'Symbol') { + return $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"`'); +}; diff --git a/node_modules/es-abstract/2020/GetPrototypeFromConstructor.js b/node_modules/es-abstract/2020/GetPrototypeFromConstructor.js new file mode 100644 index 0000000000000000000000000000000000000000..687f6ef200fb11a3dc97a27533d15430c305fb3b --- /dev/null +++ b/node_modules/es-abstract/2020/GetPrototypeFromConstructor.js @@ -0,0 +1,33 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $Function = GetIntrinsic('%Function%'); +var $TypeError = require('es-errors/type'); +var $SyntaxError = require('es-errors/syntax'); + +var Get = require('./Get'); +var IsConstructor = require('./IsConstructor'); + +var isObject = require('es-object-atoms/isObject'); + +// https://262.ecma-international.org/6.0/#sec-getprototypefromconstructor + +module.exports = function GetPrototypeFromConstructor(constructor, intrinsicDefaultProto) { + var intrinsic = GetIntrinsic(intrinsicDefaultProto); // throws if not a valid intrinsic + if (!isObject(intrinsic)) { + throw new $TypeError('intrinsicDefaultProto must be an object'); + } + if (!IsConstructor(constructor)) { + throw new $TypeError('Assertion failed: `constructor` must be a constructor'); + } + var proto = Get(constructor, 'prototype'); + if (!isObject(proto)) { + if (!(constructor instanceof $Function)) { + // ignore other realms, for now + throw new $SyntaxError('cross-realm constructors not currently supported'); + } + proto = intrinsic; + } + return proto; +}; diff --git a/node_modules/es-abstract/2020/GetSubstitution.js b/node_modules/es-abstract/2020/GetSubstitution.js new file mode 100644 index 0000000000000000000000000000000000000000..76789559b6e227b489787819e96bd1eb7dd0dc99 --- /dev/null +++ b/node_modules/es-abstract/2020/GetSubstitution.js @@ -0,0 +1,120 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var callBound = require('call-bound'); +var regexTester = require('safe-regex-test'); +var every = require('../helpers/every'); + +var $charAt = callBound('String.prototype.charAt'); +var $strSlice = callBound('String.prototype.slice'); +var $indexOf = callBound('String.prototype.indexOf'); +var $parseInt = parseInt; + +var isDigit = regexTester(/^[0-9]$/); + +var inspect = require('object-inspect'); +var isInteger = require('math-intrinsics/isInteger'); + +var Get = require('./Get'); +var IsArray = require('./IsArray'); +var ToObject = require('./ToObject'); +var ToString = require('./ToString'); + +var isStringOrUndefined = require('../helpers/isStringOrUndefined'); + +// http://262.ecma-international.org/9.0/#sec-getsubstitution + +// eslint-disable-next-line max-statements, max-params, max-lines-per-function +module.exports = function GetSubstitution(matched, str, position, captures, namedCaptures, replacement) { + if (typeof matched !== 'string') { + throw new $TypeError('Assertion failed: `matched` must be a String'); + } + var matchLength = matched.length; + + if (typeof str !== 'string') { + throw new $TypeError('Assertion failed: `str` must be a String'); + } + var stringLength = str.length; + + if (!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)); + } + + if (!IsArray(captures) || !every(captures, isStringOrUndefined)) { + throw new $TypeError('Assertion failed: `captures` must be a List of Strings or `undefined`, got ' + inspect(captures)); + } + + if (typeof replacement !== 'string') { + throw new $TypeError('Assertion failed: `replacement` must be a String'); + } + + var tailPos = position + matchLength; + var m = captures.length; + if (typeof namedCaptures !== 'undefined') { + namedCaptures = 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 = $charAt(replacement, i); + var isLast = (i + 1) >= replacement.length; + var nextIsLast = (i + 2) >= replacement.length; + if (current === '$' && !isLast) { + var next = $charAt(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 : $charAt(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 && typeof 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 && typeof captures[nnI] === 'undefined' ? '' : captures[nnI]; + i += 2; + } else if (next === '<') { + if (typeof namedCaptures === 'undefined') { + result += '$<'; + i += 2; + } else { + var endIndex = $indexOf(replacement, '>', i); + + if (endIndex > -1) { + var groupName = $strSlice(replacement, i + '$<'.length, endIndex); + var capture = Get(namedCaptures, groupName); + + if (typeof capture !== 'undefined') { + result += ToString(capture); + } + i += ('<' + groupName + '>').length; + } + } + } else { + result += '$'; + } + } + } else { + // the final $, or else not a $ + result += $charAt(replacement, i); + } + } + return result; +}; diff --git a/node_modules/es-abstract/2020/GetV.js b/node_modules/es-abstract/2020/GetV.js new file mode 100644 index 0000000000000000000000000000000000000000..920dec3c4a4eac8aa63678c2afa5683e79e3337f --- /dev/null +++ b/node_modules/es-abstract/2020/GetV.js @@ -0,0 +1,23 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var inspect = require('object-inspect'); + +var isPropertyKey = require('../helpers/isPropertyKey'); +// var ToObject = require('./ToObject'); + +// https://262.ecma-international.org/6.0/#sec-getv + +module.exports = function GetV(V, P) { + // 7.3.2.1 + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: P is not a Property Key, got ' + inspect(P)); + } + + // 7.3.2.2-3 + // var O = ToObject(V); + + // 7.3.2.4 + return V[P]; +}; diff --git a/node_modules/es-abstract/2020/GetValueFromBuffer.js b/node_modules/es-abstract/2020/GetValueFromBuffer.js new file mode 100644 index 0000000000000000000000000000000000000000..0519a10e9aacb656f66b4a875b0ce98b8695c474 --- /dev/null +++ b/node_modules/es-abstract/2020/GetValueFromBuffer.js @@ -0,0 +1,96 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $SyntaxError = require('es-errors/syntax'); +var $TypeError = require('es-errors/type'); +var $Uint8Array = GetIntrinsic('%Uint8Array%', true); +var isInteger = require('math-intrinsics/isInteger'); + +var callBound = require('call-bound'); + +var $slice = callBound('Array.prototype.slice'); + +var IsDetachedBuffer = require('./IsDetachedBuffer'); +var RawBytesToNumeric = require('./RawBytesToNumeric'); + +var isArrayBuffer = require('is-array-buffer'); +var isSharedArrayBuffer = require('is-shared-array-buffer'); +var safeConcat = require('safe-array-concat'); + +var tableTAO = require('./tables/typed-array-objects'); + +var defaultEndianness = require('../helpers/defaultEndianness'); + +// https://262.ecma-international.org/11.0/#sec-getvaluefrombuffer + +module.exports = function GetValueFromBuffer(arrayBuffer, byteIndex, type, isTypedArray, order) { + var isSAB = isSharedArrayBuffer(arrayBuffer); + if (!isArrayBuffer(arrayBuffer) && !isSAB) { + throw new $TypeError('Assertion failed: `arrayBuffer` must be an ArrayBuffer or a SharedArrayBuffer'); + } + + if (!isInteger(byteIndex)) { + throw new $TypeError('Assertion failed: `byteIndex` must be an integer'); + } + + if (typeof type !== 'string' || typeof tableTAO.size['$' + type] !== 'number') { + throw new $TypeError('Assertion failed: `type` must be one of ' + tableTAO.choices); + } + + if (typeof isTypedArray !== 'boolean') { + throw new $TypeError('Assertion failed: `isTypedArray` must be a boolean'); + } + + if (order !== 'SeqCst' && order !== 'Unordered') { + throw new $TypeError('Assertion failed: `order` must be either `SeqCst` or `Unordered`'); + } + + if (arguments.length > 5 && typeof arguments[5] !== 'boolean') { + throw new $TypeError('Assertion failed: `isLittleEndian` must be a boolean, if present'); + } + + if (IsDetachedBuffer(arrayBuffer)) { + throw new $TypeError('Assertion failed: `arrayBuffer` is detached'); // step 1 + } + + // 2. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type. + + if (byteIndex < 0) { + throw new $TypeError('Assertion failed: `byteIndex` must be non-negative'); // step 3 + } + + // 4. Let block be arrayBuffer.[[ArrayBufferData]]. + + var elementSize = tableTAO.size['$' + type]; // step 5 + if (!elementSize) { + throw new $TypeError('Assertion failed: `type` must be one of ' + tableTAO.choices); + } + + var rawValue; + if (isSAB) { // step 6 + /* + a. Let execution be the [[CandidateExecution]] field of the surrounding agent's Agent Record. + b. Let eventList be the [[EventList]] field of the element in execution.[[EventLists]] whose [[AgentSignifier]] is AgentSignifier(). + c. If isTypedArray is true and type is "Int8", "Uint8", "Int16", "Uint16", "Int32", or "Uint32", let noTear be true; otherwise let noTear be false. + d. Let rawValue be a List of length elementSize of nondeterministically chosen byte values. + e. NOTE: In implementations, rawValue is the result of a non-atomic or atomic read instruction on the underlying hardware. The nondeterminism is a semantic prescription of the memory model to describe observable behaviour of hardware with weak consistency. + f. Let readEvent be ReadSharedMemory{ [[Order]]: order, [[NoTear]]: noTear, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize }. + g. Append readEvent to eventList. + h. Append Chosen Value Record { [[Event]]: readEvent, [[ChosenValue]]: rawValue } to execution.[[ChosenValues]]. + */ + throw new $SyntaxError('SharedArrayBuffer is not supported by this implementation'); + } else { + // 7. Let rawValue be a List of elementSize containing, in order, the elementSize sequence of bytes starting with block[byteIndex]. + rawValue = $slice(new $Uint8Array(arrayBuffer, byteIndex), 0, elementSize); // step 6 + } + + // 8. If isLittleEndian is not present, set isLittleEndian to either true or false. The choice is implementation dependent and should be the alternative that is most efficient for the implementation. An implementation must use the same value each time this step is executed and the same value must be used for the corresponding step in the SetValueInBuffer abstract operation. + var isLittleEndian = arguments.length > 5 ? arguments[5] : defaultEndianness === 'little'; // step 8 + + var bytes = isLittleEndian + ? $slice(safeConcat([0, 0, 0, 0, 0, 0, 0, 0], rawValue), -elementSize) + : $slice(safeConcat(rawValue, [0, 0, 0, 0, 0, 0, 0, 0]), 0, elementSize); + + return RawBytesToNumeric(type, bytes, isLittleEndian); +}; diff --git a/node_modules/es-abstract/2020/HasOwnProperty.js b/node_modules/es-abstract/2020/HasOwnProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..617f0b856e81f2518d2c03bf72b367eea50eb6ef --- /dev/null +++ b/node_modules/es-abstract/2020/HasOwnProperty.js @@ -0,0 +1,20 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var hasOwn = require('hasown'); +var isObject = require('es-object-atoms/isObject'); + +var isPropertyKey = require('../helpers/isPropertyKey'); + +// https://262.ecma-international.org/6.0/#sec-hasownproperty + +module.exports = function HasOwnProperty(O, P) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: `O` must be an Object'); + } + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: `P` must be a Property Key'); + } + return hasOwn(O, P); +}; diff --git a/node_modules/es-abstract/2020/HasProperty.js b/node_modules/es-abstract/2020/HasProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..eb66ca9853ec09c092d87f10333fcdb19a882c83 --- /dev/null +++ b/node_modules/es-abstract/2020/HasProperty.js @@ -0,0 +1,18 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var isPropertyKey = require('../helpers/isPropertyKey'); + +// https://262.ecma-international.org/6.0/#sec-hasproperty + +module.exports = function HasProperty(O, P) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: `O` must be an Object'); + } + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: `P` must be a Property Key'); + } + return P in O; +}; diff --git a/node_modules/es-abstract/2020/HourFromTime.js b/node_modules/es-abstract/2020/HourFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..f963bfb68540ba21f46be00b623cb89db98d63f5 --- /dev/null +++ b/node_modules/es-abstract/2020/HourFromTime.js @@ -0,0 +1,14 @@ +'use strict'; + +var floor = require('./floor'); +var modulo = require('./modulo'); + +var timeConstants = require('../helpers/timeConstants'); +var msPerHour = timeConstants.msPerHour; +var HoursPerDay = timeConstants.HoursPerDay; + +// https://262.ecma-international.org/5.1/#sec-15.9.1.10 + +module.exports = function HourFromTime(t) { + return modulo(floor(t / msPerHour), HoursPerDay); +}; diff --git a/node_modules/es-abstract/2020/InLeapYear.js b/node_modules/es-abstract/2020/InLeapYear.js new file mode 100644 index 0000000000000000000000000000000000000000..4a283a4b6097f4b2c4e872b0cc775024ff517b77 --- /dev/null +++ b/node_modules/es-abstract/2020/InLeapYear.js @@ -0,0 +1,19 @@ +'use strict'; + +var $EvalError = require('es-errors/eval'); + +var DaysInYear = require('./DaysInYear'); +var YearFromTime = require('./YearFromTime'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.3 + +module.exports = function InLeapYear(t) { + var days = DaysInYear(YearFromTime(t)); + if (days === 365) { + return 0; + } + if (days === 366) { + return 1; + } + throw new $EvalError('Assertion failed: there are not 365 or 366 days in a year, got: ' + days); +}; diff --git a/node_modules/es-abstract/2020/InstanceofOperator.js b/node_modules/es-abstract/2020/InstanceofOperator.js new file mode 100644 index 0000000000000000000000000000000000000000..5dd7d04a4c16b423b1613070585b864e22b2dc9e --- /dev/null +++ b/node_modules/es-abstract/2020/InstanceofOperator.js @@ -0,0 +1,30 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var $hasInstance = GetIntrinsic('%Symbol.hasInstance%', true); + +var Call = require('./Call'); +var GetMethod = require('./GetMethod'); +var IsCallable = require('./IsCallable'); +var OrdinaryHasInstance = require('./OrdinaryHasInstance'); +var ToBoolean = require('./ToBoolean'); + +// https://262.ecma-international.org/6.0/#sec-instanceofoperator + +module.exports = function InstanceofOperator(O, C) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + var instOfHandler = $hasInstance ? GetMethod(C, $hasInstance) : void 0; + if (typeof instOfHandler !== 'undefined') { + return ToBoolean(Call(instOfHandler, C, [O])); + } + if (!IsCallable(C)) { + throw new $TypeError('`C` is not Callable'); + } + return OrdinaryHasInstance(C, O); +}; diff --git a/node_modules/es-abstract/2020/IntegerIndexedElementGet.js b/node_modules/es-abstract/2020/IntegerIndexedElementGet.js new file mode 100644 index 0000000000000000000000000000000000000000..e353bfc331285bdc233cd6ff893aee11dff82580 --- /dev/null +++ b/node_modules/es-abstract/2020/IntegerIndexedElementGet.js @@ -0,0 +1,53 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var GetValueFromBuffer = require('./GetValueFromBuffer'); +var IsDetachedBuffer = require('./IsDetachedBuffer'); +var IsValidIntegerIndex = require('./IsValidIntegerIndex'); + +var typedArrayLength = require('typed-array-length'); +var typedArrayBuffer = require('typed-array-buffer'); +var typedArrayByteOffset = require('typed-array-byte-offset'); +var whichTypedArray = require('which-typed-array'); + +var tableTAO = require('./tables/typed-array-objects'); + +// https://262.ecma-international.org/11.0/#sec-integerindexedelementget + +module.exports = function IntegerIndexedElementGet(O, index) { + var arrayTypeName = whichTypedArray(O); // step 7 + if (!arrayTypeName) { + throw new $TypeError('`O` must be a TypedArray'); // step 1 + } + + if (typeof index !== 'number') { + throw new $TypeError('`index` must be a Number'); // step 2 + } + + var buffer = typedArrayBuffer(O); // step 3 + + if (IsDetachedBuffer(buffer)) { + throw new $TypeError('`O` has a detached buffer'); // step 4 + } + + if (!IsValidIntegerIndex(O, index)) { + return void undefined; // step 5 + } + + var offset = typedArrayByteOffset(O); // step 6 + + var length = typedArrayLength(O); // step 7 + + if (index < 0 || index >= length) { + return void undefined; // step 8 + } + + var elementType = tableTAO.name['$' + arrayTypeName]; // step 10 + + var elementSize = tableTAO.size['$' + elementType]; // step 8 + + var indexedPosition = (index * elementSize) + offset; // step 9 + + return GetValueFromBuffer(buffer, indexedPosition, elementType, true, 'Unordered'); // step 11 +}; diff --git a/node_modules/es-abstract/2020/IntegerIndexedElementSet.js b/node_modules/es-abstract/2020/IntegerIndexedElementSet.js new file mode 100644 index 0000000000000000000000000000000000000000..762afb40fe65067e31b7a514a22620d78df72a83 --- /dev/null +++ b/node_modules/es-abstract/2020/IntegerIndexedElementSet.js @@ -0,0 +1,60 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var IsDetachedBuffer = require('./IsDetachedBuffer'); +var IsValidIntegerIndex = require('./IsValidIntegerIndex'); +var SetValueInBuffer = require('./SetValueInBuffer'); +var ToBigInt = require('./ToBigInt'); +var ToNumber = require('./ToNumber'); + +var typedArrayBuffer = require('typed-array-buffer'); +var typedArrayByteOffset = require('typed-array-byte-offset'); +var typedArrayLength = require('typed-array-length'); +var whichTypedArray = require('which-typed-array'); + +var tableTAO = require('./tables/typed-array-objects'); + +// https://262.ecma-international.org/11.0/#sec-integerindexedelementset + +module.exports = function IntegerIndexedElementSet(O, index, value) { + var arrayTypeName = whichTypedArray(O); // step 9 + if (!arrayTypeName) { + throw new $TypeError('`O` must be a TypedArray'); // step 1 + } + + if (typeof index !== 'number') { + throw new $TypeError('`index` must be a Number'); // step 2 + } + + var contentType = arrayTypeName === 'BigInt64Array' || arrayTypeName === 'BigUint64Array' ? 'BigInt' : 'Number'; + var numValue = contentType === 'BigInt' ? ToBigInt(value) : ToNumber(value); // steps 3 - 4 + + var buffer = typedArrayBuffer(O); // step 5 + + if (IsDetachedBuffer(buffer)) { + throw new $TypeError('`O` has a detached buffer'); // step 6 + } + + if (!IsValidIntegerIndex(O, index)) { + return false; // step 7 + } + + var offset = typedArrayByteOffset(O); // step 8 + + var length = typedArrayLength(O); // step 9 + + if (index < 0 || index >= length) { + return false; // step 10 + } + + var elementType = tableTAO.name['$' + arrayTypeName]; // step 12 + + var elementSize = tableTAO.size['$' + elementType]; // step 10 + + var indexedPosition = (index * elementSize) + offset; // step 11 + + SetValueInBuffer(buffer, indexedPosition, elementType, numValue, true, 'Unordered'); // step 13 + + return true; // step 14 +}; diff --git a/node_modules/es-abstract/2020/InternalizeJSONProperty.js b/node_modules/es-abstract/2020/InternalizeJSONProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..cb474bfdeee90929c20e26a2fd28ae9928428fab --- /dev/null +++ b/node_modules/es-abstract/2020/InternalizeJSONProperty.js @@ -0,0 +1,66 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var Call = require('./Call'); +var CreateDataProperty = require('./CreateDataProperty'); +var EnumerableOwnPropertyNames = require('./EnumerableOwnPropertyNames'); +var Get = require('./Get'); +var IsArray = require('./IsArray'); +var LengthOfArrayLike = require('./LengthOfArrayLike'); +var ToString = require('./ToString'); + +var forEach = require('../helpers/forEach'); + +// https://262.ecma-international.org/11.0/#sec-internalizejsonproperty + +module.exports = function InternalizeJSONProperty(holder, name, reviver) { + if (!isObject(holder)) { + throw new $TypeError('Assertion failed: `holder` is not an Object'); + } + if (typeof name !== 'string') { + throw new $TypeError('Assertion failed: `name` is not a String'); + } + if (typeof reviver !== 'function') { + throw new $TypeError('Assertion failed: `reviver` is not a Function'); + } + + var val = Get(holder, name); // step 1 + + if (isObject(val)) { // step 2 + var isArray = IsArray(val); // step 2.a + if (isArray) { // step 2.b + var I = 0; // step 2.b.i + + var len = LengthOfArrayLike(val, 'length'); // step 2.b.ii + + while (I < len) { // step 2.b.iii + var newElement = InternalizeJSONProperty(val, ToString(I), reviver); // step 2.b.iv.1 + + if (typeof newElement === 'undefined') { // step 2.b.iii.2 + delete val[ToString(I)]; // step 2.b.iii.2.a + } else { // step 2.b.iii.3 + CreateDataProperty(val, ToString(I), newElement); // step 2.b.iii.3.a + } + + I += 1; // step 2.b.iii.4 + } + } else { // step 2.c + var keys = EnumerableOwnPropertyNames(val, 'key'); // step 2.c.i + + forEach(keys, function (P) { // step 2.c.ii + // eslint-disable-next-line no-shadow + var newElement = InternalizeJSONProperty(val, P, reviver); // step 2.c.ii.1 + + if (typeof newElement === 'undefined') { // step 2.c.ii.2 + delete val[P]; // step 2.c.ii.2.a + } else { // step 2.c.ii.3 + CreateDataProperty(val, P, newElement); // step 2.c.ii.3.a + } + }); + } + } + + return Call(reviver, holder, [name, val]); // step 3 +}; diff --git a/node_modules/es-abstract/2020/Invoke.js b/node_modules/es-abstract/2020/Invoke.js new file mode 100644 index 0000000000000000000000000000000000000000..57bca8ebc3dcb6172949cb3bef6f134dacabbf4b --- /dev/null +++ b/node_modules/es-abstract/2020/Invoke.js @@ -0,0 +1,22 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var Call = require('./Call'); +var IsArray = require('./IsArray'); +var GetV = require('./GetV'); +var isPropertyKey = require('../helpers/isPropertyKey'); + +// https://262.ecma-international.org/6.0/#sec-invoke + +module.exports = function Invoke(O, P) { + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: P must be a Property Key'); + } + var argumentsList = arguments.length > 2 ? arguments[2] : []; + if (!IsArray(argumentsList)) { + throw new $TypeError('Assertion failed: optional `argumentsList`, if provided, must be a List'); + } + var func = GetV(O, P); + return Call(func, O, argumentsList); +}; diff --git a/node_modules/es-abstract/2020/IsAccessorDescriptor.js b/node_modules/es-abstract/2020/IsAccessorDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..f7bf73afb1c1617b04596a6e2af6d1617857bf1e --- /dev/null +++ b/node_modules/es-abstract/2020/IsAccessorDescriptor.js @@ -0,0 +1,25 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var hasOwn = require('hasown'); + +var isPropertyDescriptor = require('../helpers/records/property-descriptor'); + +// https://262.ecma-international.org/5.1/#sec-8.10.1 + +module.exports = function IsAccessorDescriptor(Desc) { + if (typeof Desc === 'undefined') { + return false; + } + + if (!isPropertyDescriptor(Desc)) { + throw new $TypeError('Assertion failed: `Desc` must be a Property Descriptor'); + } + + if (!hasOwn(Desc, '[[Get]]') && !hasOwn(Desc, '[[Set]]')) { + return false; + } + + return true; +}; diff --git a/node_modules/es-abstract/2020/IsArray.js b/node_modules/es-abstract/2020/IsArray.js new file mode 100644 index 0000000000000000000000000000000000000000..c2c48c1f233c058c691d45d7587f1b58d3de5eb2 --- /dev/null +++ b/node_modules/es-abstract/2020/IsArray.js @@ -0,0 +1,4 @@ +'use strict'; + +// https://262.ecma-international.org/6.0/#sec-isarray +module.exports = require('../helpers/IsArray'); diff --git a/node_modules/es-abstract/2020/IsBigIntElementType.js b/node_modules/es-abstract/2020/IsBigIntElementType.js new file mode 100644 index 0000000000000000000000000000000000000000..e3f58a949b3cabcde8a8078afb501cd872820398 --- /dev/null +++ b/node_modules/es-abstract/2020/IsBigIntElementType.js @@ -0,0 +1,7 @@ +'use strict'; + +// https://262.ecma-international.org/11.0/#sec-isbigintelementtype + +module.exports = function IsBigIntElementType(type) { + return type === 'BigUint64' || type === 'BigInt64'; +}; diff --git a/node_modules/es-abstract/2020/IsCallable.js b/node_modules/es-abstract/2020/IsCallable.js new file mode 100644 index 0000000000000000000000000000000000000000..3a69b19267dff33491a84421b667a0d82cba21f9 --- /dev/null +++ b/node_modules/es-abstract/2020/IsCallable.js @@ -0,0 +1,5 @@ +'use strict'; + +// http://262.ecma-international.org/5.1/#sec-9.11 + +module.exports = require('is-callable'); diff --git a/node_modules/es-abstract/2020/IsCompatiblePropertyDescriptor.js b/node_modules/es-abstract/2020/IsCompatiblePropertyDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..8bdaf3eb45d24407a2a416cc5aadab4f4eb1c7da --- /dev/null +++ b/node_modules/es-abstract/2020/IsCompatiblePropertyDescriptor.js @@ -0,0 +1,9 @@ +'use strict'; + +var ValidateAndApplyPropertyDescriptor = require('./ValidateAndApplyPropertyDescriptor'); + +// https://262.ecma-international.org/6.0/#sec-iscompatiblepropertydescriptor + +module.exports = function IsCompatiblePropertyDescriptor(Extensible, Desc, Current) { + return ValidateAndApplyPropertyDescriptor(undefined, undefined, Extensible, Desc, Current); +}; diff --git a/node_modules/es-abstract/2020/IsConcatSpreadable.js b/node_modules/es-abstract/2020/IsConcatSpreadable.js new file mode 100644 index 0000000000000000000000000000000000000000..ace2695309292c91b185505f63da3cc942534bd2 --- /dev/null +++ b/node_modules/es-abstract/2020/IsConcatSpreadable.js @@ -0,0 +1,26 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $isConcatSpreadable = GetIntrinsic('%Symbol.isConcatSpreadable%', true); + +var Get = require('./Get'); +var IsArray = require('./IsArray'); +var ToBoolean = require('./ToBoolean'); + +var isObject = require('es-object-atoms/isObject'); + +// https://262.ecma-international.org/6.0/#sec-isconcatspreadable + +module.exports = function IsConcatSpreadable(O) { + if (!isObject(O)) { + return false; + } + if ($isConcatSpreadable) { + var spreadable = Get(O, $isConcatSpreadable); + if (typeof spreadable !== 'undefined') { + return ToBoolean(spreadable); + } + } + return IsArray(O); +}; diff --git a/node_modules/es-abstract/2020/IsConstructor.js b/node_modules/es-abstract/2020/IsConstructor.js new file mode 100644 index 0000000000000000000000000000000000000000..62ac47f6a3d262927a9b147ee0057dfba9664b24 --- /dev/null +++ b/node_modules/es-abstract/2020/IsConstructor.js @@ -0,0 +1,40 @@ +'use strict'; + +var GetIntrinsic = require('../GetIntrinsic.js'); + +var $construct = GetIntrinsic('%Reflect.construct%', true); + +var DefinePropertyOrThrow = require('./DefinePropertyOrThrow'); +try { + DefinePropertyOrThrow({}, '', { '[[Get]]': function () {} }); +} catch (e) { + // Accessor properties aren't supported + DefinePropertyOrThrow = null; +} + +// https://262.ecma-international.org/6.0/#sec-isconstructor + +if (DefinePropertyOrThrow && $construct) { + var isConstructorMarker = {}; + var badArrayLike = {}; + DefinePropertyOrThrow(badArrayLike, 'length', { + '[[Get]]': function () { + throw isConstructorMarker; + }, + '[[Enumerable]]': true + }); + + module.exports = function IsConstructor(argument) { + try { + // `Reflect.construct` invokes `IsConstructor(target)` before `Get(args, 'length')`: + $construct(argument, badArrayLike); + } catch (err) { + return err === isConstructorMarker; + } + }; +} else { + module.exports = function IsConstructor(argument) { + // unfortunately there's no way to truly check this without try/catch `new argument` in old environments + return typeof argument === 'function' && !!argument.prototype; + }; +} diff --git a/node_modules/es-abstract/2020/IsDataDescriptor.js b/node_modules/es-abstract/2020/IsDataDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..d56bd36d4294369f6486f6dfc5d60dada2cc410a --- /dev/null +++ b/node_modules/es-abstract/2020/IsDataDescriptor.js @@ -0,0 +1,25 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var hasOwn = require('hasown'); + +var isPropertyDescriptor = require('../helpers/records/property-descriptor'); + +// https://262.ecma-international.org/5.1/#sec-8.10.2 + +module.exports = function IsDataDescriptor(Desc) { + if (typeof Desc === 'undefined') { + return false; + } + + if (!isPropertyDescriptor(Desc)) { + throw new $TypeError('Assertion failed: `Desc` must be a Property Descriptor'); + } + + if (!hasOwn(Desc, '[[Value]]') && !hasOwn(Desc, '[[Writable]]')) { + return false; + } + + return true; +}; diff --git a/node_modules/es-abstract/2020/IsDetachedBuffer.js b/node_modules/es-abstract/2020/IsDetachedBuffer.js new file mode 100644 index 0000000000000000000000000000000000000000..71c4f6be8d20b02a92a6721c7ae2833adf21150e --- /dev/null +++ b/node_modules/es-abstract/2020/IsDetachedBuffer.js @@ -0,0 +1,28 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var $byteLength = require('array-buffer-byte-length'); +var availableTypedArrays = require('available-typed-arrays')(); +var callBound = require('call-bound'); +var isArrayBuffer = require('is-array-buffer'); +var isSharedArrayBuffer = require('is-shared-array-buffer'); + +var $sabByteLength = callBound('SharedArrayBuffer.prototype.byteLength', true); + +// https://262.ecma-international.org/8.0/#sec-isdetachedbuffer + +module.exports = function IsDetachedBuffer(arrayBuffer) { + var isSAB = isSharedArrayBuffer(arrayBuffer); + if (!isArrayBuffer(arrayBuffer) && !isSAB) { + throw new $TypeError('Assertion failed: `arrayBuffer` must be an Object with an [[ArrayBufferData]] internal slot'); + } + if ((isSAB ? $sabByteLength : $byteLength)(arrayBuffer) === 0) { + try { + new global[availableTypedArrays[0]](arrayBuffer); // eslint-disable-line no-new + } catch (error) { + return !!error && error.name === 'TypeError'; + } + } + return false; +}; diff --git a/node_modules/es-abstract/2020/IsExtensible.js b/node_modules/es-abstract/2020/IsExtensible.js new file mode 100644 index 0000000000000000000000000000000000000000..aa19b914c2d3dc31c1215e2b203dc3ffbb78746c --- /dev/null +++ b/node_modules/es-abstract/2020/IsExtensible.js @@ -0,0 +1,18 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $preventExtensions = GetIntrinsic('%Object.preventExtensions%', true); +var $isExtensible = GetIntrinsic('%Object.isExtensible%', true); + +var isPrimitive = require('../helpers/isPrimitive'); + +// https://262.ecma-international.org/6.0/#sec-isextensible-o + +module.exports = $preventExtensions + ? function IsExtensible(obj) { + return !isPrimitive(obj) && $isExtensible(obj); + } + : function IsExtensible(obj) { + return !isPrimitive(obj); + }; diff --git a/node_modules/es-abstract/2020/IsGenericDescriptor.js b/node_modules/es-abstract/2020/IsGenericDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..9f6ef045ee44e9eaea4506a234f0e41e0bd1bac9 --- /dev/null +++ b/node_modules/es-abstract/2020/IsGenericDescriptor.js @@ -0,0 +1,26 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var IsAccessorDescriptor = require('./IsAccessorDescriptor'); +var IsDataDescriptor = require('./IsDataDescriptor'); + +var isPropertyDescriptor = require('../helpers/records/property-descriptor'); + +// https://262.ecma-international.org/6.0/#sec-isgenericdescriptor + +module.exports = function IsGenericDescriptor(Desc) { + if (typeof Desc === 'undefined') { + return false; + } + + if (!isPropertyDescriptor(Desc)) { + throw new $TypeError('Assertion failed: `Desc` must be a Property Descriptor'); + } + + if (!IsAccessorDescriptor(Desc) && !IsDataDescriptor(Desc)) { + return true; + } + + return false; +}; diff --git a/node_modules/es-abstract/2020/IsInteger.js b/node_modules/es-abstract/2020/IsInteger.js new file mode 100644 index 0000000000000000000000000000000000000000..9acd7638f5933240e9211a985556ed27df4e82ad --- /dev/null +++ b/node_modules/es-abstract/2020/IsInteger.js @@ -0,0 +1,9 @@ +'use strict'; + +var isInteger = require('math-intrinsics/isInteger'); + +// https://262.ecma-international.org/6.0/#sec-isinteger + +module.exports = function IsInteger(argument) { + return isInteger(argument); +}; diff --git a/node_modules/es-abstract/2020/IsNoTearConfiguration.js b/node_modules/es-abstract/2020/IsNoTearConfiguration.js new file mode 100644 index 0000000000000000000000000000000000000000..f0d2808737ac6c853571ca68c94f57f7ee4cb59b --- /dev/null +++ b/node_modules/es-abstract/2020/IsNoTearConfiguration.js @@ -0,0 +1,16 @@ +'use strict'; + +var IsUnclampedIntegerElementType = require('./IsUnclampedIntegerElementType'); +var IsBigIntElementType = require('./IsBigIntElementType'); + +// https://262.ecma-international.org/11.0/#sec-isnotearconfiguration + +module.exports = function IsNoTearConfiguration(type, order) { + if (IsUnclampedIntegerElementType(type)) { + return true; + } + if (IsBigIntElementType(type) && order !== 'Init' && order !== 'Unordered') { + return true; + } + return false; +}; diff --git a/node_modules/es-abstract/2020/IsNonNegativeInteger.js b/node_modules/es-abstract/2020/IsNonNegativeInteger.js new file mode 100644 index 0000000000000000000000000000000000000000..ae1f69c96449e3c8dee4a692291dbd98964c0ae5 --- /dev/null +++ b/node_modules/es-abstract/2020/IsNonNegativeInteger.js @@ -0,0 +1,9 @@ +'use strict'; + +var IsInteger = require('./IsInteger'); + +// https://262.ecma-international.org/11.0/#sec-isnonnegativeinteger + +module.exports = function IsNonNegativeInteger(argument) { + return !!IsInteger(argument) && argument >= 0; +}; diff --git a/node_modules/es-abstract/2020/IsPromise.js b/node_modules/es-abstract/2020/IsPromise.js new file mode 100644 index 0000000000000000000000000000000000000000..f3d67b1c7045d7657ec74a6d084dc088aadb5ff4 --- /dev/null +++ b/node_modules/es-abstract/2020/IsPromise.js @@ -0,0 +1,24 @@ +'use strict'; + +var callBound = require('call-bound'); + +var $PromiseThen = callBound('Promise.prototype.then', true); + +var isObject = require('es-object-atoms/isObject'); + +// https://262.ecma-international.org/6.0/#sec-ispromise + +module.exports = function IsPromise(x) { + if (!isObject(x)) { + return false; + } + if (!$PromiseThen) { // Promises are not supported + return false; + } + try { + $PromiseThen(x); // throws if not a promise + } catch (e) { + return false; + } + return true; +}; diff --git a/node_modules/es-abstract/2020/IsPropertyKey.js b/node_modules/es-abstract/2020/IsPropertyKey.js new file mode 100644 index 0000000000000000000000000000000000000000..4b1c9c71461ca474f34b517c0bc04e5d700280f2 --- /dev/null +++ b/node_modules/es-abstract/2020/IsPropertyKey.js @@ -0,0 +1,9 @@ +'use strict'; + +var isPropertyKey = require('../helpers/isPropertyKey'); + +// https://262.ecma-international.org/6.0/#sec-ispropertykey + +module.exports = function IsPropertyKey(argument) { + return isPropertyKey(argument); +}; diff --git a/node_modules/es-abstract/2020/IsRegExp.js b/node_modules/es-abstract/2020/IsRegExp.js new file mode 100644 index 0000000000000000000000000000000000000000..8855492d58ded3c061b84be35e962fe32c8de53e --- /dev/null +++ b/node_modules/es-abstract/2020/IsRegExp.js @@ -0,0 +1,25 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $match = GetIntrinsic('%Symbol.match%', true); + +var hasRegExpMatcher = require('is-regex'); +var isObject = require('es-object-atoms/isObject'); + +var ToBoolean = require('./ToBoolean'); + +// https://262.ecma-international.org/6.0/#sec-isregexp + +module.exports = function IsRegExp(argument) { + if (!isObject(argument)) { + return false; + } + if ($match) { + var isRegExp = argument[$match]; + if (typeof isRegExp !== 'undefined') { + return ToBoolean(isRegExp); + } + } + return hasRegExpMatcher(argument); +}; diff --git a/node_modules/es-abstract/2020/IsSharedArrayBuffer.js b/node_modules/es-abstract/2020/IsSharedArrayBuffer.js new file mode 100644 index 0000000000000000000000000000000000000000..41d61b116db4b3aabf7dde87e6b46cc5aa378d99 --- /dev/null +++ b/node_modules/es-abstract/2020/IsSharedArrayBuffer.js @@ -0,0 +1,16 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var isSharedArrayBuffer = require('is-shared-array-buffer'); + +// https://262.ecma-international.org/8.0/#sec-issharedarraybuffer + +module.exports = function IsSharedArrayBuffer(obj) { + if (!isObject(obj)) { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + return isSharedArrayBuffer(obj); +}; diff --git a/node_modules/es-abstract/2020/IsStringPrefix.js b/node_modules/es-abstract/2020/IsStringPrefix.js new file mode 100644 index 0000000000000000000000000000000000000000..507f9fc1f397d6382a878d4c1d6d18da2feb21a5 --- /dev/null +++ b/node_modules/es-abstract/2020/IsStringPrefix.js @@ -0,0 +1,43 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var isPrefixOf = require('../helpers/isPrefixOf'); + +// var callBound = require('call-bound'); + +// var $charAt = callBound('String.prototype.charAt'); + +// https://262.ecma-international.org/9.0/#sec-isstringprefix + +module.exports = function IsStringPrefix(p, q) { + if (typeof p !== 'string') { + throw new $TypeError('Assertion failed: "p" must be a String'); + } + + if (typeof q !== 'string') { + throw new $TypeError('Assertion failed: "q" must be a String'); + } + + return isPrefixOf(p, q); + /* + if (p === q || p === '') { + return true; + } + + var pLength = p.length; + var qLength = q.length; + if (pLength >= qLength) { + return false; + } + + // assert: pLength < qLength + + for (var i = 0; i < pLength; i += 1) { + if ($charAt(p, i) !== $charAt(q, i)) { + return false; + } + } + return true; + */ +}; diff --git a/node_modules/es-abstract/2020/IsUnclampedIntegerElementType.js b/node_modules/es-abstract/2020/IsUnclampedIntegerElementType.js new file mode 100644 index 0000000000000000000000000000000000000000..4e3a38425d65f2320b3e72bc16d3bf6b38ae3f38 --- /dev/null +++ b/node_modules/es-abstract/2020/IsUnclampedIntegerElementType.js @@ -0,0 +1,12 @@ +'use strict'; + +// https://262.ecma-international.org/11.0/#sec-isunclampedintegerelementtype + +module.exports = function IsUnclampedIntegerElementType(type) { + return type === 'Int8' + || type === 'Uint8' + || type === 'Int16' + || type === 'Uint16' + || type === 'Int32' + || type === 'Uint32'; +}; diff --git a/node_modules/es-abstract/2020/IsUnsignedElementType.js b/node_modules/es-abstract/2020/IsUnsignedElementType.js new file mode 100644 index 0000000000000000000000000000000000000000..b1ff194d73916d487ce951d1c7553b7aa5ab34cf --- /dev/null +++ b/node_modules/es-abstract/2020/IsUnsignedElementType.js @@ -0,0 +1,11 @@ +'use strict'; + +// https://262.ecma-international.org/11.0/#sec-isunsignedelementtype + +module.exports = function IsUnsignedElementType(type) { + return type === 'Uint8' + || type === 'Uint8C' + || type === 'Uint16' + || type === 'Uint32' + || type === 'BigUint64'; +}; diff --git a/node_modules/es-abstract/2020/IsValidIntegerIndex.js b/node_modules/es-abstract/2020/IsValidIntegerIndex.js new file mode 100644 index 0000000000000000000000000000000000000000..b42a39a59adae785dcbe29ae6aa6561679ba880a --- /dev/null +++ b/node_modules/es-abstract/2020/IsValidIntegerIndex.js @@ -0,0 +1,32 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var IsInteger = require('./IsInteger'); + +var isNegativeZero = require('math-intrinsics/isNegativeZero'); + +var isTypedArray = require('is-typed-array'); +var typedArrayBuffer = require('typed-array-buffer'); + +// https://262.ecma-international.org/11.0/#sec-isvalidintegerindex + +module.exports = function IsValidIntegerIndex(O, index) { + if (!isTypedArray) { + throw new $TypeError('Assertion failed: `O` must be a Typed Array'); + } + + typedArrayBuffer(O); // step 1 + + if (typeof index !== 'number') { + throw new $TypeError('Assertion failed: Type(index) is not Number'); // step 2 + } + + if (!IsInteger(index)) { return false; } // step 3 + + if (isNegativeZero(index)) { return false; } // step 4 + + if (index < 0 || index >= O.length) { return false; } // step 5 + + return true; // step 6 +}; diff --git a/node_modules/es-abstract/2020/IsWordChar.js b/node_modules/es-abstract/2020/IsWordChar.js new file mode 100644 index 0000000000000000000000000000000000000000..df2541d1c3bc13a6c89e01e6cfe04193bdf282f5 --- /dev/null +++ b/node_modules/es-abstract/2020/IsWordChar.js @@ -0,0 +1,45 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var callBound = require('call-bound'); + +var $indexOf = callBound('String.prototype.indexOf'); + +var IsArray = require('./IsArray'); +var IsInteger = require('./IsInteger'); +var WordCharacters = require('./WordCharacters'); + +var every = require('../helpers/every'); + +var isChar = function isChar(c) { + return typeof c === 'string'; +}; + +// https://262.ecma-international.org/8.0/#sec-runtime-semantics-iswordchar-abstract-operation + +// note: prior to ES2023, this AO erroneously omitted the latter of its arguments. +module.exports = function IsWordChar(e, InputLength, Input, IgnoreCase, Unicode) { + if (!IsInteger(e)) { + throw new $TypeError('Assertion failed: `e` must be an integer'); + } + if (!IsInteger(InputLength)) { + throw new $TypeError('Assertion failed: `InputLength` must be an integer'); + } + if (!IsArray(Input) || !every(Input, isChar)) { + throw new $TypeError('Assertion failed: `Input` must be a List of characters'); + } + if (typeof IgnoreCase !== 'boolean' || typeof Unicode !== 'boolean') { + throw new $TypeError('Assertion failed: `IgnoreCase` and `Unicode` must be booleans'); + } + + if (e === -1 || e === InputLength) { + return false; // step 1 + } + + var c = Input[e]; // step 2 + + var wordChars = WordCharacters(IgnoreCase, Unicode); + + return $indexOf(wordChars, c) > -1; // steps 3-4 +}; diff --git a/node_modules/es-abstract/2020/IterableToList.js b/node_modules/es-abstract/2020/IterableToList.js new file mode 100644 index 0000000000000000000000000000000000000000..6caa4a134cbe21b64ba79ebc7798286a0ec66fa8 --- /dev/null +++ b/node_modules/es-abstract/2020/IterableToList.js @@ -0,0 +1,21 @@ +'use strict'; + +var GetIterator = require('./GetIterator'); +var IteratorStep = require('./IteratorStep'); +var IteratorValue = require('./IteratorValue'); + +// https://262.ecma-international.org/9.0/#sec-iterabletolist + +module.exports = function IterableToList(items, method) { + var iterator = GetIterator(items, 'sync', method); + var values = []; + var next = true; + while (next) { + next = IteratorStep(iterator); + if (next) { + var nextValue = IteratorValue(next); + values[values.length] = nextValue; + } + } + return values; +}; diff --git a/node_modules/es-abstract/2020/IteratorClose.js b/node_modules/es-abstract/2020/IteratorClose.js new file mode 100644 index 0000000000000000000000000000000000000000..c28373b5df19807503f12da511643f30b72ad786 --- /dev/null +++ b/node_modules/es-abstract/2020/IteratorClose.js @@ -0,0 +1,51 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var Call = require('./Call'); +var CompletionRecord = require('./CompletionRecord'); +var GetMethod = require('./GetMethod'); +var IsCallable = require('./IsCallable'); + +// https://262.ecma-international.org/6.0/#sec-iteratorclose + +module.exports = function IteratorClose(iterator, completion) { + if (!isObject(iterator)) { + throw new $TypeError('Assertion failed: Type(iterator) is not Object'); + } + if (!IsCallable(completion) && !(completion instanceof CompletionRecord)) { + throw new $TypeError('Assertion failed: completion is not a thunk representing a Completion Record, nor a Completion Record instance'); + } + var completionThunk = completion instanceof CompletionRecord ? function () { return completion['?'](); } : completion; + + var iteratorReturn = GetMethod(iterator, 'return'); + + if (typeof iteratorReturn === 'undefined') { + return completionThunk(); + } + + var completionRecord; + try { + var innerResult = Call(iteratorReturn, iterator, []); + } catch (e) { + // if we hit here, then "e" is the innerResult completion that needs re-throwing + + // if the completion is of type "throw", this will throw. + completionThunk(); + // eslint-disable-next-line no-useless-assignment + completionThunk = null; // ensure it's not called twice. + + // if not, then return the innerResult completion + throw e; + } + completionRecord = completionThunk(); // if innerResult worked, then throw if the completion does + // eslint-disable-next-line no-useless-assignment + completionThunk = null; // ensure it's not called twice. + + if (!isObject(innerResult)) { + throw new $TypeError('iterator .return must return an object'); + } + + return completionRecord; +}; diff --git a/node_modules/es-abstract/2020/IteratorComplete.js b/node_modules/es-abstract/2020/IteratorComplete.js new file mode 100644 index 0000000000000000000000000000000000000000..c8a0d67c244bbec3d032bb8a4cc5597b7419d97b --- /dev/null +++ b/node_modules/es-abstract/2020/IteratorComplete.js @@ -0,0 +1,16 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var Get = require('./Get'); +var ToBoolean = require('./ToBoolean'); + +// https://262.ecma-international.org/6.0/#sec-iteratorcomplete + +module.exports = function IteratorComplete(iterResult) { + if (!isObject(iterResult)) { + throw new $TypeError('Assertion failed: Type(iterResult) is not Object'); + } + return ToBoolean(Get(iterResult, 'done')); +}; diff --git a/node_modules/es-abstract/2020/IteratorNext.js b/node_modules/es-abstract/2020/IteratorNext.js new file mode 100644 index 0000000000000000000000000000000000000000..b6bd71c68fca61d152bbf420aa5fdfb2feeab854 --- /dev/null +++ b/node_modules/es-abstract/2020/IteratorNext.js @@ -0,0 +1,16 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var Invoke = require('./Invoke'); + +// https://262.ecma-international.org/6.0/#sec-iteratornext + +module.exports = function IteratorNext(iterator, value) { + var result = Invoke(iterator, 'next', arguments.length < 2 ? [] : [value]); + if (!isObject(result)) { + throw new $TypeError('iterator next must return an object'); + } + return result; +}; diff --git a/node_modules/es-abstract/2020/IteratorStep.js b/node_modules/es-abstract/2020/IteratorStep.js new file mode 100644 index 0000000000000000000000000000000000000000..85bcd95c0410f7efd79ae16b91b0a513d404a64a --- /dev/null +++ b/node_modules/es-abstract/2020/IteratorStep.js @@ -0,0 +1,13 @@ +'use strict'; + +var IteratorComplete = require('./IteratorComplete'); +var IteratorNext = require('./IteratorNext'); + +// https://262.ecma-international.org/6.0/#sec-iteratorstep + +module.exports = function IteratorStep(iterator) { + var result = IteratorNext(iterator); + var done = IteratorComplete(result); + return done === true ? false : result; +}; + diff --git a/node_modules/es-abstract/2020/IteratorValue.js b/node_modules/es-abstract/2020/IteratorValue.js new file mode 100644 index 0000000000000000000000000000000000000000..016ddfbd4f01381dd13487740d6806003449d4b1 --- /dev/null +++ b/node_modules/es-abstract/2020/IteratorValue.js @@ -0,0 +1,16 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var Get = require('./Get'); + +// https://262.ecma-international.org/6.0/#sec-iteratorvalue + +module.exports = function IteratorValue(iterResult) { + if (!isObject(iterResult)) { + throw new $TypeError('Assertion failed: Type(iterResult) is not Object'); + } + return Get(iterResult, 'value'); +}; + diff --git a/node_modules/es-abstract/2020/LengthOfArrayLike.js b/node_modules/es-abstract/2020/LengthOfArrayLike.js new file mode 100644 index 0000000000000000000000000000000000000000..437bcd86c93b2ea23f727bb18c83ae4b58fe7e2b --- /dev/null +++ b/node_modules/es-abstract/2020/LengthOfArrayLike.js @@ -0,0 +1,18 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var Get = require('./Get'); +var ToLength = require('./ToLength'); + +// https://262.ecma-international.org/11.0/#sec-lengthofarraylike + +module.exports = function LengthOfArrayLike(obj) { + if (!isObject(obj)) { + throw new $TypeError('Assertion failed: `obj` must be an Object'); + } + return ToLength(Get(obj, 'length')); +}; + +// TODO: use this all over diff --git a/node_modules/es-abstract/2020/MakeDate.js b/node_modules/es-abstract/2020/MakeDate.js new file mode 100644 index 0000000000000000000000000000000000000000..3256ae1092afd21a469f4ca086dc028a73ecaa52 --- /dev/null +++ b/node_modules/es-abstract/2020/MakeDate.js @@ -0,0 +1,14 @@ +'use strict'; + +var $isFinite = require('math-intrinsics/isFinite'); + +var msPerDay = require('../helpers/timeConstants').msPerDay; + +// https://262.ecma-international.org/5.1/#sec-15.9.1.13 + +module.exports = function MakeDate(day, time) { + if (!$isFinite(day) || !$isFinite(time)) { + return NaN; + } + return (day * msPerDay) + time; +}; diff --git a/node_modules/es-abstract/2020/MakeDay.js b/node_modules/es-abstract/2020/MakeDay.js new file mode 100644 index 0000000000000000000000000000000000000000..d03d683855826fe3e3889b737b06a08c34ff4442 --- /dev/null +++ b/node_modules/es-abstract/2020/MakeDay.js @@ -0,0 +1,33 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $DateUTC = GetIntrinsic('%Date.UTC%'); + +var $isFinite = require('math-intrinsics/isFinite'); + +var DateFromTime = require('./DateFromTime'); +var Day = require('./Day'); +var floor = require('./floor'); +var modulo = require('./modulo'); +var MonthFromTime = require('./MonthFromTime'); +var ToInteger = require('./ToInteger'); +var YearFromTime = require('./YearFromTime'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.12 + +module.exports = function MakeDay(year, month, date) { + if (!$isFinite(year) || !$isFinite(month) || !$isFinite(date)) { + return NaN; + } + var y = ToInteger(year); + var m = ToInteger(month); + var dt = ToInteger(date); + var ym = y + floor(m / 12); + var mn = modulo(m, 12); + var t = $DateUTC(ym, mn, 1); + if (YearFromTime(t) !== ym || MonthFromTime(t) !== mn || DateFromTime(t) !== 1) { + return NaN; + } + return Day(t) + dt - 1; +}; diff --git a/node_modules/es-abstract/2020/MakeTime.js b/node_modules/es-abstract/2020/MakeTime.js new file mode 100644 index 0000000000000000000000000000000000000000..94096d6d4ec8833fa6df121cdef28a8da19c150a --- /dev/null +++ b/node_modules/es-abstract/2020/MakeTime.js @@ -0,0 +1,24 @@ +'use strict'; + +var $isFinite = require('math-intrinsics/isFinite'); + +var timeConstants = require('../helpers/timeConstants'); +var msPerSecond = timeConstants.msPerSecond; +var msPerMinute = timeConstants.msPerMinute; +var msPerHour = timeConstants.msPerHour; + +var ToInteger = require('./ToInteger'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.11 + +module.exports = function MakeTime(hour, min, sec, ms) { + if (!$isFinite(hour) || !$isFinite(min) || !$isFinite(sec) || !$isFinite(ms)) { + return NaN; + } + var h = ToInteger(hour); + var m = ToInteger(min); + var s = ToInteger(sec); + var milli = ToInteger(ms); + var t = (h * msPerHour) + (m * msPerMinute) + (s * msPerSecond) + milli; + return t; +}; diff --git a/node_modules/es-abstract/2020/MinFromTime.js b/node_modules/es-abstract/2020/MinFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..a0c631d4cc56cb21e15712def6008d5623edd0f9 --- /dev/null +++ b/node_modules/es-abstract/2020/MinFromTime.js @@ -0,0 +1,14 @@ +'use strict'; + +var floor = require('./floor'); +var modulo = require('./modulo'); + +var timeConstants = require('../helpers/timeConstants'); +var msPerMinute = timeConstants.msPerMinute; +var MinutesPerHour = timeConstants.MinutesPerHour; + +// https://262.ecma-international.org/5.1/#sec-15.9.1.10 + +module.exports = function MinFromTime(t) { + return modulo(floor(t / msPerMinute), MinutesPerHour); +}; diff --git a/node_modules/es-abstract/2020/MonthFromTime.js b/node_modules/es-abstract/2020/MonthFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..e551ee2be6da5cc49c7da94be78095c0803c53d9 --- /dev/null +++ b/node_modules/es-abstract/2020/MonthFromTime.js @@ -0,0 +1,51 @@ +'use strict'; + +var $RangeError = require('es-errors/range'); + +var DayWithinYear = require('./DayWithinYear'); +var InLeapYear = require('./InLeapYear'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.4 + +module.exports = function MonthFromTime(t) { + var day = DayWithinYear(t); + if (0 <= day && day < 31) { + return 0; + } + var leap = InLeapYear(t); + if (31 <= day && day < (59 + leap)) { + return 1; + } + if ((59 + leap) <= day && day < (90 + leap)) { + return 2; + } + if ((90 + leap) <= day && day < (120 + leap)) { + return 3; + } + if ((120 + leap) <= day && day < (151 + leap)) { + return 4; + } + if ((151 + leap) <= day && day < (181 + leap)) { + return 5; + } + if ((181 + leap) <= day && day < (212 + leap)) { + return 6; + } + if ((212 + leap) <= day && day < (243 + leap)) { + return 7; + } + if ((243 + leap) <= day && day < (273 + leap)) { + return 8; + } + if ((273 + leap) <= day && day < (304 + leap)) { + return 9; + } + if ((304 + leap) <= day && day < (334 + leap)) { + return 10; + } + if ((334 + leap) <= day && day < (365 + leap)) { + return 11; + } + + throw new $RangeError('Assertion failed: `day` is out of range'); +}; diff --git a/node_modules/es-abstract/2020/NewPromiseCapability.js b/node_modules/es-abstract/2020/NewPromiseCapability.js new file mode 100644 index 0000000000000000000000000000000000000000..893266fe9f8da7b032d6fc835750a07c30086179 --- /dev/null +++ b/node_modules/es-abstract/2020/NewPromiseCapability.js @@ -0,0 +1,34 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var IsCallable = require('./IsCallable'); +var IsConstructor = require('./IsConstructor'); + +// https://262.ecma-international.org/6.0/#sec-newpromisecapability + +module.exports = function NewPromiseCapability(C) { + if (!IsConstructor(C)) { + throw new $TypeError('C must be a constructor'); // step 1 + } + + var resolvingFunctions = { '[[Resolve]]': void undefined, '[[Reject]]': void undefined }; // step 3 + + var promise = new C(function (resolve, reject) { // steps 4-5 + if (typeof resolvingFunctions['[[Resolve]]'] !== 'undefined' || typeof resolvingFunctions['[[Reject]]'] !== 'undefined') { + throw new $TypeError('executor has already been called'); // step 4.a, 4.b + } + resolvingFunctions['[[Resolve]]'] = resolve; // step 4.c + resolvingFunctions['[[Reject]]'] = reject; // step 4.d + }); // step 4-6 + + if (!IsCallable(resolvingFunctions['[[Resolve]]']) || !IsCallable(resolvingFunctions['[[Reject]]'])) { + throw new $TypeError('executor must provide valid resolve and reject functions'); // steps 7-8 + } + + return { + '[[Promise]]': promise, + '[[Resolve]]': resolvingFunctions['[[Resolve]]'], + '[[Reject]]': resolvingFunctions['[[Reject]]'] + }; // step 9 +}; diff --git a/node_modules/es-abstract/2020/NormalCompletion.js b/node_modules/es-abstract/2020/NormalCompletion.js new file mode 100644 index 0000000000000000000000000000000000000000..1e429dd65cfaded0bd09155819605198a45c628d --- /dev/null +++ b/node_modules/es-abstract/2020/NormalCompletion.js @@ -0,0 +1,9 @@ +'use strict'; + +var CompletionRecord = require('./CompletionRecord'); + +// https://262.ecma-international.org/6.0/#sec-normalcompletion + +module.exports = function NormalCompletion(value) { + return new CompletionRecord('normal', value); +}; diff --git a/node_modules/es-abstract/2020/Number/add.js b/node_modules/es-abstract/2020/Number/add.js new file mode 100644 index 0000000000000000000000000000000000000000..f3b7207262ede1efaf0ccfc784984c8207b03787 --- /dev/null +++ b/node_modules/es-abstract/2020/Number/add.js @@ -0,0 +1,40 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var isNaN = require('../../helpers/isNaN'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-number-add + +module.exports = function NumberAdd(x, y) { + if (typeof x !== 'number' || typeof y !== 'number') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be Numbers'); + } + + if (isNaN(x) || isNaN(y) || (x === Infinity && y === -Infinity) || (x === -Infinity && y === Infinity)) { + return NaN; + } + + if ((x === Infinity && y === Infinity) || (x === -Infinity && y === -Infinity)) { + return x; + } + + if (x === Infinity) { + return x; + } + + if (y === Infinity) { + return y; + } + + if (x === y && x === 0) { + return Infinity / x === -Infinity && Infinity / y === -Infinity ? -0 : +0; + } + + if (x === -y || -x === y) { + return +0; + } + + // shortcut for the actual spec mechanics + return x + y; +}; diff --git a/node_modules/es-abstract/2020/Number/bitwiseAND.js b/node_modules/es-abstract/2020/Number/bitwiseAND.js new file mode 100644 index 0000000000000000000000000000000000000000..d85d0f6f6a657b4afcbb3abd8c655d9e5a247400 --- /dev/null +++ b/node_modules/es-abstract/2020/Number/bitwiseAND.js @@ -0,0 +1,14 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var NumberBitwiseOp = require('../NumberBitwiseOp'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-number-bitwiseAND + +module.exports = function NumberBitwiseAND(x, y) { + if (typeof x !== 'number' || typeof y !== 'number') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be Numbers'); + } + return NumberBitwiseOp('&', x, y); +}; diff --git a/node_modules/es-abstract/2020/Number/bitwiseNOT.js b/node_modules/es-abstract/2020/Number/bitwiseNOT.js new file mode 100644 index 0000000000000000000000000000000000000000..7e3035e879df0d334dab28b00d3f07c1583c0429 --- /dev/null +++ b/node_modules/es-abstract/2020/Number/bitwiseNOT.js @@ -0,0 +1,16 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var ToInt32 = require('../ToInt32'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-number-bitwiseNOT + +module.exports = function NumberBitwiseNOT(x) { + if (typeof x !== 'number') { + throw new $TypeError('Assertion failed: `x` argument must be a Number'); + } + var oldValue = ToInt32(x); + // Return the result of applying the bitwise operator op to lnum and rnum. The result is a signed 32-bit integer. + return ~oldValue; +}; diff --git a/node_modules/es-abstract/2020/Number/bitwiseOR.js b/node_modules/es-abstract/2020/Number/bitwiseOR.js new file mode 100644 index 0000000000000000000000000000000000000000..2930a61222f9cc53559ffceac2865b5fdabfeea4 --- /dev/null +++ b/node_modules/es-abstract/2020/Number/bitwiseOR.js @@ -0,0 +1,14 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var NumberBitwiseOp = require('../NumberBitwiseOp'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-number-bitwiseOR + +module.exports = function NumberBitwiseOR(x, y) { + if (typeof x !== 'number' || typeof y !== 'number') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be Numbers'); + } + return NumberBitwiseOp('|', x, y); +}; diff --git a/node_modules/es-abstract/2020/Number/bitwiseXOR.js b/node_modules/es-abstract/2020/Number/bitwiseXOR.js new file mode 100644 index 0000000000000000000000000000000000000000..fab4baae216a9c35ef1eb20fc941aca98028cb21 --- /dev/null +++ b/node_modules/es-abstract/2020/Number/bitwiseXOR.js @@ -0,0 +1,14 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var NumberBitwiseOp = require('../NumberBitwiseOp'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-number-bitwiseXOR + +module.exports = function NumberBitwiseXOR(x, y) { + if (typeof x !== 'number' || typeof y !== 'number') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be Numbers'); + } + return NumberBitwiseOp('^', x, y); +}; diff --git a/node_modules/es-abstract/2020/Number/divide.js b/node_modules/es-abstract/2020/Number/divide.js new file mode 100644 index 0000000000000000000000000000000000000000..12ec011c993217453e4633d626e47d3baf134beb --- /dev/null +++ b/node_modules/es-abstract/2020/Number/divide.js @@ -0,0 +1,18 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isFinite = require('math-intrinsics/isFinite'); +var isNaN = require('math-intrinsics/isNaN'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-number-divide + +module.exports = function NumberDivide(x, y) { + if (typeof x !== 'number' || typeof y !== 'number') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be Numbers'); + } + if (isNaN(x) || isNaN(y) || (!isFinite(x) && !isFinite(y))) { + return NaN; + } + // shortcut for the actual spec mechanics + return x / y; +}; diff --git a/node_modules/es-abstract/2020/Number/equal.js b/node_modules/es-abstract/2020/Number/equal.js new file mode 100644 index 0000000000000000000000000000000000000000..ebd9f7463a062a0b95d80a80e4ef2cbd8efc648e --- /dev/null +++ b/node_modules/es-abstract/2020/Number/equal.js @@ -0,0 +1,18 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var isNaN = require('../../helpers/isNaN'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-number-equal + +module.exports = function NumberEqual(x, y) { + if (typeof x !== 'number' || typeof y !== 'number') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be Numbers'); + } + if (isNaN(x) || isNaN(y)) { + return false; + } + // shortcut for the actual spec mechanics + return x === y; +}; diff --git a/node_modules/es-abstract/2020/Number/exponentiate.js b/node_modules/es-abstract/2020/Number/exponentiate.js new file mode 100644 index 0000000000000000000000000000000000000000..37812d85bccd0b0438c66595e1e6d5aef4c94bc7 --- /dev/null +++ b/node_modules/es-abstract/2020/Number/exponentiate.js @@ -0,0 +1,74 @@ +'use strict'; + +// var isNegativeZero = require('math-intrinsics/isNegativeZero'); +var $pow = require('math-intrinsics/pow'); + +var $TypeError = require('es-errors/type'); + +/* +var abs = require('math-intrinsics/abs'); +var isFinite = require('math-intrinsics/isFinite'); +var isNaN = require('math-intrinsics/isNaN'); + +var IsInteger = require('math-intrinsics/isInteger'); +*/ + +// https://262.ecma-international.org/11.0/#sec-numeric-types-number-exponentiate + +/* eslint max-lines-per-function: 0, max-statements: 0 */ + +module.exports = function NumberExponentiate(base, exponent) { + if (typeof base !== 'number' || typeof exponent !== 'number') { + throw new $TypeError('Assertion failed: `base` and `exponent` arguments must be Numbers'); + } + return $pow(base, exponent); + /* + if (isNaN(exponent)) { + return NaN; + } + if (exponent === 0) { + return 1; + } + if (isNaN(base)) { + return NaN; + } + var aB = abs(base); + if (aB > 1 && exponent === Infinity) { + return Infinity; + } + if (aB > 1 && exponent === -Infinity) { + return 0; + } + if (aB === 1 && (exponent === Infinity || exponent === -Infinity)) { + return NaN; + } + if (aB < 1 && exponent === Infinity) { + return +0; + } + if (aB < 1 && exponent === -Infinity) { + return Infinity; + } + if (base === Infinity) { + return exponent > 0 ? Infinity : 0; + } + if (base === -Infinity) { + var isOdd = true; + if (exponent > 0) { + return isOdd ? -Infinity : Infinity; + } + return isOdd ? -0 : 0; + } + if (exponent > 0) { + return isNegativeZero(base) ? Infinity : 0; + } + if (isNegativeZero(base)) { + if (exponent > 0) { + return isOdd ? -0 : 0; + } + return isOdd ? -Infinity : Infinity; + } + if (base < 0 && isFinite(base) && isFinite(exponent) && !IsInteger(exponent)) { + return NaN; + } + */ +}; diff --git a/node_modules/es-abstract/2020/Number/index.js b/node_modules/es-abstract/2020/Number/index.js new file mode 100644 index 0000000000000000000000000000000000000000..63ec52da69e285d605f9f5db2ffe69ed4af591f2 --- /dev/null +++ b/node_modules/es-abstract/2020/Number/index.js @@ -0,0 +1,43 @@ +'use strict'; + +var add = require('./add'); +var bitwiseAND = require('./bitwiseAND'); +var bitwiseNOT = require('./bitwiseNOT'); +var bitwiseOR = require('./bitwiseOR'); +var bitwiseXOR = require('./bitwiseXOR'); +var divide = require('./divide'); +var equal = require('./equal'); +var exponentiate = require('./exponentiate'); +var leftShift = require('./leftShift'); +var lessThan = require('./lessThan'); +var multiply = require('./multiply'); +var remainder = require('./remainder'); +var sameValue = require('./sameValue'); +var sameValueZero = require('./sameValueZero'); +var signedRightShift = require('./signedRightShift'); +var subtract = require('./subtract'); +var toString = require('./toString'); +var unaryMinus = require('./unaryMinus'); +var unsignedRightShift = require('./unsignedRightShift'); + +module.exports = { + add: add, + bitwiseAND: bitwiseAND, + bitwiseNOT: bitwiseNOT, + bitwiseOR: bitwiseOR, + bitwiseXOR: bitwiseXOR, + divide: divide, + equal: equal, + exponentiate: exponentiate, + leftShift: leftShift, + lessThan: lessThan, + multiply: multiply, + remainder: remainder, + sameValue: sameValue, + sameValueZero: sameValueZero, + signedRightShift: signedRightShift, + subtract: subtract, + toString: toString, + unaryMinus: unaryMinus, + unsignedRightShift: unsignedRightShift +}; diff --git a/node_modules/es-abstract/2020/Number/leftShift.js b/node_modules/es-abstract/2020/Number/leftShift.js new file mode 100644 index 0000000000000000000000000000000000000000..26f21f737ca235d79bcf5fd562945aafab21c350 --- /dev/null +++ b/node_modules/es-abstract/2020/Number/leftShift.js @@ -0,0 +1,21 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var ToInt32 = require('../ToInt32'); +var ToUint32 = require('../ToUint32'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-number-leftShift + +module.exports = function NumberLeftShift(x, y) { + if (typeof x !== 'number' || typeof y !== 'number') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be Numbers'); + } + + var lnum = ToInt32(x); + var rnum = ToUint32(y); + + var shiftCount = rnum & 0x1F; + + return lnum << shiftCount; +}; diff --git a/node_modules/es-abstract/2020/Number/lessThan.js b/node_modules/es-abstract/2020/Number/lessThan.js new file mode 100644 index 0000000000000000000000000000000000000000..538174306dd342a14dc82f25f2b8e5a56c9e6a32 --- /dev/null +++ b/node_modules/es-abstract/2020/Number/lessThan.js @@ -0,0 +1,22 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var isNaN = require('../../helpers/isNaN'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-number-lessThan + +module.exports = function NumberLessThan(x, y) { + if (typeof x !== 'number' || typeof y !== 'number') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be Numbers'); + } + + // If x is NaN, return undefined. + // If y is NaN, return undefined. + if (isNaN(x) || isNaN(y)) { + return void undefined; + } + + // shortcut for the actual spec mechanics + return x < y; +}; diff --git a/node_modules/es-abstract/2020/Number/multiply.js b/node_modules/es-abstract/2020/Number/multiply.js new file mode 100644 index 0000000000000000000000000000000000000000..318787cbab9b472dca1f47e18c0faec44c4da1c3 --- /dev/null +++ b/node_modules/es-abstract/2020/Number/multiply.js @@ -0,0 +1,29 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var isNaN = require('../../helpers/isNaN'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-number-multiply + +module.exports = function NumberMultiply(x, y) { + if (typeof x !== 'number' || typeof y !== 'number') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be Numbers'); + } + + if (isNaN(x) || isNaN(y) || (x === 0 && !isFinite(y)) || (!isFinite(x) && y === 0)) { + return NaN; + } + if (!isFinite(x) && !isFinite(y)) { + return x === y ? Infinity : -Infinity; + } + if (!isFinite(x) && y !== 0) { + return x > 0 ? Infinity : -Infinity; + } + if (!isFinite(y) && x !== 0) { + return y > 0 ? Infinity : -Infinity; + } + + // shortcut for the actual spec mechanics + return x * y; +}; diff --git a/node_modules/es-abstract/2020/Number/remainder.js b/node_modules/es-abstract/2020/Number/remainder.js new file mode 100644 index 0000000000000000000000000000000000000000..70cd2d634a7c1415558e8184c8d68bc333d6f200 --- /dev/null +++ b/node_modules/es-abstract/2020/Number/remainder.js @@ -0,0 +1,28 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var isNaN = require('../../helpers/isNaN'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-number-remainder + +module.exports = function NumberRemainder(n, d) { + if (typeof n !== 'number' || typeof d !== 'number') { + throw new $TypeError('Assertion failed: `n` and `d` arguments must be Numbers'); + } + + // If either operand is NaN, the result is NaN. + // If the dividend is an infinity, or the divisor is a zero, or both, the result is NaN. + if (isNaN(n) || isNaN(d) || !isFinite(n) || d === 0) { + return NaN; + } + + // If the dividend is finite and the divisor is an infinity, the result equals the dividend. + // If the dividend is a zero and the divisor is nonzero and finite, the result is the same as the dividend. + if (!isFinite(d) || (n === 0 && d !== 0)) { + return n; + } + + // In the remaining cases, where neither an infinity, nor a zero, nor NaN is involved… + return n % d; +}; diff --git a/node_modules/es-abstract/2020/Number/sameValue.js b/node_modules/es-abstract/2020/Number/sameValue.js new file mode 100644 index 0000000000000000000000000000000000000000..f7c6f78a4afc352f3ead59cd4ffc866dadc74130 --- /dev/null +++ b/node_modules/es-abstract/2020/Number/sameValue.js @@ -0,0 +1,18 @@ +'use strict'; + +var isNegativeZero = require('math-intrinsics/isNegativeZero'); +var $TypeError = require('es-errors/type'); + +var NumberSameValueZero = require('./sameValueZero'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-number-sameValue + +module.exports = function NumberSameValue(x, y) { + if (typeof x !== 'number' || typeof y !== 'number') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be Numbers'); + } + if (x === 0 && y === 0) { + return !(isNegativeZero(x) ^ isNegativeZero(y)); + } + return NumberSameValueZero(x, y); +}; diff --git a/node_modules/es-abstract/2020/Number/sameValueZero.js b/node_modules/es-abstract/2020/Number/sameValueZero.js new file mode 100644 index 0000000000000000000000000000000000000000..383ab82f70c8612fed5287ec4b0b0b5814f48750 --- /dev/null +++ b/node_modules/es-abstract/2020/Number/sameValueZero.js @@ -0,0 +1,20 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var isNaN = require('../../helpers/isNaN'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-number-sameValueZero + +module.exports = function NumberSameValueZero(x, y) { + if (typeof x !== 'number' || typeof y !== 'number') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be Numbers'); + } + + var xNaN = isNaN(x); + var yNaN = isNaN(y); + if (xNaN || yNaN) { + return xNaN === yNaN; + } + return x === y; +}; diff --git a/node_modules/es-abstract/2020/Number/signedRightShift.js b/node_modules/es-abstract/2020/Number/signedRightShift.js new file mode 100644 index 0000000000000000000000000000000000000000..2e27fcf9bad8f012f15f12d2e775024fe1b68a0c --- /dev/null +++ b/node_modules/es-abstract/2020/Number/signedRightShift.js @@ -0,0 +1,21 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var ToInt32 = require('../ToInt32'); +var ToUint32 = require('../ToUint32'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-number-signedRightShift + +module.exports = function NumberSignedRightShift(x, y) { + if (typeof x !== 'number' || typeof y !== 'number') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be Numbers'); + } + + var lnum = ToInt32(x); + var rnum = ToUint32(y); + + var shiftCount = rnum & 0x1F; + + return lnum >> shiftCount; +}; diff --git a/node_modules/es-abstract/2020/Number/subtract.js b/node_modules/es-abstract/2020/Number/subtract.js new file mode 100644 index 0000000000000000000000000000000000000000..ed85d0baa8e69007568c2597fabcd850838891d3 --- /dev/null +++ b/node_modules/es-abstract/2020/Number/subtract.js @@ -0,0 +1,12 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-number-subtract + +module.exports = function NumberSubtract(x, y) { + if (typeof x !== 'number' || typeof y !== 'number') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be Numbers'); + } + return x - y; +}; diff --git a/node_modules/es-abstract/2020/Number/toString.js b/node_modules/es-abstract/2020/Number/toString.js new file mode 100644 index 0000000000000000000000000000000000000000..833353dc3bce29b8b8a7fe2cbf7b10185a3b149d --- /dev/null +++ b/node_modules/es-abstract/2020/Number/toString.js @@ -0,0 +1,16 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $String = GetIntrinsic('%String%'); +var $TypeError = require('es-errors/type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-number-tostring + +module.exports = function NumberToString(x) { + if (typeof x !== 'number') { + throw new $TypeError('Assertion failed: `x` must be a Number'); + } + + return $String(x); +}; diff --git a/node_modules/es-abstract/2020/Number/unaryMinus.js b/node_modules/es-abstract/2020/Number/unaryMinus.js new file mode 100644 index 0000000000000000000000000000000000000000..ab4ed98b2db294cfcd12edd31d9a7fd06649b9dd --- /dev/null +++ b/node_modules/es-abstract/2020/Number/unaryMinus.js @@ -0,0 +1,17 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var isNaN = require('../../helpers/isNaN'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-number-unaryMinus + +module.exports = function NumberUnaryMinus(x) { + if (typeof x !== 'number') { + throw new $TypeError('Assertion failed: `x` argument must be a Number'); + } + if (isNaN(x)) { + return NaN; + } + return -x; +}; diff --git a/node_modules/es-abstract/2020/Number/unsignedRightShift.js b/node_modules/es-abstract/2020/Number/unsignedRightShift.js new file mode 100644 index 0000000000000000000000000000000000000000..7823611fcc89f599231f03b9933db5502b7fc09a --- /dev/null +++ b/node_modules/es-abstract/2020/Number/unsignedRightShift.js @@ -0,0 +1,21 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var ToInt32 = require('../ToInt32'); +var ToUint32 = require('../ToUint32'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-number-unsignedRightShift + +module.exports = function NumberUnsignedRightShift(x, y) { + if (typeof x !== 'number' || typeof y !== 'number') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be Numbers'); + } + + var lnum = ToInt32(x); + var rnum = ToUint32(y); + + var shiftCount = rnum & 0x1F; + + return lnum >>> shiftCount; +}; diff --git a/node_modules/es-abstract/2020/NumberBitwiseOp.js b/node_modules/es-abstract/2020/NumberBitwiseOp.js new file mode 100644 index 0000000000000000000000000000000000000000..769d1fa15aee1ba5ee58abd4f96579f9ba38138f --- /dev/null +++ b/node_modules/es-abstract/2020/NumberBitwiseOp.js @@ -0,0 +1,26 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var ToInt32 = require('./ToInt32'); +var ToUint32 = require('./ToUint32'); + +// https://262.ecma-international.org/11.0/#sec-numberbitwiseop + +module.exports = function NumberBitwiseOp(op, x, y) { + if (op !== '&' && op !== '|' && op !== '^') { + throw new $TypeError('Assertion failed: `op` must be `&`, `|`, or `^`'); + } + if (typeof x !== 'number' || typeof y !== 'number') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be Numbers'); + } + var lnum = ToInt32(x); + var rnum = ToUint32(y); + if (op === '&') { + return lnum & rnum; + } + if (op === '|') { + return lnum | rnum; + } + return lnum ^ rnum; +}; diff --git a/node_modules/es-abstract/2020/NumberToBigInt.js b/node_modules/es-abstract/2020/NumberToBigInt.js new file mode 100644 index 0000000000000000000000000000000000000000..724d56d735c29316f81abadd443706f9e3349d87 --- /dev/null +++ b/node_modules/es-abstract/2020/NumberToBigInt.js @@ -0,0 +1,24 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $BigInt = GetIntrinsic('%BigInt%', true); +var $RangeError = require('es-errors/range'); +var $SyntaxError = require('es-errors/syntax'); +var $TypeError = require('es-errors/type'); +var isInteger = require('math-intrinsics/isInteger'); + +// https://262.ecma-international.org/11.0/#sec-numbertobigint + +module.exports = function NumberToBigInt(number) { + if (typeof number !== 'number') { + throw new $TypeError('Assertion failed: `number` must be a String'); + } + if (!isInteger(number)) { + throw new $RangeError('The number ' + number + ' cannot be converted to a BigInt because it is not an integer'); + } + if (!$BigInt) { + throw new $SyntaxError('BigInts are not supported in this environment'); + } + return $BigInt(number); +}; diff --git a/node_modules/es-abstract/2020/NumericToRawBytes.js b/node_modules/es-abstract/2020/NumericToRawBytes.js new file mode 100644 index 0000000000000000000000000000000000000000..db42a4fbb0951c865b5c3d85a9cbb874b825a3c6 --- /dev/null +++ b/node_modules/es-abstract/2020/NumericToRawBytes.js @@ -0,0 +1,62 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var hasOwnProperty = require('./HasOwnProperty'); +var ToBigInt64 = require('./ToBigInt64'); +var ToBigUint64 = require('./ToBigUint64'); +var ToInt16 = require('./ToInt16'); +var ToInt32 = require('./ToInt32'); +var ToInt8 = require('./ToInt8'); +var ToUint16 = require('./ToUint16'); +var ToUint32 = require('./ToUint32'); +var ToUint8 = require('./ToUint8'); +var ToUint8Clamp = require('./ToUint8Clamp'); + +var valueToFloat32Bytes = require('../helpers/valueToFloat32Bytes'); +var valueToFloat64Bytes = require('../helpers/valueToFloat64Bytes'); +var integerToNBytes = require('../helpers/integerToNBytes'); + +var tableTAO = require('./tables/typed-array-objects'); + +// https://262.ecma-international.org/11.0/#table-the-typedarray-constructors +var TypeToAO = { + __proto__: null, + $Int8: ToInt8, + $Uint8: ToUint8, + $Uint8C: ToUint8Clamp, + $Int16: ToInt16, + $Uint16: ToUint16, + $Int32: ToInt32, + $Uint32: ToUint32, + $BigInt64: ToBigInt64, + $BigUint64: ToBigUint64 +}; + +// https://262.ecma-international.org/11.0/#sec-numerictorawbytes + +module.exports = function NumericToRawBytes(type, value, isLittleEndian) { + if (typeof type !== 'string' || !hasOwnProperty(tableTAO.size, '$' + type)) { + throw new $TypeError('Assertion failed: `type` must be a TypedArray element type'); + } + if (typeof value !== 'number' && typeof value !== 'bigint') { + throw new $TypeError('Assertion failed: `value` must be a Number or a BigInt'); + } + if (typeof isLittleEndian !== 'boolean') { + throw new $TypeError('Assertion failed: `isLittleEndian` must be a Boolean'); + } + + if (type === 'Float32') { // step 1 + return valueToFloat32Bytes(value, isLittleEndian); + } else if (type === 'Float64') { // step 2 + return valueToFloat64Bytes(value, isLittleEndian); + } // step 3 + + var n = tableTAO.size['$' + type]; // step 3.a + + var convOp = TypeToAO['$' + type]; // step 3.b + + var intValue = convOp(value); // step 3.c + + return integerToNBytes(intValue, n, isLittleEndian); // step 3.d, 3.e, 4 +}; diff --git a/node_modules/es-abstract/2020/ObjectDefineProperties.js b/node_modules/es-abstract/2020/ObjectDefineProperties.js new file mode 100644 index 0000000000000000000000000000000000000000..0d41322bcc146b95dea2f81dbb533ed69495414a --- /dev/null +++ b/node_modules/es-abstract/2020/ObjectDefineProperties.js @@ -0,0 +1,37 @@ +'use strict'; + +var DefinePropertyOrThrow = require('./DefinePropertyOrThrow'); +var Get = require('./Get'); +var OrdinaryGetOwnProperty = require('./OrdinaryGetOwnProperty'); +var ToObject = require('./ToObject'); +var ToPropertyDescriptor = require('./ToPropertyDescriptor'); + +var forEach = require('../helpers/forEach'); +var OwnPropertyKeys = require('own-keys'); + +// https://262.ecma-international.org/6.0/#sec-objectdefineproperties + +/** @type { = {}>(O: T, Properties: object) => T} */ +module.exports = function ObjectDefineProperties(O, Properties) { + var props = ToObject(Properties); // step 1 + var keys = OwnPropertyKeys(props); // step 2 + /** @type {[string | symbol, import('../types').Descriptor][]} */ + var descriptors = []; // step 3 + + forEach(keys, function (nextKey) { // step 4 + var propDesc = OrdinaryGetOwnProperty(props, nextKey); // ToPropertyDescriptor(getOwnPropertyDescriptor(props, nextKey)); // step 4.a + if (typeof propDesc !== 'undefined' && propDesc['[[Enumerable]]']) { // step 4.b + var descObj = Get(props, nextKey); // step 4.b.i + var desc = ToPropertyDescriptor(descObj); // step 4.b.ii + descriptors[descriptors.length] = [nextKey, desc]; // step 4.b.iii + } + }); + + forEach(descriptors, function (pair) { // step 5 + var P = pair[0]; // step 5.a + var desc = pair[1]; // step 5.b + DefinePropertyOrThrow(O, P, desc); // step 5.c + }); + + return O; // step 6 +}; diff --git a/node_modules/es-abstract/2020/OrdinaryCreateFromConstructor.js b/node_modules/es-abstract/2020/OrdinaryCreateFromConstructor.js new file mode 100644 index 0000000000000000000000000000000000000000..ac997c828209e0a91a21801f62f206d4dd642c29 --- /dev/null +++ b/node_modules/es-abstract/2020/OrdinaryCreateFromConstructor.js @@ -0,0 +1,20 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); +var $TypeError = require('es-errors/type'); + +var GetPrototypeFromConstructor = require('./GetPrototypeFromConstructor'); +var IsArray = require('./IsArray'); +var OrdinaryObjectCreate = require('./OrdinaryObjectCreate'); + +// https://262.ecma-international.org/6.0/#sec-ordinarycreatefromconstructor + +module.exports = function OrdinaryCreateFromConstructor(constructor, intrinsicDefaultProto) { + GetIntrinsic(intrinsicDefaultProto); // throws if not a valid intrinsic + var proto = GetPrototypeFromConstructor(constructor, intrinsicDefaultProto); + var slots = arguments.length < 3 ? [] : arguments[2]; + if (!IsArray(slots)) { + throw new $TypeError('Assertion failed: if provided, `internalSlotsList` must be a List'); + } + return OrdinaryObjectCreate(proto, slots); +}; diff --git a/node_modules/es-abstract/2020/OrdinaryDefineOwnProperty.js b/node_modules/es-abstract/2020/OrdinaryDefineOwnProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..1a61488c6311f778620cdccb377e0b377040b055 --- /dev/null +++ b/node_modules/es-abstract/2020/OrdinaryDefineOwnProperty.js @@ -0,0 +1,54 @@ +'use strict'; + +var $gOPD = require('gopd'); +var $SyntaxError = require('es-errors/syntax'); +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var isPropertyDescriptor = require('../helpers/records/property-descriptor'); + +var IsAccessorDescriptor = require('./IsAccessorDescriptor'); +var IsExtensible = require('./IsExtensible'); +var isPropertyKey = require('../helpers/isPropertyKey'); +var ToPropertyDescriptor = require('./ToPropertyDescriptor'); +var SameValue = require('./SameValue'); +var ValidateAndApplyPropertyDescriptor = require('./ValidateAndApplyPropertyDescriptor'); + +// https://262.ecma-international.org/6.0/#sec-ordinarydefineownproperty + +module.exports = function OrdinaryDefineOwnProperty(O, P, Desc) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: O must be an Object'); + } + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: P must be a Property Key'); + } + if (!isPropertyDescriptor(Desc)) { + throw new $TypeError('Assertion failed: Desc must be a Property Descriptor'); + } + if (!$gOPD) { + // ES3/IE 8 fallback + if (IsAccessorDescriptor(Desc)) { + throw new $SyntaxError('This environment does not support accessor property descriptors.'); + } + var creatingNormalDataProperty = !(P in O) + && Desc['[[Writable]]'] + && Desc['[[Enumerable]]'] + && Desc['[[Configurable]]'] + && '[[Value]]' in Desc; + var settingExistingDataProperty = (P in O) + && (!('[[Configurable]]' in Desc) || Desc['[[Configurable]]']) + && (!('[[Enumerable]]' in Desc) || Desc['[[Enumerable]]']) + && (!('[[Writable]]' in Desc) || Desc['[[Writable]]']) + && '[[Value]]' in Desc; + if (creatingNormalDataProperty || settingExistingDataProperty) { + O[P] = Desc['[[Value]]']; // eslint-disable-line no-param-reassign + return SameValue(O[P], Desc['[[Value]]']); + } + throw new $SyntaxError('This environment does not support defining non-writable, non-enumerable, or non-configurable properties'); + } + var desc = $gOPD(O, P); + var current = desc && ToPropertyDescriptor(desc); + var extensible = IsExtensible(O); + return ValidateAndApplyPropertyDescriptor(O, P, extensible, Desc, current); +}; diff --git a/node_modules/es-abstract/2020/OrdinaryGetOwnProperty.js b/node_modules/es-abstract/2020/OrdinaryGetOwnProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..fdf6cc0cad72a7d2af37ee6eb9db36cffde6b822 --- /dev/null +++ b/node_modules/es-abstract/2020/OrdinaryGetOwnProperty.js @@ -0,0 +1,40 @@ +'use strict'; + +var $gOPD = require('gopd'); +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); +var hasOwn = require('hasown'); +var callBound = require('call-bound'); + +var $isEnumerable = callBound('Object.prototype.propertyIsEnumerable'); + +var IsArray = require('./IsArray'); +var isPropertyKey = require('../helpers/isPropertyKey'); +var IsRegExp = require('./IsRegExp'); +var ToPropertyDescriptor = require('./ToPropertyDescriptor'); + +// https://262.ecma-international.org/6.0/#sec-ordinarygetownproperty + +module.exports = function OrdinaryGetOwnProperty(O, P) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: O must be an Object'); + } + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: P must be a Property Key'); + } + if (!hasOwn(O, P)) { + return void 0; + } + if (!$gOPD) { + // ES3 / IE 8 fallback + var arrayLength = IsArray(O) && P === 'length'; + var regexLastIndex = IsRegExp(O) && P === 'lastIndex'; + return { + '[[Configurable]]': !(arrayLength || regexLastIndex), + '[[Enumerable]]': $isEnumerable(O, P), + '[[Value]]': O[P], + '[[Writable]]': true + }; + } + return ToPropertyDescriptor($gOPD(O, P)); +}; diff --git a/node_modules/es-abstract/2020/OrdinaryGetPrototypeOf.js b/node_modules/es-abstract/2020/OrdinaryGetPrototypeOf.js new file mode 100644 index 0000000000000000000000000000000000000000..7ef8bee34617c4ecaa2bd4b55cf1eb6a6665fe50 --- /dev/null +++ b/node_modules/es-abstract/2020/OrdinaryGetPrototypeOf.js @@ -0,0 +1,18 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var $getProto = require('get-proto'); + +// https://262.ecma-international.org/7.0/#sec-ordinarygetprototypeof + +module.exports = function OrdinaryGetPrototypeOf(O) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: O must be an Object'); + } + if (!$getProto) { + throw new $TypeError('This environment does not support fetching prototypes.'); + } + return $getProto(O); +}; diff --git a/node_modules/es-abstract/2020/OrdinaryHasInstance.js b/node_modules/es-abstract/2020/OrdinaryHasInstance.js new file mode 100644 index 0000000000000000000000000000000000000000..a0a83e6733a49e898d0f9db5df20a54028ad69e3 --- /dev/null +++ b/node_modules/es-abstract/2020/OrdinaryHasInstance.js @@ -0,0 +1,23 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var Get = require('./Get'); +var IsCallable = require('./IsCallable'); + +// https://262.ecma-international.org/6.0/#sec-ordinaryhasinstance + +module.exports = function OrdinaryHasInstance(C, O) { + if (!IsCallable(C)) { + return false; + } + if (!isObject(O)) { + return false; + } + var P = Get(C, 'prototype'); + if (!isObject(P)) { + throw new $TypeError('OrdinaryHasInstance called on an object with an invalid prototype property.'); + } + return O instanceof C; +}; diff --git a/node_modules/es-abstract/2020/OrdinaryHasProperty.js b/node_modules/es-abstract/2020/OrdinaryHasProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..c6c5c11961374a2c3c4beb751aca52a9973093d6 --- /dev/null +++ b/node_modules/es-abstract/2020/OrdinaryHasProperty.js @@ -0,0 +1,18 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var isPropertyKey = require('../helpers/isPropertyKey'); + +// https://262.ecma-international.org/6.0/#sec-ordinaryhasproperty + +module.exports = function OrdinaryHasProperty(O, P) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: P must be a Property Key'); + } + return P in O; +}; diff --git a/node_modules/es-abstract/2020/OrdinaryObjectCreate.js b/node_modules/es-abstract/2020/OrdinaryObjectCreate.js new file mode 100644 index 0000000000000000000000000000000000000000..aca0ac014fead59cc298b13659179c082a4ae82a --- /dev/null +++ b/node_modules/es-abstract/2020/OrdinaryObjectCreate.js @@ -0,0 +1,56 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $ObjectCreate = GetIntrinsic('%Object.create%', true); +var $TypeError = require('es-errors/type'); +var $SyntaxError = require('es-errors/syntax'); +var isObject = require('es-object-atoms/isObject'); + +var IsArray = require('./IsArray'); + +var forEach = require('../helpers/forEach'); + +var SLOT = require('internal-slot'); + +var hasProto = require('has-proto')(); + +// https://262.ecma-international.org/11.0/#sec-objectcreate + +module.exports = function OrdinaryObjectCreate(proto) { + if (proto !== null && !isObject(proto)) { + throw new $TypeError('Assertion failed: `proto` must be null or an object'); + } + var additionalInternalSlotsList = arguments.length < 2 ? [] : arguments[1]; + if (!IsArray(additionalInternalSlotsList)) { + throw new $TypeError('Assertion failed: `additionalInternalSlotsList` must be an Array'); + } + + // var internalSlotsList = ['[[Prototype]]', '[[Extensible]]']; // step 1 + // internalSlotsList.push(...additionalInternalSlotsList); // step 2 + // var O = MakeBasicObject(internalSlotsList); // step 3 + // setProto(O, proto); // step 4 + // return O; // step 5 + + var O; + if (hasProto) { + O = { __proto__: proto }; + } else if ($ObjectCreate) { + O = $ObjectCreate(proto); + } else { + if (proto === null) { + throw new $SyntaxError('native Object.create support is required to create null objects'); + } + var T = function T() {}; + T.prototype = proto; + O = new T(); + } + + if (additionalInternalSlotsList.length > 0) { + forEach(additionalInternalSlotsList, function (slot) { + SLOT.set(O, slot, void undefined); + }); + } + + return O; +}; diff --git a/node_modules/es-abstract/2020/OrdinarySetPrototypeOf.js b/node_modules/es-abstract/2020/OrdinarySetPrototypeOf.js new file mode 100644 index 0000000000000000000000000000000000000000..b493a442ddd22b125fde2ed40eeebddf2d080a2d --- /dev/null +++ b/node_modules/es-abstract/2020/OrdinarySetPrototypeOf.js @@ -0,0 +1,50 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var $setProto = require('set-proto'); +var isObject = require('es-object-atoms/isObject'); + +var OrdinaryGetPrototypeOf = require('./OrdinaryGetPrototypeOf'); + +// https://262.ecma-international.org/7.0/#sec-ordinarysetprototypeof + +module.exports = function OrdinarySetPrototypeOf(O, V) { + if (V !== null && !isObject(V)) { + throw new $TypeError('Assertion failed: V must be Object or Null'); + } + /* + var extensible = IsExtensible(O); + var current = OrdinaryGetPrototypeOf(O); + if (SameValue(V, current)) { + return true; + } + if (!extensible) { + return false; + } + */ + try { + $setProto(O, V); + } catch (e) { + return false; + } + return OrdinaryGetPrototypeOf(O) === V; + /* + var p = V; + var done = false; + while (!done) { + if (p === null) { + done = true; + } else if (SameValue(p, O)) { + return false; + } else { + if (wat) { + done = true; + } else { + p = p.[[Prototype]]; + } + } + } + O.[[Prototype]] = V; + return true; + */ +}; diff --git a/node_modules/es-abstract/2020/OrdinaryToPrimitive.js b/node_modules/es-abstract/2020/OrdinaryToPrimitive.js new file mode 100644 index 0000000000000000000000000000000000000000..5feb5694e8aba94591eac365aa6bd8a6b985f305 --- /dev/null +++ b/node_modules/es-abstract/2020/OrdinaryToPrimitive.js @@ -0,0 +1,36 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var Call = require('./Call'); +var Get = require('./Get'); +var IsCallable = require('./IsCallable'); + +var inspect = require('object-inspect'); + +// https://262.ecma-international.org/8.0/#sec-ordinarytoprimitive + +module.exports = function OrdinaryToPrimitive(O, hint) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + if (/* typeof hint !== 'string' || */ hint !== 'string' && hint !== 'number') { + throw new $TypeError('Assertion failed: `hint` must be "string" or "number"'); + } + + var methodNames = hint === 'string' ? ['toString', 'valueOf'] : ['valueOf', 'toString']; + + for (var i = 0; i < methodNames.length; i += 1) { + var name = methodNames[i]; + var method = Get(O, name); + if (IsCallable(method)) { + var result = Call(method, O); + if (!isObject(result)) { + return result; + } + } + } + + throw new $TypeError('No primitive value for ' + inspect(O)); +}; diff --git a/node_modules/es-abstract/2020/PromiseResolve.js b/node_modules/es-abstract/2020/PromiseResolve.js new file mode 100644 index 0000000000000000000000000000000000000000..dfb7d82fd2e9a378da3188a73ff006a06ce14463 --- /dev/null +++ b/node_modules/es-abstract/2020/PromiseResolve.js @@ -0,0 +1,18 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); +var callBind = require('call-bind'); +var $SyntaxError = require('es-errors/syntax'); + +var $resolve = GetIntrinsic('%Promise.resolve%', true); +var $PromiseResolve = $resolve && callBind($resolve); + +// https://262.ecma-international.org/9.0/#sec-promise-resolve + +module.exports = function PromiseResolve(C, x) { + if (!$PromiseResolve) { + throw new $SyntaxError('This environment does not support Promises.'); + } + return $PromiseResolve(C, x); +}; + diff --git a/node_modules/es-abstract/2020/QuoteJSONString.js b/node_modules/es-abstract/2020/QuoteJSONString.js new file mode 100644 index 0000000000000000000000000000000000000000..f90e3094c2f30f00d3f36a6eb67a3a3aad44277b --- /dev/null +++ b/node_modules/es-abstract/2020/QuoteJSONString.js @@ -0,0 +1,52 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var callBound = require('call-bound'); +var forEach = require('../helpers/forEach'); +var isLeadingSurrogate = require('../helpers/isLeadingSurrogate'); +var isTrailingSurrogate = require('../helpers/isTrailingSurrogate'); + +var $charCodeAt = callBound('String.prototype.charCodeAt'); +var $strSplit = callBound('String.prototype.split'); + +var UnicodeEscape = require('./UnicodeEscape'); +var UTF16DecodeString = require('./UTF16DecodeString'); +var UTF16Encoding = require('./UTF16Encoding'); + +var hasOwn = require('hasown'); + +// https://262.ecma-international.org/11.0/#sec-quotejsonstring + +var escapes = { + '\u0008': '\\b', + '\u0009': '\\t', + '\u000A': '\\n', + '\u000C': '\\f', + '\u000D': '\\r', + '\u0022': '\\"', + '\u005c': '\\\\' +}; + +module.exports = function QuoteJSONString(value) { + if (typeof value !== 'string') { + throw new $TypeError('Assertion failed: `value` must be a String'); + } + var product = '"'; + if (value) { + forEach($strSplit(UTF16DecodeString(value), ''), function (C) { + if (hasOwn(escapes, C)) { + product += escapes[C]; + } else { + var cCharCode = $charCodeAt(C, 0); + if (cCharCode < 0x20 || isLeadingSurrogate(cCharCode) || isTrailingSurrogate(cCharCode)) { + product += UnicodeEscape(C); + } else { + product += UTF16Encoding(cCharCode); + } + } + }); + } + product += '"'; + return product; +}; diff --git a/node_modules/es-abstract/2020/RawBytesToNumeric.js b/node_modules/es-abstract/2020/RawBytesToNumeric.js new file mode 100644 index 0000000000000000000000000000000000000000..70c24064ca2c7208f10baec57d50b6a31d4038a2 --- /dev/null +++ b/node_modules/es-abstract/2020/RawBytesToNumeric.js @@ -0,0 +1,67 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); +var callBound = require('call-bound'); + +var $RangeError = require('es-errors/range'); +var $SyntaxError = require('es-errors/syntax'); +var $TypeError = require('es-errors/type'); +var $BigInt = GetIntrinsic('%BigInt%', true); + +var hasOwnProperty = require('./HasOwnProperty'); +var IsArray = require('./IsArray'); +var IsBigIntElementType = require('./IsBigIntElementType'); +var IsUnsignedElementType = require('./IsUnsignedElementType'); + +var bytesAsFloat32 = require('../helpers/bytesAsFloat32'); +var bytesAsFloat64 = require('../helpers/bytesAsFloat64'); +var bytesAsInteger = require('../helpers/bytesAsInteger'); +var every = require('../helpers/every'); +var isByteValue = require('../helpers/isByteValue'); + +var $reverse = callBound('Array.prototype.reverse'); +var $slice = callBound('Array.prototype.slice'); + +var tableTAO = require('./tables/typed-array-objects'); + +// https://262.ecma-international.org/11.0/#sec-rawbytestonumeric + +module.exports = function RawBytesToNumeric(type, rawBytes, isLittleEndian) { + if (typeof type !== 'string' || !hasOwnProperty(tableTAO.size, '$' + type)) { + throw new $TypeError('Assertion failed: `type` must be a TypedArray element type'); + } + if (!IsArray(rawBytes) || !every(rawBytes, isByteValue)) { + throw new $TypeError('Assertion failed: `rawBytes` must be an Array of bytes'); + } + if (typeof isLittleEndian !== 'boolean') { + throw new $TypeError('Assertion failed: `isLittleEndian` must be a Boolean'); + } + + var elementSize = tableTAO.size['$' + type]; // step 1 + + if (rawBytes.length !== elementSize) { + // this assertion is not in the spec, but it'd be an editorial error if it were ever violated + throw new $RangeError('Assertion failed: `rawBytes` must have a length of ' + elementSize + ' for type ' + type); + } + + var isBigInt = IsBigIntElementType(type); + if (isBigInt && !$BigInt) { + throw new $SyntaxError('this environment does not support BigInts'); + } + + // eslint-disable-next-line no-param-reassign + rawBytes = $slice(rawBytes, 0, elementSize); + if (!isLittleEndian) { + $reverse(rawBytes); // step 2 + } + + if (type === 'Float32') { // step 3 + return bytesAsFloat32(rawBytes); + } + + if (type === 'Float64') { // step 4 + return bytesAsFloat64(rawBytes); + } + + return bytesAsInteger(rawBytes, elementSize, IsUnsignedElementType(type), isBigInt); +}; diff --git a/node_modules/es-abstract/2020/RegExpCreate.js b/node_modules/es-abstract/2020/RegExpCreate.js new file mode 100644 index 0000000000000000000000000000000000000000..68e31605ed1764b9e1addddc5b910e9c9d73fba2 --- /dev/null +++ b/node_modules/es-abstract/2020/RegExpCreate.js @@ -0,0 +1,21 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $RegExp = GetIntrinsic('%RegExp%'); + +// var RegExpAlloc = require('./RegExpAlloc'); +// var RegExpInitialize = require('./RegExpInitialize'); +var ToString = require('./ToString'); + +// https://262.ecma-international.org/6.0/#sec-regexpcreate + +module.exports = function RegExpCreate(P, F) { + // var obj = RegExpAlloc($RegExp); + // return RegExpInitialize(obj, P, F); + + // covers spec mechanics; bypass regex brand checking + var pattern = typeof P === 'undefined' ? '' : ToString(P); + var flags = typeof F === 'undefined' ? '' : ToString(F); + return new $RegExp(pattern, flags); +}; diff --git a/node_modules/es-abstract/2020/RegExpExec.js b/node_modules/es-abstract/2020/RegExpExec.js new file mode 100644 index 0000000000000000000000000000000000000000..15762b8343aa380c2c90257eef552a87c56745ae --- /dev/null +++ b/node_modules/es-abstract/2020/RegExpExec.js @@ -0,0 +1,29 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); +var regexExec = require('call-bound')('RegExp.prototype.exec'); + +var Call = require('./Call'); +var Get = require('./Get'); +var IsCallable = require('./IsCallable'); + +// https://262.ecma-international.org/6.0/#sec-regexpexec + +module.exports = function RegExpExec(R, S) { + if (!isObject(R)) { + throw new $TypeError('Assertion failed: `R` must be an Object'); + } + if (typeof S !== 'string') { + throw new $TypeError('Assertion failed: `S` must be a String'); + } + var exec = Get(R, 'exec'); + if (IsCallable(exec)) { + var result = Call(exec, R, [S]); + if (result === null || isObject(result)) { + return result; + } + throw new $TypeError('"exec" method must return `null` or an Object'); + } + return regexExec(R, S); +}; diff --git a/node_modules/es-abstract/2020/RequireObjectCoercible.js b/node_modules/es-abstract/2020/RequireObjectCoercible.js new file mode 100644 index 0000000000000000000000000000000000000000..b816d1f34b01a80352e783672836a17c49cc06f0 --- /dev/null +++ b/node_modules/es-abstract/2020/RequireObjectCoercible.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('es-object-atoms/RequireObjectCoercible'); diff --git a/node_modules/es-abstract/2020/SameValue.js b/node_modules/es-abstract/2020/SameValue.js new file mode 100644 index 0000000000000000000000000000000000000000..d07bbb8a8f3fec5ad22ffdfb617245331fcff412 --- /dev/null +++ b/node_modules/es-abstract/2020/SameValue.js @@ -0,0 +1,13 @@ +'use strict'; + +var $isNaN = require('math-intrinsics/isNaN'); + +// http://262.ecma-international.org/5.1/#sec-9.12 + +module.exports = function SameValue(x, y) { + if (x === y) { // 0 === -0, but they are not identical. + if (x === 0) { return 1 / x === 1 / y; } + return true; + } + return $isNaN(x) && $isNaN(y); +}; diff --git a/node_modules/es-abstract/2020/SameValueNonNumeric.js b/node_modules/es-abstract/2020/SameValueNonNumeric.js new file mode 100644 index 0000000000000000000000000000000000000000..7c28e0f53c57f0fe4587928b6d91850992d91b8f --- /dev/null +++ b/node_modules/es-abstract/2020/SameValueNonNumeric.js @@ -0,0 +1,18 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var SameValue = require('./SameValue'); +var Type = require('./Type'); + +// https://262.ecma-international.org/11.0/#sec-samevaluenonnumeric + +module.exports = function SameValueNonNumeric(x, y) { + if (typeof x === 'number' || typeof x === 'bigint') { + throw new $TypeError('Assertion failed: SameValueNonNumeric does not accept Number or BigInt values'); + } + if (Type(x) !== Type(y)) { + throw new $TypeError('SameValueNonNumeric requires two non-numeric values of the same type.'); + } + return SameValue(x, y); +}; diff --git a/node_modules/es-abstract/2020/SameValueZero.js b/node_modules/es-abstract/2020/SameValueZero.js new file mode 100644 index 0000000000000000000000000000000000000000..8880e915941eeae2d890f2bdeb1bd057516e3d50 --- /dev/null +++ b/node_modules/es-abstract/2020/SameValueZero.js @@ -0,0 +1,9 @@ +'use strict'; + +var $isNaN = require('math-intrinsics/isNaN'); + +// https://262.ecma-international.org/6.0/#sec-samevaluezero + +module.exports = function SameValueZero(x, y) { + return (x === y) || ($isNaN(x) && $isNaN(y)); +}; diff --git a/node_modules/es-abstract/2020/SecFromTime.js b/node_modules/es-abstract/2020/SecFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..fc2e44560240f134cf345e63ab69d5f8a2d8cec1 --- /dev/null +++ b/node_modules/es-abstract/2020/SecFromTime.js @@ -0,0 +1,14 @@ +'use strict'; + +var floor = require('./floor'); +var modulo = require('./modulo'); + +var timeConstants = require('../helpers/timeConstants'); +var msPerSecond = timeConstants.msPerSecond; +var SecondsPerMinute = timeConstants.SecondsPerMinute; + +// https://262.ecma-international.org/5.1/#sec-15.9.1.10 + +module.exports = function SecFromTime(t) { + return modulo(floor(t / msPerSecond), SecondsPerMinute); +}; diff --git a/node_modules/es-abstract/2020/Set.js b/node_modules/es-abstract/2020/Set.js new file mode 100644 index 0000000000000000000000000000000000000000..f814076a8fb813648eb16093fe86a46182c0fccf --- /dev/null +++ b/node_modules/es-abstract/2020/Set.js @@ -0,0 +1,45 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var isPropertyKey = require('../helpers/isPropertyKey'); +var SameValue = require('./SameValue'); + +// IE 9 does not throw in strict mode when writability/configurability/extensibility is violated +var noThrowOnStrictViolation = (function () { + try { + delete [].length; + return true; + } catch (e) { + return false; + } +}()); + +// https://262.ecma-international.org/6.0/#sec-set-o-p-v-throw + +module.exports = function Set(O, P, V, Throw) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: `O` must be an Object'); + } + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: `P` must be a Property Key'); + } + if (typeof Throw !== 'boolean') { + throw new $TypeError('Assertion failed: `Throw` must be a Boolean'); + } + if (Throw) { + O[P] = V; // eslint-disable-line no-param-reassign + if (noThrowOnStrictViolation && !SameValue(O[P], V)) { + throw new $TypeError('Attempted to assign to readonly property.'); + } + return true; + } + try { + O[P] = V; // eslint-disable-line no-param-reassign + return noThrowOnStrictViolation ? SameValue(O[P], V) : true; + } catch (e) { + return false; + } + +}; diff --git a/node_modules/es-abstract/2020/SetFunctionLength.js b/node_modules/es-abstract/2020/SetFunctionLength.js new file mode 100644 index 0000000000000000000000000000000000000000..10a020826183af7bc0e432dc488a5ef6d47eb39f --- /dev/null +++ b/node_modules/es-abstract/2020/SetFunctionLength.js @@ -0,0 +1,28 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var DefinePropertyOrThrow = require('./DefinePropertyOrThrow'); +var HasOwnProperty = require('./HasOwnProperty'); +var IsExtensible = require('./IsExtensible'); +var IsNonNegativeInteger = require('./IsNonNegativeInteger'); + +// https://262.ecma-international.org/11.0/#sec-setfunctionlength + +module.exports = function SetFunctionLength(F, length) { + if (typeof F !== 'function' || !IsExtensible(F) || HasOwnProperty(F, 'length')) { + throw new $TypeError('Assertion failed: `F` must be an extensible function and lack an own `length` property'); + } + if (typeof length !== 'number') { + throw new $TypeError('Assertion failed: `length` must be a Number'); + } + if (!IsNonNegativeInteger(length)) { + throw new $TypeError('Assertion failed: `length` must be an integer >= 0'); + } + return DefinePropertyOrThrow(F, 'length', { + '[[Configurable]]': true, + '[[Enumerable]]': false, + '[[Value]]': length, + '[[Writable]]': false + }); +}; diff --git a/node_modules/es-abstract/2020/SetFunctionName.js b/node_modules/es-abstract/2020/SetFunctionName.js new file mode 100644 index 0000000000000000000000000000000000000000..9e8511fd46bc115d0459cc66f44bb6560ba2bc3a --- /dev/null +++ b/node_modules/es-abstract/2020/SetFunctionName.js @@ -0,0 +1,40 @@ +'use strict'; + +var hasOwn = require('hasown'); + +var $TypeError = require('es-errors/type'); + +var getSymbolDescription = require('get-symbol-description'); + +var DefinePropertyOrThrow = require('./DefinePropertyOrThrow'); +var IsExtensible = require('./IsExtensible'); + +// https://262.ecma-international.org/6.0/#sec-setfunctionname + +module.exports = function SetFunctionName(F, name) { + if (typeof F !== 'function') { + throw new $TypeError('Assertion failed: `F` must be a function'); + } + if (!IsExtensible(F) || hasOwn(F, 'name')) { + throw new $TypeError('Assertion failed: `F` must be extensible, and must not have a `name` own property'); + } + if (typeof name !== 'symbol' && typeof name !== 'string') { + throw new $TypeError('Assertion failed: `name` must be a Symbol or a String'); + } + if (typeof name === 'symbol') { + var description = getSymbolDescription(name); + // eslint-disable-next-line no-param-reassign + name = typeof description === 'undefined' ? '' : '[' + description + ']'; + } + if (arguments.length > 2) { + var prefix = arguments[2]; + // eslint-disable-next-line no-param-reassign + name = prefix + ' ' + name; + } + return DefinePropertyOrThrow(F, 'name', { + '[[Value]]': name, + '[[Writable]]': false, + '[[Enumerable]]': false, + '[[Configurable]]': true + }); +}; diff --git a/node_modules/es-abstract/2020/SetIntegrityLevel.js b/node_modules/es-abstract/2020/SetIntegrityLevel.js new file mode 100644 index 0000000000000000000000000000000000000000..ad92fb99b004f2b05e23fa0b2ef45dfc3775025e --- /dev/null +++ b/node_modules/es-abstract/2020/SetIntegrityLevel.js @@ -0,0 +1,57 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $SyntaxError = require('es-errors/syntax'); +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); +var $gOPD = require('gopd'); +var $preventExtensions = GetIntrinsic('%Object.preventExtensions%', true); +var $gOPN = GetIntrinsic('%Object.getOwnPropertyNames%', true); + +var forEach = require('../helpers/forEach'); + +var DefinePropertyOrThrow = require('./DefinePropertyOrThrow'); +var IsAccessorDescriptor = require('./IsAccessorDescriptor'); +var ToPropertyDescriptor = require('./ToPropertyDescriptor'); + +// https://262.ecma-international.org/6.0/#sec-setintegritylevel + +module.exports = function SetIntegrityLevel(O, level) { + if (!isObject(O)) { + 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); + if (level === 'sealed') { + forEach(theKeys, function (k) { + 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 (IsAccessorDescriptor(ToPropertyDescriptor(currentDesc))) { + desc = { configurable: false }; + } else { + desc = { configurable: false, writable: false }; + } + DefinePropertyOrThrow(O, k, desc); + } + }); + } + return true; +}; diff --git a/node_modules/es-abstract/2020/SetValueInBuffer.js b/node_modules/es-abstract/2020/SetValueInBuffer.js new file mode 100644 index 0000000000000000000000000000000000000000..2082b6fb632d801690039e61787573018899172d --- /dev/null +++ b/node_modules/es-abstract/2020/SetValueInBuffer.js @@ -0,0 +1,96 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $SyntaxError = require('es-errors/syntax'); +var $TypeError = require('es-errors/type'); +var $Uint8Array = GetIntrinsic('%Uint8Array%', true); +var isInteger = require('math-intrinsics/isInteger'); + +var IsBigIntElementType = require('./IsBigIntElementType'); +var IsDetachedBuffer = require('./IsDetachedBuffer'); +var NumericToRawBytes = require('./NumericToRawBytes'); + +var isArrayBuffer = require('is-array-buffer'); +var isSharedArrayBuffer = require('is-shared-array-buffer'); +var hasOwn = require('hasown'); + +var tableTAO = require('./tables/typed-array-objects'); + +var defaultEndianness = require('../helpers/defaultEndianness'); +var forEach = require('../helpers/forEach'); + +// https://262.ecma-international.org/11.0/#sec-setvalueinbuffer + +/* eslint max-params: 0 */ + +module.exports = function SetValueInBuffer(arrayBuffer, byteIndex, type, value, isTypedArray, order) { + var isSAB = isSharedArrayBuffer(arrayBuffer); + if (!isArrayBuffer(arrayBuffer) && !isSAB) { + throw new $TypeError('Assertion failed: `arrayBuffer` must be an ArrayBuffer or a SharedArrayBuffer'); + } + + if (!isInteger(byteIndex)) { + throw new $TypeError('Assertion failed: `byteIndex` must be an integer'); + } + + if (typeof type !== 'string' || !hasOwn(tableTAO.size, '$' + type)) { + throw new $TypeError('Assertion failed: `type` must be one of ' + tableTAO.choices); + } + + if (typeof value !== 'number' && typeof value !== 'bigint') { + throw new $TypeError('Assertion failed: `value` must be a Number or a BigInt'); + } + + if (typeof isTypedArray !== 'boolean') { + throw new $TypeError('Assertion failed: `isTypedArray` must be a boolean'); + } + if (order !== 'SeqCst' && order !== 'Unordered' && order !== 'Init') { + throw new $TypeError('Assertion failed: `order` must be `"SeqCst"`, `"Unordered"`, or `"Init"`'); + } + + if (arguments.length > 6 && typeof arguments[6] !== 'boolean') { + throw new $TypeError('Assertion failed: `isLittleEndian` must be a boolean, if present'); + } + + if (IsDetachedBuffer(arrayBuffer)) { + throw new $TypeError('Assertion failed: ArrayBuffer is detached'); // step 1 + } + + // 2. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type. + + if (byteIndex < 0) { + throw new $TypeError('Assertion failed: `byteIndex` must be non-negative'); // step 3 + } + + if (IsBigIntElementType(type) ? typeof value !== 'bigint' : typeof value !== 'number') { // step 4 + throw new $TypeError('Assertion failed: `value` must be a BigInt if type is BigInt64 or BigUint64, otherwise a Number'); + } + + // 5. Let block be arrayBuffer.[[ArrayBufferData]]. + + var elementSize = tableTAO.size['$' + type]; // step 6 + + // 7. If isLittleEndian is not present, set isLittleEndian to to the value of the [[LittleEndian]] field of the surrounding agent's Agent Record. + var isLittleEndian = arguments.length > 6 ? arguments[6] : defaultEndianness === 'little'; // step 8 + + var rawBytes = NumericToRawBytes(type, value, isLittleEndian); // step 8 + + if (isSAB) { // step 9 + /* + Let execution be the [[CandidateExecution]] field of the surrounding agent's Agent Record. + Let eventList be the [[EventList]] field of the element in execution.[[EventsRecords]] whose [[AgentSignifier]] is AgentSignifier(). + If isTypedArray is true and IsNoTearConfiguration(type, order) is true, let noTear be true; otherwise let noTear be false. + Append WriteSharedMemory { [[Order]]: order, [[NoTear]]: noTear, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize, [[Payload]]: rawBytes } to eventList. + */ + throw new $SyntaxError('SharedArrayBuffer is not supported by this implementation'); + } else { + // 10. Store the individual bytes of rawBytes into block, in order, starting at block[byteIndex]. + var arr = new $Uint8Array(arrayBuffer, byteIndex, elementSize); + forEach(rawBytes, function (rawByte, i) { + arr[i] = rawByte; + }); + } + + // 11. Return NormalCompletion(undefined). +}; diff --git a/node_modules/es-abstract/2020/SpeciesConstructor.js b/node_modules/es-abstract/2020/SpeciesConstructor.js new file mode 100644 index 0000000000000000000000000000000000000000..23e32b443ef3655f56639920d5cf58474500bf67 --- /dev/null +++ b/node_modules/es-abstract/2020/SpeciesConstructor.js @@ -0,0 +1,32 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $species = GetIntrinsic('%Symbol.species%', true); +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var IsConstructor = require('./IsConstructor'); + +// https://262.ecma-international.org/6.0/#sec-speciesconstructor + +module.exports = function SpeciesConstructor(O, defaultConstructor) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + var C = O.constructor; + if (typeof C === 'undefined') { + return defaultConstructor; + } + if (!isObject(C)) { + throw new $TypeError('O.constructor is not an Object'); + } + var S = $species ? C[$species] : void 0; + if (S == null) { + return defaultConstructor; + } + if (IsConstructor(S)) { + return S; + } + throw new $TypeError('no constructor found'); +}; diff --git a/node_modules/es-abstract/2020/SplitMatch.js b/node_modules/es-abstract/2020/SplitMatch.js new file mode 100644 index 0000000000000000000000000000000000000000..c04fa7f63c6884e6d40b21689784dae891ceb655 --- /dev/null +++ b/node_modules/es-abstract/2020/SplitMatch.js @@ -0,0 +1,35 @@ +'use strict'; + +var callBound = require('call-bound'); + +var $TypeError = require('es-errors/type'); +var isInteger = require('math-intrinsics/isInteger'); + +var $charAt = callBound('String.prototype.charAt'); + +// https://262.ecma-international.org/6.0/#sec-splitmatch + +module.exports = function SplitMatch(S, q, R) { + if (typeof S !== 'string') { + throw new $TypeError('Assertion failed: `S` must be a String'); + } + if (!isInteger(q)) { + throw new $TypeError('Assertion failed: `q` must be an integer'); + } + if (typeof R !== 'string') { + throw new $TypeError('Assertion failed: `R` must be a String'); + } + var r = R.length; + var s = S.length; + if (q + r > s) { + return false; + } + + for (var i = 0; i < r; i += 1) { + if ($charAt(S, q + i) !== $charAt(R, i)) { + return false; + } + } + + return q + r; +}; diff --git a/node_modules/es-abstract/2020/StrictEqualityComparison.js b/node_modules/es-abstract/2020/StrictEqualityComparison.js new file mode 100644 index 0000000000000000000000000000000000000000..d056c44e79a546022718908720ab19cd27e7415e --- /dev/null +++ b/node_modules/es-abstract/2020/StrictEqualityComparison.js @@ -0,0 +1,15 @@ +'use strict'; + +var Type = require('./Type'); + +// https://262.ecma-international.org/5.1/#sec-11.9.6 + +module.exports = function StrictEqualityComparison(x, y) { + if (Type(x) !== Type(y)) { + return false; + } + if (typeof x === 'undefined' || x === null) { + return true; + } + return x === y; // shortcut for steps 4-7 +}; diff --git a/node_modules/es-abstract/2020/StringCreate.js b/node_modules/es-abstract/2020/StringCreate.js new file mode 100644 index 0000000000000000000000000000000000000000..3e2aa43c50d8aa6317c0eef7eaf0b87e32916d4d --- /dev/null +++ b/node_modules/es-abstract/2020/StringCreate.js @@ -0,0 +1,38 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $Object = require('es-object-atoms'); +var $StringPrototype = GetIntrinsic('%String.prototype%'); +var $SyntaxError = require('es-errors/syntax'); +var $TypeError = require('es-errors/type'); +var setProto = require('set-proto'); + +var DefinePropertyOrThrow = require('./DefinePropertyOrThrow'); + +// https://262.ecma-international.org/6.0/#sec-stringcreate + +module.exports = function StringCreate(value, prototype) { + if (typeof value !== 'string') { + throw new $TypeError('Assertion failed: `S` must be a String'); + } + + var S = $Object(value); + if (prototype !== $StringPrototype) { + if (setProto) { + setProto(S, prototype); + } else { + throw new $SyntaxError('StringCreate: a `proto` argument that is not `String.prototype` is not supported in an environment that does not support setting the [[Prototype]]'); + } + } + + var length = value.length; + DefinePropertyOrThrow(S, 'length', { + '[[Configurable]]': false, + '[[Enumerable]]': false, + '[[Value]]': length, + '[[Writable]]': false + }); + + return S; +}; diff --git a/node_modules/es-abstract/2020/StringGetOwnProperty.js b/node_modules/es-abstract/2020/StringGetOwnProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..60a94ddc36368c245f5f54a807ea74e49bf663aa --- /dev/null +++ b/node_modules/es-abstract/2020/StringGetOwnProperty.js @@ -0,0 +1,47 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var callBound = require('call-bound'); +var $charAt = callBound('String.prototype.charAt'); +var $stringToString = callBound('String.prototype.toString'); + +var CanonicalNumericIndexString = require('./CanonicalNumericIndexString'); +var IsInteger = require('./IsInteger'); + +var isPropertyKey = require('../helpers/isPropertyKey'); + +var isNegativeZero = require('math-intrinsics/isNegativeZero'); + +// https://262.ecma-international.org/8.0/#sec-stringgetownproperty + +module.exports = function StringGetOwnProperty(S, P) { + var str; + if (isObject(S)) { + try { + str = $stringToString(S); + } catch (e) { /**/ } + } + if (typeof str !== 'string') { + throw new $TypeError('Assertion failed: `S` must be a boxed string object'); + } + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: P is not a Property Key'); + } + if (typeof P !== 'string') { + return void undefined; + } + var index = CanonicalNumericIndexString(P); + var len = str.length; + if (typeof index === 'undefined' || !IsInteger(index) || isNegativeZero(index) || index < 0 || len <= index) { + return void undefined; + } + var resultStr = $charAt(S, index); + return { + '[[Configurable]]': false, + '[[Enumerable]]': true, + '[[Value]]': resultStr, + '[[Writable]]': false + }; +}; diff --git a/node_modules/es-abstract/2020/StringPad.js b/node_modules/es-abstract/2020/StringPad.js new file mode 100644 index 0000000000000000000000000000000000000000..473b0b7bd490c72f1d1b90bd2a56f6d638fb0000 --- /dev/null +++ b/node_modules/es-abstract/2020/StringPad.js @@ -0,0 +1,41 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var callBound = require('call-bound'); + +var ToLength = require('./ToLength'); +var ToString = require('./ToString'); + +var $strSlice = callBound('String.prototype.slice'); + +// https://262.ecma-international.org/11.0/#sec-stringpad + +module.exports = function StringPad(O, maxLength, fillString, placement) { + if (placement !== 'start' && placement !== 'end') { + throw new $TypeError('Assertion failed: `placement` must be "start" or "end"'); + } + var S = ToString(O); + var intMaxLength = ToLength(maxLength); + var stringLength = S.length; + if (intMaxLength <= stringLength) { + return S; + } + var filler = typeof fillString === 'undefined' ? ' ' : ToString(fillString); + if (filler === '') { + return S; + } + var fillLen = intMaxLength - stringLength; + + // the String value consisting of repeated concatenations of filler truncated to length fillLen. + var truncatedStringFiller = ''; + while (truncatedStringFiller.length < fillLen) { + truncatedStringFiller += filler; + } + truncatedStringFiller = $strSlice(truncatedStringFiller, 0, fillLen); + + if (placement === 'start') { + return truncatedStringFiller + S; + } + return S + truncatedStringFiller; +}; diff --git a/node_modules/es-abstract/2020/StringToBigInt.js b/node_modules/es-abstract/2020/StringToBigInt.js new file mode 100644 index 0000000000000000000000000000000000000000..896c3bdc338a3f569dd7ac3065594be72ea35316 --- /dev/null +++ b/node_modules/es-abstract/2020/StringToBigInt.js @@ -0,0 +1,23 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $BigInt = GetIntrinsic('%BigInt%', true); +var $TypeError = require('es-errors/type'); +var $SyntaxError = require('es-errors/syntax'); + +// https://262.ecma-international.org/11.0/#sec-stringtobigint + +module.exports = function StringToBigInt(argument) { + if (typeof argument !== 'string') { + throw new $TypeError('`argument` must be a string'); + } + if (!$BigInt) { + throw new $SyntaxError('BigInts are not supported in this environment'); + } + try { + return $BigInt(argument); + } catch (e) { + return NaN; + } +}; diff --git a/node_modules/es-abstract/2020/SymbolDescriptiveString.js b/node_modules/es-abstract/2020/SymbolDescriptiveString.js new file mode 100644 index 0000000000000000000000000000000000000000..444e3f70004626a3053f672a290e5e81b0f5cf51 --- /dev/null +++ b/node_modules/es-abstract/2020/SymbolDescriptiveString.js @@ -0,0 +1,16 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var callBound = require('call-bound'); + +var $SymbolToString = callBound('Symbol.prototype.toString', true); + +// https://262.ecma-international.org/6.0/#sec-symboldescriptivestring + +module.exports = function SymbolDescriptiveString(sym) { + if (typeof sym !== 'symbol') { + throw new $TypeError('Assertion failed: `sym` must be a Symbol'); + } + return $SymbolToString(sym); +}; diff --git a/node_modules/es-abstract/2020/TestIntegrityLevel.js b/node_modules/es-abstract/2020/TestIntegrityLevel.js new file mode 100644 index 0000000000000000000000000000000000000000..0e802f42786f89bac378b6a58e6009c9620be721 --- /dev/null +++ b/node_modules/es-abstract/2020/TestIntegrityLevel.js @@ -0,0 +1,40 @@ +'use strict'; + +var $gOPD = require('gopd'); +var $TypeError = require('es-errors/type'); + +var every = require('../helpers/every'); +var OwnPropertyKeys = require('own-keys'); +var isObject = require('es-object-atoms/isObject'); + +var IsDataDescriptor = require('./IsDataDescriptor'); +var IsExtensible = require('./IsExtensible'); +var ToPropertyDescriptor = require('./ToPropertyDescriptor'); + +// https://262.ecma-international.org/6.0/#sec-testintegritylevel + +module.exports = function TestIntegrityLevel(O, level) { + if (!isObject(O)) { + 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 = IsExtensible(O); + if (status || !$gOPD) { + return false; + } + var theKeys = OwnPropertyKeys(O); + 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' && IsDataDescriptor(ToPropertyDescriptor(currentDesc)) && currentDesc.writable) { + return false; + } + } + return true; + }); +}; diff --git a/node_modules/es-abstract/2020/ThrowCompletion.js b/node_modules/es-abstract/2020/ThrowCompletion.js new file mode 100644 index 0000000000000000000000000000000000000000..b7d388a35292e2a9faf88d4808b74e2c4878bbe7 --- /dev/null +++ b/node_modules/es-abstract/2020/ThrowCompletion.js @@ -0,0 +1,9 @@ +'use strict'; + +var CompletionRecord = require('./CompletionRecord'); + +// https://262.ecma-international.org/9.0/#sec-throwcompletion + +module.exports = function ThrowCompletion(argument) { + return new CompletionRecord('throw', argument); +}; diff --git a/node_modules/es-abstract/2020/TimeClip.js b/node_modules/es-abstract/2020/TimeClip.js new file mode 100644 index 0000000000000000000000000000000000000000..77c8dd4226c4765855024b1784b842f869fa5bfe --- /dev/null +++ b/node_modules/es-abstract/2020/TimeClip.js @@ -0,0 +1,20 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $Date = GetIntrinsic('%Date%'); + +var $isFinite = require('math-intrinsics/isFinite'); +var abs = require('math-intrinsics/abs'); + +var ToNumber = require('./ToNumber'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.14 + +module.exports = function TimeClip(time) { + if (!$isFinite(time) || abs(time) > 8.64e15) { + return NaN; + } + return +new $Date(ToNumber(time)); +}; + diff --git a/node_modules/es-abstract/2020/TimeFromYear.js b/node_modules/es-abstract/2020/TimeFromYear.js new file mode 100644 index 0000000000000000000000000000000000000000..f3518a41a19146c9ba59e1362c3fb33f800daaa1 --- /dev/null +++ b/node_modules/es-abstract/2020/TimeFromYear.js @@ -0,0 +1,11 @@ +'use strict'; + +var msPerDay = require('../helpers/timeConstants').msPerDay; + +var DayFromYear = require('./DayFromYear'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.3 + +module.exports = function TimeFromYear(y) { + return msPerDay * DayFromYear(y); +}; diff --git a/node_modules/es-abstract/2020/TimeString.js b/node_modules/es-abstract/2020/TimeString.js new file mode 100644 index 0000000000000000000000000000000000000000..f79080d6c3523a6d272d53f45a1e1501b655ae75 --- /dev/null +++ b/node_modules/es-abstract/2020/TimeString.js @@ -0,0 +1,22 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var $isNaN = require('math-intrinsics/isNaN'); +var padTimeComponent = require('../helpers/padTimeComponent'); + +var HourFromTime = require('./HourFromTime'); +var MinFromTime = require('./MinFromTime'); +var SecFromTime = require('./SecFromTime'); + +// https://262.ecma-international.org/9.0/#sec-timestring + +module.exports = function TimeString(tv) { + if (typeof tv !== 'number' || $isNaN(tv)) { + throw new $TypeError('Assertion failed: `tv` must be a non-NaN Number'); + } + var hour = HourFromTime(tv); + var minute = MinFromTime(tv); + var second = SecFromTime(tv); + return padTimeComponent(hour) + ':' + padTimeComponent(minute) + ':' + padTimeComponent(second) + '\x20GMT'; +}; diff --git a/node_modules/es-abstract/2020/TimeWithinDay.js b/node_modules/es-abstract/2020/TimeWithinDay.js new file mode 100644 index 0000000000000000000000000000000000000000..2bba83386c141873d3b603ed19d0f37069d1016a --- /dev/null +++ b/node_modules/es-abstract/2020/TimeWithinDay.js @@ -0,0 +1,12 @@ +'use strict'; + +var modulo = require('./modulo'); + +var msPerDay = require('../helpers/timeConstants').msPerDay; + +// https://262.ecma-international.org/5.1/#sec-15.9.1.2 + +module.exports = function TimeWithinDay(t) { + return modulo(t, msPerDay); +}; + diff --git a/node_modules/es-abstract/2020/TimeZoneString.js b/node_modules/es-abstract/2020/TimeZoneString.js new file mode 100644 index 0000000000000000000000000000000000000000..aa4d5b1cdea32a13bc20fb9526f7a76b89194431 --- /dev/null +++ b/node_modules/es-abstract/2020/TimeZoneString.js @@ -0,0 +1,33 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $Date = GetIntrinsic('%Date%'); +var $TypeError = require('es-errors/type'); + +var isNaN = require('math-intrinsics/isNaN'); + +var callBound = require('call-bound'); + +var $indexOf = callBound('String.prototype.indexOf'); +var $slice = callBound('String.prototype.slice'); +var $toTimeString = callBound('Date.prototype.toTimeString'); + +// https://262.ecma-international.org/9.0/#sec-timezoneestring + +module.exports = function TimeZoneString(tv) { + if (typeof tv !== 'number' || isNaN(tv)) { + throw new $TypeError('Assertion failed: `tv` must be a non-NaN Number'); // steps 1 - 2 + } + + // 3. Let offset be LocalTZA(tv, true). + // 4. If offset ≥ 0, let offsetSign be "+"; otherwise, let offsetSign be "-". + // 5. Let offsetMin be the String representation of MinFromTime(abs(offset)), formatted as a two-digit decimal number, padded to the left with a zero if necessary. + // 6. Let offsetHour be the String representation of HourFromTime(abs(offset)), formatted as a two-digit decimal number, padded to the left with a zero if necessary. + // 7. Let tzName be an implementation-defined string that is either the empty string or the string-concatenation of the code unit 0x0020 (SPACE), the code unit 0x0028 (LEFT PARENTHESIS), an implementation-dependent timezone name, and the code unit 0x0029 (RIGHT PARENTHESIS). + // 8. Return the string-concatenation of offsetSign, offsetHour, offsetMin, and tzName. + + // hack until LocalTZA, and "implementation-defined string" are available + var ts = $toTimeString(new $Date(tv)); + return $slice(ts, $indexOf(ts, '(') + 1, $indexOf(ts, ')')); +}; diff --git a/node_modules/es-abstract/2020/ToBigInt.js b/node_modules/es-abstract/2020/ToBigInt.js new file mode 100644 index 0000000000000000000000000000000000000000..4d1feefd492a36739d908deb6c160f1dedb62359 --- /dev/null +++ b/node_modules/es-abstract/2020/ToBigInt.js @@ -0,0 +1,53 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $BigInt = GetIntrinsic('%BigInt%', true); +var $Number = GetIntrinsic('%Number%'); +var $TypeError = require('es-errors/type'); +var $SyntaxError = require('es-errors/syntax'); + +var StringToBigInt = require('./StringToBigInt'); +var ToPrimitive = require('./ToPrimitive'); + +var isNaN = require('math-intrinsics/isNaN'); + +// https://262.ecma-international.org/11.0/#sec-tobigint + +module.exports = function ToBigInt(argument) { + if (!$BigInt) { + throw new $SyntaxError('BigInts are not supported in this environment'); + } + + var prim = ToPrimitive(argument, $Number); + + if (prim == null) { + throw new $TypeError('Cannot convert null or undefined to a BigInt'); + } + + if (typeof prim === 'boolean') { + return prim ? $BigInt(1) : $BigInt(0); + } + + if (typeof prim === 'number') { + throw new $TypeError('Cannot convert a Number value to a BigInt'); + } + + if (typeof prim === 'string') { + var n = StringToBigInt(prim); + if (isNaN(n)) { + throw new $TypeError('Failed to parse String to BigInt'); + } + return n; + } + + if (typeof prim === 'symbol') { + throw new $TypeError('Cannot convert a Symbol value to a BigInt'); + } + + if (typeof prim !== 'bigint') { + throw new $SyntaxError('Assertion failed: unknown primitive type'); + } + + return prim; +}; diff --git a/node_modules/es-abstract/2020/ToBigInt64.js b/node_modules/es-abstract/2020/ToBigInt64.js new file mode 100644 index 0000000000000000000000000000000000000000..627acba3d06e0e6d1e8b0b91088efbc7d6d42b0a --- /dev/null +++ b/node_modules/es-abstract/2020/ToBigInt64.js @@ -0,0 +1,25 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $BigInt = GetIntrinsic('%BigInt%', true); +var $pow = require('math-intrinsics/pow'); + +var ToBigInt = require('./ToBigInt'); +var BigIntRemainder = require('./BigInt/remainder'); + +var modBigInt = require('../helpers/modBigInt'); + +// BigInt(2**63), but node v10.4-v10.8 have a bug where you can't `BigInt(x)` anything larger than MAX_SAFE_INTEGER +var twoSixtyThree = $BigInt && (BigInt($pow(2, 32)) * BigInt($pow(2, 31))); + +// BigInt(2**64), but node v10.4-v10.8 have a bug where you can't `BigInt(x)` anything larger than MAX_SAFE_INTEGER +var twoSixtyFour = $BigInt && (BigInt($pow(2, 32)) * BigInt($pow(2, 32))); + +// https://262.ecma-international.org/11.0/#sec-tobigint64 + +module.exports = function ToBigInt64(argument) { + var n = ToBigInt(argument); + var int64bit = modBigInt(BigIntRemainder, n, twoSixtyFour); + return int64bit >= twoSixtyThree ? int64bit - twoSixtyFour : int64bit; +}; diff --git a/node_modules/es-abstract/2020/ToBigUint64.js b/node_modules/es-abstract/2020/ToBigUint64.js new file mode 100644 index 0000000000000000000000000000000000000000..f4038dc7bcaceb9b24157f6e6bcdfa286138f785 --- /dev/null +++ b/node_modules/es-abstract/2020/ToBigUint64.js @@ -0,0 +1,23 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $BigInt = GetIntrinsic('%BigInt%', true); + +var $pow = require('math-intrinsics/pow'); + +var ToBigInt = require('./ToBigInt'); +var BigIntRemainder = require('./BigInt/remainder'); + +var modBigInt = require('../helpers/modBigInt'); + +// BigInt(2**64), but node v10.4-v10.8 have a bug where you can't `BigInt(x)` anything larger than MAX_SAFE_INTEGER +var twoSixtyFour = $BigInt && (BigInt($pow(2, 32)) * BigInt($pow(2, 32))); + +// https://262.ecma-international.org/11.0/#sec-tobiguint64 + +module.exports = function ToBigUint64(argument) { + var n = ToBigInt(argument); + var int64bit = modBigInt(BigIntRemainder, n, twoSixtyFour); + return int64bit; +}; diff --git a/node_modules/es-abstract/2020/ToBoolean.js b/node_modules/es-abstract/2020/ToBoolean.js new file mode 100644 index 0000000000000000000000000000000000000000..466404bf9992f0ba636249264c620d6c56215d6a --- /dev/null +++ b/node_modules/es-abstract/2020/ToBoolean.js @@ -0,0 +1,5 @@ +'use strict'; + +// http://262.ecma-international.org/5.1/#sec-9.2 + +module.exports = function ToBoolean(value) { return !!value; }; diff --git a/node_modules/es-abstract/2020/ToDateString.js b/node_modules/es-abstract/2020/ToDateString.js new file mode 100644 index 0000000000000000000000000000000000000000..d9bb434185ca0adfa055d91bf592efdce3ed1d94 --- /dev/null +++ b/node_modules/es-abstract/2020/ToDateString.js @@ -0,0 +1,21 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = require('es-errors/type'); +var $Date = GetIntrinsic('%Date%'); +var $String = GetIntrinsic('%String%'); + +var $isNaN = require('math-intrinsics/isNaN'); + +// https://262.ecma-international.org/6.0/#sec-todatestring + +module.exports = function ToDateString(tv) { + if (typeof tv !== 'number') { + throw new $TypeError('Assertion failed: `tv` must be a Number'); + } + if ($isNaN(tv)) { + return 'Invalid Date'; + } + return $String(new $Date(tv)); +}; diff --git a/node_modules/es-abstract/2020/ToIndex.js b/node_modules/es-abstract/2020/ToIndex.js new file mode 100644 index 0000000000000000000000000000000000000000..126fc837e8ad090d81ada8aad8e656770c662a5c --- /dev/null +++ b/node_modules/es-abstract/2020/ToIndex.js @@ -0,0 +1,24 @@ +'use strict'; + +var $RangeError = require('es-errors/range'); + +var ToInteger = require('./ToInteger'); +var ToLength = require('./ToLength'); +var SameValue = require('./SameValue'); + +// https://262.ecma-international.org/12.0/#sec-toindex + +module.exports = function ToIndex(value) { + if (typeof value === 'undefined') { + return 0; + } + var integerIndex = ToInteger(value); + if (integerIndex < 0) { + throw new $RangeError('index must be >= 0'); + } + var index = ToLength(integerIndex); + if (!SameValue(integerIndex, index)) { + throw new $RangeError('index must be >= 0 and < 2 ** 53 - 1'); + } + return index; +}; diff --git a/node_modules/es-abstract/2020/ToInt16.js b/node_modules/es-abstract/2020/ToInt16.js new file mode 100644 index 0000000000000000000000000000000000000000..21694bdeb923cd78791c7c01e242d892b4833af0 --- /dev/null +++ b/node_modules/es-abstract/2020/ToInt16.js @@ -0,0 +1,10 @@ +'use strict'; + +var ToUint16 = require('./ToUint16'); + +// https://262.ecma-international.org/6.0/#sec-toint16 + +module.exports = function ToInt16(argument) { + var int16bit = ToUint16(argument); + return int16bit >= 0x8000 ? int16bit - 0x10000 : int16bit; +}; diff --git a/node_modules/es-abstract/2020/ToInt32.js b/node_modules/es-abstract/2020/ToInt32.js new file mode 100644 index 0000000000000000000000000000000000000000..b879ccc479e039097fa2d1017299579a2d8a8162 --- /dev/null +++ b/node_modules/es-abstract/2020/ToInt32.js @@ -0,0 +1,9 @@ +'use strict'; + +var ToNumber = require('./ToNumber'); + +// http://262.ecma-international.org/5.1/#sec-9.5 + +module.exports = function ToInt32(x) { + return ToNumber(x) >> 0; +}; diff --git a/node_modules/es-abstract/2020/ToInt8.js b/node_modules/es-abstract/2020/ToInt8.js new file mode 100644 index 0000000000000000000000000000000000000000..e223b6c1d352a3432da2d272d0f7e66bbfa818b4 --- /dev/null +++ b/node_modules/es-abstract/2020/ToInt8.js @@ -0,0 +1,10 @@ +'use strict'; + +var ToUint8 = require('./ToUint8'); + +// https://262.ecma-international.org/6.0/#sec-toint8 + +module.exports = function ToInt8(argument) { + var int8bit = ToUint8(argument); + return int8bit >= 0x80 ? int8bit - 0x100 : int8bit; +}; diff --git a/node_modules/es-abstract/2020/ToInteger.js b/node_modules/es-abstract/2020/ToInteger.js new file mode 100644 index 0000000000000000000000000000000000000000..9210af89e918a892c86877ff82d4bff068c6606f --- /dev/null +++ b/node_modules/es-abstract/2020/ToInteger.js @@ -0,0 +1,15 @@ +'use strict'; + +var ES5ToInteger = require('../5/ToInteger'); + +var ToNumber = require('./ToNumber'); + +// https://262.ecma-international.org/11.0/#sec-tointeger + +module.exports = function ToInteger(value) { + var number = ToNumber(value); + if (number !== 0) { + number = ES5ToInteger(number); + } + return number === 0 ? 0 : number; +}; diff --git a/node_modules/es-abstract/2020/ToLength.js b/node_modules/es-abstract/2020/ToLength.js new file mode 100644 index 0000000000000000000000000000000000000000..afa8fb5576c98149d8b6e3327fde8370cd34794c --- /dev/null +++ b/node_modules/es-abstract/2020/ToLength.js @@ -0,0 +1,14 @@ +'use strict'; + +var MAX_SAFE_INTEGER = require('math-intrinsics/constants/maxSafeInteger'); + +var ToInteger = require('./ToInteger'); + +// https://262.ecma-international.org/6.0/#sec-tolength + +module.exports = function ToLength(argument) { + var len = ToInteger(argument); + if (len <= 0) { return 0; } // includes converting -0 to +0 + if (len > MAX_SAFE_INTEGER) { return MAX_SAFE_INTEGER; } + return len; +}; diff --git a/node_modules/es-abstract/2020/ToNumber.js b/node_modules/es-abstract/2020/ToNumber.js new file mode 100644 index 0000000000000000000000000000000000000000..bf3cae3f2b378bdc19eeb7148b9309684fe395e8 --- /dev/null +++ b/node_modules/es-abstract/2020/ToNumber.js @@ -0,0 +1,51 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = require('es-errors/type'); +var $Number = GetIntrinsic('%Number%'); +var $RegExp = GetIntrinsic('%RegExp%'); +var $parseInteger = GetIntrinsic('%parseInt%'); + +var callBound = require('call-bound'); +var regexTester = require('safe-regex-test'); +var isPrimitive = require('../helpers/isPrimitive'); + +var $strSlice = callBound('String.prototype.slice'); +var isBinary = regexTester(/^0b[01]+$/i); +var isOctal = regexTester(/^0o[0-7]+$/i); +var isInvalidHexLiteral = regexTester(/^[-+]0x[0-9a-f]+$/i); +var nonWS = ['\u0085', '\u200b', '\ufffe'].join(''); +var nonWSregex = new $RegExp('[' + nonWS + ']', 'g'); +var hasNonWS = regexTester(nonWSregex); + +var $trim = require('string.prototype.trim'); + +var ToPrimitive = require('./ToPrimitive'); + +// https://262.ecma-international.org/6.0/#sec-tonumber + +module.exports = function ToNumber(argument) { + var value = isPrimitive(argument) ? argument : ToPrimitive(argument, $Number); + if (typeof value === 'symbol') { + throw new $TypeError('Cannot convert a Symbol value to a number'); + } + if (typeof value === 'bigint') { + throw new $TypeError('Conversion from \'BigInt\' to \'number\' is not allowed.'); + } + if (typeof value === 'string') { + if (isBinary(value)) { + return ToNumber($parseInteger($strSlice(value, 2), 2)); + } else if (isOctal(value)) { + return ToNumber($parseInteger($strSlice(value, 2), 8)); + } else if (hasNonWS(value) || isInvalidHexLiteral(value)) { + return NaN; + } + var trimmed = $trim(value); + if (trimmed !== value) { + return ToNumber(trimmed); + } + + } + return +value; +}; diff --git a/node_modules/es-abstract/2020/ToNumeric.js b/node_modules/es-abstract/2020/ToNumeric.js new file mode 100644 index 0000000000000000000000000000000000000000..00a436dc0848803af47df54584e7d851dfe1b4a0 --- /dev/null +++ b/node_modules/es-abstract/2020/ToNumeric.js @@ -0,0 +1,20 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $Number = GetIntrinsic('%Number%'); + +var isPrimitive = require('../helpers/isPrimitive'); + +var ToPrimitive = require('./ToPrimitive'); +var ToNumber = require('./ToNumber'); + +// https://262.ecma-international.org/11.0/#sec-tonumeric + +module.exports = function ToNumeric(argument) { + var primValue = isPrimitive(argument) ? argument : ToPrimitive(argument, $Number); + if (typeof primValue === 'bigint') { + return primValue; + } + return ToNumber(primValue); +}; diff --git a/node_modules/es-abstract/2020/ToObject.js b/node_modules/es-abstract/2020/ToObject.js new file mode 100644 index 0000000000000000000000000000000000000000..70226aaa331e7fd7aa487e680d4aca6bb6874f5b --- /dev/null +++ b/node_modules/es-abstract/2020/ToObject.js @@ -0,0 +1,5 @@ +'use strict'; + +// https://262.ecma-international.org/6.0/#sec-toobject + +module.exports = require('es-object-atoms/ToObject'); diff --git a/node_modules/es-abstract/2020/ToPrimitive.js b/node_modules/es-abstract/2020/ToPrimitive.js new file mode 100644 index 0000000000000000000000000000000000000000..56bcf1aa9eb269d753119497686556384800b092 --- /dev/null +++ b/node_modules/es-abstract/2020/ToPrimitive.js @@ -0,0 +1,12 @@ +'use strict'; + +var toPrimitive = require('es-to-primitive/es2015'); + +// https://262.ecma-international.org/6.0/#sec-toprimitive + +module.exports = function ToPrimitive(input) { + if (arguments.length > 1) { + return toPrimitive(input, arguments[1]); + } + return toPrimitive(input); +}; diff --git a/node_modules/es-abstract/2020/ToPropertyDescriptor.js b/node_modules/es-abstract/2020/ToPropertyDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..017350d593b202573a928ccefeacc7472c803a5e --- /dev/null +++ b/node_modules/es-abstract/2020/ToPropertyDescriptor.js @@ -0,0 +1,50 @@ +'use strict'; + +var hasOwn = require('hasown'); + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var IsCallable = require('./IsCallable'); +var ToBoolean = require('./ToBoolean'); + +// https://262.ecma-international.org/5.1/#sec-8.10.5 + +module.exports = function ToPropertyDescriptor(Obj) { + if (!isObject(Obj)) { + throw new $TypeError('ToPropertyDescriptor requires an object'); + } + + var desc = {}; + if (hasOwn(Obj, 'enumerable')) { + desc['[[Enumerable]]'] = ToBoolean(Obj.enumerable); + } + if (hasOwn(Obj, 'configurable')) { + desc['[[Configurable]]'] = ToBoolean(Obj.configurable); + } + if (hasOwn(Obj, 'value')) { + desc['[[Value]]'] = Obj.value; + } + if (hasOwn(Obj, 'writable')) { + desc['[[Writable]]'] = ToBoolean(Obj.writable); + } + if (hasOwn(Obj, 'get')) { + var getter = Obj.get; + if (typeof getter !== 'undefined' && !IsCallable(getter)) { + throw new $TypeError('getter must be a function'); + } + desc['[[Get]]'] = getter; + } + if (hasOwn(Obj, 'set')) { + var setter = Obj.set; + if (typeof setter !== 'undefined' && !IsCallable(setter)) { + throw new $TypeError('setter must be a function'); + } + desc['[[Set]]'] = setter; + } + + if ((hasOwn(desc, '[[Get]]') || hasOwn(desc, '[[Set]]')) && (hasOwn(desc, '[[Value]]') || hasOwn(desc, '[[Writable]]'))) { + throw new $TypeError('Invalid property descriptor. Cannot both specify accessors and a value or writable attribute'); + } + return desc; +}; diff --git a/node_modules/es-abstract/2020/ToPropertyKey.js b/node_modules/es-abstract/2020/ToPropertyKey.js new file mode 100644 index 0000000000000000000000000000000000000000..e363cd93b1722ddcff99896fb5667079bb95c932 --- /dev/null +++ b/node_modules/es-abstract/2020/ToPropertyKey.js @@ -0,0 +1,15 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $String = GetIntrinsic('%String%'); + +var ToPrimitive = require('./ToPrimitive'); +var ToString = require('./ToString'); + +// https://262.ecma-international.org/6.0/#sec-topropertykey + +module.exports = function ToPropertyKey(argument) { + var key = ToPrimitive(argument, $String); + return typeof key === 'symbol' ? key : ToString(key); +}; diff --git a/node_modules/es-abstract/2020/ToString.js b/node_modules/es-abstract/2020/ToString.js new file mode 100644 index 0000000000000000000000000000000000000000..16b4ccf893640ee9162ff07ad484038311e6210d --- /dev/null +++ b/node_modules/es-abstract/2020/ToString.js @@ -0,0 +1,15 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $String = GetIntrinsic('%String%'); +var $TypeError = require('es-errors/type'); + +// https://262.ecma-international.org/6.0/#sec-tostring + +module.exports = function ToString(argument) { + if (typeof argument === 'symbol') { + throw new $TypeError('Cannot convert a Symbol value to a string'); + } + return $String(argument); +}; diff --git a/node_modules/es-abstract/2020/ToUint16.js b/node_modules/es-abstract/2020/ToUint16.js new file mode 100644 index 0000000000000000000000000000000000000000..117485e616437b348b9b74dddc3fc5e7af9f9ed0 --- /dev/null +++ b/node_modules/es-abstract/2020/ToUint16.js @@ -0,0 +1,19 @@ +'use strict'; + +var modulo = require('./modulo'); +var ToNumber = require('./ToNumber'); + +var abs = require('math-intrinsics/abs'); +var floor = require('math-intrinsics/floor'); +var $isNaN = require('math-intrinsics/isNaN'); +var $isFinite = require('math-intrinsics/isFinite'); +var $sign = require('math-intrinsics/sign'); + +// http://262.ecma-international.org/5.1/#sec-9.7 + +module.exports = function ToUint16(value) { + var number = ToNumber(value); + if ($isNaN(number) || number === 0 || !$isFinite(number)) { return 0; } + var posInt = $sign(number) * floor(abs(number)); + return modulo(posInt, 0x10000); +}; diff --git a/node_modules/es-abstract/2020/ToUint32.js b/node_modules/es-abstract/2020/ToUint32.js new file mode 100644 index 0000000000000000000000000000000000000000..2a8e9dd6a3794a0940b6bae175a99f00c0e2d25d --- /dev/null +++ b/node_modules/es-abstract/2020/ToUint32.js @@ -0,0 +1,9 @@ +'use strict'; + +var ToNumber = require('./ToNumber'); + +// http://262.ecma-international.org/5.1/#sec-9.6 + +module.exports = function ToUint32(x) { + return ToNumber(x) >>> 0; +}; diff --git a/node_modules/es-abstract/2020/ToUint8.js b/node_modules/es-abstract/2020/ToUint8.js new file mode 100644 index 0000000000000000000000000000000000000000..e3af8ede13a7ef1e5e3eb8833701d6497f8611e0 --- /dev/null +++ b/node_modules/es-abstract/2020/ToUint8.js @@ -0,0 +1,19 @@ +'use strict'; + +var ToNumber = require('./ToNumber'); + +var $isNaN = require('math-intrinsics/isNaN'); +var $isFinite = require('math-intrinsics/isFinite'); +var $sign = require('math-intrinsics/sign'); +var abs = require('math-intrinsics/abs'); +var floor = require('math-intrinsics/floor'); +var modulo = require('math-intrinsics/mod'); + +// https://262.ecma-international.org/6.0/#sec-touint8 + +module.exports = function ToUint8(argument) { + var number = ToNumber(argument); + if ($isNaN(number) || number === 0 || !$isFinite(number)) { return 0; } + var posInt = $sign(number) * floor(abs(number)); + return modulo(posInt, 0x100); +}; diff --git a/node_modules/es-abstract/2020/ToUint8Clamp.js b/node_modules/es-abstract/2020/ToUint8Clamp.js new file mode 100644 index 0000000000000000000000000000000000000000..ac1b06e461ba4d562700971000c2d30a9b9dfca4 --- /dev/null +++ b/node_modules/es-abstract/2020/ToUint8Clamp.js @@ -0,0 +1,19 @@ +'use strict'; + +var ToNumber = require('./ToNumber'); +var floor = require('./floor'); + +var $isNaN = require('math-intrinsics/isNaN'); + +// https://262.ecma-international.org/6.0/#sec-touint8clamp + +module.exports = function ToUint8Clamp(argument) { + var number = ToNumber(argument); + if ($isNaN(number) || number <= 0) { return 0; } + if (number >= 0xFF) { return 0xFF; } + var f = floor(number); + if (f + 0.5 < number) { return f + 1; } + if (number < f + 0.5) { return f; } + if (f % 2 !== 0) { return f + 1; } + return f; +}; diff --git a/node_modules/es-abstract/2020/TrimString.js b/node_modules/es-abstract/2020/TrimString.js new file mode 100644 index 0000000000000000000000000000000000000000..516ef254819cc6b4d11788176a2e90b7ca18b7e4 --- /dev/null +++ b/node_modules/es-abstract/2020/TrimString.js @@ -0,0 +1,27 @@ +'use strict'; + +var trimStart = require('string.prototype.trimstart'); +var trimEnd = require('string.prototype.trimend'); + +var $TypeError = require('es-errors/type'); + +var RequireObjectCoercible = require('./RequireObjectCoercible'); +var ToString = require('./ToString'); + +// https://262.ecma-international.org/10.0/#sec-trimstring + +module.exports = function TrimString(string, where) { + var str = RequireObjectCoercible(string); + var S = ToString(str); + var T; + if (where === 'start') { + T = trimStart(S); + } else if (where === 'end') { + T = trimEnd(S); + } else if (where === 'start+end') { + T = trimStart(trimEnd(S)); + } else { + throw new $TypeError('Assertion failed: invalid `where` value; must be "start", "end", or "start+end"'); + } + return T; +}; diff --git a/node_modules/es-abstract/2020/Type.js b/node_modules/es-abstract/2020/Type.js new file mode 100644 index 0000000000000000000000000000000000000000..555ca74ea51969958716accd635da40009319542 --- /dev/null +++ b/node_modules/es-abstract/2020/Type.js @@ -0,0 +1,15 @@ +'use strict'; + +var ES5Type = require('../5/Type'); + +// https://262.ecma-international.org/11.0/#sec-ecmascript-data-types-and-values + +module.exports = function Type(x) { + if (typeof x === 'symbol') { + return 'Symbol'; + } + if (typeof x === 'bigint') { + return 'BigInt'; + } + return ES5Type(x); +}; diff --git a/node_modules/es-abstract/2020/TypedArrayCreate.js b/node_modules/es-abstract/2020/TypedArrayCreate.js new file mode 100644 index 0000000000000000000000000000000000000000..c598dfff9fe1d42461198227a6004e0fe4512226 --- /dev/null +++ b/node_modules/es-abstract/2020/TypedArrayCreate.js @@ -0,0 +1,47 @@ +'use strict'; + +var $SyntaxError = require('es-errors/syntax'); +var $TypeError = require('es-errors/type'); + +var IsArray = require('./IsArray'); +var IsConstructor = require('./IsConstructor'); +var ValidateTypedArray = require('./ValidateTypedArray'); + +var availableTypedArrays = require('available-typed-arrays')(); +var typedArrayLength = require('typed-array-length'); + +// https://262.ecma-international.org/7.0/#typedarray-create + +module.exports = function TypedArrayCreate(constructor, argumentList) { + if (!IsConstructor(constructor)) { + throw new $TypeError('Assertion failed: `constructor` must be a constructor'); + } + if (!IsArray(argumentList)) { + throw new $TypeError('Assertion failed: `argumentList` must be a List'); + } + if (availableTypedArrays.length === 0) { + throw new $SyntaxError('Assertion failed: Typed Arrays are not supported in this environment'); + } + + // var newTypedArray = Construct(constructor, argumentList); // step 1 + var newTypedArray; + if (argumentList.length === 0) { + newTypedArray = new constructor(); + } else if (argumentList.length === 1) { + newTypedArray = new constructor(argumentList[0]); + } else if (argumentList.length === 2) { + newTypedArray = new constructor(argumentList[0], argumentList[1]); + } else { + newTypedArray = new constructor(argumentList[0], argumentList[1], argumentList[2]); + } + + ValidateTypedArray(newTypedArray); // step 2 + + if (argumentList.length === 1 && typeof argumentList[0] === 'number') { // step 3 + if (typedArrayLength(newTypedArray) < argumentList[0]) { + throw new $TypeError('Assertion failed: `argumentList[0]` must be <= `newTypedArray.length`'); // step 3.a + } + } + + return newTypedArray; // step 4 +}; diff --git a/node_modules/es-abstract/2020/TypedArraySpeciesCreate.js b/node_modules/es-abstract/2020/TypedArraySpeciesCreate.js new file mode 100644 index 0000000000000000000000000000000000000000..6c71498a052bbfc121b4887e2aa3fff5572510b2 --- /dev/null +++ b/node_modules/es-abstract/2020/TypedArraySpeciesCreate.js @@ -0,0 +1,37 @@ +'use strict'; + +var $SyntaxError = require('es-errors/syntax'); +var $TypeError = require('es-errors/type'); + +var whichTypedArray = require('which-typed-array'); +var availableTypedArrays = require('available-typed-arrays')(); + +var IsArray = require('./IsArray'); +var SpeciesConstructor = require('./SpeciesConstructor'); +var TypedArrayCreate = require('./TypedArrayCreate'); + +var getConstructor = require('../helpers/typedArrayConstructors'); + +// https://262.ecma-international.org/7.0/#typedarray-species-create + +module.exports = function TypedArraySpeciesCreate(exemplar, argumentList) { + if (availableTypedArrays.length === 0) { + throw new $SyntaxError('Assertion failed: Typed Arrays are not supported in this environment'); + } + + var kind = whichTypedArray(exemplar); + if (!kind) { + throw new $TypeError('Assertion failed: exemplar must be a TypedArray'); // step 1 + } + if (!IsArray(argumentList)) { + throw new $TypeError('Assertion failed: `argumentList` must be a List'); // step 1 + } + + var defaultConstructor = getConstructor(kind); // step 2 + if (typeof defaultConstructor !== 'function') { + throw new $SyntaxError('Assertion failed: `constructor` of `exemplar` (' + kind + ') must exist. Please report this!'); + } + var constructor = SpeciesConstructor(exemplar, defaultConstructor); // step 3 + + return TypedArrayCreate(constructor, argumentList); // step 4 +}; diff --git a/node_modules/es-abstract/2020/UTF16DecodeString.js b/node_modules/es-abstract/2020/UTF16DecodeString.js new file mode 100644 index 0000000000000000000000000000000000000000..95ccc4129a93e8d4dc4c45a34b235bc7b432718f --- /dev/null +++ b/node_modules/es-abstract/2020/UTF16DecodeString.js @@ -0,0 +1,22 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var CodePointAt = require('./CodePointAt'); + +// https://262.ecma-international.org/11.0/#sec-utf16decodestring + +module.exports = function UTF16DecodeString(string) { + if (typeof string !== 'string') { + throw new $TypeError('Assertion failed: `string` must be a String'); + } + var codePoints = []; + var size = string.length; + var position = 0; + while (position < size) { + var cp = CodePointAt(string, position); + codePoints[codePoints.length] = cp['[[CodePoint]]']; + position += cp['[[CodeUnitCount]]']; + } + return codePoints; +}; diff --git a/node_modules/es-abstract/2020/UTF16DecodeSurrogatePair.js b/node_modules/es-abstract/2020/UTF16DecodeSurrogatePair.js new file mode 100644 index 0000000000000000000000000000000000000000..d60dea17bc022e8a42ed2aaae7cf266950f5b726 --- /dev/null +++ b/node_modules/es-abstract/2020/UTF16DecodeSurrogatePair.js @@ -0,0 +1,19 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = require('es-errors/type'); +var $fromCharCode = GetIntrinsic('%String.fromCharCode%'); + +var isLeadingSurrogate = require('../helpers/isLeadingSurrogate'); +var isTrailingSurrogate = require('../helpers/isTrailingSurrogate'); + +// https://262.ecma-international.org/11.0/#sec-utf16decodesurrogatepair + +module.exports = function UTF16DecodeSurrogatePair(lead, trail) { + if (!isLeadingSurrogate(lead) || !isTrailingSurrogate(trail)) { + throw new $TypeError('Assertion failed: `lead` must be a leading surrogate char code, and `trail` must be a trailing surrogate char code'); + } + // var cp = (lead - 0xD800) * 0x400 + (trail - 0xDC00) + 0x10000; + return $fromCharCode(lead) + $fromCharCode(trail); +}; diff --git a/node_modules/es-abstract/2020/UTF16Encoding.js b/node_modules/es-abstract/2020/UTF16Encoding.js new file mode 100644 index 0000000000000000000000000000000000000000..81e567dc6766e5be802ce39f03d49ab930292154 --- /dev/null +++ b/node_modules/es-abstract/2020/UTF16Encoding.js @@ -0,0 +1,25 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = require('es-errors/type'); +var $fromCharCode = GetIntrinsic('%String.fromCharCode%'); + +var floor = require('./floor'); +var modulo = require('./modulo'); + +var isCodePoint = require('../helpers/isCodePoint'); + +// https://262.ecma-international.org/7.0/#sec-utf16encoding + +module.exports = function UTF16Encoding(cp) { + if (!isCodePoint(cp)) { + throw new $TypeError('Assertion failed: `cp` must be >= 0 and <= 0x10FFFF'); + } + if (cp <= 65535) { + return $fromCharCode(cp); + } + var cu1 = $fromCharCode(floor((cp - 65536) / 1024) + 0xD800); + var cu2 = $fromCharCode(modulo(cp - 65536, 1024) + 0xDC00); + return cu1 + cu2; +}; diff --git a/node_modules/es-abstract/2020/UnicodeEscape.js b/node_modules/es-abstract/2020/UnicodeEscape.js new file mode 100644 index 0000000000000000000000000000000000000000..739602cc8352d251c3d89180f3042bb397dabb76 --- /dev/null +++ b/node_modules/es-abstract/2020/UnicodeEscape.js @@ -0,0 +1,25 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var callBound = require('call-bound'); + +var $charCodeAt = callBound('String.prototype.charCodeAt'); +var $numberToString = callBound('Number.prototype.toString'); +var $toLowerCase = callBound('String.prototype.toLowerCase'); + +var StringPad = require('./StringPad'); + +// https://262.ecma-international.org/11.0/#sec-unicodeescape + +module.exports = function UnicodeEscape(C) { + if (typeof C !== 'string' || C.length !== 1) { + throw new $TypeError('Assertion failed: `C` must be a single code unit'); + } + var n = $charCodeAt(C, 0); + if (n > 0xFFFF) { + throw new $TypeError('`Assertion failed: numeric value of `C` must be <= 0xFFFF'); + } + + return '\\u' + StringPad($toLowerCase($numberToString(n, 16)), 4, '0', 'start'); +}; diff --git a/node_modules/es-abstract/2020/ValidateAndApplyPropertyDescriptor.js b/node_modules/es-abstract/2020/ValidateAndApplyPropertyDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..12cab5dff05ac5d79240ac4b40af54aa99c5fd5e --- /dev/null +++ b/node_modules/es-abstract/2020/ValidateAndApplyPropertyDescriptor.js @@ -0,0 +1,159 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var DefineOwnProperty = require('../helpers/DefineOwnProperty'); +var isPropertyDescriptor = require('../helpers/records/property-descriptor'); +var isSamePropertyDescriptor = require('../helpers/isSamePropertyDescriptor'); + +var FromPropertyDescriptor = require('./FromPropertyDescriptor'); +var IsAccessorDescriptor = require('./IsAccessorDescriptor'); +var IsDataDescriptor = require('./IsDataDescriptor'); +var IsGenericDescriptor = require('./IsGenericDescriptor'); +var isPropertyKey = require('../helpers/isPropertyKey'); +var SameValue = require('./SameValue'); + +// https://262.ecma-international.org/6.0/#sec-validateandapplypropertydescriptor +// https://262.ecma-international.org/8.0/#sec-validateandapplypropertydescriptor + +// eslint-disable-next-line max-lines-per-function, max-statements +module.exports = function ValidateAndApplyPropertyDescriptor(O, P, extensible, Desc, current) { + // this uses the ES2017+ logic, since it fixes a number of bugs in the ES2015 logic. + if (typeof O !== 'undefined' && !isObject(O)) { + throw new $TypeError('Assertion failed: O must be undefined or an Object'); + } + if (typeof extensible !== 'boolean') { + throw new $TypeError('Assertion failed: extensible must be a Boolean'); + } + if (!isPropertyDescriptor(Desc)) { + throw new $TypeError('Assertion failed: Desc must be a Property Descriptor'); + } + if (typeof current !== 'undefined' && !isPropertyDescriptor(current)) { + throw new $TypeError('Assertion failed: current must be a Property Descriptor, or undefined'); + } + if (typeof O !== 'undefined' && !isPropertyKey(P)) { + throw new $TypeError('Assertion failed: if O is not undefined, P must be a Property Key'); + } + if (typeof current === 'undefined') { + if (!extensible) { + return false; + } + if (IsGenericDescriptor(Desc) || IsDataDescriptor(Desc)) { + if (typeof O !== 'undefined') { + DefineOwnProperty( + IsDataDescriptor, + SameValue, + FromPropertyDescriptor, + O, + P, + { + '[[Configurable]]': Desc['[[Configurable]]'], + '[[Enumerable]]': Desc['[[Enumerable]]'], + '[[Value]]': Desc['[[Value]]'], + '[[Writable]]': Desc['[[Writable]]'] + } + ); + } + } else { + if (!IsAccessorDescriptor(Desc)) { + throw new $TypeError('Assertion failed: Desc is not an accessor descriptor'); + } + if (typeof O !== 'undefined') { + return DefineOwnProperty( + IsDataDescriptor, + SameValue, + FromPropertyDescriptor, + O, + P, + Desc + ); + } + } + return true; + } + if (IsGenericDescriptor(Desc) && !('[[Configurable]]' in Desc) && !('[[Enumerable]]' in Desc)) { + return true; + } + if (isSamePropertyDescriptor({ SameValue: SameValue }, 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 (IsGenericDescriptor(Desc)) { + // no further validation is required. + } else if (IsDataDescriptor(current) !== IsDataDescriptor(Desc)) { + if (!current['[[Configurable]]']) { + return false; + } + if (IsDataDescriptor(current)) { + if (typeof O !== 'undefined') { + DefineOwnProperty( + IsDataDescriptor, + SameValue, + FromPropertyDescriptor, + O, + P, + { + '[[Configurable]]': current['[[Configurable]]'], + '[[Enumerable]]': current['[[Enumerable]]'], + '[[Get]]': undefined + } + ); + } + } else if (typeof O !== 'undefined') { + DefineOwnProperty( + IsDataDescriptor, + SameValue, + FromPropertyDescriptor, + O, + P, + { + '[[Configurable]]': current['[[Configurable]]'], + '[[Enumerable]]': current['[[Enumerable]]'], + '[[Value]]': undefined + } + ); + } + } else if (IsDataDescriptor(current) && IsDataDescriptor(Desc)) { + if (!current['[[Configurable]]'] && !current['[[Writable]]']) { + if ('[[Writable]]' in Desc && Desc['[[Writable]]']) { + return false; + } + if ('[[Value]]' in Desc && !SameValue(Desc['[[Value]]'], current['[[Value]]'])) { + return false; + } + return true; + } + } else if (IsAccessorDescriptor(current) && IsAccessorDescriptor(Desc)) { + if (!current['[[Configurable]]']) { + if ('[[Set]]' in Desc && !SameValue(Desc['[[Set]]'], current['[[Set]]'])) { + return false; + } + if ('[[Get]]' in Desc && !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 (typeof O !== 'undefined') { + return DefineOwnProperty( + IsDataDescriptor, + SameValue, + FromPropertyDescriptor, + O, + P, + Desc + ); + } + return true; +}; diff --git a/node_modules/es-abstract/2020/ValidateAtomicAccess.js b/node_modules/es-abstract/2020/ValidateAtomicAccess.js new file mode 100644 index 0000000000000000000000000000000000000000..f902b7d18bfc3e06cba4a46dcce5099220418093 --- /dev/null +++ b/node_modules/es-abstract/2020/ValidateAtomicAccess.js @@ -0,0 +1,34 @@ +'use strict'; + +var $RangeError = require('es-errors/range'); +var $TypeError = require('es-errors/type'); + +var ToIndex = require('./ToIndex'); + +var isTypedArray = require('is-typed-array'); +var typedArrayLength = require('typed-array-length'); + +// https://262.ecma-international.org/8.0/#sec-validateatomicaccess + +module.exports = function ValidateAtomicAccess(typedArray, requestIndex) { + if (!isTypedArray(typedArray)) { + throw new $TypeError('Assertion failed: `typedArray` must be a TypedArray'); // step 1 + } + + var accessIndex = ToIndex(requestIndex); // step 2 + + var length = typedArrayLength(typedArray); // step 3 + + /* + // this assertion can never be reached + if (!(accessIndex >= 0)) { + throw new $TypeError('Assertion failed: accessIndex >= 0'); // step 4 + } + */ + + if (accessIndex >= length) { + throw new $RangeError('index out of range'); // step 5 + } + + return accessIndex; // step 6 +}; diff --git a/node_modules/es-abstract/2020/ValidateTypedArray.js b/node_modules/es-abstract/2020/ValidateTypedArray.js new file mode 100644 index 0000000000000000000000000000000000000000..87fa8d17872f4463582e77a803dc98ff0019f878 --- /dev/null +++ b/node_modules/es-abstract/2020/ValidateTypedArray.js @@ -0,0 +1,28 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var IsDetachedBuffer = require('./IsDetachedBuffer'); + +var isTypedArray = require('is-typed-array'); +var typedArrayBuffer = require('typed-array-buffer'); + +// https://262.ecma-international.org/6.0/#sec-validatetypedarray + +module.exports = function ValidateTypedArray(O) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: `O` must be an Object'); // step 1 + } + if (!isTypedArray(O)) { + throw new $TypeError('Assertion failed: `O` must be a Typed Array'); // steps 2 - 3 + } + + var buffer = typedArrayBuffer(O); // step 4 + + if (IsDetachedBuffer(buffer)) { + throw new $TypeError('`O` must be backed by a non-detached buffer'); // step 5 + } + + return buffer; // step 6 +}; diff --git a/node_modules/es-abstract/2020/WeekDay.js b/node_modules/es-abstract/2020/WeekDay.js new file mode 100644 index 0000000000000000000000000000000000000000..17cf94ca34ce0aae649c1e0236cd18f248d54e3d --- /dev/null +++ b/node_modules/es-abstract/2020/WeekDay.js @@ -0,0 +1,10 @@ +'use strict'; + +var Day = require('./Day'); +var modulo = require('./modulo'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.6 + +module.exports = function WeekDay(t) { + return modulo(Day(t) + 4, 7); +}; diff --git a/node_modules/es-abstract/2020/WordCharacters.js b/node_modules/es-abstract/2020/WordCharacters.js new file mode 100644 index 0000000000000000000000000000000000000000..36532afc9087057ccdf6fb52434e7fe523714f4d --- /dev/null +++ b/node_modules/es-abstract/2020/WordCharacters.js @@ -0,0 +1,46 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var callBound = require('call-bound'); +var $indexOf = callBound('String.prototype.indexOf'); + +var Canonicalize = require('./Canonicalize'); + +var caseFolding = require('../helpers/caseFolding.json'); +var forEach = require('../helpers/forEach'); +var OwnPropertyKeys = require('own-keys'); + +var A = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_'; // step 1 + +// https://262.ecma-international.org/8.0/#sec-runtime-semantics-wordcharacters-abstract-operation + +module.exports = function WordCharacters(IgnoreCase, Unicode) { + if (typeof IgnoreCase !== 'boolean' || typeof Unicode !== 'boolean') { + throw new $TypeError('Assertion failed: `IgnoreCase` and `Unicode` must be booleans'); + } + + var U = ''; + forEach(OwnPropertyKeys(caseFolding.C), function (c) { + if ( + $indexOf(A, c) === -1 // c not in A + && $indexOf(A, Canonicalize(c, IgnoreCase, Unicode)) > -1 // canonicalized c IS in A + ) { + U += caseFolding.C[c]; // step 3 + } + }); + forEach(OwnPropertyKeys(caseFolding.S), function (c) { + if ( + $indexOf(A, c) === -1 // c not in A + && $indexOf(A, Canonicalize(c, IgnoreCase, Unicode)) > -1 // canonicalized c IS in A + ) { + U += caseFolding.S[c]; // step 3 + } + }); + + if ((!Unicode || !IgnoreCase) && U.length > 0) { + throw new $TypeError('Assertion failed: `U` must be empty when `IgnoreCase` and `Unicode` are not both true'); // step 4 + } + + return A + U; // step 5, 6 +}; diff --git a/node_modules/es-abstract/2020/YearFromTime.js b/node_modules/es-abstract/2020/YearFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..18958182021b0ecc71645057fe8ed826ef786586 --- /dev/null +++ b/node_modules/es-abstract/2020/YearFromTime.js @@ -0,0 +1,16 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $Date = GetIntrinsic('%Date%'); + +var callBound = require('call-bound'); + +var $getUTCFullYear = callBound('Date.prototype.getUTCFullYear'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.3 + +module.exports = function YearFromTime(t) { + // largest y such that this.TimeFromYear(y) <= t + return $getUTCFullYear(new $Date(t)); +}; diff --git a/node_modules/es-abstract/2020/abs.js b/node_modules/es-abstract/2020/abs.js new file mode 100644 index 0000000000000000000000000000000000000000..457f2a4a3d48f83c061c763cd26724fd8d4297f3 --- /dev/null +++ b/node_modules/es-abstract/2020/abs.js @@ -0,0 +1,9 @@ +'use strict'; + +var $abs = require('math-intrinsics/abs'); + +// https://262.ecma-international.org/11.0/#eqn-abs + +module.exports = function abs(x) { + return typeof x === 'bigint' ? BigInt($abs(Number(x))) : $abs(x); +}; diff --git a/node_modules/es-abstract/2020/floor.js b/node_modules/es-abstract/2020/floor.js new file mode 100644 index 0000000000000000000000000000000000000000..eece19b5cbf2bd71a7655ea6d2f329cc8cd1a11d --- /dev/null +++ b/node_modules/es-abstract/2020/floor.js @@ -0,0 +1,14 @@ +'use strict'; + +// var modulo = require('./modulo'); +var $floor = require('math-intrinsics/floor'); + +// http://262.ecma-international.org/11.0/#eqn-floor + +module.exports = function floor(x) { + // return x - modulo(x, 1); + if (typeof x === 'bigint') { + return x; + } + return $floor(x); +}; diff --git a/node_modules/es-abstract/2020/max.js b/node_modules/es-abstract/2020/max.js new file mode 100644 index 0000000000000000000000000000000000000000..f83b038a221fed3a500c72b41f5fdc31e1100827 --- /dev/null +++ b/node_modules/es-abstract/2020/max.js @@ -0,0 +1,5 @@ +'use strict'; + +// https://262.ecma-international.org/6.0/#sec-algorithm-conventions + +module.exports = require('math-intrinsics/max'); diff --git a/node_modules/es-abstract/2020/min.js b/node_modules/es-abstract/2020/min.js new file mode 100644 index 0000000000000000000000000000000000000000..3a8f50539f0a6519251299edf4169f98a6db0bd9 --- /dev/null +++ b/node_modules/es-abstract/2020/min.js @@ -0,0 +1,5 @@ +'use strict'; + +// https://262.ecma-international.org/6.0/#sec-algorithm-conventions + +module.exports = require('math-intrinsics/min'); diff --git a/node_modules/es-abstract/2020/modulo.js b/node_modules/es-abstract/2020/modulo.js new file mode 100644 index 0000000000000000000000000000000000000000..b94bb52bb3c62e45629a4b1e8f0ebba219d5e41e --- /dev/null +++ b/node_modules/es-abstract/2020/modulo.js @@ -0,0 +1,9 @@ +'use strict'; + +var mod = require('../helpers/mod'); + +// https://262.ecma-international.org/5.1/#sec-5.2 + +module.exports = function modulo(x, y) { + return mod(x, y); +}; diff --git a/node_modules/es-abstract/2020/msFromTime.js b/node_modules/es-abstract/2020/msFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..a6bae767aed31c8a467b8ea1fb2128e64860a972 --- /dev/null +++ b/node_modules/es-abstract/2020/msFromTime.js @@ -0,0 +1,11 @@ +'use strict'; + +var modulo = require('./modulo'); + +var msPerSecond = require('../helpers/timeConstants').msPerSecond; + +// https://262.ecma-international.org/5.1/#sec-15.9.1.10 + +module.exports = function msFromTime(t) { + return modulo(t, msPerSecond); +}; diff --git a/node_modules/es-abstract/2020/tables/typed-array-objects.js b/node_modules/es-abstract/2020/tables/typed-array-objects.js new file mode 100644 index 0000000000000000000000000000000000000000..8d6c70aba3046702ccb796ad62eb46fc99e038ef --- /dev/null +++ b/node_modules/es-abstract/2020/tables/typed-array-objects.js @@ -0,0 +1,36 @@ +'use strict'; + +// https://262.ecma-international.org/11.0/#table-the-typedarray-constructors + +module.exports = { + __proto__: null, + name: { + __proto__: null, + $Int8Array: 'Int8', + $Uint8Array: 'Uint8', + $Uint8ClampedArray: 'Uint8C', + $Int16Array: 'Int16', + $Uint16Array: 'Uint16', + $Int32Array: 'Int32', + $Uint32Array: 'Uint32', + $BigInt64Array: 'BigInt64', + $BigUint64Array: 'BigUint64', + $Float32Array: 'Float32', + $Float64Array: 'Float64' + }, + size: { + __proto__: null, + $Int8: 1, + $Uint8: 1, + $Uint8C: 1, + $Int16: 2, + $Uint16: 2, + $Int32: 4, + $Uint32: 4, + $BigInt64: 8, + $BigUint64: 8, + $Float32: 4, + $Float64: 8 + }, + choices: '"Int8", "Uint8", "Uint8C", "Int16", "Uint16", "Int32", "Uint32", "BigInt64", "BigUint64", "Float32", or "Float64"' +}; diff --git a/node_modules/es-abstract/2020/thisBigIntValue.js b/node_modules/es-abstract/2020/thisBigIntValue.js new file mode 100644 index 0000000000000000000000000000000000000000..ad281d3d0115e46f8e8accfeac1864be7dfdd459 --- /dev/null +++ b/node_modules/es-abstract/2020/thisBigIntValue.js @@ -0,0 +1,18 @@ +'use strict'; + +var callBound = require('call-bound'); + +var $SyntaxError = require('es-errors/syntax'); +var $bigIntValueOf = callBound('BigInt.prototype.valueOf', true); + +// https://262.ecma-international.org/11.0/#sec-thisbigintvalue + +module.exports = function thisBigIntValue(value) { + if (typeof value === 'bigint') { + return value; + } + if (!$bigIntValueOf) { + throw new $SyntaxError('BigInt is not supported'); + } + return $bigIntValueOf(value); +}; diff --git a/node_modules/es-abstract/2020/thisBooleanValue.js b/node_modules/es-abstract/2020/thisBooleanValue.js new file mode 100644 index 0000000000000000000000000000000000000000..265fff335bed60f2a636b2fa3bf2ac113b896ff7 --- /dev/null +++ b/node_modules/es-abstract/2020/thisBooleanValue.js @@ -0,0 +1,13 @@ +'use strict'; + +var $BooleanValueOf = require('call-bound')('Boolean.prototype.valueOf'); + +// https://262.ecma-international.org/6.0/#sec-properties-of-the-boolean-prototype-object + +module.exports = function thisBooleanValue(value) { + if (typeof value === 'boolean') { + return value; + } + + return $BooleanValueOf(value); +}; diff --git a/node_modules/es-abstract/2020/thisNumberValue.js b/node_modules/es-abstract/2020/thisNumberValue.js new file mode 100644 index 0000000000000000000000000000000000000000..e2457fb3f076d4f8c500d7f5ce7b19ff4846cf2d --- /dev/null +++ b/node_modules/es-abstract/2020/thisNumberValue.js @@ -0,0 +1,16 @@ +'use strict'; + +var callBound = require('call-bound'); + +var $NumberValueOf = callBound('Number.prototype.valueOf'); + +// https://262.ecma-international.org/6.0/#sec-properties-of-the-number-prototype-object + +module.exports = function thisNumberValue(value) { + if (typeof value === 'number') { + return value; + } + + return $NumberValueOf(value); +}; + diff --git a/node_modules/es-abstract/2020/thisStringValue.js b/node_modules/es-abstract/2020/thisStringValue.js new file mode 100644 index 0000000000000000000000000000000000000000..a5c70534670cd719ca425055d597ac6b5f5994c2 --- /dev/null +++ b/node_modules/es-abstract/2020/thisStringValue.js @@ -0,0 +1,13 @@ +'use strict'; + +var $StringValueOf = require('call-bound')('String.prototype.valueOf'); + +// https://262.ecma-international.org/6.0/#sec-properties-of-the-string-prototype-object + +module.exports = function thisStringValue(value) { + if (typeof value === 'string') { + return value; + } + + return $StringValueOf(value); +}; diff --git a/node_modules/es-abstract/2020/thisSymbolValue.js b/node_modules/es-abstract/2020/thisSymbolValue.js new file mode 100644 index 0000000000000000000000000000000000000000..77342ad16a77128cddbb7c79e9eb576bbe6b126c --- /dev/null +++ b/node_modules/es-abstract/2020/thisSymbolValue.js @@ -0,0 +1,20 @@ +'use strict'; + +var $SyntaxError = require('es-errors/syntax'); +var callBound = require('call-bound'); + +var $SymbolValueOf = callBound('Symbol.prototype.valueOf', true); + +// https://262.ecma-international.org/9.0/#sec-thissymbolvalue + +module.exports = function thisSymbolValue(value) { + if (typeof value === 'symbol') { + return value; + } + + if (!$SymbolValueOf) { + throw new $SyntaxError('Symbols are not supported; thisSymbolValue requires that `value` be a Symbol or a Symbol object'); + } + + return $SymbolValueOf(value); +}; diff --git a/node_modules/es-abstract/2020/thisTimeValue.js b/node_modules/es-abstract/2020/thisTimeValue.js new file mode 100644 index 0000000000000000000000000000000000000000..f64be83fcaed6a3766a1397c1c373981c0543b1a --- /dev/null +++ b/node_modules/es-abstract/2020/thisTimeValue.js @@ -0,0 +1,9 @@ +'use strict'; + +var timeValue = require('../helpers/timeValue'); + +// https://262.ecma-international.org/6.0/#sec-properties-of-the-date-prototype-object + +module.exports = function thisTimeValue(value) { + return timeValue(value); +}; diff --git a/node_modules/es-abstract/2021/AbstractEqualityComparison.js b/node_modules/es-abstract/2021/AbstractEqualityComparison.js new file mode 100644 index 0000000000000000000000000000000000000000..dba5595b7e58d701c4a1f1baf02ae285df4ae595 --- /dev/null +++ b/node_modules/es-abstract/2021/AbstractEqualityComparison.js @@ -0,0 +1,56 @@ +'use strict'; + +var StrictEqualityComparison = require('./StrictEqualityComparison'); +var StringToBigInt = require('./StringToBigInt'); +var ToNumber = require('./ToNumber'); +var ToPrimitive = require('./ToPrimitive'); + +var isNaN = require('math-intrinsics/isNaN'); +var isObject = require('es-object-atoms/isObject'); +var isSameType = require('../helpers/isSameType'); + +// https://262.ecma-international.org/11.0/#sec-abstract-equality-comparison + +module.exports = function AbstractEqualityComparison(x, y) { + if (isSameType(x, y)) { + return StrictEqualityComparison(x, y); + } + if (x == null && y == null) { + return true; + } + if (typeof x === 'number' && typeof y === 'string') { + return AbstractEqualityComparison(x, ToNumber(y)); + } + if (typeof x === 'string' && typeof y === 'number') { + return AbstractEqualityComparison(ToNumber(x), y); + } + if (typeof x === 'bigint' && typeof y === 'string') { + var n = StringToBigInt(y); + if (isNaN(n)) { + return false; + } + return AbstractEqualityComparison(x, n); + } + if (typeof x === 'string' && typeof y === 'bigint') { + return AbstractEqualityComparison(y, x); + } + if (typeof x === 'boolean') { + return AbstractEqualityComparison(ToNumber(x), y); + } + if (typeof y === 'boolean') { + return AbstractEqualityComparison(x, ToNumber(y)); + } + if ((typeof x === 'string' || typeof x === 'number' || typeof x === 'bigint' || typeof x === 'symbol') && isObject(y)) { + return AbstractEqualityComparison(x, ToPrimitive(y)); + } + if (isObject(x) && (typeof y === 'string' || typeof y === 'number' || typeof y === 'bigint' || typeof y === 'symbol')) { + return AbstractEqualityComparison(ToPrimitive(x), y); + } + if ((typeof x === 'bigint' && typeof y === 'number') || (typeof x === 'number' && typeof y === 'bigint')) { + if (isNaN(x) || isNaN(y) || x === Infinity || y === Infinity || x === -Infinity || y === -Infinity) { + return false; + } + return x == y; // eslint-disable-line eqeqeq + } + return false; +}; diff --git a/node_modules/es-abstract/2021/AbstractRelationalComparison.js b/node_modules/es-abstract/2021/AbstractRelationalComparison.js new file mode 100644 index 0000000000000000000000000000000000000000..811c944d82e39d04a23e4f28b228b07a8655c5d3 --- /dev/null +++ b/node_modules/es-abstract/2021/AbstractRelationalComparison.js @@ -0,0 +1,80 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $Number = GetIntrinsic('%Number%'); +var $TypeError = require('es-errors/type'); + +var $isNaN = require('math-intrinsics/isNaN'); + +var IsStringPrefix = require('./IsStringPrefix'); +var StringToBigInt = require('./StringToBigInt'); +var ToNumeric = require('./ToNumeric'); +var ToPrimitive = require('./ToPrimitive'); + +var BigIntLessThan = require('./BigInt/lessThan'); +var NumberLessThan = require('./Number/lessThan'); + +var isSameType = require('../helpers/isSameType'); + +// https://262.ecma-international.org/11.0/#sec-abstract-relational-comparison + +// eslint-disable-next-line max-statements, max-lines-per-function +module.exports = function AbstractRelationalComparison(x, y, LeftFirst) { + if (typeof LeftFirst !== 'boolean') { + throw new $TypeError('Assertion failed: LeftFirst argument must be a Boolean'); + } + var px; + var py; + if (LeftFirst) { + px = ToPrimitive(x, $Number); + py = ToPrimitive(y, $Number); + } else { + py = ToPrimitive(y, $Number); + px = ToPrimitive(x, $Number); + } + if (typeof px === 'string' && typeof py === 'string') { + if (IsStringPrefix(py, px)) { + return false; + } + if (IsStringPrefix(px, py)) { + return true; + } + return px < py; // both strings, neither a prefix of the other. shortcut for steps 3 c-f + } + + var nx; + var ny; + if (typeof px === 'bigint' && typeof py === 'string') { + ny = StringToBigInt(py); + if ($isNaN(ny)) { + return void undefined; + } + return BigIntLessThan(px, ny); + } + if (typeof px === 'string' && typeof py === 'bigint') { + nx = StringToBigInt(px); + if ($isNaN(nx)) { + return void undefined; + } + return BigIntLessThan(nx, py); + } + + nx = ToNumeric(px); + ny = ToNumeric(py); + if (isSameType(nx, ny)) { + return typeof nx === 'number' ? NumberLessThan(nx, ny) : BigIntLessThan(nx, ny); + } + + if ($isNaN(nx) || $isNaN(ny)) { + return void undefined; + } + if (nx === -Infinity || ny === Infinity) { + return true; + } + if (nx === Infinity || ny === -Infinity) { + return false; + } + + return nx < ny; // by now, these are both nonzero, finite, and not equal +}; diff --git a/node_modules/es-abstract/2021/AddEntriesFromIterable.js b/node_modules/es-abstract/2021/AddEntriesFromIterable.js new file mode 100644 index 0000000000000000000000000000000000000000..8c1c1e60007d69caa21ce9bd420b5a000bcf8a24 --- /dev/null +++ b/node_modules/es-abstract/2021/AddEntriesFromIterable.js @@ -0,0 +1,44 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); +var inspect = require('object-inspect'); + +var Call = require('./Call'); +var Get = require('./Get'); +var GetIterator = require('./GetIterator'); +var IsCallable = require('./IsCallable'); +var IteratorClose = require('./IteratorClose'); +var IteratorStep = require('./IteratorStep'); +var IteratorValue = require('./IteratorValue'); +var ThrowCompletion = require('./ThrowCompletion'); + +// https://262.ecma-international.org/10.0/#sec-add-entries-from-iterable + +module.exports = function AddEntriesFromIterable(target, iterable, adder) { + if (!IsCallable(adder)) { + throw new $TypeError('Assertion failed: `adder` is not callable'); + } + if (iterable == null) { + throw new $TypeError('Assertion failed: `iterable` is present, and not nullish'); + } + var iteratorRecord = GetIterator(iterable); + while (true) { + var next = IteratorStep(iteratorRecord); + if (!next) { + return target; + } + var nextItem = IteratorValue(next); + if (!isObject(nextItem)) { + var error = ThrowCompletion(new $TypeError('iterator next must return an Object, got ' + inspect(nextItem))); + return IteratorClose(iteratorRecord, error); + } + try { + var k = Get(nextItem, '0'); + var v = Get(nextItem, '1'); + Call(adder, target, [k, v]); + } catch (e) { + return IteratorClose(iteratorRecord, ThrowCompletion(e)); + } + } +}; diff --git a/node_modules/es-abstract/2021/AddToKeptObjects.js b/node_modules/es-abstract/2021/AddToKeptObjects.js new file mode 100644 index 0000000000000000000000000000000000000000..cce51955a6db7899e1be22e5077fb91d4f658600 --- /dev/null +++ b/node_modules/es-abstract/2021/AddToKeptObjects.js @@ -0,0 +1,18 @@ +'use strict'; + +var SLOT = require('internal-slot'); + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var ClearKeptObjects = require('./ClearKeptObjects'); + +// https://262.ecma-international.org/12.0/#sec-addtokeptobjects + +module.exports = function AddToKeptObjects(object) { + if (!isObject(object)) { + throw new $TypeError('Assertion failed: `object` must be an Object'); + } + var arr = SLOT.get(ClearKeptObjects, '[[es-abstract internal: KeptAlive]]'); + arr[arr.length] = object; +}; diff --git a/node_modules/es-abstract/2021/AdvanceStringIndex.js b/node_modules/es-abstract/2021/AdvanceStringIndex.js new file mode 100644 index 0000000000000000000000000000000000000000..370917df9dfff158449f930ef7d03643ee38982d --- /dev/null +++ b/node_modules/es-abstract/2021/AdvanceStringIndex.js @@ -0,0 +1,30 @@ +'use strict'; + +var CodePointAt = require('./CodePointAt'); + +var $TypeError = require('es-errors/type'); +var isInteger = require('math-intrinsics/isInteger'); +var MAX_SAFE_INTEGER = require('math-intrinsics/constants/maxSafeInteger'); + +// https://262.ecma-international.org/12.0/#sec-advancestringindex + +module.exports = function AdvanceStringIndex(S, index, unicode) { + if (typeof S !== 'string') { + throw new $TypeError('Assertion failed: `S` must be a String'); + } + if (!isInteger(index) || index < 0 || index > MAX_SAFE_INTEGER) { + throw new $TypeError('Assertion failed: `length` must be an integer >= 0 and <= 2**53'); + } + if (typeof unicode !== 'boolean') { + throw new $TypeError('Assertion failed: `unicode` must be a Boolean'); + } + if (!unicode) { + return index + 1; + } + var length = S.length; + if ((index + 1) >= length) { + return index + 1; + } + var cp = CodePointAt(S, index); + return index + cp['[[CodeUnitCount]]']; +}; diff --git a/node_modules/es-abstract/2021/ApplyStringOrNumericBinaryOperator.js b/node_modules/es-abstract/2021/ApplyStringOrNumericBinaryOperator.js new file mode 100644 index 0000000000000000000000000000000000000000..e65b6b2e79c756dcf2e533624ec8152e8dbfc161 --- /dev/null +++ b/node_modules/es-abstract/2021/ApplyStringOrNumericBinaryOperator.js @@ -0,0 +1,77 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var HasOwnProperty = require('./HasOwnProperty'); +var ToNumeric = require('./ToNumeric'); +var ToPrimitive = require('./ToPrimitive'); +var ToString = require('./ToString'); +var Type = require('./Type'); + +var NumberAdd = require('./Number/add'); +var NumberBitwiseAND = require('./Number/bitwiseAND'); +var NumberBitwiseOR = require('./Number/bitwiseOR'); +var NumberBitwiseXOR = require('./Number/bitwiseXOR'); +var NumberDivide = require('./Number/divide'); +var NumberExponentiate = require('./Number/exponentiate'); +var NumberLeftShift = require('./Number/leftShift'); +var NumberMultiply = require('./Number/multiply'); +var NumberRemainder = require('./Number/remainder'); +var NumberSignedRightShift = require('./Number/signedRightShift'); +var NumberSubtract = require('./Number/subtract'); +var NumberUnsignedRightShift = require('./Number/unsignedRightShift'); +var BigIntAdd = require('./BigInt/add'); +var BigIntBitwiseAND = require('./BigInt/bitwiseAND'); +var BigIntBitwiseOR = require('./BigInt/bitwiseOR'); +var BigIntBitwiseXOR = require('./BigInt/bitwiseXOR'); +var BigIntDivide = require('./BigInt/divide'); +var BigIntExponentiate = require('./BigInt/exponentiate'); +var BigIntLeftShift = require('./BigInt/leftShift'); +var BigIntMultiply = require('./BigInt/multiply'); +var BigIntRemainder = require('./BigInt/remainder'); +var BigIntSignedRightShift = require('./BigInt/signedRightShift'); +var BigIntSubtract = require('./BigInt/subtract'); +var BigIntUnsignedRightShift = require('./BigInt/unsignedRightShift'); + +// https://262.ecma-international.org/12.0/#sec-applystringornumericbinaryoperator + +// https://262.ecma-international.org/12.0/#step-applystringornumericbinaryoperator-operations-table +var table = { + '**': [NumberExponentiate, BigIntExponentiate], + '*': [NumberMultiply, BigIntMultiply], + '/': [NumberDivide, BigIntDivide], + '%': [NumberRemainder, BigIntRemainder], + '+': [NumberAdd, BigIntAdd], + '-': [NumberSubtract, BigIntSubtract], + '<<': [NumberLeftShift, BigIntLeftShift], + '>>': [NumberSignedRightShift, BigIntSignedRightShift], + '>>>': [NumberUnsignedRightShift, BigIntUnsignedRightShift], + '&': [NumberBitwiseAND, BigIntBitwiseAND], + '^': [NumberBitwiseXOR, BigIntBitwiseXOR], + '|': [NumberBitwiseOR, BigIntBitwiseOR] +}; + +module.exports = function ApplyStringOrNumericBinaryOperator(lval, opText, rval) { + if (typeof opText !== 'string' || !HasOwnProperty(table, opText)) { + throw new $TypeError('Assertion failed: `opText` must be a valid operation string'); + } + if (opText === '+') { + var lprim = ToPrimitive(lval); + var rprim = ToPrimitive(rval); + if (typeof lprim === 'string' || typeof rprim === 'string') { + var lstr = ToString(lprim); + var rstr = ToString(rprim); + return lstr + rstr; + } + /* eslint no-param-reassign: 1 */ + lval = lprim; + rval = rprim; + } + var lnum = ToNumeric(lval); + var rnum = ToNumeric(rval); + if (Type(lnum) !== Type(rnum)) { + throw new $TypeError('types of ' + lnum + ' and ' + rnum + ' differ'); + } + var Operation = table[opText][typeof lnum === 'bigint' ? 1 : 0]; + return Operation(lnum, rnum); +}; diff --git a/node_modules/es-abstract/2021/ArrayCreate.js b/node_modules/es-abstract/2021/ArrayCreate.js new file mode 100644 index 0000000000000000000000000000000000000000..568632b8a6d2ef76124399192dee465859e0ed1b --- /dev/null +++ b/node_modules/es-abstract/2021/ArrayCreate.js @@ -0,0 +1,42 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $ArrayPrototype = GetIntrinsic('%Array.prototype%'); +var $RangeError = require('es-errors/range'); +var $SyntaxError = require('es-errors/syntax'); +var $TypeError = require('es-errors/type'); +var isInteger = require('math-intrinsics/isInteger'); +var MAX_ARRAY_LENGTH = require('math-intrinsics/constants/maxArrayLength'); +var $setProto = require('set-proto'); + +// https://262.ecma-international.org/12.0/#sec-arraycreate + +module.exports = function ArrayCreate(length) { + if (!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 3, 5 + if (proto !== $ArrayPrototype) { // step 4 + 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 6 + A.length = length; + } + /* step 6, the above as a shortcut for the below + OrdinaryDefineOwnProperty(A, 'length', { + '[[Configurable]]': false, + '[[Enumerable]]': false, + '[[Value]]': length, + '[[Writable]]': true + }); + */ + return A; +}; diff --git a/node_modules/es-abstract/2021/ArraySetLength.js b/node_modules/es-abstract/2021/ArraySetLength.js new file mode 100644 index 0000000000000000000000000000000000000000..7f7a4339c2af5c8656165189f47c4212732ee1bd --- /dev/null +++ b/node_modules/es-abstract/2021/ArraySetLength.js @@ -0,0 +1,77 @@ +'use strict'; + +var $RangeError = require('es-errors/range'); +var $TypeError = require('es-errors/type'); + +var assign = require('object.assign'); + +var isPropertyDescriptor = require('../helpers/records/property-descriptor'); + +var IsArray = require('./IsArray'); +var IsDataDescriptor = require('./IsDataDescriptor'); +var OrdinaryDefineOwnProperty = require('./OrdinaryDefineOwnProperty'); +var OrdinaryGetOwnProperty = require('./OrdinaryGetOwnProperty'); +var ToNumber = require('./ToNumber'); +var ToString = require('./ToString'); +var ToUint32 = require('./ToUint32'); + +// https://262.ecma-international.org/6.0/#sec-arraysetlength + +// eslint-disable-next-line max-statements, max-lines-per-function +module.exports = function ArraySetLength(A, Desc) { + if (!IsArray(A)) { + throw new $TypeError('Assertion failed: A must be an Array'); + } + if (!isPropertyDescriptor(Desc)) { + throw new $TypeError('Assertion failed: Desc must be a Property Descriptor'); + } + if (!('[[Value]]' in Desc)) { + return OrdinaryDefineOwnProperty(A, 'length', Desc); + } + var newLenDesc = assign({}, Desc); + var newLen = ToUint32(Desc['[[Value]]']); + var numberLen = ToNumber(Desc['[[Value]]']); + if (newLen !== numberLen) { + throw new $RangeError('Invalid array length'); + } + newLenDesc['[[Value]]'] = newLen; + var oldLenDesc = OrdinaryGetOwnProperty(A, 'length'); + if (!IsDataDescriptor(oldLenDesc)) { + throw new $TypeError('Assertion failed: an array had a non-data descriptor on `length`'); + } + var oldLen = oldLenDesc['[[Value]]']; + if (newLen >= oldLen) { + return 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 = OrdinaryDefineOwnProperty(A, 'length', newLenDesc); + if (!succeeded) { + return false; + } + while (newLen < oldLen) { + oldLen -= 1; + // eslint-disable-next-line no-param-reassign + var deleteSucceeded = delete A[ToString(oldLen)]; + if (!deleteSucceeded) { + newLenDesc['[[Value]]'] = oldLen + 1; + if (!newWritable) { + newLenDesc['[[Writable]]'] = false; + OrdinaryDefineOwnProperty(A, 'length', newLenDesc); + return false; + } + } + } + if (!newWritable) { + return OrdinaryDefineOwnProperty(A, 'length', { '[[Writable]]': false }); + } + return true; +}; diff --git a/node_modules/es-abstract/2021/ArraySpeciesCreate.js b/node_modules/es-abstract/2021/ArraySpeciesCreate.js new file mode 100644 index 0000000000000000000000000000000000000000..2589c90787151d6dd4534c32499a6906b982c505 --- /dev/null +++ b/node_modules/es-abstract/2021/ArraySpeciesCreate.js @@ -0,0 +1,48 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $species = GetIntrinsic('%Symbol.species%', true); +var $TypeError = require('es-errors/type'); +var isInteger = require('math-intrinsics/isInteger'); +var isObject = require('es-object-atoms/isObject'); + +var ArrayCreate = require('./ArrayCreate'); +var Get = require('./Get'); +var IsArray = require('./IsArray'); +var IsConstructor = require('./IsConstructor'); + +// https://262.ecma-international.org/12.0/#sec-arrayspeciescreate + +module.exports = function ArraySpeciesCreate(originalArray, length) { + if (!isInteger(length) || length < 0) { + throw new $TypeError('Assertion failed: length must be an integer >= 0'); + } + + var isArray = IsArray(originalArray); + if (!isArray) { + return ArrayCreate(length); + } + + var C = Get(originalArray, 'constructor'); + // TODO: figure out how to make a cross-realm normal Array, a same-realm Array + // if (IsConstructor(C)) { + // if C is another realm's Array, C = undefined + // Object.getPrototypeOf(Object.getPrototypeOf(Object.getPrototypeOf(Array))) === null ? + // } + if ($species && isObject(C)) { + C = Get(C, $species); + if (C === null) { + C = void 0; + } + } + + if (typeof C === 'undefined') { + return ArrayCreate(length); + } + if (!IsConstructor(C)) { + throw new $TypeError('C must be a constructor'); + } + return new C(length); // Construct(C, length); +}; + diff --git a/node_modules/es-abstract/2021/AsyncFromSyncIteratorContinuation.js b/node_modules/es-abstract/2021/AsyncFromSyncIteratorContinuation.js new file mode 100644 index 0000000000000000000000000000000000000000..d545b6bfc70974e44350f20e4ec28812d9cbf9e2 --- /dev/null +++ b/node_modules/es-abstract/2021/AsyncFromSyncIteratorContinuation.js @@ -0,0 +1,45 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $SyntaxError = require('es-errors/syntax'); +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); +var $Promise = GetIntrinsic('%Promise%', true); + +var callBound = require('call-bound'); + +var CreateIterResultObject = require('./CreateIterResultObject'); +var IteratorComplete = require('./IteratorComplete'); +var IteratorValue = require('./IteratorValue'); +var PromiseResolve = require('./PromiseResolve'); + +var $then = callBound('Promise.prototype.then', true); + +// https://262.ecma-international.org/10.0/#sec-asyncfromsynciteratorcontinuation + +module.exports = function AsyncFromSyncIteratorContinuation(result) { + if (!isObject(result)) { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + if (arguments.length > 1) { + throw new $SyntaxError('although AsyncFromSyncIteratorContinuation should take a second argument, it is not used in this implementation'); + } + + if (!$Promise) { + throw new $SyntaxError('This environment does not support Promises.'); + } + + return new $Promise(function (resolve) { + var done = IteratorComplete(result); // step 2 + var value = IteratorValue(result); // step 4 + var valueWrapper = PromiseResolve($Promise, value); // step 6 + + // eslint-disable-next-line no-shadow + var onFulfilled = function (value) { // steps 8-9 + return CreateIterResultObject(value, done); // step 8.a + }; + resolve($then(valueWrapper, onFulfilled)); // step 11 + }); // step 12 +}; diff --git a/node_modules/es-abstract/2021/AsyncIteratorClose.js b/node_modules/es-abstract/2021/AsyncIteratorClose.js new file mode 100644 index 0000000000000000000000000000000000000000..d1cda2a301d35c13bee2a0e343b365fc48023edc --- /dev/null +++ b/node_modules/es-abstract/2021/AsyncIteratorClose.js @@ -0,0 +1,70 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $SyntaxError = require('es-errors/syntax'); +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); +var $Promise = GetIntrinsic('%Promise%', true); + +var Call = require('./Call'); +var CompletionRecord = require('./CompletionRecord'); +var GetMethod = require('./GetMethod'); + +var isIteratorRecord = require('../helpers/records/iterator-record-2023'); + +var callBound = require('call-bound'); + +var $then = callBound('Promise.prototype.then', true); + +// https://262.ecma-international.org/12.0/#sec-asynciteratorclose + +module.exports = function AsyncIteratorClose(iteratorRecord, completion) { + if (!isIteratorRecord(iteratorRecord)) { + throw new $TypeError('Assertion failed: `iteratorRecord` must be an Iterator Record'); // step 1 + } + + if (!(completion instanceof CompletionRecord)) { + throw new $TypeError('Assertion failed: completion is not a Completion Record instance'); // step 2 + } + + if (!$then) { + throw new $SyntaxError('This environment does not support Promises.'); + } + + var iterator = iteratorRecord['[[Iterator]]']; // step 3 + + return $then( + $then( + $then( + new $Promise(function (resolve) { + resolve(GetMethod(iterator, 'return')); // step 4 + // resolve(Call(ret, iterator, [])); // step 6 + }), + function (returnV) { // step 5.a + if (typeof returnV === 'undefined') { + return completion; // step 5.b + } + return Call(returnV, iterator); // step 5.c, 5.d. + } + ), + null, + function (e) { + if (completion.type() === 'throw') { + completion['?'](); // step 6 + } else { + throw e; // step 7 + } + } + ), + function (innerResult) { // step 8 + if (completion.type() === 'throw') { + completion['?'](); // step 6 + } + if (!isObject(innerResult)) { + throw new $TypeError('`innerResult` must be an Object'); // step 10 + } + return completion; + } + ); +}; diff --git a/node_modules/es-abstract/2021/BigInt/add.js b/node_modules/es-abstract/2021/BigInt/add.js new file mode 100644 index 0000000000000000000000000000000000000000..25cc9fa60f58e2433eb392a4cc0e00a0569474ba --- /dev/null +++ b/node_modules/es-abstract/2021/BigInt/add.js @@ -0,0 +1,14 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-add + +module.exports = function BigIntAdd(x, y) { + if (typeof x !== 'bigint' || typeof y !== 'bigint') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + + // shortcut for the actual spec mechanics + return x + y; +}; diff --git a/node_modules/es-abstract/2021/BigInt/bitwiseAND.js b/node_modules/es-abstract/2021/BigInt/bitwiseAND.js new file mode 100644 index 0000000000000000000000000000000000000000..106f4a273945d92cdb34715249ae5a72c1af93d8 --- /dev/null +++ b/node_modules/es-abstract/2021/BigInt/bitwiseAND.js @@ -0,0 +1,14 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var BigIntBitwiseOp = require('../BigIntBitwiseOp'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-bitwiseAND + +module.exports = function BigIntBitwiseAND(x, y) { + if (typeof x !== 'bigint' || typeof y !== 'bigint') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + return BigIntBitwiseOp('&', x, y); +}; diff --git a/node_modules/es-abstract/2021/BigInt/bitwiseNOT.js b/node_modules/es-abstract/2021/BigInt/bitwiseNOT.js new file mode 100644 index 0000000000000000000000000000000000000000..9fe67405f674c3501fe410d55c63c59874841d87 --- /dev/null +++ b/node_modules/es-abstract/2021/BigInt/bitwiseNOT.js @@ -0,0 +1,15 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $BigInt = GetIntrinsic('%BigInt%', true); +var $TypeError = require('es-errors/type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-bitwiseNOT + +module.exports = function BigIntBitwiseNOT(x) { + if (typeof x !== 'bigint') { + throw new $TypeError('Assertion failed: `x` argument must be a BigInt'); + } + return -x - $BigInt(1); +}; diff --git a/node_modules/es-abstract/2021/BigInt/bitwiseOR.js b/node_modules/es-abstract/2021/BigInt/bitwiseOR.js new file mode 100644 index 0000000000000000000000000000000000000000..b0ba812a8a321e0f92a9d446b4e5439ec898fd47 --- /dev/null +++ b/node_modules/es-abstract/2021/BigInt/bitwiseOR.js @@ -0,0 +1,14 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var BigIntBitwiseOp = require('../BigIntBitwiseOp'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-bitwiseOR + +module.exports = function BigIntBitwiseOR(x, y) { + if (typeof x !== 'bigint' || typeof y !== 'bigint') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + return BigIntBitwiseOp('|', x, y); +}; diff --git a/node_modules/es-abstract/2021/BigInt/bitwiseXOR.js b/node_modules/es-abstract/2021/BigInt/bitwiseXOR.js new file mode 100644 index 0000000000000000000000000000000000000000..79ac4a1f4568d559d69b64ba88061aabb1460c57 --- /dev/null +++ b/node_modules/es-abstract/2021/BigInt/bitwiseXOR.js @@ -0,0 +1,14 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var BigIntBitwiseOp = require('../BigIntBitwiseOp'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-bitwiseXOR + +module.exports = function BigIntBitwiseXOR(x, y) { + if (typeof x !== 'bigint' || typeof y !== 'bigint') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + return BigIntBitwiseOp('^', x, y); +}; diff --git a/node_modules/es-abstract/2021/BigInt/divide.js b/node_modules/es-abstract/2021/BigInt/divide.js new file mode 100644 index 0000000000000000000000000000000000000000..a194302eb682514dc75061f391f75fdad1f0da4e --- /dev/null +++ b/node_modules/es-abstract/2021/BigInt/divide.js @@ -0,0 +1,20 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $BigInt = GetIntrinsic('%BigInt%', true); +var $RangeError = require('es-errors/range'); +var $TypeError = require('es-errors/type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-divide + +module.exports = function BigIntDivide(x, y) { + if (typeof x !== 'bigint' || typeof y !== 'bigint') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + if (y === $BigInt(0)) { + throw new $RangeError('Division by zero'); + } + // shortcut for the actual spec mechanics + return x / y; +}; diff --git a/node_modules/es-abstract/2021/BigInt/equal.js b/node_modules/es-abstract/2021/BigInt/equal.js new file mode 100644 index 0000000000000000000000000000000000000000..d6b36a2551cb08160a812a8bab4dc3a63e751a8b --- /dev/null +++ b/node_modules/es-abstract/2021/BigInt/equal.js @@ -0,0 +1,13 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-equal + +module.exports = function BigIntEqual(x, y) { + if (typeof x !== 'bigint' || typeof y !== 'bigint') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + // shortcut for the actual spec mechanics + return x === y; +}; diff --git a/node_modules/es-abstract/2021/BigInt/exponentiate.js b/node_modules/es-abstract/2021/BigInt/exponentiate.js new file mode 100644 index 0000000000000000000000000000000000000000..f5bcdc148af1bc7658596120cbf5d72f7036c599 --- /dev/null +++ b/node_modules/es-abstract/2021/BigInt/exponentiate.js @@ -0,0 +1,29 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $BigInt = GetIntrinsic('%BigInt%', true); +var $RangeError = require('es-errors/range'); +var $TypeError = require('es-errors/type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-exponentiate + +module.exports = function BigIntExponentiate(base, exponent) { + if (typeof base !== 'bigint' || typeof exponent !== 'bigint') { + throw new $TypeError('Assertion failed: `base` and `exponent` arguments must be BigInts'); + } + if (exponent < $BigInt(0)) { + throw new $RangeError('Exponent must be positive'); + } + if (/* base === $BigInt(0) && */ exponent === $BigInt(0)) { + return $BigInt(1); + } + + var square = base; + var remaining = exponent; + while (remaining > $BigInt(0)) { + square += exponent; + --remaining; // eslint-disable-line no-plusplus + } + return square; +}; diff --git a/node_modules/es-abstract/2021/BigInt/index.js b/node_modules/es-abstract/2021/BigInt/index.js new file mode 100644 index 0000000000000000000000000000000000000000..63ec52da69e285d605f9f5db2ffe69ed4af591f2 --- /dev/null +++ b/node_modules/es-abstract/2021/BigInt/index.js @@ -0,0 +1,43 @@ +'use strict'; + +var add = require('./add'); +var bitwiseAND = require('./bitwiseAND'); +var bitwiseNOT = require('./bitwiseNOT'); +var bitwiseOR = require('./bitwiseOR'); +var bitwiseXOR = require('./bitwiseXOR'); +var divide = require('./divide'); +var equal = require('./equal'); +var exponentiate = require('./exponentiate'); +var leftShift = require('./leftShift'); +var lessThan = require('./lessThan'); +var multiply = require('./multiply'); +var remainder = require('./remainder'); +var sameValue = require('./sameValue'); +var sameValueZero = require('./sameValueZero'); +var signedRightShift = require('./signedRightShift'); +var subtract = require('./subtract'); +var toString = require('./toString'); +var unaryMinus = require('./unaryMinus'); +var unsignedRightShift = require('./unsignedRightShift'); + +module.exports = { + add: add, + bitwiseAND: bitwiseAND, + bitwiseNOT: bitwiseNOT, + bitwiseOR: bitwiseOR, + bitwiseXOR: bitwiseXOR, + divide: divide, + equal: equal, + exponentiate: exponentiate, + leftShift: leftShift, + lessThan: lessThan, + multiply: multiply, + remainder: remainder, + sameValue: sameValue, + sameValueZero: sameValueZero, + signedRightShift: signedRightShift, + subtract: subtract, + toString: toString, + unaryMinus: unaryMinus, + unsignedRightShift: unsignedRightShift +}; diff --git a/node_modules/es-abstract/2021/BigInt/leftShift.js b/node_modules/es-abstract/2021/BigInt/leftShift.js new file mode 100644 index 0000000000000000000000000000000000000000..327592ea62472441e0750d4a6e5bccc81a7a5c71 --- /dev/null +++ b/node_modules/es-abstract/2021/BigInt/leftShift.js @@ -0,0 +1,14 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-leftShift + +module.exports = function BigIntLeftShift(x, y) { + if (typeof x !== 'bigint' || typeof y !== 'bigint') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + + // shortcut for the actual spec mechanics + return x << y; +}; diff --git a/node_modules/es-abstract/2021/BigInt/lessThan.js b/node_modules/es-abstract/2021/BigInt/lessThan.js new file mode 100644 index 0000000000000000000000000000000000000000..612f2dbbc4ea4aa7e5b27781f68071baa10f8727 --- /dev/null +++ b/node_modules/es-abstract/2021/BigInt/lessThan.js @@ -0,0 +1,14 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-lessThan + +module.exports = function BigIntLessThan(x, y) { + if (typeof x !== 'bigint' || typeof y !== 'bigint') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + + // shortcut for the actual spec mechanics + return x < y; +}; diff --git a/node_modules/es-abstract/2021/BigInt/multiply.js b/node_modules/es-abstract/2021/BigInt/multiply.js new file mode 100644 index 0000000000000000000000000000000000000000..a9bfbd5936a77ce9ddaec1e442a36fc2c4eb96de --- /dev/null +++ b/node_modules/es-abstract/2021/BigInt/multiply.js @@ -0,0 +1,14 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-multiply + +module.exports = function BigIntMultiply(x, y) { + if (typeof x !== 'bigint' || typeof y !== 'bigint') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + + // shortcut for the actual spec mechanics + return x * y; +}; diff --git a/node_modules/es-abstract/2021/BigInt/remainder.js b/node_modules/es-abstract/2021/BigInt/remainder.js new file mode 100644 index 0000000000000000000000000000000000000000..60346ecdeec72fc2f63f823c80fea5a45208abab --- /dev/null +++ b/node_modules/es-abstract/2021/BigInt/remainder.js @@ -0,0 +1,28 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $BigInt = GetIntrinsic('%BigInt%', true); +var $RangeError = require('es-errors/range'); +var $TypeError = require('es-errors/type'); + +var zero = $BigInt && $BigInt(0); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-remainder + +module.exports = function BigIntRemainder(n, d) { + if (typeof n !== 'bigint' || typeof d !== 'bigint') { + throw new $TypeError('Assertion failed: `n` and `d` arguments must be BigInts'); + } + + if (d === zero) { + throw new $RangeError('Division by zero'); + } + + if (n === zero) { + return zero; + } + + // shortcut for the actual spec mechanics + return n % d; +}; diff --git a/node_modules/es-abstract/2021/BigInt/sameValue.js b/node_modules/es-abstract/2021/BigInt/sameValue.js new file mode 100644 index 0000000000000000000000000000000000000000..c4851a067c23ab5b48214b51dd6cc0744f1798ef --- /dev/null +++ b/node_modules/es-abstract/2021/BigInt/sameValue.js @@ -0,0 +1,15 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var BigIntEqual = require('./equal'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-sameValue + +module.exports = function BigIntSameValue(x, y) { + if (typeof x !== 'bigint' || typeof y !== 'bigint') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + + return BigIntEqual(x, y); +}; diff --git a/node_modules/es-abstract/2021/BigInt/sameValueZero.js b/node_modules/es-abstract/2021/BigInt/sameValueZero.js new file mode 100644 index 0000000000000000000000000000000000000000..0505ca376eb92ac77300bc70ec8c99f12bb90dc8 --- /dev/null +++ b/node_modules/es-abstract/2021/BigInt/sameValueZero.js @@ -0,0 +1,15 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var BigIntEqual = require('./equal'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-sameValueZero + +module.exports = function BigIntSameValueZero(x, y) { + if (typeof x !== 'bigint' || typeof y !== 'bigint') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + + return BigIntEqual(x, y); +}; diff --git a/node_modules/es-abstract/2021/BigInt/signedRightShift.js b/node_modules/es-abstract/2021/BigInt/signedRightShift.js new file mode 100644 index 0000000000000000000000000000000000000000..90967d66e622397fc8e7cd54ee6e1f7c5426b786 --- /dev/null +++ b/node_modules/es-abstract/2021/BigInt/signedRightShift.js @@ -0,0 +1,15 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var BigIntLeftShift = require('./leftShift'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-signedRightShift + +module.exports = function BigIntSignedRightShift(x, y) { + if (typeof x !== 'bigint' || typeof y !== 'bigint') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + + return BigIntLeftShift(x, -y); +}; diff --git a/node_modules/es-abstract/2021/BigInt/subtract.js b/node_modules/es-abstract/2021/BigInt/subtract.js new file mode 100644 index 0000000000000000000000000000000000000000..32de730a3cbea3a14df35755a24c54dcb9e5de9f --- /dev/null +++ b/node_modules/es-abstract/2021/BigInt/subtract.js @@ -0,0 +1,14 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-subtract + +module.exports = function BigIntSubtract(x, y) { + if (typeof x !== 'bigint' || typeof y !== 'bigint') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + + // shortcut for the actual spec mechanics + return x - y; +}; diff --git a/node_modules/es-abstract/2021/BigInt/toString.js b/node_modules/es-abstract/2021/BigInt/toString.js new file mode 100644 index 0000000000000000000000000000000000000000..5dc8a6a672c957e7c54eca452857436ff5794c9d --- /dev/null +++ b/node_modules/es-abstract/2021/BigInt/toString.js @@ -0,0 +1,16 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $String = GetIntrinsic('%String%'); +var $TypeError = require('es-errors/type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-tostring + +module.exports = function BigIntToString(x) { + if (typeof x !== 'bigint') { + throw new $TypeError('Assertion failed: `x` must be a BigInt'); + } + + return $String(x); +}; diff --git a/node_modules/es-abstract/2021/BigInt/unaryMinus.js b/node_modules/es-abstract/2021/BigInt/unaryMinus.js new file mode 100644 index 0000000000000000000000000000000000000000..161f02fbdba7eca7078ee2a2404f646e03b4d0be --- /dev/null +++ b/node_modules/es-abstract/2021/BigInt/unaryMinus.js @@ -0,0 +1,22 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $BigInt = GetIntrinsic('%BigInt%', true); +var $TypeError = require('es-errors/type'); + +var zero = $BigInt && $BigInt(0); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-unaryMinus + +module.exports = function BigIntUnaryMinus(x) { + if (typeof x !== 'bigint') { + throw new $TypeError('Assertion failed: `x` argument must be a BigInt'); + } + + if (x === zero) { + return zero; + } + + return -x; +}; diff --git a/node_modules/es-abstract/2021/BigInt/unsignedRightShift.js b/node_modules/es-abstract/2021/BigInt/unsignedRightShift.js new file mode 100644 index 0000000000000000000000000000000000000000..d695cb43beb3716c8015d4b83f93d6fc7307da73 --- /dev/null +++ b/node_modules/es-abstract/2021/BigInt/unsignedRightShift.js @@ -0,0 +1,13 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-unsignedRightShift + +module.exports = function BigIntUnsignedRightShift(x, y) { + if (typeof x !== 'bigint' || typeof y !== 'bigint') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + + throw new $TypeError('BigInts have no unsigned right shift, use >> instead'); +}; diff --git a/node_modules/es-abstract/2021/BigIntBitwiseOp.js b/node_modules/es-abstract/2021/BigIntBitwiseOp.js new file mode 100644 index 0000000000000000000000000000000000000000..40e1a13185c4a1b7273f3e53a48f04f9ec5161b6 --- /dev/null +++ b/node_modules/es-abstract/2021/BigIntBitwiseOp.js @@ -0,0 +1,63 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +// var $BigInt = GetIntrinsic('%BigInt%', true); +// var $pow = require('math-intrinsics/pow'); + +// var BinaryAnd = require('./BinaryAnd'); +// var BinaryOr = require('./BinaryOr'); +// var BinaryXor = require('./BinaryXor'); +// var modulo = require('./modulo'); + +// var zero = $BigInt && $BigInt(0); +// var negOne = $BigInt && $BigInt(-1); +// var two = $BigInt && $BigInt(2); + +// https://262.ecma-international.org/11.0/#sec-bigintbitwiseop + +module.exports = function BigIntBitwiseOp(op, x, y) { + if (op !== '&' && op !== '|' && op !== '^') { + throw new $TypeError('Assertion failed: `op` must be `&`, `|`, or `^`'); + } + if (typeof x !== 'bigint' || typeof y !== 'bigint') { + throw new $TypeError('`x` and `y` must be BigInts'); + } + + if (op === '&') { + return x & y; + } + if (op === '|') { + return x | y; + } + return x ^ y; + /* + var result = zero; + var shift = 0; + while (x !== zero && x !== negOne && y !== zero && y !== negOne) { + var xDigit = modulo(x, two); + var yDigit = modulo(y, two); + if (op === '&') { + result += $pow(2, shift) * BinaryAnd(xDigit, yDigit); + } else if (op === '|') { + result += $pow(2, shift) * BinaryOr(xDigit, yDigit); + } else if (op === '^') { + result += $pow(2, shift) * BinaryXor(xDigit, yDigit); + } + shift += 1; + x = (x - xDigit) / two; + y = (y - yDigit) / two; + } + var tmp; + if (op === '&') { + tmp = BinaryAnd(modulo(x, two), modulo(y, two)); + } else if (op === '|') { + tmp = BinaryAnd(modulo(x, two), modulo(y, two)); + } else { + tmp = BinaryXor(modulo(x, two), modulo(y, two)); + } + if (tmp !== 0) { + result -= $pow(2, shift); + } + return result; + */ +}; diff --git a/node_modules/es-abstract/2021/BinaryAnd.js b/node_modules/es-abstract/2021/BinaryAnd.js new file mode 100644 index 0000000000000000000000000000000000000000..bb361dea6141f1b0d447cb06b5ee18e96ea426ce --- /dev/null +++ b/node_modules/es-abstract/2021/BinaryAnd.js @@ -0,0 +1,12 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +// https://262.ecma-international.org/11.0/#sec-binaryand + +module.exports = function BinaryAnd(x, y) { + if ((x !== 0 && x !== 1) || (y !== 0 && y !== 1)) { + throw new $TypeError('Assertion failed: `x` and `y` must be either 0 or 1'); + } + return x & y; +}; diff --git a/node_modules/es-abstract/2021/BinaryOr.js b/node_modules/es-abstract/2021/BinaryOr.js new file mode 100644 index 0000000000000000000000000000000000000000..76200f8744087b5c72020f4826d5bc8f55bd3886 --- /dev/null +++ b/node_modules/es-abstract/2021/BinaryOr.js @@ -0,0 +1,12 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +// https://262.ecma-international.org/11.0/#sec-binaryor + +module.exports = function BinaryOr(x, y) { + if ((x !== 0 && x !== 1) || (y !== 0 && y !== 1)) { + throw new $TypeError('Assertion failed: `x` and `y` must be either 0 or 1'); + } + return x | y; +}; diff --git a/node_modules/es-abstract/2021/BinaryXor.js b/node_modules/es-abstract/2021/BinaryXor.js new file mode 100644 index 0000000000000000000000000000000000000000..c1da53b26c67c6379ceaa50349f7861827eb6e10 --- /dev/null +++ b/node_modules/es-abstract/2021/BinaryXor.js @@ -0,0 +1,12 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +// https://262.ecma-international.org/11.0/#sec-binaryxor + +module.exports = function BinaryXor(x, y) { + if ((x !== 0 && x !== 1) || (y !== 0 && y !== 1)) { + throw new $TypeError('Assertion failed: `x` and `y` must be either 0 or 1'); + } + return x ^ y; +}; diff --git a/node_modules/es-abstract/2021/ByteListBitwiseOp.js b/node_modules/es-abstract/2021/ByteListBitwiseOp.js new file mode 100644 index 0000000000000000000000000000000000000000..7aba5bc6346a74cdb51b6070e1e6a8159783fce0 --- /dev/null +++ b/node_modules/es-abstract/2021/ByteListBitwiseOp.js @@ -0,0 +1,39 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var IsArray = require('./IsArray'); + +var isByteValue = require('../helpers/isByteValue'); + +// https://262.ecma-international.org/12.0/#sec-bytelistbitwiseop + +module.exports = function ByteListBitwiseOp(op, xBytes, yBytes) { + if (op !== '&' && op !== '^' && op !== '|') { + throw new $TypeError('Assertion failed: `op` must be `&`, `^`, or `|`'); + } + if (!IsArray(xBytes) || !IsArray(yBytes) || xBytes.length !== yBytes.length) { + throw new $TypeError('Assertion failed: `xBytes` and `yBytes` must be same-length sequences of byte values (an integer 0-255, inclusive)'); + } + + var result = []; + + for (var i = 0; i < xBytes.length; i += 1) { + var xByte = xBytes[i]; + var yByte = yBytes[i]; + if (!isByteValue(xByte) || !isByteValue(yByte)) { + throw new $TypeError('Assertion failed: `xBytes` and `yBytes` must be same-length sequences of byte values (an integer 0-255, inclusive)'); + } + var resultByte; + if (op === '&') { + resultByte = xByte & yByte; + } else if (op === '^') { + resultByte = xByte ^ yByte; + } else { + resultByte = xByte | yByte; + } + result[result.length] = resultByte; + } + + return result; +}; diff --git a/node_modules/es-abstract/2021/ByteListEqual.js b/node_modules/es-abstract/2021/ByteListEqual.js new file mode 100644 index 0000000000000000000000000000000000000000..b581cbba25a97b6211880bf53391bfcde3986715 --- /dev/null +++ b/node_modules/es-abstract/2021/ByteListEqual.js @@ -0,0 +1,31 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var IsArray = require('./IsArray'); + +var isByteValue = require('../helpers/isByteValue'); + +// https://262.ecma-international.org/12.0/#sec-bytelistequal + +module.exports = function ByteListEqual(xBytes, yBytes) { + if (!IsArray(xBytes) || !IsArray(yBytes)) { + throw new $TypeError('Assertion failed: `xBytes` and `yBytes` must be sequences of byte values (an integer 0-255, inclusive)'); + } + + if (xBytes.length !== yBytes.length) { + return false; + } + + for (var i = 0; i < xBytes.length; i += 1) { + var xByte = xBytes[i]; + var yByte = yBytes[i]; + if (!isByteValue(xByte) || !isByteValue(yByte)) { + throw new $TypeError('Assertion failed: `xBytes` and `yBytes` must be sequences of byte values (an integer 0-255, inclusive)'); + } + if (xByte !== yByte) { + return false; + } + } + return true; +}; diff --git a/node_modules/es-abstract/2021/Call.js b/node_modules/es-abstract/2021/Call.js new file mode 100644 index 0000000000000000000000000000000000000000..90b3519cb954848f531c4921eaa79ec7d37d06bd --- /dev/null +++ b/node_modules/es-abstract/2021/Call.js @@ -0,0 +1,20 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); +var callBound = require('call-bound'); + +var $TypeError = require('es-errors/type'); + +var IsArray = require('./IsArray'); + +var $apply = GetIntrinsic('%Reflect.apply%', true) || callBound('Function.prototype.apply'); + +// https://262.ecma-international.org/6.0/#sec-call + +module.exports = function Call(F, V) { + var argumentsList = arguments.length > 2 ? arguments[2] : []; + if (!IsArray(argumentsList)) { + throw new $TypeError('Assertion failed: optional `argumentsList`, if provided, must be a List'); + } + return $apply(F, V, argumentsList); +}; diff --git a/node_modules/es-abstract/2021/CanonicalNumericIndexString.js b/node_modules/es-abstract/2021/CanonicalNumericIndexString.js new file mode 100644 index 0000000000000000000000000000000000000000..74ed02f050d21c13dbfc06c80c21ae20a8e530ee --- /dev/null +++ b/node_modules/es-abstract/2021/CanonicalNumericIndexString.js @@ -0,0 +1,19 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var SameValue = require('./SameValue'); +var ToNumber = require('./ToNumber'); +var ToString = require('./ToString'); + +// https://262.ecma-international.org/6.0/#sec-canonicalnumericindexstring + +module.exports = function CanonicalNumericIndexString(argument) { + if (typeof argument !== 'string') { + throw new $TypeError('Assertion failed: `argument` must be a String'); + } + if (argument === '-0') { return -0; } + var n = ToNumber(argument); + if (SameValue(ToString(n), argument)) { return n; } + return void 0; +}; diff --git a/node_modules/es-abstract/2021/Canonicalize.js b/node_modules/es-abstract/2021/Canonicalize.js new file mode 100644 index 0000000000000000000000000000000000000000..63a58c4028e12d41fc2775615441ea23228b6719 --- /dev/null +++ b/node_modules/es-abstract/2021/Canonicalize.js @@ -0,0 +1,51 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var callBound = require('call-bound'); +var hasOwn = require('hasown'); + +var $charCodeAt = callBound('String.prototype.charCodeAt'); +var $toUpperCase = callBound('String.prototype.toUpperCase'); + +var caseFolding = require('../helpers/caseFolding.json'); + +// https://262.ecma-international.org/6.0/#sec-runtime-semantics-canonicalize-ch + +module.exports = function Canonicalize(ch, IgnoreCase, Unicode) { + if (typeof ch !== 'string') { + throw new $TypeError('Assertion failed: `ch` must be a character'); + } + + if (typeof IgnoreCase !== 'boolean' || typeof Unicode !== 'boolean') { + throw new $TypeError('Assertion failed: `IgnoreCase` and `Unicode` must be Booleans'); + } + + if (!IgnoreCase) { + return ch; // step 1 + } + + if (Unicode) { // step 2 + if (hasOwn(caseFolding.C, ch)) { + return caseFolding.C[ch]; + } + if (hasOwn(caseFolding.S, ch)) { + return caseFolding.S[ch]; + } + return ch; // step 2.b + } + + var u = $toUpperCase(ch); // step 2 + + if (u.length !== 1) { + return ch; // step 3 + } + + var cu = u; // step 4 + + if ($charCodeAt(ch, 0) >= 128 && $charCodeAt(cu, 0) < 128) { + return ch; // step 5 + } + + return cu; +}; diff --git a/node_modules/es-abstract/2021/CharacterRange.js b/node_modules/es-abstract/2021/CharacterRange.js new file mode 100644 index 0000000000000000000000000000000000000000..e41cb7870a7411344a21dfe7fbfc7cd6888b7c9e --- /dev/null +++ b/node_modules/es-abstract/2021/CharacterRange.js @@ -0,0 +1,53 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); +var callBound = require('call-bound'); + +var $fromCharCode = GetIntrinsic('%String.fromCharCode%'); +var $TypeError = require('es-errors/type'); +var $charCodeAt = callBound('String.prototype.charCodeAt'); + +var CharSet = require('../helpers/CharSet').CharSet; + +module.exports = function CharacterRange(A, B) { + var a; + var b; + + if (A instanceof CharSet || B instanceof CharSet) { + if (!(A instanceof CharSet) || !(B instanceof CharSet)) { + throw new $TypeError('Assertion failed: CharSets A and B are not both CharSets'); + } + + A.yield(function (c) { + if (typeof a !== 'undefined') { + throw new $TypeError('Assertion failed: CharSet A has more than one character'); + } + a = c; + }); + B.yield(function (c) { + if (typeof b !== 'undefined') { + throw new $TypeError('Assertion failed: CharSet B has more than one character'); + } + b = c; + }); + } else { + if (A.length !== 1 || B.length !== 1) { + throw new $TypeError('Assertion failed: CharSets A and B contain exactly one character'); + } + a = A[0]; + b = B[0]; + } + + var i = $charCodeAt(a, 0); + var j = $charCodeAt(b, 0); + + if (!(i <= j)) { + throw new $TypeError('Assertion failed: i is not <= j'); + } + + var arr = []; + for (var k = i; k <= j; k += 1) { + arr[arr.length] = $fromCharCode(k); + } + return arr; +}; diff --git a/node_modules/es-abstract/2021/ClearKeptObjects.js b/node_modules/es-abstract/2021/ClearKeptObjects.js new file mode 100644 index 0000000000000000000000000000000000000000..50bd4a5da4199b973650ca675584246ef492edac --- /dev/null +++ b/node_modules/es-abstract/2021/ClearKeptObjects.js @@ -0,0 +1,12 @@ +'use strict'; + +var SLOT = require('internal-slot'); +var keptObjects = []; + +// https://262.ecma-international.org/12.0/#sec-clear-kept-objects + +module.exports = function ClearKeptObjects() { + keptObjects.length = 0; +}; + +SLOT.set(module.exports, '[[es-abstract internal: KeptAlive]]', keptObjects); diff --git a/node_modules/es-abstract/2021/CloneArrayBuffer.js b/node_modules/es-abstract/2021/CloneArrayBuffer.js new file mode 100644 index 0000000000000000000000000000000000000000..27c8ba96184211b7d06388f9f7302f8f4e293638 --- /dev/null +++ b/node_modules/es-abstract/2021/CloneArrayBuffer.js @@ -0,0 +1,46 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var GetPrototypeFromConstructor = require('./GetPrototypeFromConstructor'); +var IsConstructor = require('./IsConstructor'); +var IsDetachedBuffer = require('./IsDetachedBuffer'); +var OrdinarySetPrototypeOf = require('./OrdinarySetPrototypeOf'); + +var isInteger = require('math-intrinsics/isInteger'); +var isArrayBuffer = require('is-array-buffer'); +var arrayBufferSlice = require('arraybuffer.prototype.slice'); + +// https://262.ecma-international.org/12.0/#sec-clonearraybuffer + +module.exports = function CloneArrayBuffer(srcBuffer, srcByteOffset, srcLength, cloneConstructor) { + if (!isArrayBuffer(srcBuffer)) { + throw new $TypeError('Assertion failed: `srcBuffer` must be an ArrayBuffer instance'); + } + if (!isInteger(srcByteOffset) || srcByteOffset < 0) { + throw new $TypeError('Assertion failed: `srcByteOffset` must be a non-negative integer'); + } + if (!isInteger(srcLength) || srcLength < 0) { + throw new $TypeError('Assertion failed: `srcLength` must be a non-negative integer'); + } + if (!IsConstructor(cloneConstructor)) { + throw new $TypeError('Assertion failed: `cloneConstructor` must be a constructor'); + } + + // 3. Let targetBuffer be ? AllocateArrayBuffer(cloneConstructor, srcLength). + var proto = GetPrototypeFromConstructor(cloneConstructor, '%ArrayBufferPrototype%'); // step 3, kinda + + if (IsDetachedBuffer(srcBuffer)) { + throw new $TypeError('`srcBuffer` must not be a detached ArrayBuffer'); // step 4 + } + + /* + 5. Let srcBlock be srcBuffer.[[ArrayBufferData]]. + 6. Let targetBlock be targetBuffer.[[ArrayBufferData]]. + 7. Perform CopyDataBlockBytes(targetBlock, 0, srcBlock, srcByteOffset, srcLength). + */ + var targetBuffer = arrayBufferSlice(srcBuffer, srcByteOffset, srcByteOffset + srcLength); // steps 5-7 + OrdinarySetPrototypeOf(targetBuffer, proto); // step 3 + + return targetBuffer; // step 8 +}; diff --git a/node_modules/es-abstract/2021/CodePointAt.js b/node_modules/es-abstract/2021/CodePointAt.js new file mode 100644 index 0000000000000000000000000000000000000000..466d11cb64df54d4dd73c331b83903069323e526 --- /dev/null +++ b/node_modules/es-abstract/2021/CodePointAt.js @@ -0,0 +1,55 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var callBound = require('call-bound'); +var isLeadingSurrogate = require('../helpers/isLeadingSurrogate'); +var isTrailingSurrogate = require('../helpers/isTrailingSurrogate'); + +var UTF16SurrogatePairToCodePoint = require('./UTF16SurrogatePairToCodePoint'); + +var $charAt = callBound('String.prototype.charAt'); +var $charCodeAt = callBound('String.prototype.charCodeAt'); + +// https://262.ecma-international.org/12.0/#sec-codepointat + +module.exports = function CodePointAt(string, position) { + if (typeof string !== 'string') { + throw new $TypeError('Assertion failed: `string` must be a String'); + } + var size = string.length; + if (position < 0 || position >= size) { + throw new $TypeError('Assertion failed: `position` must be >= 0, and < the length of `string`'); + } + var first = $charCodeAt(string, position); + var cp = $charAt(string, position); + var firstIsLeading = isLeadingSurrogate(first); + var firstIsTrailing = isTrailingSurrogate(first); + if (!firstIsLeading && !firstIsTrailing) { + return { + '[[CodePoint]]': cp, + '[[CodeUnitCount]]': 1, + '[[IsUnpairedSurrogate]]': false + }; + } + if (firstIsTrailing || (position + 1 === size)) { + return { + '[[CodePoint]]': cp, + '[[CodeUnitCount]]': 1, + '[[IsUnpairedSurrogate]]': true + }; + } + var second = $charCodeAt(string, position + 1); + if (!isTrailingSurrogate(second)) { + return { + '[[CodePoint]]': cp, + '[[CodeUnitCount]]': 1, + '[[IsUnpairedSurrogate]]': true + }; + } + + return { + '[[CodePoint]]': UTF16SurrogatePairToCodePoint(first, second), + '[[CodeUnitCount]]': 2, + '[[IsUnpairedSurrogate]]': false + }; +}; diff --git a/node_modules/es-abstract/2021/CodePointsToString.js b/node_modules/es-abstract/2021/CodePointsToString.js new file mode 100644 index 0000000000000000000000000000000000000000..c15bcb4c93be5996162f356749622a1d104de7af --- /dev/null +++ b/node_modules/es-abstract/2021/CodePointsToString.js @@ -0,0 +1,25 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var UTF16EncodeCodePoint = require('./UTF16EncodeCodePoint'); +var IsArray = require('./IsArray'); + +var forEach = require('../helpers/forEach'); +var isCodePoint = require('../helpers/isCodePoint'); + +// https://262.ecma-international.org/12.0/#sec-codepointstostring + +module.exports = function CodePointsToString(text) { + if (!IsArray(text)) { + throw new $TypeError('Assertion failed: `text` must be a sequence of Unicode Code Points'); + } + var result = ''; + forEach(text, function (cp) { + if (!isCodePoint(cp)) { + throw new $TypeError('Assertion failed: `text` must be a sequence of Unicode Code Points'); + } + result += UTF16EncodeCodePoint(cp); + }); + return result; +}; diff --git a/node_modules/es-abstract/2021/CompletePropertyDescriptor.js b/node_modules/es-abstract/2021/CompletePropertyDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..8c9e3f441111638a3b3c9fd69857d3da22c779ee --- /dev/null +++ b/node_modules/es-abstract/2021/CompletePropertyDescriptor.js @@ -0,0 +1,43 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var hasOwn = require('hasown'); + +var IsDataDescriptor = require('./IsDataDescriptor'); +var IsGenericDescriptor = require('./IsGenericDescriptor'); + +var isPropertyDescriptor = require('../helpers/records/property-descriptor'); + +// https://262.ecma-international.org/6.0/#sec-completepropertydescriptor + +module.exports = function CompletePropertyDescriptor(Desc) { + if (!isPropertyDescriptor(Desc)) { + throw new $TypeError('Assertion failed: `Desc` must be a Property Descriptor'); + } + + /* eslint no-param-reassign: 0 */ + + if (IsGenericDescriptor(Desc) || IsDataDescriptor(Desc)) { + if (!hasOwn(Desc, '[[Value]]')) { + Desc['[[Value]]'] = void 0; + } + if (!hasOwn(Desc, '[[Writable]]')) { + Desc['[[Writable]]'] = false; + } + } else { + if (!hasOwn(Desc, '[[Get]]')) { + Desc['[[Get]]'] = void 0; + } + if (!hasOwn(Desc, '[[Set]]')) { + Desc['[[Set]]'] = void 0; + } + } + if (!hasOwn(Desc, '[[Enumerable]]')) { + Desc['[[Enumerable]]'] = false; + } + if (!hasOwn(Desc, '[[Configurable]]')) { + Desc['[[Configurable]]'] = false; + } + return Desc; +}; diff --git a/node_modules/es-abstract/2021/CompletionRecord.js b/node_modules/es-abstract/2021/CompletionRecord.js new file mode 100644 index 0000000000000000000000000000000000000000..0a7a6817c87e69578cfbc5546901b1c4dba112a9 --- /dev/null +++ b/node_modules/es-abstract/2021/CompletionRecord.js @@ -0,0 +1,48 @@ +'use strict'; + +var $SyntaxError = require('es-errors/syntax'); + +var SLOT = require('internal-slot'); + +// https://262.ecma-international.org/7.0/#sec-completion-record-specification-type + +var CompletionRecord = function CompletionRecord(type, value) { + if (!(this instanceof CompletionRecord)) { + return new CompletionRecord(type, value); + } + if (type !== 'normal' && type !== 'break' && type !== 'continue' && type !== 'return' && type !== 'throw') { + throw new $SyntaxError('Assertion failed: `type` must be one of "normal", "break", "continue", "return", or "throw"'); + } + SLOT.set(this, '[[Type]]', type); + SLOT.set(this, '[[Value]]', value); + // [[Target]] slot? +}; + +CompletionRecord.prototype.type = function Type() { + return SLOT.get(this, '[[Type]]'); +}; + +CompletionRecord.prototype.value = function Value() { + return SLOT.get(this, '[[Value]]'); +}; + +CompletionRecord.prototype['?'] = function ReturnIfAbrupt() { + var type = SLOT.get(this, '[[Type]]'); + var value = SLOT.get(this, '[[Value]]'); + + if (type === 'throw') { + throw value; + } + return value; +}; + +CompletionRecord.prototype['!'] = function assert() { + var type = SLOT.get(this, '[[Type]]'); + + if (type !== 'normal') { + throw new $SyntaxError('Assertion failed: Completion Record is not of type "normal"'); + } + return SLOT.get(this, '[[Value]]'); +}; + +module.exports = CompletionRecord; diff --git a/node_modules/es-abstract/2021/CopyDataProperties.js b/node_modules/es-abstract/2021/CopyDataProperties.js new file mode 100644 index 0000000000000000000000000000000000000000..182720710e8b97fc0ed0f09cb7743aeb4baae938 --- /dev/null +++ b/node_modules/es-abstract/2021/CopyDataProperties.js @@ -0,0 +1,69 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); +var callBound = require('call-bound'); +var OwnPropertyKeys = require('own-keys'); + +var forEach = require('../helpers/forEach'); +var every = require('../helpers/every'); +var some = require('../helpers/some'); + +var $isEnumerable = callBound('Object.prototype.propertyIsEnumerable'); + +var CreateDataPropertyOrThrow = require('./CreateDataPropertyOrThrow'); +var Get = require('./Get'); +var IsArray = require('./IsArray'); +var isPropertyKey = require('../helpers/isPropertyKey'); +var SameValue = require('./SameValue'); +var ToNumber = require('./ToNumber'); +var ToObject = require('./ToObject'); + +var isInteger = require('math-intrinsics/isInteger'); + +// https://262.ecma-international.org/12.0/#sec-copydataproperties + +module.exports = function CopyDataProperties(target, source, excludedItems) { + if (!isObject(target)) { + throw new $TypeError('Assertion failed: "target" must be an Object'); + } + + if (!IsArray(excludedItems) || !every(excludedItems, isPropertyKey)) { + throw new $TypeError('Assertion failed: "excludedItems" must be a List of Property Keys'); + } + + if (typeof source === 'undefined' || source === null) { + return target; + } + + var from = ToObject(source); + + var keys = OwnPropertyKeys(from); + forEach(keys, function (nextKey) { + var excluded = some(excludedItems, function (e) { + return SameValue(e, nextKey) === true; + }); + /* + var excluded = false; + + forEach(excludedItems, function (e) { + if (SameValue(e, nextKey) === true) { + excluded = true; + } + }); + */ + + var enumerable = $isEnumerable(from, nextKey) || ( + // this is to handle string keys being non-enumerable in older engines + typeof source === 'string' + && nextKey >= 0 + && isInteger(ToNumber(nextKey)) + ); + if (excluded === false && enumerable) { + var propValue = Get(from, nextKey); + CreateDataPropertyOrThrow(target, nextKey, propValue); + } + }); + + return target; +}; diff --git a/node_modules/es-abstract/2021/CreateAsyncFromSyncIterator.js b/node_modules/es-abstract/2021/CreateAsyncFromSyncIterator.js new file mode 100644 index 0000000000000000000000000000000000000000..33c02bebc80cfdf01f16758e05a21b6d1ff7720c --- /dev/null +++ b/node_modules/es-abstract/2021/CreateAsyncFromSyncIterator.js @@ -0,0 +1,137 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $SyntaxError = require('es-errors/syntax'); +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); +var $Promise = GetIntrinsic('%Promise%', true); + +var AsyncFromSyncIteratorContinuation = require('./AsyncFromSyncIteratorContinuation'); +var Call = require('./Call'); +var CreateIterResultObject = require('./CreateIterResultObject'); +var Get = require('./Get'); +var GetMethod = require('./GetMethod'); +var IteratorNext = require('./IteratorNext'); +var OrdinaryObjectCreate = require('./OrdinaryObjectCreate'); + +var isIteratorRecord = require('../helpers/records/iterator-record-2023'); + +var SLOT = require('internal-slot'); + +var $AsyncFromSyncIteratorPrototype = GetIntrinsic('%AsyncFromSyncIteratorPrototype%', true) || { + next: function next(value) { + if (!$Promise) { + throw new $SyntaxError('This environment does not support Promises.'); + } + + var O = this; // step 1 + + SLOT.assert(O, '[[SyncIteratorRecord]]'); // step 2 + + var argsLength = arguments.length; + + return new $Promise(function (resolve) { // step 3 + var syncIteratorRecord = SLOT.get(O, '[[SyncIteratorRecord]]'); // step 4 + var result; + if (argsLength > 0) { + result = IteratorNext(syncIteratorRecord['[[Iterator]]'], value); // step 5.a + } else { // step 6 + result = IteratorNext(syncIteratorRecord['[[Iterator]]']);// step 6.a + } + resolve(AsyncFromSyncIteratorContinuation(result)); // step 8 + }); + }, + 'return': function () { + if (!$Promise) { + throw new $SyntaxError('This environment does not support Promises.'); + } + + var O = this; // step 1 + + SLOT.assert(O, '[[SyncIteratorRecord]]'); // step 2 + + var valueIsPresent = arguments.length > 0; + var value = valueIsPresent ? arguments[0] : void undefined; + + return new $Promise(function (resolve, reject) { // step 3 + var syncIterator = SLOT.get(O, '[[SyncIteratorRecord]]')['[[Iterator]]']; // step 4 + var iteratorReturn = GetMethod(syncIterator, 'return'); // step 5 + + if (typeof iteratorReturn === 'undefined') { // step 7 + var iterResult = CreateIterResultObject(value, true); // step 7.a + Call(resolve, undefined, [iterResult]); // step 7.b + return; + } + var result; + if (valueIsPresent) { // step 8 + result = Call(iteratorReturn, syncIterator, [value]); // step 8.a + } else { // step 9 + result = Call(iteratorReturn, syncIterator); // step 9.a + } + if (!isObject(result)) { // step 11 + Call(reject, undefined, [new $TypeError('Iterator `return` method returned a non-object value.')]); // step 11.a + return; + } + + resolve(AsyncFromSyncIteratorContinuation(result)); // step 12 + }); + }, + 'throw': function () { + if (!$Promise) { + throw new $SyntaxError('This environment does not support Promises.'); + } + + var O = this; // step 1 + + SLOT.assert(O, '[[SyncIteratorRecord]]'); // step 2 + + var valueIsPresent = arguments.length > 0; + var value = valueIsPresent ? arguments[0] : void undefined; + + return new $Promise(function (resolve, reject) { // step 3 + var syncIterator = SLOT.get(O, '[[SyncIteratorRecord]]')['[[Iterator]]']; // step 4 + + var throwMethod = GetMethod(syncIterator, 'throw'); // step 5 + + if (typeof throwMethod === 'undefined') { // step 7 + Call(reject, undefined, [value]); // step 7.a + return; + } + + var result; + if (valueIsPresent) { // step 8 + result = Call(throwMethod, syncIterator, [value]); // step 8.a + } else { // step 9 + result = Call(throwMethod, syncIterator); // step 9.a + } + if (!isObject(result)) { // step 11 + Call(reject, undefined, [new $TypeError('Iterator `throw` method returned a non-object value.')]); // step 11.a + return; + } + + resolve(AsyncFromSyncIteratorContinuation(result/* , promiseCapability */)); // step 12 + }); + } +}; + +// https://262.ecma-international.org/11.0/#sec-createasyncfromsynciterator + +module.exports = function CreateAsyncFromSyncIterator(syncIteratorRecord) { + if (!isIteratorRecord(syncIteratorRecord)) { + throw new $TypeError('Assertion failed: `syncIteratorRecord` must be an Iterator Record'); + } + + // var asyncIterator = OrdinaryObjectCreate(%AsyncFromSyncIteratorPrototype%, « [[SyncIteratorRecord]] »); // step 1 + var asyncIterator = OrdinaryObjectCreate($AsyncFromSyncIteratorPrototype); + + SLOT.set(asyncIterator, '[[SyncIteratorRecord]]', syncIteratorRecord); // step 2 + + var nextMethod = Get(asyncIterator, 'next'); // step 3 + + return { // steps 3-4 + '[[Iterator]]': asyncIterator, + '[[NextMethod]]': nextMethod, + '[[Done]]': false + }; +}; diff --git a/node_modules/es-abstract/2021/CreateDataProperty.js b/node_modules/es-abstract/2021/CreateDataProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..897617c0ca1e0365cb55a83855b0983550e3e298 --- /dev/null +++ b/node_modules/es-abstract/2021/CreateDataProperty.js @@ -0,0 +1,25 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var isPropertyKey = require('../helpers/isPropertyKey'); +var OrdinaryDefineOwnProperty = require('./OrdinaryDefineOwnProperty'); + +// https://262.ecma-international.org/6.0/#sec-createdataproperty + +module.exports = function CreateDataProperty(O, P, V) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: P is not a Property Key'); + } + var newDesc = { + '[[Configurable]]': true, + '[[Enumerable]]': true, + '[[Value]]': V, + '[[Writable]]': true + }; + return OrdinaryDefineOwnProperty(O, P, newDesc); +}; diff --git a/node_modules/es-abstract/2021/CreateDataPropertyOrThrow.js b/node_modules/es-abstract/2021/CreateDataPropertyOrThrow.js new file mode 100644 index 0000000000000000000000000000000000000000..42327aaef58a8ffc3c320851135e886106dcbad6 --- /dev/null +++ b/node_modules/es-abstract/2021/CreateDataPropertyOrThrow.js @@ -0,0 +1,24 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var CreateDataProperty = require('./CreateDataProperty'); + +var isPropertyKey = require('../helpers/isPropertyKey'); + +// // https://262.ecma-international.org/6.0/#sec-createdatapropertyorthrow + +module.exports = function CreateDataPropertyOrThrow(O, P, V) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: P is not a Property Key'); + } + var success = CreateDataProperty(O, P, V); + if (!success) { + throw new $TypeError('unable to create data property'); + } + return success; +}; diff --git a/node_modules/es-abstract/2021/CreateHTML.js b/node_modules/es-abstract/2021/CreateHTML.js new file mode 100644 index 0000000000000000000000000000000000000000..25630f43085954792b398e93a870ac78b46e3fc4 --- /dev/null +++ b/node_modules/es-abstract/2021/CreateHTML.js @@ -0,0 +1,27 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var callBound = require('call-bound'); + +var $replace = callBound('String.prototype.replace'); + +var RequireObjectCoercible = require('./RequireObjectCoercible'); +var ToString = require('./ToString'); + +// https://262.ecma-international.org/6.0/#sec-createhtml + +module.exports = function CreateHTML(string, tag, attribute, value) { + if (typeof tag !== 'string' || typeof attribute !== 'string') { + throw new $TypeError('Assertion failed: `tag` and `attribute` must be strings'); + } + var str = RequireObjectCoercible(string); + var S = ToString(str); + var p1 = '<' + tag; + if (attribute !== '') { + var V = ToString(value); + var escapedV = $replace(V, /\x22/g, '"'); + p1 += '\x20' + attribute + '\x3D\x22' + escapedV + '\x22'; + } + return p1 + '>' + S + ''; +}; diff --git a/node_modules/es-abstract/2021/CreateIterResultObject.js b/node_modules/es-abstract/2021/CreateIterResultObject.js new file mode 100644 index 0000000000000000000000000000000000000000..679bdf00ea851b40cce0dc9e6d55526aa9d5c5d7 --- /dev/null +++ b/node_modules/es-abstract/2021/CreateIterResultObject.js @@ -0,0 +1,15 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +// https://262.ecma-international.org/6.0/#sec-createiterresultobject + +module.exports = function CreateIterResultObject(value, done) { + if (typeof done !== 'boolean') { + throw new $TypeError('Assertion failed: Type(done) is not Boolean'); + } + return { + value: value, + done: done + }; +}; diff --git a/node_modules/es-abstract/2021/CreateListFromArrayLike.js b/node_modules/es-abstract/2021/CreateListFromArrayLike.js new file mode 100644 index 0000000000000000000000000000000000000000..3cd2d5c27a0867bd7a1fef684d6915a516544e32 --- /dev/null +++ b/node_modules/es-abstract/2021/CreateListFromArrayLike.js @@ -0,0 +1,44 @@ +'use strict'; + +var callBound = require('call-bound'); + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); +var $indexOf = callBound('Array.prototype.indexOf', true) || callBound('String.prototype.indexOf'); + +var Get = require('./Get'); +var IsArray = require('./IsArray'); +var LengthOfArrayLike = require('./LengthOfArrayLike'); +var ToString = require('./ToString'); +var Type = require('./Type'); + +var defaultElementTypes = ['Undefined', 'Null', 'Boolean', 'String', 'Symbol', 'Number', 'BigInt', 'Object']; + +// https://262.ecma-international.org/11.0/#sec-createlistfromarraylike + +module.exports = function CreateListFromArrayLike(obj) { + var elementTypes = arguments.length > 1 + ? arguments[1] + : defaultElementTypes; + + if (!isObject(obj)) { + throw new $TypeError('Assertion failed: `obj` must be an Object'); + } + if (!IsArray(elementTypes)) { + throw new $TypeError('Assertion failed: `elementTypes`, if provided, must be an array'); + } + var len = LengthOfArrayLike(obj); + var list = []; + var index = 0; + while (index < len) { + var indexName = ToString(index); + var next = Get(obj, indexName); + var nextType = Type(next); + if ($indexOf(elementTypes, nextType) < 0) { + throw new $TypeError('item type ' + nextType + ' is not a valid elementType'); + } + list[list.length] = next; + index += 1; + } + return list; +}; diff --git a/node_modules/es-abstract/2021/CreateMethodProperty.js b/node_modules/es-abstract/2021/CreateMethodProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..4c53a40986ad2c0f6678b161465bca1ba569dd21 --- /dev/null +++ b/node_modules/es-abstract/2021/CreateMethodProperty.js @@ -0,0 +1,38 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var DefineOwnProperty = require('../helpers/DefineOwnProperty'); + +var FromPropertyDescriptor = require('./FromPropertyDescriptor'); +var IsDataDescriptor = require('./IsDataDescriptor'); +var isPropertyKey = require('../helpers/isPropertyKey'); +var SameValue = require('./SameValue'); + +// https://262.ecma-international.org/6.0/#sec-createmethodproperty + +module.exports = function CreateMethodProperty(O, P, V) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: P is not a Property Key'); + } + + var newDesc = { + '[[Configurable]]': true, + '[[Enumerable]]': false, + '[[Value]]': V, + '[[Writable]]': true + }; + return DefineOwnProperty( + IsDataDescriptor, + SameValue, + FromPropertyDescriptor, + O, + P, + newDesc + ); +}; diff --git a/node_modules/es-abstract/2021/CreateRegExpStringIterator.js b/node_modules/es-abstract/2021/CreateRegExpStringIterator.js new file mode 100644 index 0000000000000000000000000000000000000000..d7cc09963e2b8c33147bd8285d986e86d80201ea --- /dev/null +++ b/node_modules/es-abstract/2021/CreateRegExpStringIterator.js @@ -0,0 +1,100 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); +var hasSymbols = require('has-symbols')(); + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); +var IteratorPrototype = GetIntrinsic('%IteratorPrototype%', true); + +var AdvanceStringIndex = require('./AdvanceStringIndex'); +var CreateIterResultObject = require('./CreateIterResultObject'); +var CreateMethodProperty = require('./CreateMethodProperty'); +var Get = require('./Get'); +var OrdinaryObjectCreate = require('./OrdinaryObjectCreate'); +var RegExpExec = require('./RegExpExec'); +var Set = require('./Set'); +var ToLength = require('./ToLength'); +var ToString = require('./ToString'); + +var SLOT = require('internal-slot'); +var setToStringTag = require('es-set-tostringtag'); + +var RegExpStringIterator = function RegExpStringIterator(R, S, global, fullUnicode) { + if (typeof S !== 'string') { + throw new $TypeError('`S` must be a string'); + } + if (typeof global !== 'boolean') { + throw new $TypeError('`global` must be a boolean'); + } + if (typeof fullUnicode !== 'boolean') { + throw new $TypeError('`fullUnicode` must be a boolean'); + } + SLOT.set(this, '[[IteratingRegExp]]', R); + SLOT.set(this, '[[IteratedString]]', S); + SLOT.set(this, '[[Global]]', global); + SLOT.set(this, '[[Unicode]]', fullUnicode); + SLOT.set(this, '[[Done]]', false); +}; + +if (IteratorPrototype) { + RegExpStringIterator.prototype = OrdinaryObjectCreate(IteratorPrototype); +} + +var RegExpStringIteratorNext = function next() { + var O = this; + if (!isObject(O)) { + throw new $TypeError('receiver must be an object'); + } + if ( + !(O instanceof RegExpStringIterator) + || !SLOT.has(O, '[[IteratingRegExp]]') + || !SLOT.has(O, '[[IteratedString]]') + || !SLOT.has(O, '[[Global]]') + || !SLOT.has(O, '[[Unicode]]') + || !SLOT.has(O, '[[Done]]') + ) { + throw new $TypeError('"this" value must be a RegExpStringIterator instance'); + } + if (SLOT.get(O, '[[Done]]')) { + return CreateIterResultObject(undefined, true); + } + var R = SLOT.get(O, '[[IteratingRegExp]]'); + var S = SLOT.get(O, '[[IteratedString]]'); + var global = SLOT.get(O, '[[Global]]'); + var fullUnicode = SLOT.get(O, '[[Unicode]]'); + var match = RegExpExec(R, S); + if (match === null) { + SLOT.set(O, '[[Done]]', true); + return CreateIterResultObject(undefined, true); + } + if (global) { + var matchStr = ToString(Get(match, '0')); + if (matchStr === '') { + var thisIndex = ToLength(Get(R, 'lastIndex')); + var nextIndex = AdvanceStringIndex(S, thisIndex, fullUnicode); + Set(R, 'lastIndex', nextIndex, true); + } + return CreateIterResultObject(match, false); + } + SLOT.set(O, '[[Done]]', true); + return CreateIterResultObject(match, false); +}; +CreateMethodProperty(RegExpStringIterator.prototype, 'next', RegExpStringIteratorNext); + +if (hasSymbols) { + setToStringTag(RegExpStringIterator.prototype, 'RegExp String Iterator'); + + if (Symbol.iterator && typeof RegExpStringIterator.prototype[Symbol.iterator] !== 'function') { + var iteratorFn = function SymbolIterator() { + return this; + }; + CreateMethodProperty(RegExpStringIterator.prototype, Symbol.iterator, iteratorFn); + } +} + +// https://262.ecma-international.org/11.0/#sec-createregexpstringiterator +module.exports = function CreateRegExpStringIterator(R, S, global, fullUnicode) { + // assert R.global === global && R.unicode === fullUnicode? + return new RegExpStringIterator(R, S, global, fullUnicode); +}; diff --git a/node_modules/es-abstract/2021/DateFromTime.js b/node_modules/es-abstract/2021/DateFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..ec7edcd295f8bdd79eb60e44d8a17bb0b90fd80d --- /dev/null +++ b/node_modules/es-abstract/2021/DateFromTime.js @@ -0,0 +1,52 @@ +'use strict'; + +var $EvalError = require('es-errors/eval'); + +var DayWithinYear = require('./DayWithinYear'); +var InLeapYear = require('./InLeapYear'); +var MonthFromTime = require('./MonthFromTime'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.5 + +module.exports = function DateFromTime(t) { + var m = MonthFromTime(t); + var d = DayWithinYear(t); + if (m === 0) { + return d + 1; + } + if (m === 1) { + return d - 30; + } + var leap = InLeapYear(t); + if (m === 2) { + return d - 58 - leap; + } + if (m === 3) { + return d - 89 - leap; + } + if (m === 4) { + return d - 119 - leap; + } + if (m === 5) { + return d - 150 - leap; + } + if (m === 6) { + return d - 180 - leap; + } + if (m === 7) { + return d - 211 - leap; + } + if (m === 8) { + return d - 242 - leap; + } + if (m === 9) { + return d - 272 - leap; + } + if (m === 10) { + return d - 303 - leap; + } + if (m === 11) { + return d - 333 - leap; + } + throw new $EvalError('Assertion failed: MonthFromTime returned an impossible value: ' + m); +}; diff --git a/node_modules/es-abstract/2021/DateString.js b/node_modules/es-abstract/2021/DateString.js new file mode 100644 index 0000000000000000000000000000000000000000..8106127a7d9e7708279035a2488e66cd49bbd5cb --- /dev/null +++ b/node_modules/es-abstract/2021/DateString.js @@ -0,0 +1,27 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var weekdays = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']; +var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; + +var $isNaN = require('math-intrinsics/isNaN'); +var padTimeComponent = require('../helpers/padTimeComponent'); + +var DateFromTime = require('./DateFromTime'); +var MonthFromTime = require('./MonthFromTime'); +var WeekDay = require('./WeekDay'); +var YearFromTime = require('./YearFromTime'); + +// https://262.ecma-international.org/9.0/#sec-datestring + +module.exports = function DateString(tv) { + if (typeof tv !== 'number' || $isNaN(tv)) { + throw new $TypeError('Assertion failed: `tv` must be a non-NaN Number'); + } + var weekday = weekdays[WeekDay(tv)]; + var month = months[MonthFromTime(tv)]; + var day = padTimeComponent(DateFromTime(tv)); + var year = padTimeComponent(YearFromTime(tv), 4); + return weekday + '\x20' + month + '\x20' + day + '\x20' + year; +}; diff --git a/node_modules/es-abstract/2021/Day.js b/node_modules/es-abstract/2021/Day.js new file mode 100644 index 0000000000000000000000000000000000000000..51d01033c81cbd356ff4da8010c166137364237d --- /dev/null +++ b/node_modules/es-abstract/2021/Day.js @@ -0,0 +1,11 @@ +'use strict'; + +var floor = require('./floor'); + +var msPerDay = require('../helpers/timeConstants').msPerDay; + +// https://262.ecma-international.org/5.1/#sec-15.9.1.2 + +module.exports = function Day(t) { + return floor(t / msPerDay); +}; diff --git a/node_modules/es-abstract/2021/DayFromYear.js b/node_modules/es-abstract/2021/DayFromYear.js new file mode 100644 index 0000000000000000000000000000000000000000..341bf22a6c19352ec6225944fb49adeed22983e8 --- /dev/null +++ b/node_modules/es-abstract/2021/DayFromYear.js @@ -0,0 +1,10 @@ +'use strict'; + +var floor = require('./floor'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.3 + +module.exports = function DayFromYear(y) { + return (365 * (y - 1970)) + floor((y - 1969) / 4) - floor((y - 1901) / 100) + floor((y - 1601) / 400); +}; + diff --git a/node_modules/es-abstract/2021/DayWithinYear.js b/node_modules/es-abstract/2021/DayWithinYear.js new file mode 100644 index 0000000000000000000000000000000000000000..4c580940a58c58dcc3f7c2f96c5bca8e8237ebfc --- /dev/null +++ b/node_modules/es-abstract/2021/DayWithinYear.js @@ -0,0 +1,11 @@ +'use strict'; + +var Day = require('./Day'); +var DayFromYear = require('./DayFromYear'); +var YearFromTime = require('./YearFromTime'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.4 + +module.exports = function DayWithinYear(t) { + return Day(t) - DayFromYear(YearFromTime(t)); +}; diff --git a/node_modules/es-abstract/2021/DaysInYear.js b/node_modules/es-abstract/2021/DaysInYear.js new file mode 100644 index 0000000000000000000000000000000000000000..7116c69027022323e41130f384db7cc3d35709f9 --- /dev/null +++ b/node_modules/es-abstract/2021/DaysInYear.js @@ -0,0 +1,18 @@ +'use strict'; + +var modulo = require('./modulo'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.3 + +module.exports = function DaysInYear(y) { + if (modulo(y, 4) !== 0) { + return 365; + } + if (modulo(y, 100) !== 0) { + return 366; + } + if (modulo(y, 400) !== 0) { + return 365; + } + return 366; +}; diff --git a/node_modules/es-abstract/2021/DefinePropertyOrThrow.js b/node_modules/es-abstract/2021/DefinePropertyOrThrow.js new file mode 100644 index 0000000000000000000000000000000000000000..ff6683c3dc954ec27c072032bfcc0cfd70936587 --- /dev/null +++ b/node_modules/es-abstract/2021/DefinePropertyOrThrow.js @@ -0,0 +1,39 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var isPropertyDescriptor = require('../helpers/records/property-descriptor'); +var DefineOwnProperty = require('../helpers/DefineOwnProperty'); + +var FromPropertyDescriptor = require('./FromPropertyDescriptor'); +var IsDataDescriptor = require('./IsDataDescriptor'); +var isPropertyKey = require('../helpers/isPropertyKey'); +var SameValue = require('./SameValue'); +var ToPropertyDescriptor = require('./ToPropertyDescriptor'); + +// https://262.ecma-international.org/6.0/#sec-definepropertyorthrow + +module.exports = function DefinePropertyOrThrow(O, P, desc) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: P is not a Property Key'); + } + + var Desc = isPropertyDescriptor(desc) ? desc : ToPropertyDescriptor(desc); + if (!isPropertyDescriptor(Desc)) { + throw new $TypeError('Assertion failed: Desc is not a valid Property Descriptor'); + } + + return DefineOwnProperty( + IsDataDescriptor, + SameValue, + FromPropertyDescriptor, + O, + P, + Desc + ); +}; diff --git a/node_modules/es-abstract/2021/DeletePropertyOrThrow.js b/node_modules/es-abstract/2021/DeletePropertyOrThrow.js new file mode 100644 index 0000000000000000000000000000000000000000..8841fda81f7663673367bdfc1af99794fb0ef747 --- /dev/null +++ b/node_modules/es-abstract/2021/DeletePropertyOrThrow.js @@ -0,0 +1,25 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var isPropertyKey = require('../helpers/isPropertyKey'); + +// https://262.ecma-international.org/6.0/#sec-deletepropertyorthrow + +module.exports = function DeletePropertyOrThrow(O, P) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: P is not a Property Key'); + } + + // eslint-disable-next-line no-param-reassign + var success = delete O[P]; + if (!success) { + throw new $TypeError('Attempt to delete property failed.'); + } + return success; +}; diff --git a/node_modules/es-abstract/2021/DetachArrayBuffer.js b/node_modules/es-abstract/2021/DetachArrayBuffer.js new file mode 100644 index 0000000000000000000000000000000000000000..6ded9de5652c4483ba14060ba82380eb3e63d92a --- /dev/null +++ b/node_modules/es-abstract/2021/DetachArrayBuffer.js @@ -0,0 +1,46 @@ +'use strict'; + +var $SyntaxError = require('es-errors/syntax'); +var $TypeError = require('es-errors/type'); + +var IsDetachedBuffer = require('./IsDetachedBuffer'); + +var isArrayBuffer = require('is-array-buffer'); +var isSharedArrayBuffer = require('is-shared-array-buffer'); + +var MessageChannel; +try { + // eslint-disable-next-line global-require + MessageChannel = require('worker_threads').MessageChannel; +} catch (e) { /**/ } + +// https://262.ecma-international.org/9.0/#sec-detacharraybuffer + +/* globals postMessage */ + +module.exports = function DetachArrayBuffer(arrayBuffer) { + if (!isArrayBuffer(arrayBuffer) || isSharedArrayBuffer(arrayBuffer)) { + throw new $TypeError('Assertion failed: `arrayBuffer` must be an Object with an [[ArrayBufferData]] internal slot, and not a Shared Array Buffer'); + } + + // commented out since there's no way to set or access this key + // var key = arguments.length > 1 ? arguments[1] : void undefined; + + // if (!SameValue(arrayBuffer[[ArrayBufferDetachKey]], key)) { + // throw new $TypeError('Assertion failed: `key` must be the value of the [[ArrayBufferDetachKey]] internal slot of `arrayBuffer`'); + // } + + if (!IsDetachedBuffer(arrayBuffer)) { // node v21.0.0+ throws when you structuredClone a detached buffer + if (typeof structuredClone === 'function') { + structuredClone(arrayBuffer, { transfer: [arrayBuffer] }); + } else if (typeof postMessage === 'function') { + postMessage('', '/', [arrayBuffer]); // TODO: see if this might trigger listeners + } else if (MessageChannel) { + (new MessageChannel()).port1.postMessage(null, [arrayBuffer]); + } else { + throw new $SyntaxError('DetachArrayBuffer is not supported in this environment'); + } + } + + return null; +}; diff --git a/node_modules/es-abstract/2021/EnumerableOwnPropertyNames.js b/node_modules/es-abstract/2021/EnumerableOwnPropertyNames.js new file mode 100644 index 0000000000000000000000000000000000000000..f08d846e95148ddd0b96f0475ea6d1ae3554e704 --- /dev/null +++ b/node_modules/es-abstract/2021/EnumerableOwnPropertyNames.js @@ -0,0 +1,37 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var objectKeys = require('object-keys'); +var safePushApply = require('safe-push-apply'); +var callBound = require('call-bound'); + +var $isEnumerable = callBound('Object.prototype.propertyIsEnumerable'); + +var forEach = require('../helpers/forEach'); + +// https://262.ecma-international.org/8.0/#sec-enumerableownproperties + +module.exports = function EnumerableOwnPropertyNames(O, kind) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + var keys = objectKeys(O); + if (kind === 'key') { + return keys; + } + if (kind === 'value' || kind === 'key+value') { + var results = []; + forEach(keys, function (key) { + if ($isEnumerable(O, key)) { + safePushApply(results, [ + kind === 'value' ? O[key] : [key, O[key]] + ]); + } + }); + return results; + } + throw new $TypeError('Assertion failed: "kind" is not "key", "value", or "key+value": ' + kind); +}; diff --git a/node_modules/es-abstract/2021/FlattenIntoArray.js b/node_modules/es-abstract/2021/FlattenIntoArray.js new file mode 100644 index 0000000000000000000000000000000000000000..78dc57c8cc90f0c0a60adb32fc7f41c230c4a591 --- /dev/null +++ b/node_modules/es-abstract/2021/FlattenIntoArray.js @@ -0,0 +1,55 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var MAX_SAFE_INTEGER = require('math-intrinsics/constants/maxSafeInteger'); + +var Call = require('./Call'); +var CreateDataPropertyOrThrow = require('./CreateDataPropertyOrThrow'); +var Get = require('./Get'); +var HasProperty = require('./HasProperty'); +var IsArray = require('./IsArray'); +var LengthOfArrayLike = require('./LengthOfArrayLike'); +var ToString = require('./ToString'); + +// https://262.ecma-international.org/11.0/#sec-flattenintoarray + +module.exports = function FlattenIntoArray(target, source, sourceLen, start, depth) { + var mapperFunction; + if (arguments.length > 5) { + mapperFunction = arguments[5]; + } + + var targetIndex = start; + var sourceIndex = 0; + while (sourceIndex < sourceLen) { + var P = ToString(sourceIndex); + var exists = HasProperty(source, P); + if (exists === true) { + var element = Get(source, P); + if (typeof mapperFunction !== 'undefined') { + if (arguments.length <= 6) { + throw new $TypeError('Assertion failed: thisArg is required when mapperFunction is provided'); + } + element = Call(mapperFunction, arguments[6], [element, sourceIndex, source]); + } + var shouldFlatten = false; + if (depth > 0) { + shouldFlatten = IsArray(element); + } + if (shouldFlatten) { + var elementLen = LengthOfArrayLike(element); + targetIndex = FlattenIntoArray(target, element, elementLen, targetIndex, depth - 1); + } else { + if (targetIndex >= MAX_SAFE_INTEGER) { + throw new $TypeError('index too large'); + } + CreateDataPropertyOrThrow(target, ToString(targetIndex), element); + targetIndex += 1; + } + } + sourceIndex += 1; + } + + return targetIndex; +}; diff --git a/node_modules/es-abstract/2021/FromPropertyDescriptor.js b/node_modules/es-abstract/2021/FromPropertyDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..45b6379f1214c415e1e43b855db01f18b3566cba --- /dev/null +++ b/node_modules/es-abstract/2021/FromPropertyDescriptor.js @@ -0,0 +1,16 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var isPropertyDescriptor = require('../helpers/records/property-descriptor'); +var fromPropertyDescriptor = require('../helpers/fromPropertyDescriptor'); + +// https://262.ecma-international.org/6.0/#sec-frompropertydescriptor + +module.exports = function FromPropertyDescriptor(Desc) { + if (typeof Desc !== 'undefined' && !isPropertyDescriptor(Desc)) { + throw new $TypeError('Assertion failed: `Desc` must be a Property Descriptor'); + } + + return fromPropertyDescriptor(Desc); +}; diff --git a/node_modules/es-abstract/2021/Get.js b/node_modules/es-abstract/2021/Get.js new file mode 100644 index 0000000000000000000000000000000000000000..42f7a14d853e05735d4166708590df2743cfa74c --- /dev/null +++ b/node_modules/es-abstract/2021/Get.js @@ -0,0 +1,24 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var inspect = require('object-inspect'); + +var isPropertyKey = require('../helpers/isPropertyKey'); + +var isObject = require('es-object-atoms/isObject'); + +// https://262.ecma-international.org/6.0/#sec-get-o-p + +module.exports = function Get(O, P) { + // 7.3.1.1 + if (!isObject(O)) { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + // 7.3.1.2 + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: P is not a Property Key, got ' + inspect(P)); + } + // 7.3.1.3 + return O[P]; +}; diff --git a/node_modules/es-abstract/2021/GetGlobalObject.js b/node_modules/es-abstract/2021/GetGlobalObject.js new file mode 100644 index 0000000000000000000000000000000000000000..0541ede0c48889fefe9a137e0e37a2e13573c091 --- /dev/null +++ b/node_modules/es-abstract/2021/GetGlobalObject.js @@ -0,0 +1,9 @@ +'use strict'; + +var getGlobal = require('globalthis/polyfill'); + +// https://262.ecma-international.org/6.0/#sec-getglobalobject + +module.exports = function GetGlobalObject() { + return getGlobal(); +}; diff --git a/node_modules/es-abstract/2021/GetIterator.js b/node_modules/es-abstract/2021/GetIterator.js new file mode 100644 index 0000000000000000000000000000000000000000..9c7bdfce51f79e2501c0a15702476bd78458028f --- /dev/null +++ b/node_modules/es-abstract/2021/GetIterator.js @@ -0,0 +1,63 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = require('es-errors/type'); +var $SyntaxError = require('es-errors/syntax'); +var isObject = require('es-object-atoms/isObject'); +var $asyncIterator = GetIntrinsic('%Symbol.asyncIterator%', true); + +var inspect = require('object-inspect'); +var hasSymbols = require('has-symbols')(); + +var getIteratorMethod = require('../helpers/getIteratorMethod'); +var AdvanceStringIndex = require('./AdvanceStringIndex'); +var Call = require('./Call'); +var GetMethod = require('./GetMethod'); + +var ES = { + AdvanceStringIndex: AdvanceStringIndex, + GetMethod: GetMethod +}; + +// https://262.ecma-international.org/9.0/#sec-getiterator + +module.exports = function GetIterator(obj, hint, method) { + var actualHint = hint; + if (arguments.length < 2) { + actualHint = 'sync'; + } + if (actualHint !== 'sync' && actualHint !== 'async') { + throw new $TypeError("Assertion failed: `hint` must be one of 'sync' or 'async', got " + inspect(hint)); + } + + var actualMethod = method; + if (arguments.length < 3) { + if (actualHint === 'async') { + if (hasSymbols && $asyncIterator) { + actualMethod = GetMethod(obj, $asyncIterator); + } + if (actualMethod === undefined) { + throw new $SyntaxError("async from sync iterators aren't currently supported"); + } + } else { + actualMethod = getIteratorMethod(ES, obj); + } + } + var iterator = Call(actualMethod, obj); + if (!isObject(iterator)) { + throw new $TypeError('iterator must return an object'); + } + + return iterator; + + // TODO: This should return an IteratorRecord + /* + var nextMethod = GetV(iterator, 'next'); + return { + '[[Iterator]]': iterator, + '[[NextMethod]]': nextMethod, + '[[Done]]': false + }; + */ +}; diff --git a/node_modules/es-abstract/2021/GetMethod.js b/node_modules/es-abstract/2021/GetMethod.js new file mode 100644 index 0000000000000000000000000000000000000000..e28bb1501fc8e4d4a67250c5110cba73bbcba385 --- /dev/null +++ b/node_modules/es-abstract/2021/GetMethod.js @@ -0,0 +1,34 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var GetV = require('./GetV'); +var IsCallable = require('./IsCallable'); +var isPropertyKey = require('../helpers/isPropertyKey'); + +var inspect = require('object-inspect'); + +// https://262.ecma-international.org/6.0/#sec-getmethod + +module.exports = function GetMethod(O, P) { + // 7.3.9.1 + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: P is not a Property Key'); + } + + // 7.3.9.2 + var func = GetV(O, P); + + // 7.3.9.4 + if (func == null) { + return void 0; + } + + // 7.3.9.5 + if (!IsCallable(func)) { + throw new $TypeError(inspect(P) + ' is not a function: ' + inspect(func)); + } + + // 7.3.9.6 + return func; +}; diff --git a/node_modules/es-abstract/2021/GetOwnPropertyKeys.js b/node_modules/es-abstract/2021/GetOwnPropertyKeys.js new file mode 100644 index 0000000000000000000000000000000000000000..e9b50d744a5fdf42221ad18e6674e777fa3b0a47 --- /dev/null +++ b/node_modules/es-abstract/2021/GetOwnPropertyKeys.js @@ -0,0 +1,30 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var hasSymbols = require('has-symbols')(); + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var $gOPN = GetIntrinsic('%Object.getOwnPropertyNames%', true); +var $gOPS = hasSymbols && GetIntrinsic('%Object.getOwnPropertySymbols%', true); +var keys = require('object-keys'); + +// https://262.ecma-international.org/6.0/#sec-getownpropertykeys + +module.exports = function GetOwnPropertyKeys(O, Type) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + if (Type === 'Symbol') { + return $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"`'); +}; diff --git a/node_modules/es-abstract/2021/GetPromiseResolve.js b/node_modules/es-abstract/2021/GetPromiseResolve.js new file mode 100644 index 0000000000000000000000000000000000000000..7c9d9a945a0c268fa7558eec169a2cee0e903b86 --- /dev/null +++ b/node_modules/es-abstract/2021/GetPromiseResolve.js @@ -0,0 +1,20 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var Get = require('./Get'); +var IsCallable = require('./IsCallable'); +var IsConstructor = require('./IsConstructor'); + +// https://262.ecma-international.org/12.0/#sec-getpromiseresolve + +module.exports = function GetPromiseResolve(promiseConstructor) { + if (!IsConstructor(promiseConstructor)) { + throw new $TypeError('Assertion failed: `promiseConstructor` must be a constructor'); + } + var promiseResolve = Get(promiseConstructor, 'resolve'); + if (IsCallable(promiseResolve) === false) { + throw new $TypeError('`resolve` method is not callable'); + } + return promiseResolve; +}; diff --git a/node_modules/es-abstract/2021/GetPrototypeFromConstructor.js b/node_modules/es-abstract/2021/GetPrototypeFromConstructor.js new file mode 100644 index 0000000000000000000000000000000000000000..687f6ef200fb11a3dc97a27533d15430c305fb3b --- /dev/null +++ b/node_modules/es-abstract/2021/GetPrototypeFromConstructor.js @@ -0,0 +1,33 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $Function = GetIntrinsic('%Function%'); +var $TypeError = require('es-errors/type'); +var $SyntaxError = require('es-errors/syntax'); + +var Get = require('./Get'); +var IsConstructor = require('./IsConstructor'); + +var isObject = require('es-object-atoms/isObject'); + +// https://262.ecma-international.org/6.0/#sec-getprototypefromconstructor + +module.exports = function GetPrototypeFromConstructor(constructor, intrinsicDefaultProto) { + var intrinsic = GetIntrinsic(intrinsicDefaultProto); // throws if not a valid intrinsic + if (!isObject(intrinsic)) { + throw new $TypeError('intrinsicDefaultProto must be an object'); + } + if (!IsConstructor(constructor)) { + throw new $TypeError('Assertion failed: `constructor` must be a constructor'); + } + var proto = Get(constructor, 'prototype'); + if (!isObject(proto)) { + if (!(constructor instanceof $Function)) { + // ignore other realms, for now + throw new $SyntaxError('cross-realm constructors not currently supported'); + } + proto = intrinsic; + } + return proto; +}; diff --git a/node_modules/es-abstract/2021/GetSubstitution.js b/node_modules/es-abstract/2021/GetSubstitution.js new file mode 100644 index 0000000000000000000000000000000000000000..091443340bac906b993b7b159a77123190ceb168 --- /dev/null +++ b/node_modules/es-abstract/2021/GetSubstitution.js @@ -0,0 +1,119 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var callBound = require('call-bound'); +var regexTester = require('safe-regex-test'); +var isInteger = require('math-intrinsics/isInteger'); + +var $charAt = callBound('String.prototype.charAt'); +var $strSlice = callBound('String.prototype.slice'); +var $indexOf = callBound('String.prototype.indexOf'); +var $parseInt = parseInt; + +var isDigit = regexTester(/^[0-9]$/); + +var inspect = require('object-inspect'); + +var Get = require('./Get'); +var IsArray = require('./IsArray'); +var ToObject = require('./ToObject'); +var ToString = require('./ToString'); + +var every = require('../helpers/every'); +var isStringOrUndefined = require('../helpers/isStringOrUndefined'); + +// http://www.ecma-international.org/ecma-262/12.0/#sec-getsubstitution + +// eslint-disable-next-line max-statements, max-params, max-lines-per-function +module.exports = function GetSubstitution(matched, str, position, captures, namedCaptures, replacement) { + if (typeof matched !== 'string') { + throw new $TypeError('Assertion failed: `matched` must be a String'); + } + var matchLength = matched.length; + + if (typeof str !== 'string') { + throw new $TypeError('Assertion failed: `str` must be a String'); + } + var stringLength = str.length; + + if (!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)); + } + + if (!IsArray(captures) || !every(captures, isStringOrUndefined)) { + throw new $TypeError('Assertion failed: `captures` must be a possibly-empty List of Strings or `undefined`, got ' + inspect(captures)); + } + + if (typeof replacement !== 'string') { + throw new $TypeError('Assertion failed: `replacement` must be a String'); + } + + var tailPos = position + matchLength; + var m = captures.length; + if (typeof namedCaptures !== 'undefined') { + namedCaptures = 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 = $charAt(replacement, i); + var isLast = (i + 1) >= replacement.length; + var nextIsLast = (i + 2) >= replacement.length; + if (current === '$' && !isLast) { + var next = $charAt(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 : $charAt(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 && typeof 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 && typeof captures[nnI] === 'undefined' ? '' : captures[nnI]; + i += 2; + } else if (next === '<') { + if (typeof namedCaptures === 'undefined') { + result += '$<'; + i += 2; + } else { + var endIndex = $indexOf(replacement, '>', i); + if (endIndex > -1) { + var groupName = $strSlice(replacement, i + '$<'.length, endIndex); + var capture = Get(namedCaptures, groupName); + + if (typeof capture !== 'undefined') { + result += ToString(capture); + } + i += ('<' + groupName + '>').length; + } + } + } else { + result += '$'; + } + } + } else { + // the final $, or else not a $ + result += $charAt(replacement, i); + } + } + return result; +}; diff --git a/node_modules/es-abstract/2021/GetV.js b/node_modules/es-abstract/2021/GetV.js new file mode 100644 index 0000000000000000000000000000000000000000..920dec3c4a4eac8aa63678c2afa5683e79e3337f --- /dev/null +++ b/node_modules/es-abstract/2021/GetV.js @@ -0,0 +1,23 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var inspect = require('object-inspect'); + +var isPropertyKey = require('../helpers/isPropertyKey'); +// var ToObject = require('./ToObject'); + +// https://262.ecma-international.org/6.0/#sec-getv + +module.exports = function GetV(V, P) { + // 7.3.2.1 + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: P is not a Property Key, got ' + inspect(P)); + } + + // 7.3.2.2-3 + // var O = ToObject(V); + + // 7.3.2.4 + return V[P]; +}; diff --git a/node_modules/es-abstract/2021/GetValueFromBuffer.js b/node_modules/es-abstract/2021/GetValueFromBuffer.js new file mode 100644 index 0000000000000000000000000000000000000000..0519a10e9aacb656f66b4a875b0ce98b8695c474 --- /dev/null +++ b/node_modules/es-abstract/2021/GetValueFromBuffer.js @@ -0,0 +1,96 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $SyntaxError = require('es-errors/syntax'); +var $TypeError = require('es-errors/type'); +var $Uint8Array = GetIntrinsic('%Uint8Array%', true); +var isInteger = require('math-intrinsics/isInteger'); + +var callBound = require('call-bound'); + +var $slice = callBound('Array.prototype.slice'); + +var IsDetachedBuffer = require('./IsDetachedBuffer'); +var RawBytesToNumeric = require('./RawBytesToNumeric'); + +var isArrayBuffer = require('is-array-buffer'); +var isSharedArrayBuffer = require('is-shared-array-buffer'); +var safeConcat = require('safe-array-concat'); + +var tableTAO = require('./tables/typed-array-objects'); + +var defaultEndianness = require('../helpers/defaultEndianness'); + +// https://262.ecma-international.org/11.0/#sec-getvaluefrombuffer + +module.exports = function GetValueFromBuffer(arrayBuffer, byteIndex, type, isTypedArray, order) { + var isSAB = isSharedArrayBuffer(arrayBuffer); + if (!isArrayBuffer(arrayBuffer) && !isSAB) { + throw new $TypeError('Assertion failed: `arrayBuffer` must be an ArrayBuffer or a SharedArrayBuffer'); + } + + if (!isInteger(byteIndex)) { + throw new $TypeError('Assertion failed: `byteIndex` must be an integer'); + } + + if (typeof type !== 'string' || typeof tableTAO.size['$' + type] !== 'number') { + throw new $TypeError('Assertion failed: `type` must be one of ' + tableTAO.choices); + } + + if (typeof isTypedArray !== 'boolean') { + throw new $TypeError('Assertion failed: `isTypedArray` must be a boolean'); + } + + if (order !== 'SeqCst' && order !== 'Unordered') { + throw new $TypeError('Assertion failed: `order` must be either `SeqCst` or `Unordered`'); + } + + if (arguments.length > 5 && typeof arguments[5] !== 'boolean') { + throw new $TypeError('Assertion failed: `isLittleEndian` must be a boolean, if present'); + } + + if (IsDetachedBuffer(arrayBuffer)) { + throw new $TypeError('Assertion failed: `arrayBuffer` is detached'); // step 1 + } + + // 2. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type. + + if (byteIndex < 0) { + throw new $TypeError('Assertion failed: `byteIndex` must be non-negative'); // step 3 + } + + // 4. Let block be arrayBuffer.[[ArrayBufferData]]. + + var elementSize = tableTAO.size['$' + type]; // step 5 + if (!elementSize) { + throw new $TypeError('Assertion failed: `type` must be one of ' + tableTAO.choices); + } + + var rawValue; + if (isSAB) { // step 6 + /* + a. Let execution be the [[CandidateExecution]] field of the surrounding agent's Agent Record. + b. Let eventList be the [[EventList]] field of the element in execution.[[EventLists]] whose [[AgentSignifier]] is AgentSignifier(). + c. If isTypedArray is true and type is "Int8", "Uint8", "Int16", "Uint16", "Int32", or "Uint32", let noTear be true; otherwise let noTear be false. + d. Let rawValue be a List of length elementSize of nondeterministically chosen byte values. + e. NOTE: In implementations, rawValue is the result of a non-atomic or atomic read instruction on the underlying hardware. The nondeterminism is a semantic prescription of the memory model to describe observable behaviour of hardware with weak consistency. + f. Let readEvent be ReadSharedMemory{ [[Order]]: order, [[NoTear]]: noTear, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize }. + g. Append readEvent to eventList. + h. Append Chosen Value Record { [[Event]]: readEvent, [[ChosenValue]]: rawValue } to execution.[[ChosenValues]]. + */ + throw new $SyntaxError('SharedArrayBuffer is not supported by this implementation'); + } else { + // 7. Let rawValue be a List of elementSize containing, in order, the elementSize sequence of bytes starting with block[byteIndex]. + rawValue = $slice(new $Uint8Array(arrayBuffer, byteIndex), 0, elementSize); // step 6 + } + + // 8. If isLittleEndian is not present, set isLittleEndian to either true or false. The choice is implementation dependent and should be the alternative that is most efficient for the implementation. An implementation must use the same value each time this step is executed and the same value must be used for the corresponding step in the SetValueInBuffer abstract operation. + var isLittleEndian = arguments.length > 5 ? arguments[5] : defaultEndianness === 'little'; // step 8 + + var bytes = isLittleEndian + ? $slice(safeConcat([0, 0, 0, 0, 0, 0, 0, 0], rawValue), -elementSize) + : $slice(safeConcat(rawValue, [0, 0, 0, 0, 0, 0, 0, 0]), 0, elementSize); + + return RawBytesToNumeric(type, bytes, isLittleEndian); +}; diff --git a/node_modules/es-abstract/2021/HasOwnProperty.js b/node_modules/es-abstract/2021/HasOwnProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..617f0b856e81f2518d2c03bf72b367eea50eb6ef --- /dev/null +++ b/node_modules/es-abstract/2021/HasOwnProperty.js @@ -0,0 +1,20 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var hasOwn = require('hasown'); +var isObject = require('es-object-atoms/isObject'); + +var isPropertyKey = require('../helpers/isPropertyKey'); + +// https://262.ecma-international.org/6.0/#sec-hasownproperty + +module.exports = function HasOwnProperty(O, P) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: `O` must be an Object'); + } + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: `P` must be a Property Key'); + } + return hasOwn(O, P); +}; diff --git a/node_modules/es-abstract/2021/HasProperty.js b/node_modules/es-abstract/2021/HasProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..eb66ca9853ec09c092d87f10333fcdb19a882c83 --- /dev/null +++ b/node_modules/es-abstract/2021/HasProperty.js @@ -0,0 +1,18 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var isPropertyKey = require('../helpers/isPropertyKey'); + +// https://262.ecma-international.org/6.0/#sec-hasproperty + +module.exports = function HasProperty(O, P) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: `O` must be an Object'); + } + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: `P` must be a Property Key'); + } + return P in O; +}; diff --git a/node_modules/es-abstract/2021/HourFromTime.js b/node_modules/es-abstract/2021/HourFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..f963bfb68540ba21f46be00b623cb89db98d63f5 --- /dev/null +++ b/node_modules/es-abstract/2021/HourFromTime.js @@ -0,0 +1,14 @@ +'use strict'; + +var floor = require('./floor'); +var modulo = require('./modulo'); + +var timeConstants = require('../helpers/timeConstants'); +var msPerHour = timeConstants.msPerHour; +var HoursPerDay = timeConstants.HoursPerDay; + +// https://262.ecma-international.org/5.1/#sec-15.9.1.10 + +module.exports = function HourFromTime(t) { + return modulo(floor(t / msPerHour), HoursPerDay); +}; diff --git a/node_modules/es-abstract/2021/InLeapYear.js b/node_modules/es-abstract/2021/InLeapYear.js new file mode 100644 index 0000000000000000000000000000000000000000..4a283a4b6097f4b2c4e872b0cc775024ff517b77 --- /dev/null +++ b/node_modules/es-abstract/2021/InLeapYear.js @@ -0,0 +1,19 @@ +'use strict'; + +var $EvalError = require('es-errors/eval'); + +var DaysInYear = require('./DaysInYear'); +var YearFromTime = require('./YearFromTime'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.3 + +module.exports = function InLeapYear(t) { + var days = DaysInYear(YearFromTime(t)); + if (days === 365) { + return 0; + } + if (days === 366) { + return 1; + } + throw new $EvalError('Assertion failed: there are not 365 or 366 days in a year, got: ' + days); +}; diff --git a/node_modules/es-abstract/2021/InstanceofOperator.js b/node_modules/es-abstract/2021/InstanceofOperator.js new file mode 100644 index 0000000000000000000000000000000000000000..5dd7d04a4c16b423b1613070585b864e22b2dc9e --- /dev/null +++ b/node_modules/es-abstract/2021/InstanceofOperator.js @@ -0,0 +1,30 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var $hasInstance = GetIntrinsic('%Symbol.hasInstance%', true); + +var Call = require('./Call'); +var GetMethod = require('./GetMethod'); +var IsCallable = require('./IsCallable'); +var OrdinaryHasInstance = require('./OrdinaryHasInstance'); +var ToBoolean = require('./ToBoolean'); + +// https://262.ecma-international.org/6.0/#sec-instanceofoperator + +module.exports = function InstanceofOperator(O, C) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + var instOfHandler = $hasInstance ? GetMethod(C, $hasInstance) : void 0; + if (typeof instOfHandler !== 'undefined') { + return ToBoolean(Call(instOfHandler, C, [O])); + } + if (!IsCallable(C)) { + throw new $TypeError('`C` is not Callable'); + } + return OrdinaryHasInstance(C, O); +}; diff --git a/node_modules/es-abstract/2021/IntegerIndexedElementGet.js b/node_modules/es-abstract/2021/IntegerIndexedElementGet.js new file mode 100644 index 0000000000000000000000000000000000000000..4be6efd67b5ead6ac9852892cf9c26cb6607dbb7 --- /dev/null +++ b/node_modules/es-abstract/2021/IntegerIndexedElementGet.js @@ -0,0 +1,39 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var GetValueFromBuffer = require('./GetValueFromBuffer'); +var IsValidIntegerIndex = require('./IsValidIntegerIndex'); + +var typedArrayBuffer = require('typed-array-buffer'); +var typedArrayByteOffset = require('typed-array-byte-offset'); +var whichTypedArray = require('which-typed-array'); + +var tableTAO = require('./tables/typed-array-objects'); + +// https://262.ecma-international.org/12.0/#sec-integerindexedelementget + +module.exports = function IntegerIndexedElementGet(O, index) { + var arrayTypeName = whichTypedArray(O); // step 4 + if (!arrayTypeName) { + throw new $TypeError('Assertion failed: `O` must be a TypedArray'); // step 1 + } + + if (typeof index !== 'number') { + throw new $TypeError('Assertion failed: `index` must be a Number'); + } + + if (!IsValidIntegerIndex(O, index)) { + return void undefined; // step 2 + } + + var offset = typedArrayByteOffset(O); // step 3 + + var elementType = tableTAO.name['$' + arrayTypeName]; // step 7 + + var elementSize = tableTAO.size['$' + elementType]; // step 5 + + var indexedPosition = (index * elementSize) + offset; // step 6 + + return GetValueFromBuffer(typedArrayBuffer(O), indexedPosition, elementType, true, 'Unordered'); // step 11 +}; diff --git a/node_modules/es-abstract/2021/IntegerIndexedElementSet.js b/node_modules/es-abstract/2021/IntegerIndexedElementSet.js new file mode 100644 index 0000000000000000000000000000000000000000..cd609ce215b401f6e44b3266fadce9e2a549c303 --- /dev/null +++ b/node_modules/es-abstract/2021/IntegerIndexedElementSet.js @@ -0,0 +1,44 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var IsValidIntegerIndex = require('./IsValidIntegerIndex'); +var SetValueInBuffer = require('./SetValueInBuffer'); +var ToBigInt = require('./ToBigInt'); +var ToNumber = require('./ToNumber'); + +var typedArrayBuffer = require('typed-array-buffer'); +var typedArrayByteOffset = require('typed-array-byte-offset'); +var whichTypedArray = require('which-typed-array'); + +var tableTAO = require('./tables/typed-array-objects'); + +// https://262.ecma-international.org/12.0/#sec-integerindexedelementset + +module.exports = function IntegerIndexedElementSet(O, index, value) { + if (typeof index !== 'number') { + throw new $TypeError('Assertion failed: `index` must be a Number'); + } + + var arrayTypeName = whichTypedArray(O); // step 4.b + if (!arrayTypeName) { + throw new $TypeError('Assertion failed: `O` must be a TypedArray'); // step 1 + } + + var contentType = arrayTypeName === 'BigInt64Array' || arrayTypeName === 'BigUint64Array' ? 'BigInt' : 'Number'; + var numValue = contentType === 'BigInt' ? ToBigInt(value) : ToNumber(value); // steps 2 - 3 + + if (IsValidIntegerIndex(O, index)) { // step 4 + var offset = typedArrayByteOffset(O); // step 4.a + + var elementType = tableTAO.name['$' + arrayTypeName]; // step 4.e + + var elementSize = tableTAO.size['$' + elementType]; // step 4.c + + var indexedPosition = (index * elementSize) + offset; // step 4.d + + SetValueInBuffer(typedArrayBuffer(O), indexedPosition, elementType, numValue, true, 'Unordered'); // step 4.e + } + + // 5. Return NormalCompletion(undefined) +}; diff --git a/node_modules/es-abstract/2021/InternalizeJSONProperty.js b/node_modules/es-abstract/2021/InternalizeJSONProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..cb474bfdeee90929c20e26a2fd28ae9928428fab --- /dev/null +++ b/node_modules/es-abstract/2021/InternalizeJSONProperty.js @@ -0,0 +1,66 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var Call = require('./Call'); +var CreateDataProperty = require('./CreateDataProperty'); +var EnumerableOwnPropertyNames = require('./EnumerableOwnPropertyNames'); +var Get = require('./Get'); +var IsArray = require('./IsArray'); +var LengthOfArrayLike = require('./LengthOfArrayLike'); +var ToString = require('./ToString'); + +var forEach = require('../helpers/forEach'); + +// https://262.ecma-international.org/11.0/#sec-internalizejsonproperty + +module.exports = function InternalizeJSONProperty(holder, name, reviver) { + if (!isObject(holder)) { + throw new $TypeError('Assertion failed: `holder` is not an Object'); + } + if (typeof name !== 'string') { + throw new $TypeError('Assertion failed: `name` is not a String'); + } + if (typeof reviver !== 'function') { + throw new $TypeError('Assertion failed: `reviver` is not a Function'); + } + + var val = Get(holder, name); // step 1 + + if (isObject(val)) { // step 2 + var isArray = IsArray(val); // step 2.a + if (isArray) { // step 2.b + var I = 0; // step 2.b.i + + var len = LengthOfArrayLike(val, 'length'); // step 2.b.ii + + while (I < len) { // step 2.b.iii + var newElement = InternalizeJSONProperty(val, ToString(I), reviver); // step 2.b.iv.1 + + if (typeof newElement === 'undefined') { // step 2.b.iii.2 + delete val[ToString(I)]; // step 2.b.iii.2.a + } else { // step 2.b.iii.3 + CreateDataProperty(val, ToString(I), newElement); // step 2.b.iii.3.a + } + + I += 1; // step 2.b.iii.4 + } + } else { // step 2.c + var keys = EnumerableOwnPropertyNames(val, 'key'); // step 2.c.i + + forEach(keys, function (P) { // step 2.c.ii + // eslint-disable-next-line no-shadow + var newElement = InternalizeJSONProperty(val, P, reviver); // step 2.c.ii.1 + + if (typeof newElement === 'undefined') { // step 2.c.ii.2 + delete val[P]; // step 2.c.ii.2.a + } else { // step 2.c.ii.3 + CreateDataProperty(val, P, newElement); // step 2.c.ii.3.a + } + }); + } + } + + return Call(reviver, holder, [name, val]); // step 3 +}; diff --git a/node_modules/es-abstract/2021/Invoke.js b/node_modules/es-abstract/2021/Invoke.js new file mode 100644 index 0000000000000000000000000000000000000000..57bca8ebc3dcb6172949cb3bef6f134dacabbf4b --- /dev/null +++ b/node_modules/es-abstract/2021/Invoke.js @@ -0,0 +1,22 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var Call = require('./Call'); +var IsArray = require('./IsArray'); +var GetV = require('./GetV'); +var isPropertyKey = require('../helpers/isPropertyKey'); + +// https://262.ecma-international.org/6.0/#sec-invoke + +module.exports = function Invoke(O, P) { + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: P must be a Property Key'); + } + var argumentsList = arguments.length > 2 ? arguments[2] : []; + if (!IsArray(argumentsList)) { + throw new $TypeError('Assertion failed: optional `argumentsList`, if provided, must be a List'); + } + var func = GetV(O, P); + return Call(func, O, argumentsList); +}; diff --git a/node_modules/es-abstract/2021/IsAccessorDescriptor.js b/node_modules/es-abstract/2021/IsAccessorDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..f7bf73afb1c1617b04596a6e2af6d1617857bf1e --- /dev/null +++ b/node_modules/es-abstract/2021/IsAccessorDescriptor.js @@ -0,0 +1,25 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var hasOwn = require('hasown'); + +var isPropertyDescriptor = require('../helpers/records/property-descriptor'); + +// https://262.ecma-international.org/5.1/#sec-8.10.1 + +module.exports = function IsAccessorDescriptor(Desc) { + if (typeof Desc === 'undefined') { + return false; + } + + if (!isPropertyDescriptor(Desc)) { + throw new $TypeError('Assertion failed: `Desc` must be a Property Descriptor'); + } + + if (!hasOwn(Desc, '[[Get]]') && !hasOwn(Desc, '[[Set]]')) { + return false; + } + + return true; +}; diff --git a/node_modules/es-abstract/2021/IsArray.js b/node_modules/es-abstract/2021/IsArray.js new file mode 100644 index 0000000000000000000000000000000000000000..c2c48c1f233c058c691d45d7587f1b58d3de5eb2 --- /dev/null +++ b/node_modules/es-abstract/2021/IsArray.js @@ -0,0 +1,4 @@ +'use strict'; + +// https://262.ecma-international.org/6.0/#sec-isarray +module.exports = require('../helpers/IsArray'); diff --git a/node_modules/es-abstract/2021/IsBigIntElementType.js b/node_modules/es-abstract/2021/IsBigIntElementType.js new file mode 100644 index 0000000000000000000000000000000000000000..e3f58a949b3cabcde8a8078afb501cd872820398 --- /dev/null +++ b/node_modules/es-abstract/2021/IsBigIntElementType.js @@ -0,0 +1,7 @@ +'use strict'; + +// https://262.ecma-international.org/11.0/#sec-isbigintelementtype + +module.exports = function IsBigIntElementType(type) { + return type === 'BigUint64' || type === 'BigInt64'; +}; diff --git a/node_modules/es-abstract/2021/IsCallable.js b/node_modules/es-abstract/2021/IsCallable.js new file mode 100644 index 0000000000000000000000000000000000000000..3a69b19267dff33491a84421b667a0d82cba21f9 --- /dev/null +++ b/node_modules/es-abstract/2021/IsCallable.js @@ -0,0 +1,5 @@ +'use strict'; + +// http://262.ecma-international.org/5.1/#sec-9.11 + +module.exports = require('is-callable'); diff --git a/node_modules/es-abstract/2021/IsCompatiblePropertyDescriptor.js b/node_modules/es-abstract/2021/IsCompatiblePropertyDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..8bdaf3eb45d24407a2a416cc5aadab4f4eb1c7da --- /dev/null +++ b/node_modules/es-abstract/2021/IsCompatiblePropertyDescriptor.js @@ -0,0 +1,9 @@ +'use strict'; + +var ValidateAndApplyPropertyDescriptor = require('./ValidateAndApplyPropertyDescriptor'); + +// https://262.ecma-international.org/6.0/#sec-iscompatiblepropertydescriptor + +module.exports = function IsCompatiblePropertyDescriptor(Extensible, Desc, Current) { + return ValidateAndApplyPropertyDescriptor(undefined, undefined, Extensible, Desc, Current); +}; diff --git a/node_modules/es-abstract/2021/IsConcatSpreadable.js b/node_modules/es-abstract/2021/IsConcatSpreadable.js new file mode 100644 index 0000000000000000000000000000000000000000..ace2695309292c91b185505f63da3cc942534bd2 --- /dev/null +++ b/node_modules/es-abstract/2021/IsConcatSpreadable.js @@ -0,0 +1,26 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $isConcatSpreadable = GetIntrinsic('%Symbol.isConcatSpreadable%', true); + +var Get = require('./Get'); +var IsArray = require('./IsArray'); +var ToBoolean = require('./ToBoolean'); + +var isObject = require('es-object-atoms/isObject'); + +// https://262.ecma-international.org/6.0/#sec-isconcatspreadable + +module.exports = function IsConcatSpreadable(O) { + if (!isObject(O)) { + return false; + } + if ($isConcatSpreadable) { + var spreadable = Get(O, $isConcatSpreadable); + if (typeof spreadable !== 'undefined') { + return ToBoolean(spreadable); + } + } + return IsArray(O); +}; diff --git a/node_modules/es-abstract/2021/IsConstructor.js b/node_modules/es-abstract/2021/IsConstructor.js new file mode 100644 index 0000000000000000000000000000000000000000..62ac47f6a3d262927a9b147ee0057dfba9664b24 --- /dev/null +++ b/node_modules/es-abstract/2021/IsConstructor.js @@ -0,0 +1,40 @@ +'use strict'; + +var GetIntrinsic = require('../GetIntrinsic.js'); + +var $construct = GetIntrinsic('%Reflect.construct%', true); + +var DefinePropertyOrThrow = require('./DefinePropertyOrThrow'); +try { + DefinePropertyOrThrow({}, '', { '[[Get]]': function () {} }); +} catch (e) { + // Accessor properties aren't supported + DefinePropertyOrThrow = null; +} + +// https://262.ecma-international.org/6.0/#sec-isconstructor + +if (DefinePropertyOrThrow && $construct) { + var isConstructorMarker = {}; + var badArrayLike = {}; + DefinePropertyOrThrow(badArrayLike, 'length', { + '[[Get]]': function () { + throw isConstructorMarker; + }, + '[[Enumerable]]': true + }); + + module.exports = function IsConstructor(argument) { + try { + // `Reflect.construct` invokes `IsConstructor(target)` before `Get(args, 'length')`: + $construct(argument, badArrayLike); + } catch (err) { + return err === isConstructorMarker; + } + }; +} else { + module.exports = function IsConstructor(argument) { + // unfortunately there's no way to truly check this without try/catch `new argument` in old environments + return typeof argument === 'function' && !!argument.prototype; + }; +} diff --git a/node_modules/es-abstract/2021/IsDataDescriptor.js b/node_modules/es-abstract/2021/IsDataDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..d56bd36d4294369f6486f6dfc5d60dada2cc410a --- /dev/null +++ b/node_modules/es-abstract/2021/IsDataDescriptor.js @@ -0,0 +1,25 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var hasOwn = require('hasown'); + +var isPropertyDescriptor = require('../helpers/records/property-descriptor'); + +// https://262.ecma-international.org/5.1/#sec-8.10.2 + +module.exports = function IsDataDescriptor(Desc) { + if (typeof Desc === 'undefined') { + return false; + } + + if (!isPropertyDescriptor(Desc)) { + throw new $TypeError('Assertion failed: `Desc` must be a Property Descriptor'); + } + + if (!hasOwn(Desc, '[[Value]]') && !hasOwn(Desc, '[[Writable]]')) { + return false; + } + + return true; +}; diff --git a/node_modules/es-abstract/2021/IsDetachedBuffer.js b/node_modules/es-abstract/2021/IsDetachedBuffer.js new file mode 100644 index 0000000000000000000000000000000000000000..71c4f6be8d20b02a92a6721c7ae2833adf21150e --- /dev/null +++ b/node_modules/es-abstract/2021/IsDetachedBuffer.js @@ -0,0 +1,28 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var $byteLength = require('array-buffer-byte-length'); +var availableTypedArrays = require('available-typed-arrays')(); +var callBound = require('call-bound'); +var isArrayBuffer = require('is-array-buffer'); +var isSharedArrayBuffer = require('is-shared-array-buffer'); + +var $sabByteLength = callBound('SharedArrayBuffer.prototype.byteLength', true); + +// https://262.ecma-international.org/8.0/#sec-isdetachedbuffer + +module.exports = function IsDetachedBuffer(arrayBuffer) { + var isSAB = isSharedArrayBuffer(arrayBuffer); + if (!isArrayBuffer(arrayBuffer) && !isSAB) { + throw new $TypeError('Assertion failed: `arrayBuffer` must be an Object with an [[ArrayBufferData]] internal slot'); + } + if ((isSAB ? $sabByteLength : $byteLength)(arrayBuffer) === 0) { + try { + new global[availableTypedArrays[0]](arrayBuffer); // eslint-disable-line no-new + } catch (error) { + return !!error && error.name === 'TypeError'; + } + } + return false; +}; diff --git a/node_modules/es-abstract/2021/IsExtensible.js b/node_modules/es-abstract/2021/IsExtensible.js new file mode 100644 index 0000000000000000000000000000000000000000..aa19b914c2d3dc31c1215e2b203dc3ffbb78746c --- /dev/null +++ b/node_modules/es-abstract/2021/IsExtensible.js @@ -0,0 +1,18 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $preventExtensions = GetIntrinsic('%Object.preventExtensions%', true); +var $isExtensible = GetIntrinsic('%Object.isExtensible%', true); + +var isPrimitive = require('../helpers/isPrimitive'); + +// https://262.ecma-international.org/6.0/#sec-isextensible-o + +module.exports = $preventExtensions + ? function IsExtensible(obj) { + return !isPrimitive(obj) && $isExtensible(obj); + } + : function IsExtensible(obj) { + return !isPrimitive(obj); + }; diff --git a/node_modules/es-abstract/2021/IsGenericDescriptor.js b/node_modules/es-abstract/2021/IsGenericDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..9f6ef045ee44e9eaea4506a234f0e41e0bd1bac9 --- /dev/null +++ b/node_modules/es-abstract/2021/IsGenericDescriptor.js @@ -0,0 +1,26 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var IsAccessorDescriptor = require('./IsAccessorDescriptor'); +var IsDataDescriptor = require('./IsDataDescriptor'); + +var isPropertyDescriptor = require('../helpers/records/property-descriptor'); + +// https://262.ecma-international.org/6.0/#sec-isgenericdescriptor + +module.exports = function IsGenericDescriptor(Desc) { + if (typeof Desc === 'undefined') { + return false; + } + + if (!isPropertyDescriptor(Desc)) { + throw new $TypeError('Assertion failed: `Desc` must be a Property Descriptor'); + } + + if (!IsAccessorDescriptor(Desc) && !IsDataDescriptor(Desc)) { + return true; + } + + return false; +}; diff --git a/node_modules/es-abstract/2021/IsIntegralNumber.js b/node_modules/es-abstract/2021/IsIntegralNumber.js new file mode 100644 index 0000000000000000000000000000000000000000..df4240f9f74b4881cf5c8e13b8df9820f8ebabe1 --- /dev/null +++ b/node_modules/es-abstract/2021/IsIntegralNumber.js @@ -0,0 +1,9 @@ +'use strict'; + +var isInteger = require('math-intrinsics/isInteger'); + +// https://262.ecma-international.org/12.0/#sec-isinteger + +module.exports = function IsIntegralNumber(argument) { + return isInteger(argument); +}; diff --git a/node_modules/es-abstract/2021/IsNoTearConfiguration.js b/node_modules/es-abstract/2021/IsNoTearConfiguration.js new file mode 100644 index 0000000000000000000000000000000000000000..f0d2808737ac6c853571ca68c94f57f7ee4cb59b --- /dev/null +++ b/node_modules/es-abstract/2021/IsNoTearConfiguration.js @@ -0,0 +1,16 @@ +'use strict'; + +var IsUnclampedIntegerElementType = require('./IsUnclampedIntegerElementType'); +var IsBigIntElementType = require('./IsBigIntElementType'); + +// https://262.ecma-international.org/11.0/#sec-isnotearconfiguration + +module.exports = function IsNoTearConfiguration(type, order) { + if (IsUnclampedIntegerElementType(type)) { + return true; + } + if (IsBigIntElementType(type) && order !== 'Init' && order !== 'Unordered') { + return true; + } + return false; +}; diff --git a/node_modules/es-abstract/2021/IsPromise.js b/node_modules/es-abstract/2021/IsPromise.js new file mode 100644 index 0000000000000000000000000000000000000000..f3d67b1c7045d7657ec74a6d084dc088aadb5ff4 --- /dev/null +++ b/node_modules/es-abstract/2021/IsPromise.js @@ -0,0 +1,24 @@ +'use strict'; + +var callBound = require('call-bound'); + +var $PromiseThen = callBound('Promise.prototype.then', true); + +var isObject = require('es-object-atoms/isObject'); + +// https://262.ecma-international.org/6.0/#sec-ispromise + +module.exports = function IsPromise(x) { + if (!isObject(x)) { + return false; + } + if (!$PromiseThen) { // Promises are not supported + return false; + } + try { + $PromiseThen(x); // throws if not a promise + } catch (e) { + return false; + } + return true; +}; diff --git a/node_modules/es-abstract/2021/IsPropertyKey.js b/node_modules/es-abstract/2021/IsPropertyKey.js new file mode 100644 index 0000000000000000000000000000000000000000..4b1c9c71461ca474f34b517c0bc04e5d700280f2 --- /dev/null +++ b/node_modules/es-abstract/2021/IsPropertyKey.js @@ -0,0 +1,9 @@ +'use strict'; + +var isPropertyKey = require('../helpers/isPropertyKey'); + +// https://262.ecma-international.org/6.0/#sec-ispropertykey + +module.exports = function IsPropertyKey(argument) { + return isPropertyKey(argument); +}; diff --git a/node_modules/es-abstract/2021/IsRegExp.js b/node_modules/es-abstract/2021/IsRegExp.js new file mode 100644 index 0000000000000000000000000000000000000000..8855492d58ded3c061b84be35e962fe32c8de53e --- /dev/null +++ b/node_modules/es-abstract/2021/IsRegExp.js @@ -0,0 +1,25 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $match = GetIntrinsic('%Symbol.match%', true); + +var hasRegExpMatcher = require('is-regex'); +var isObject = require('es-object-atoms/isObject'); + +var ToBoolean = require('./ToBoolean'); + +// https://262.ecma-international.org/6.0/#sec-isregexp + +module.exports = function IsRegExp(argument) { + if (!isObject(argument)) { + return false; + } + if ($match) { + var isRegExp = argument[$match]; + if (typeof isRegExp !== 'undefined') { + return ToBoolean(isRegExp); + } + } + return hasRegExpMatcher(argument); +}; diff --git a/node_modules/es-abstract/2021/IsSharedArrayBuffer.js b/node_modules/es-abstract/2021/IsSharedArrayBuffer.js new file mode 100644 index 0000000000000000000000000000000000000000..41d61b116db4b3aabf7dde87e6b46cc5aa378d99 --- /dev/null +++ b/node_modules/es-abstract/2021/IsSharedArrayBuffer.js @@ -0,0 +1,16 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var isSharedArrayBuffer = require('is-shared-array-buffer'); + +// https://262.ecma-international.org/8.0/#sec-issharedarraybuffer + +module.exports = function IsSharedArrayBuffer(obj) { + if (!isObject(obj)) { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + return isSharedArrayBuffer(obj); +}; diff --git a/node_modules/es-abstract/2021/IsStringPrefix.js b/node_modules/es-abstract/2021/IsStringPrefix.js new file mode 100644 index 0000000000000000000000000000000000000000..507f9fc1f397d6382a878d4c1d6d18da2feb21a5 --- /dev/null +++ b/node_modules/es-abstract/2021/IsStringPrefix.js @@ -0,0 +1,43 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var isPrefixOf = require('../helpers/isPrefixOf'); + +// var callBound = require('call-bound'); + +// var $charAt = callBound('String.prototype.charAt'); + +// https://262.ecma-international.org/9.0/#sec-isstringprefix + +module.exports = function IsStringPrefix(p, q) { + if (typeof p !== 'string') { + throw new $TypeError('Assertion failed: "p" must be a String'); + } + + if (typeof q !== 'string') { + throw new $TypeError('Assertion failed: "q" must be a String'); + } + + return isPrefixOf(p, q); + /* + if (p === q || p === '') { + return true; + } + + var pLength = p.length; + var qLength = q.length; + if (pLength >= qLength) { + return false; + } + + // assert: pLength < qLength + + for (var i = 0; i < pLength; i += 1) { + if ($charAt(p, i) !== $charAt(q, i)) { + return false; + } + } + return true; + */ +}; diff --git a/node_modules/es-abstract/2021/IsUnclampedIntegerElementType.js b/node_modules/es-abstract/2021/IsUnclampedIntegerElementType.js new file mode 100644 index 0000000000000000000000000000000000000000..4e3a38425d65f2320b3e72bc16d3bf6b38ae3f38 --- /dev/null +++ b/node_modules/es-abstract/2021/IsUnclampedIntegerElementType.js @@ -0,0 +1,12 @@ +'use strict'; + +// https://262.ecma-international.org/11.0/#sec-isunclampedintegerelementtype + +module.exports = function IsUnclampedIntegerElementType(type) { + return type === 'Int8' + || type === 'Uint8' + || type === 'Int16' + || type === 'Uint16' + || type === 'Int32' + || type === 'Uint32'; +}; diff --git a/node_modules/es-abstract/2021/IsUnsignedElementType.js b/node_modules/es-abstract/2021/IsUnsignedElementType.js new file mode 100644 index 0000000000000000000000000000000000000000..b1ff194d73916d487ce951d1c7553b7aa5ab34cf --- /dev/null +++ b/node_modules/es-abstract/2021/IsUnsignedElementType.js @@ -0,0 +1,11 @@ +'use strict'; + +// https://262.ecma-international.org/11.0/#sec-isunsignedelementtype + +module.exports = function IsUnsignedElementType(type) { + return type === 'Uint8' + || type === 'Uint8C' + || type === 'Uint16' + || type === 'Uint32' + || type === 'BigUint64'; +}; diff --git a/node_modules/es-abstract/2021/IsValidIntegerIndex.js b/node_modules/es-abstract/2021/IsValidIntegerIndex.js new file mode 100644 index 0000000000000000000000000000000000000000..d5deae7a72ff0e4bad585acc679453c2f22538e9 --- /dev/null +++ b/node_modules/es-abstract/2021/IsValidIntegerIndex.js @@ -0,0 +1,30 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isNegativeZero = require('math-intrinsics/isNegativeZero'); + +var IsDetachedBuffer = require('./IsDetachedBuffer'); + +var isInteger = require('math-intrinsics/isInteger'); +var typedArrayBuffer = require('typed-array-buffer'); + +// https://262.ecma-international.org/12.0/#sec-isvalidintegerindex + +module.exports = function IsValidIntegerIndex(O, index) { + // Assert: O is an Integer-Indexed exotic object. + var buffer = typedArrayBuffer(O); // step 1 + + if (typeof index !== 'number') { + throw new $TypeError('Assertion failed: Type(index) is not Number'); + } + + if (IsDetachedBuffer(buffer)) { return false; } // step 2 + + if (!isInteger(index)) { return false; } // step 3 + + if (isNegativeZero(index)) { return false; } // step 4 + + if (index < 0 || index >= O.length) { return false; } // step 5 + + return true; // step 6 +}; diff --git a/node_modules/es-abstract/2021/IsWordChar.js b/node_modules/es-abstract/2021/IsWordChar.js new file mode 100644 index 0000000000000000000000000000000000000000..c976c7166bd12f2e85b3d2264a1332440d2709ce --- /dev/null +++ b/node_modules/es-abstract/2021/IsWordChar.js @@ -0,0 +1,46 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var callBound = require('call-bound'); + +var $indexOf = callBound('String.prototype.indexOf'); + +var IsArray = require('./IsArray'); +var WordCharacters = require('./WordCharacters'); + +var every = require('../helpers/every'); + +var isInteger = require('math-intrinsics/isInteger'); + +var isChar = function isChar(c) { + return typeof c === 'string'; +}; + +// https://262.ecma-international.org/12.0/#sec-runtime-semantics-iswordchar-abstract-operation + +// note: prior to ES2023, this AO erroneously omitted the latter of its arguments. +module.exports = function IsWordChar(e, InputLength, Input, IgnoreCase, Unicode) { + if (!isInteger(e)) { + throw new $TypeError('Assertion failed: `e` must be an integer'); + } + if (!isInteger(InputLength)) { + throw new $TypeError('Assertion failed: `InputLength` must be an integer'); + } + if (!IsArray(Input) || !every(Input, isChar)) { + throw new $TypeError('Assertion failed: `Input` must be a List of characters'); + } + if (typeof IgnoreCase !== 'boolean' || typeof Unicode !== 'boolean') { + throw new $TypeError('Assertion failed: `IgnoreCase` and `Unicode` must be booleans'); + } + + if (e === -1 || e === InputLength) { + return false; // step 1 + } + + var c = Input[e]; // step 2 + + var wordChars = WordCharacters(IgnoreCase, Unicode); + + return $indexOf(wordChars, c) > -1; // steps 3-4 +}; diff --git a/node_modules/es-abstract/2021/IterableToList.js b/node_modules/es-abstract/2021/IterableToList.js new file mode 100644 index 0000000000000000000000000000000000000000..a4c3394156609058a701d0384daa973cfc8bc04c --- /dev/null +++ b/node_modules/es-abstract/2021/IterableToList.js @@ -0,0 +1,26 @@ +'use strict'; + +var GetIterator = require('./GetIterator'); +var IteratorStep = require('./IteratorStep'); +var IteratorValue = require('./IteratorValue'); + +// https://262.ecma-international.org/12.0/#sec-iterabletolist + +module.exports = function IterableToList(items) { + var iterator; + if (arguments.length > 1) { + iterator = GetIterator(items, 'sync', arguments[1]); + } else { + iterator = GetIterator(items, 'sync'); + } + var values = []; + var next = true; + while (next) { + next = IteratorStep(iterator); + if (next) { + var nextValue = IteratorValue(next); + values[values.length] = nextValue; + } + } + return values; +}; diff --git a/node_modules/es-abstract/2021/IteratorClose.js b/node_modules/es-abstract/2021/IteratorClose.js new file mode 100644 index 0000000000000000000000000000000000000000..c28373b5df19807503f12da511643f30b72ad786 --- /dev/null +++ b/node_modules/es-abstract/2021/IteratorClose.js @@ -0,0 +1,51 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var Call = require('./Call'); +var CompletionRecord = require('./CompletionRecord'); +var GetMethod = require('./GetMethod'); +var IsCallable = require('./IsCallable'); + +// https://262.ecma-international.org/6.0/#sec-iteratorclose + +module.exports = function IteratorClose(iterator, completion) { + if (!isObject(iterator)) { + throw new $TypeError('Assertion failed: Type(iterator) is not Object'); + } + if (!IsCallable(completion) && !(completion instanceof CompletionRecord)) { + throw new $TypeError('Assertion failed: completion is not a thunk representing a Completion Record, nor a Completion Record instance'); + } + var completionThunk = completion instanceof CompletionRecord ? function () { return completion['?'](); } : completion; + + var iteratorReturn = GetMethod(iterator, 'return'); + + if (typeof iteratorReturn === 'undefined') { + return completionThunk(); + } + + var completionRecord; + try { + var innerResult = Call(iteratorReturn, iterator, []); + } catch (e) { + // if we hit here, then "e" is the innerResult completion that needs re-throwing + + // if the completion is of type "throw", this will throw. + completionThunk(); + // eslint-disable-next-line no-useless-assignment + completionThunk = null; // ensure it's not called twice. + + // if not, then return the innerResult completion + throw e; + } + completionRecord = completionThunk(); // if innerResult worked, then throw if the completion does + // eslint-disable-next-line no-useless-assignment + completionThunk = null; // ensure it's not called twice. + + if (!isObject(innerResult)) { + throw new $TypeError('iterator .return must return an object'); + } + + return completionRecord; +}; diff --git a/node_modules/es-abstract/2021/IteratorComplete.js b/node_modules/es-abstract/2021/IteratorComplete.js new file mode 100644 index 0000000000000000000000000000000000000000..c8a0d67c244bbec3d032bb8a4cc5597b7419d97b --- /dev/null +++ b/node_modules/es-abstract/2021/IteratorComplete.js @@ -0,0 +1,16 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var Get = require('./Get'); +var ToBoolean = require('./ToBoolean'); + +// https://262.ecma-international.org/6.0/#sec-iteratorcomplete + +module.exports = function IteratorComplete(iterResult) { + if (!isObject(iterResult)) { + throw new $TypeError('Assertion failed: Type(iterResult) is not Object'); + } + return ToBoolean(Get(iterResult, 'done')); +}; diff --git a/node_modules/es-abstract/2021/IteratorNext.js b/node_modules/es-abstract/2021/IteratorNext.js new file mode 100644 index 0000000000000000000000000000000000000000..b6bd71c68fca61d152bbf420aa5fdfb2feeab854 --- /dev/null +++ b/node_modules/es-abstract/2021/IteratorNext.js @@ -0,0 +1,16 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var Invoke = require('./Invoke'); + +// https://262.ecma-international.org/6.0/#sec-iteratornext + +module.exports = function IteratorNext(iterator, value) { + var result = Invoke(iterator, 'next', arguments.length < 2 ? [] : [value]); + if (!isObject(result)) { + throw new $TypeError('iterator next must return an object'); + } + return result; +}; diff --git a/node_modules/es-abstract/2021/IteratorStep.js b/node_modules/es-abstract/2021/IteratorStep.js new file mode 100644 index 0000000000000000000000000000000000000000..85bcd95c0410f7efd79ae16b91b0a513d404a64a --- /dev/null +++ b/node_modules/es-abstract/2021/IteratorStep.js @@ -0,0 +1,13 @@ +'use strict'; + +var IteratorComplete = require('./IteratorComplete'); +var IteratorNext = require('./IteratorNext'); + +// https://262.ecma-international.org/6.0/#sec-iteratorstep + +module.exports = function IteratorStep(iterator) { + var result = IteratorNext(iterator); + var done = IteratorComplete(result); + return done === true ? false : result; +}; + diff --git a/node_modules/es-abstract/2021/IteratorValue.js b/node_modules/es-abstract/2021/IteratorValue.js new file mode 100644 index 0000000000000000000000000000000000000000..016ddfbd4f01381dd13487740d6806003449d4b1 --- /dev/null +++ b/node_modules/es-abstract/2021/IteratorValue.js @@ -0,0 +1,16 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var Get = require('./Get'); + +// https://262.ecma-international.org/6.0/#sec-iteratorvalue + +module.exports = function IteratorValue(iterResult) { + if (!isObject(iterResult)) { + throw new $TypeError('Assertion failed: Type(iterResult) is not Object'); + } + return Get(iterResult, 'value'); +}; + diff --git a/node_modules/es-abstract/2021/LengthOfArrayLike.js b/node_modules/es-abstract/2021/LengthOfArrayLike.js new file mode 100644 index 0000000000000000000000000000000000000000..437bcd86c93b2ea23f727bb18c83ae4b58fe7e2b --- /dev/null +++ b/node_modules/es-abstract/2021/LengthOfArrayLike.js @@ -0,0 +1,18 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var Get = require('./Get'); +var ToLength = require('./ToLength'); + +// https://262.ecma-international.org/11.0/#sec-lengthofarraylike + +module.exports = function LengthOfArrayLike(obj) { + if (!isObject(obj)) { + throw new $TypeError('Assertion failed: `obj` must be an Object'); + } + return ToLength(Get(obj, 'length')); +}; + +// TODO: use this all over diff --git a/node_modules/es-abstract/2021/MakeDate.js b/node_modules/es-abstract/2021/MakeDate.js new file mode 100644 index 0000000000000000000000000000000000000000..3256ae1092afd21a469f4ca086dc028a73ecaa52 --- /dev/null +++ b/node_modules/es-abstract/2021/MakeDate.js @@ -0,0 +1,14 @@ +'use strict'; + +var $isFinite = require('math-intrinsics/isFinite'); + +var msPerDay = require('../helpers/timeConstants').msPerDay; + +// https://262.ecma-international.org/5.1/#sec-15.9.1.13 + +module.exports = function MakeDate(day, time) { + if (!$isFinite(day) || !$isFinite(time)) { + return NaN; + } + return (day * msPerDay) + time; +}; diff --git a/node_modules/es-abstract/2021/MakeDay.js b/node_modules/es-abstract/2021/MakeDay.js new file mode 100644 index 0000000000000000000000000000000000000000..3e5a91e6d1696ed0b1ede1140b517182ab10c84a --- /dev/null +++ b/node_modules/es-abstract/2021/MakeDay.js @@ -0,0 +1,36 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $DateUTC = GetIntrinsic('%Date.UTC%'); + +var $isFinite = require('math-intrinsics/isFinite'); + +var DateFromTime = require('./DateFromTime'); +var Day = require('./Day'); +var floor = require('./floor'); +var modulo = require('./modulo'); +var MonthFromTime = require('./MonthFromTime'); +var ToIntegerOrInfinity = require('./ToIntegerOrInfinity'); +var YearFromTime = require('./YearFromTime'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.12 + +module.exports = function MakeDay(year, month, date) { + if (!$isFinite(year) || !$isFinite(month) || !$isFinite(date)) { + return NaN; + } + var y = ToIntegerOrInfinity(year); + var m = ToIntegerOrInfinity(month); + var dt = ToIntegerOrInfinity(date); + var ym = y + floor(m / 12); + if (!$isFinite(ym)) { + return NaN; + } + var mn = modulo(m, 12); + var t = $DateUTC(ym, mn, 1); + if (YearFromTime(t) !== ym || MonthFromTime(t) !== mn || DateFromTime(t) !== 1) { + return NaN; + } + return Day(t) + dt - 1; +}; diff --git a/node_modules/es-abstract/2021/MakeTime.js b/node_modules/es-abstract/2021/MakeTime.js new file mode 100644 index 0000000000000000000000000000000000000000..ac7d81f7aeb735f350796f6f1e12bce24c8eb114 --- /dev/null +++ b/node_modules/es-abstract/2021/MakeTime.js @@ -0,0 +1,23 @@ +'use strict'; + +var $isFinite = require('math-intrinsics/isFinite'); +var timeConstants = require('../helpers/timeConstants'); +var msPerSecond = timeConstants.msPerSecond; +var msPerMinute = timeConstants.msPerMinute; +var msPerHour = timeConstants.msPerHour; + +var ToIntegerOrInfinity = require('./ToIntegerOrInfinity'); + +// https://262.ecma-international.org/12.0/#sec-maketime + +module.exports = function MakeTime(hour, min, sec, ms) { + if (!$isFinite(hour) || !$isFinite(min) || !$isFinite(sec) || !$isFinite(ms)) { + return NaN; + } + var h = ToIntegerOrInfinity(hour); + var m = ToIntegerOrInfinity(min); + var s = ToIntegerOrInfinity(sec); + var milli = ToIntegerOrInfinity(ms); + var t = (h * msPerHour) + (m * msPerMinute) + (s * msPerSecond) + milli; + return t; +}; diff --git a/node_modules/es-abstract/2021/MinFromTime.js b/node_modules/es-abstract/2021/MinFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..a0c631d4cc56cb21e15712def6008d5623edd0f9 --- /dev/null +++ b/node_modules/es-abstract/2021/MinFromTime.js @@ -0,0 +1,14 @@ +'use strict'; + +var floor = require('./floor'); +var modulo = require('./modulo'); + +var timeConstants = require('../helpers/timeConstants'); +var msPerMinute = timeConstants.msPerMinute; +var MinutesPerHour = timeConstants.MinutesPerHour; + +// https://262.ecma-international.org/5.1/#sec-15.9.1.10 + +module.exports = function MinFromTime(t) { + return modulo(floor(t / msPerMinute), MinutesPerHour); +}; diff --git a/node_modules/es-abstract/2021/MonthFromTime.js b/node_modules/es-abstract/2021/MonthFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..e551ee2be6da5cc49c7da94be78095c0803c53d9 --- /dev/null +++ b/node_modules/es-abstract/2021/MonthFromTime.js @@ -0,0 +1,51 @@ +'use strict'; + +var $RangeError = require('es-errors/range'); + +var DayWithinYear = require('./DayWithinYear'); +var InLeapYear = require('./InLeapYear'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.4 + +module.exports = function MonthFromTime(t) { + var day = DayWithinYear(t); + if (0 <= day && day < 31) { + return 0; + } + var leap = InLeapYear(t); + if (31 <= day && day < (59 + leap)) { + return 1; + } + if ((59 + leap) <= day && day < (90 + leap)) { + return 2; + } + if ((90 + leap) <= day && day < (120 + leap)) { + return 3; + } + if ((120 + leap) <= day && day < (151 + leap)) { + return 4; + } + if ((151 + leap) <= day && day < (181 + leap)) { + return 5; + } + if ((181 + leap) <= day && day < (212 + leap)) { + return 6; + } + if ((212 + leap) <= day && day < (243 + leap)) { + return 7; + } + if ((243 + leap) <= day && day < (273 + leap)) { + return 8; + } + if ((273 + leap) <= day && day < (304 + leap)) { + return 9; + } + if ((304 + leap) <= day && day < (334 + leap)) { + return 10; + } + if ((334 + leap) <= day && day < (365 + leap)) { + return 11; + } + + throw new $RangeError('Assertion failed: `day` is out of range'); +}; diff --git a/node_modules/es-abstract/2021/NewPromiseCapability.js b/node_modules/es-abstract/2021/NewPromiseCapability.js new file mode 100644 index 0000000000000000000000000000000000000000..893266fe9f8da7b032d6fc835750a07c30086179 --- /dev/null +++ b/node_modules/es-abstract/2021/NewPromiseCapability.js @@ -0,0 +1,34 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var IsCallable = require('./IsCallable'); +var IsConstructor = require('./IsConstructor'); + +// https://262.ecma-international.org/6.0/#sec-newpromisecapability + +module.exports = function NewPromiseCapability(C) { + if (!IsConstructor(C)) { + throw new $TypeError('C must be a constructor'); // step 1 + } + + var resolvingFunctions = { '[[Resolve]]': void undefined, '[[Reject]]': void undefined }; // step 3 + + var promise = new C(function (resolve, reject) { // steps 4-5 + if (typeof resolvingFunctions['[[Resolve]]'] !== 'undefined' || typeof resolvingFunctions['[[Reject]]'] !== 'undefined') { + throw new $TypeError('executor has already been called'); // step 4.a, 4.b + } + resolvingFunctions['[[Resolve]]'] = resolve; // step 4.c + resolvingFunctions['[[Reject]]'] = reject; // step 4.d + }); // step 4-6 + + if (!IsCallable(resolvingFunctions['[[Resolve]]']) || !IsCallable(resolvingFunctions['[[Reject]]'])) { + throw new $TypeError('executor must provide valid resolve and reject functions'); // steps 7-8 + } + + return { + '[[Promise]]': promise, + '[[Resolve]]': resolvingFunctions['[[Resolve]]'], + '[[Reject]]': resolvingFunctions['[[Reject]]'] + }; // step 9 +}; diff --git a/node_modules/es-abstract/2021/NormalCompletion.js b/node_modules/es-abstract/2021/NormalCompletion.js new file mode 100644 index 0000000000000000000000000000000000000000..1e429dd65cfaded0bd09155819605198a45c628d --- /dev/null +++ b/node_modules/es-abstract/2021/NormalCompletion.js @@ -0,0 +1,9 @@ +'use strict'; + +var CompletionRecord = require('./CompletionRecord'); + +// https://262.ecma-international.org/6.0/#sec-normalcompletion + +module.exports = function NormalCompletion(value) { + return new CompletionRecord('normal', value); +}; diff --git a/node_modules/es-abstract/2021/Number/add.js b/node_modules/es-abstract/2021/Number/add.js new file mode 100644 index 0000000000000000000000000000000000000000..eead1f19fec68bed3c141340b4318116f7e9ec06 --- /dev/null +++ b/node_modules/es-abstract/2021/Number/add.js @@ -0,0 +1,31 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isFinite = require('math-intrinsics/isFinite'); +var isNaN = require('math-intrinsics/isNaN'); + +// https://262.ecma-international.org/12.0/#sec-numeric-types-number-add + +module.exports = function NumberAdd(x, y) { + if (typeof x !== 'number' || typeof y !== 'number') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be Numbers'); + } + + if (isNaN(x) || isNaN(y) || (x === Infinity && y === -Infinity) || (x === -Infinity && y === Infinity)) { + return NaN; + } + + if (!isFinite(x)) { + return x; + } + if (!isFinite(y)) { + return y; + } + + if (x === y && x === 0) { // both zeroes + return Infinity / x === -Infinity && Infinity / y === -Infinity ? -0 : +0; + } + + // shortcut for the actual spec mechanics + return x + y; +}; diff --git a/node_modules/es-abstract/2021/Number/bitwiseAND.js b/node_modules/es-abstract/2021/Number/bitwiseAND.js new file mode 100644 index 0000000000000000000000000000000000000000..d85d0f6f6a657b4afcbb3abd8c655d9e5a247400 --- /dev/null +++ b/node_modules/es-abstract/2021/Number/bitwiseAND.js @@ -0,0 +1,14 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var NumberBitwiseOp = require('../NumberBitwiseOp'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-number-bitwiseAND + +module.exports = function NumberBitwiseAND(x, y) { + if (typeof x !== 'number' || typeof y !== 'number') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be Numbers'); + } + return NumberBitwiseOp('&', x, y); +}; diff --git a/node_modules/es-abstract/2021/Number/bitwiseNOT.js b/node_modules/es-abstract/2021/Number/bitwiseNOT.js new file mode 100644 index 0000000000000000000000000000000000000000..7e3035e879df0d334dab28b00d3f07c1583c0429 --- /dev/null +++ b/node_modules/es-abstract/2021/Number/bitwiseNOT.js @@ -0,0 +1,16 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var ToInt32 = require('../ToInt32'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-number-bitwiseNOT + +module.exports = function NumberBitwiseNOT(x) { + if (typeof x !== 'number') { + throw new $TypeError('Assertion failed: `x` argument must be a Number'); + } + var oldValue = ToInt32(x); + // Return the result of applying the bitwise operator op to lnum and rnum. The result is a signed 32-bit integer. + return ~oldValue; +}; diff --git a/node_modules/es-abstract/2021/Number/bitwiseOR.js b/node_modules/es-abstract/2021/Number/bitwiseOR.js new file mode 100644 index 0000000000000000000000000000000000000000..2930a61222f9cc53559ffceac2865b5fdabfeea4 --- /dev/null +++ b/node_modules/es-abstract/2021/Number/bitwiseOR.js @@ -0,0 +1,14 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var NumberBitwiseOp = require('../NumberBitwiseOp'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-number-bitwiseOR + +module.exports = function NumberBitwiseOR(x, y) { + if (typeof x !== 'number' || typeof y !== 'number') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be Numbers'); + } + return NumberBitwiseOp('|', x, y); +}; diff --git a/node_modules/es-abstract/2021/Number/bitwiseXOR.js b/node_modules/es-abstract/2021/Number/bitwiseXOR.js new file mode 100644 index 0000000000000000000000000000000000000000..fab4baae216a9c35ef1eb20fc941aca98028cb21 --- /dev/null +++ b/node_modules/es-abstract/2021/Number/bitwiseXOR.js @@ -0,0 +1,14 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var NumberBitwiseOp = require('../NumberBitwiseOp'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-number-bitwiseXOR + +module.exports = function NumberBitwiseXOR(x, y) { + if (typeof x !== 'number' || typeof y !== 'number') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be Numbers'); + } + return NumberBitwiseOp('^', x, y); +}; diff --git a/node_modules/es-abstract/2021/Number/divide.js b/node_modules/es-abstract/2021/Number/divide.js new file mode 100644 index 0000000000000000000000000000000000000000..12ec011c993217453e4633d626e47d3baf134beb --- /dev/null +++ b/node_modules/es-abstract/2021/Number/divide.js @@ -0,0 +1,18 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isFinite = require('math-intrinsics/isFinite'); +var isNaN = require('math-intrinsics/isNaN'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-number-divide + +module.exports = function NumberDivide(x, y) { + if (typeof x !== 'number' || typeof y !== 'number') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be Numbers'); + } + if (isNaN(x) || isNaN(y) || (!isFinite(x) && !isFinite(y))) { + return NaN; + } + // shortcut for the actual spec mechanics + return x / y; +}; diff --git a/node_modules/es-abstract/2021/Number/equal.js b/node_modules/es-abstract/2021/Number/equal.js new file mode 100644 index 0000000000000000000000000000000000000000..ebd9f7463a062a0b95d80a80e4ef2cbd8efc648e --- /dev/null +++ b/node_modules/es-abstract/2021/Number/equal.js @@ -0,0 +1,18 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var isNaN = require('../../helpers/isNaN'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-number-equal + +module.exports = function NumberEqual(x, y) { + if (typeof x !== 'number' || typeof y !== 'number') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be Numbers'); + } + if (isNaN(x) || isNaN(y)) { + return false; + } + // shortcut for the actual spec mechanics + return x === y; +}; diff --git a/node_modules/es-abstract/2021/Number/exponentiate.js b/node_modules/es-abstract/2021/Number/exponentiate.js new file mode 100644 index 0000000000000000000000000000000000000000..37812d85bccd0b0438c66595e1e6d5aef4c94bc7 --- /dev/null +++ b/node_modules/es-abstract/2021/Number/exponentiate.js @@ -0,0 +1,74 @@ +'use strict'; + +// var isNegativeZero = require('math-intrinsics/isNegativeZero'); +var $pow = require('math-intrinsics/pow'); + +var $TypeError = require('es-errors/type'); + +/* +var abs = require('math-intrinsics/abs'); +var isFinite = require('math-intrinsics/isFinite'); +var isNaN = require('math-intrinsics/isNaN'); + +var IsInteger = require('math-intrinsics/isInteger'); +*/ + +// https://262.ecma-international.org/11.0/#sec-numeric-types-number-exponentiate + +/* eslint max-lines-per-function: 0, max-statements: 0 */ + +module.exports = function NumberExponentiate(base, exponent) { + if (typeof base !== 'number' || typeof exponent !== 'number') { + throw new $TypeError('Assertion failed: `base` and `exponent` arguments must be Numbers'); + } + return $pow(base, exponent); + /* + if (isNaN(exponent)) { + return NaN; + } + if (exponent === 0) { + return 1; + } + if (isNaN(base)) { + return NaN; + } + var aB = abs(base); + if (aB > 1 && exponent === Infinity) { + return Infinity; + } + if (aB > 1 && exponent === -Infinity) { + return 0; + } + if (aB === 1 && (exponent === Infinity || exponent === -Infinity)) { + return NaN; + } + if (aB < 1 && exponent === Infinity) { + return +0; + } + if (aB < 1 && exponent === -Infinity) { + return Infinity; + } + if (base === Infinity) { + return exponent > 0 ? Infinity : 0; + } + if (base === -Infinity) { + var isOdd = true; + if (exponent > 0) { + return isOdd ? -Infinity : Infinity; + } + return isOdd ? -0 : 0; + } + if (exponent > 0) { + return isNegativeZero(base) ? Infinity : 0; + } + if (isNegativeZero(base)) { + if (exponent > 0) { + return isOdd ? -0 : 0; + } + return isOdd ? -Infinity : Infinity; + } + if (base < 0 && isFinite(base) && isFinite(exponent) && !IsInteger(exponent)) { + return NaN; + } + */ +}; diff --git a/node_modules/es-abstract/2021/Number/index.js b/node_modules/es-abstract/2021/Number/index.js new file mode 100644 index 0000000000000000000000000000000000000000..63ec52da69e285d605f9f5db2ffe69ed4af591f2 --- /dev/null +++ b/node_modules/es-abstract/2021/Number/index.js @@ -0,0 +1,43 @@ +'use strict'; + +var add = require('./add'); +var bitwiseAND = require('./bitwiseAND'); +var bitwiseNOT = require('./bitwiseNOT'); +var bitwiseOR = require('./bitwiseOR'); +var bitwiseXOR = require('./bitwiseXOR'); +var divide = require('./divide'); +var equal = require('./equal'); +var exponentiate = require('./exponentiate'); +var leftShift = require('./leftShift'); +var lessThan = require('./lessThan'); +var multiply = require('./multiply'); +var remainder = require('./remainder'); +var sameValue = require('./sameValue'); +var sameValueZero = require('./sameValueZero'); +var signedRightShift = require('./signedRightShift'); +var subtract = require('./subtract'); +var toString = require('./toString'); +var unaryMinus = require('./unaryMinus'); +var unsignedRightShift = require('./unsignedRightShift'); + +module.exports = { + add: add, + bitwiseAND: bitwiseAND, + bitwiseNOT: bitwiseNOT, + bitwiseOR: bitwiseOR, + bitwiseXOR: bitwiseXOR, + divide: divide, + equal: equal, + exponentiate: exponentiate, + leftShift: leftShift, + lessThan: lessThan, + multiply: multiply, + remainder: remainder, + sameValue: sameValue, + sameValueZero: sameValueZero, + signedRightShift: signedRightShift, + subtract: subtract, + toString: toString, + unaryMinus: unaryMinus, + unsignedRightShift: unsignedRightShift +}; diff --git a/node_modules/es-abstract/2021/Number/leftShift.js b/node_modules/es-abstract/2021/Number/leftShift.js new file mode 100644 index 0000000000000000000000000000000000000000..bbaffae5d3e3bca167fbf5e501f43beece5b2e7f --- /dev/null +++ b/node_modules/es-abstract/2021/Number/leftShift.js @@ -0,0 +1,22 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var ToInt32 = require('../ToInt32'); +var ToUint32 = require('../ToUint32'); +var modulo = require('../modulo'); + +// https://262.ecma-international.org/12.0/#sec-numeric-types-number-leftShift + +module.exports = function NumberLeftShift(x, y) { + if (typeof x !== 'number' || typeof y !== 'number') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be Numbers'); + } + + var lnum = ToInt32(x); + var rnum = ToUint32(y); + + var shiftCount = modulo(rnum, 32); + + return lnum << shiftCount; +}; diff --git a/node_modules/es-abstract/2021/Number/lessThan.js b/node_modules/es-abstract/2021/Number/lessThan.js new file mode 100644 index 0000000000000000000000000000000000000000..538174306dd342a14dc82f25f2b8e5a56c9e6a32 --- /dev/null +++ b/node_modules/es-abstract/2021/Number/lessThan.js @@ -0,0 +1,22 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var isNaN = require('../../helpers/isNaN'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-number-lessThan + +module.exports = function NumberLessThan(x, y) { + if (typeof x !== 'number' || typeof y !== 'number') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be Numbers'); + } + + // If x is NaN, return undefined. + // If y is NaN, return undefined. + if (isNaN(x) || isNaN(y)) { + return void undefined; + } + + // shortcut for the actual spec mechanics + return x < y; +}; diff --git a/node_modules/es-abstract/2021/Number/multiply.js b/node_modules/es-abstract/2021/Number/multiply.js new file mode 100644 index 0000000000000000000000000000000000000000..318787cbab9b472dca1f47e18c0faec44c4da1c3 --- /dev/null +++ b/node_modules/es-abstract/2021/Number/multiply.js @@ -0,0 +1,29 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var isNaN = require('../../helpers/isNaN'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-number-multiply + +module.exports = function NumberMultiply(x, y) { + if (typeof x !== 'number' || typeof y !== 'number') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be Numbers'); + } + + if (isNaN(x) || isNaN(y) || (x === 0 && !isFinite(y)) || (!isFinite(x) && y === 0)) { + return NaN; + } + if (!isFinite(x) && !isFinite(y)) { + return x === y ? Infinity : -Infinity; + } + if (!isFinite(x) && y !== 0) { + return x > 0 ? Infinity : -Infinity; + } + if (!isFinite(y) && x !== 0) { + return y > 0 ? Infinity : -Infinity; + } + + // shortcut for the actual spec mechanics + return x * y; +}; diff --git a/node_modules/es-abstract/2021/Number/remainder.js b/node_modules/es-abstract/2021/Number/remainder.js new file mode 100644 index 0000000000000000000000000000000000000000..8d1b1790fe607ba4f26936946224277dfe137072 --- /dev/null +++ b/node_modules/es-abstract/2021/Number/remainder.js @@ -0,0 +1,28 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var isNaN = require('../../helpers/isNaN'); + +// https://262.ecma-international.org/12.0/#sec-numeric-types-number-remainder + +module.exports = function NumberRemainder(n, d) { + if (typeof n !== 'number' || typeof d !== 'number') { + throw new $TypeError('Assertion failed: `n` and `d` arguments must be Numbers'); + } + + // If either operand is NaN, the result is NaN. + // If the dividend is an infinity, or the divisor is a zero, or both, the result is NaN. + if (isNaN(n) || isNaN(d) || !isFinite(n) || d === 0) { + return NaN; + } + + // If the dividend is finite and the divisor is an infinity, the result equals the dividend. + // If the dividend is a zero and the divisor is nonzero and finite, the result is the same as the dividend. + if (!isFinite(d) || n === 0) { + return n; + } + + // In the remaining cases, where neither an infinity, nor a zero, nor NaN is involved… + return n % d; +}; diff --git a/node_modules/es-abstract/2021/Number/sameValue.js b/node_modules/es-abstract/2021/Number/sameValue.js new file mode 100644 index 0000000000000000000000000000000000000000..f7c6f78a4afc352f3ead59cd4ffc866dadc74130 --- /dev/null +++ b/node_modules/es-abstract/2021/Number/sameValue.js @@ -0,0 +1,18 @@ +'use strict'; + +var isNegativeZero = require('math-intrinsics/isNegativeZero'); +var $TypeError = require('es-errors/type'); + +var NumberSameValueZero = require('./sameValueZero'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-number-sameValue + +module.exports = function NumberSameValue(x, y) { + if (typeof x !== 'number' || typeof y !== 'number') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be Numbers'); + } + if (x === 0 && y === 0) { + return !(isNegativeZero(x) ^ isNegativeZero(y)); + } + return NumberSameValueZero(x, y); +}; diff --git a/node_modules/es-abstract/2021/Number/sameValueZero.js b/node_modules/es-abstract/2021/Number/sameValueZero.js new file mode 100644 index 0000000000000000000000000000000000000000..383ab82f70c8612fed5287ec4b0b0b5814f48750 --- /dev/null +++ b/node_modules/es-abstract/2021/Number/sameValueZero.js @@ -0,0 +1,20 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var isNaN = require('../../helpers/isNaN'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-number-sameValueZero + +module.exports = function NumberSameValueZero(x, y) { + if (typeof x !== 'number' || typeof y !== 'number') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be Numbers'); + } + + var xNaN = isNaN(x); + var yNaN = isNaN(y); + if (xNaN || yNaN) { + return xNaN === yNaN; + } + return x === y; +}; diff --git a/node_modules/es-abstract/2021/Number/signedRightShift.js b/node_modules/es-abstract/2021/Number/signedRightShift.js new file mode 100644 index 0000000000000000000000000000000000000000..b22775b14f06bec9ec6e4e1b53096d9e69740327 --- /dev/null +++ b/node_modules/es-abstract/2021/Number/signedRightShift.js @@ -0,0 +1,22 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var ToInt32 = require('../ToInt32'); +var ToUint32 = require('../ToUint32'); +var modulo = require('../modulo'); + +// https://262.ecma-international.org/12.0/#sec-numeric-types-number-signedRightShift + +module.exports = function NumberSignedRightShift(x, y) { + if (typeof x !== 'number' || typeof y !== 'number') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be Numbers'); + } + + var lnum = ToInt32(x); + var rnum = ToUint32(y); + + var shiftCount = modulo(rnum, 32); + + return lnum >> shiftCount; +}; diff --git a/node_modules/es-abstract/2021/Number/subtract.js b/node_modules/es-abstract/2021/Number/subtract.js new file mode 100644 index 0000000000000000000000000000000000000000..9f66df451ff8029461369d79f81debc17766379a --- /dev/null +++ b/node_modules/es-abstract/2021/Number/subtract.js @@ -0,0 +1,15 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var NumberAdd = require('./add'); +var NumberUnaryMinus = require('./unaryMinus'); + +// https://262.ecma-international.org/12.0/#sec-numeric-types-number-subtract + +module.exports = function NumberSubtract(x, y) { + if (typeof x !== 'number' || typeof y !== 'number') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be Numbers'); + } + return NumberAdd(x, NumberUnaryMinus(y)); +}; diff --git a/node_modules/es-abstract/2021/Number/toString.js b/node_modules/es-abstract/2021/Number/toString.js new file mode 100644 index 0000000000000000000000000000000000000000..833353dc3bce29b8b8a7fe2cbf7b10185a3b149d --- /dev/null +++ b/node_modules/es-abstract/2021/Number/toString.js @@ -0,0 +1,16 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $String = GetIntrinsic('%String%'); +var $TypeError = require('es-errors/type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-number-tostring + +module.exports = function NumberToString(x) { + if (typeof x !== 'number') { + throw new $TypeError('Assertion failed: `x` must be a Number'); + } + + return $String(x); +}; diff --git a/node_modules/es-abstract/2021/Number/unaryMinus.js b/node_modules/es-abstract/2021/Number/unaryMinus.js new file mode 100644 index 0000000000000000000000000000000000000000..ab4ed98b2db294cfcd12edd31d9a7fd06649b9dd --- /dev/null +++ b/node_modules/es-abstract/2021/Number/unaryMinus.js @@ -0,0 +1,17 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var isNaN = require('../../helpers/isNaN'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-number-unaryMinus + +module.exports = function NumberUnaryMinus(x) { + if (typeof x !== 'number') { + throw new $TypeError('Assertion failed: `x` argument must be a Number'); + } + if (isNaN(x)) { + return NaN; + } + return -x; +}; diff --git a/node_modules/es-abstract/2021/Number/unsignedRightShift.js b/node_modules/es-abstract/2021/Number/unsignedRightShift.js new file mode 100644 index 0000000000000000000000000000000000000000..70334bd60c5a4417c07b2a5f51ba942fc8731d8f --- /dev/null +++ b/node_modules/es-abstract/2021/Number/unsignedRightShift.js @@ -0,0 +1,22 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var ToInt32 = require('../ToInt32'); +var ToUint32 = require('../ToUint32'); +var modulo = require('../modulo'); + +// https://262.ecma-international.org/12.0/#sec-numeric-types-number-unsignedRightShift + +module.exports = function NumberUnsignedRightShift(x, y) { + if (typeof x !== 'number' || typeof y !== 'number') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be Numbers'); + } + + var lnum = ToInt32(x); + var rnum = ToUint32(y); + + var shiftCount = modulo(rnum, 32); + + return lnum >>> shiftCount; +}; diff --git a/node_modules/es-abstract/2021/NumberBitwiseOp.js b/node_modules/es-abstract/2021/NumberBitwiseOp.js new file mode 100644 index 0000000000000000000000000000000000000000..769d1fa15aee1ba5ee58abd4f96579f9ba38138f --- /dev/null +++ b/node_modules/es-abstract/2021/NumberBitwiseOp.js @@ -0,0 +1,26 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var ToInt32 = require('./ToInt32'); +var ToUint32 = require('./ToUint32'); + +// https://262.ecma-international.org/11.0/#sec-numberbitwiseop + +module.exports = function NumberBitwiseOp(op, x, y) { + if (op !== '&' && op !== '|' && op !== '^') { + throw new $TypeError('Assertion failed: `op` must be `&`, `|`, or `^`'); + } + if (typeof x !== 'number' || typeof y !== 'number') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be Numbers'); + } + var lnum = ToInt32(x); + var rnum = ToUint32(y); + if (op === '&') { + return lnum & rnum; + } + if (op === '|') { + return lnum | rnum; + } + return lnum ^ rnum; +}; diff --git a/node_modules/es-abstract/2021/NumberToBigInt.js b/node_modules/es-abstract/2021/NumberToBigInt.js new file mode 100644 index 0000000000000000000000000000000000000000..27fb6682301aaeb4a93dfad4ed9bcbdbaa24f6c2 --- /dev/null +++ b/node_modules/es-abstract/2021/NumberToBigInt.js @@ -0,0 +1,25 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $BigInt = GetIntrinsic('%BigInt%', true); +var $RangeError = require('es-errors/range'); +var $SyntaxError = require('es-errors/syntax'); +var $TypeError = require('es-errors/type'); + +var isInteger = require('math-intrinsics/isInteger'); + +// https://262.ecma-international.org/12.0/#sec-numbertobigint + +module.exports = function NumberToBigInt(number) { + if (typeof number !== 'number') { + throw new $TypeError('Assertion failed: `number` must be a String'); + } + if (!isInteger(number)) { + throw new $RangeError('The number ' + number + ' cannot be converted to a BigInt because it is not an integer'); + } + if (!$BigInt) { + throw new $SyntaxError('BigInts are not supported in this environment'); + } + return $BigInt(number); +}; diff --git a/node_modules/es-abstract/2021/NumericToRawBytes.js b/node_modules/es-abstract/2021/NumericToRawBytes.js new file mode 100644 index 0000000000000000000000000000000000000000..db42a4fbb0951c865b5c3d85a9cbb874b825a3c6 --- /dev/null +++ b/node_modules/es-abstract/2021/NumericToRawBytes.js @@ -0,0 +1,62 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var hasOwnProperty = require('./HasOwnProperty'); +var ToBigInt64 = require('./ToBigInt64'); +var ToBigUint64 = require('./ToBigUint64'); +var ToInt16 = require('./ToInt16'); +var ToInt32 = require('./ToInt32'); +var ToInt8 = require('./ToInt8'); +var ToUint16 = require('./ToUint16'); +var ToUint32 = require('./ToUint32'); +var ToUint8 = require('./ToUint8'); +var ToUint8Clamp = require('./ToUint8Clamp'); + +var valueToFloat32Bytes = require('../helpers/valueToFloat32Bytes'); +var valueToFloat64Bytes = require('../helpers/valueToFloat64Bytes'); +var integerToNBytes = require('../helpers/integerToNBytes'); + +var tableTAO = require('./tables/typed-array-objects'); + +// https://262.ecma-international.org/11.0/#table-the-typedarray-constructors +var TypeToAO = { + __proto__: null, + $Int8: ToInt8, + $Uint8: ToUint8, + $Uint8C: ToUint8Clamp, + $Int16: ToInt16, + $Uint16: ToUint16, + $Int32: ToInt32, + $Uint32: ToUint32, + $BigInt64: ToBigInt64, + $BigUint64: ToBigUint64 +}; + +// https://262.ecma-international.org/11.0/#sec-numerictorawbytes + +module.exports = function NumericToRawBytes(type, value, isLittleEndian) { + if (typeof type !== 'string' || !hasOwnProperty(tableTAO.size, '$' + type)) { + throw new $TypeError('Assertion failed: `type` must be a TypedArray element type'); + } + if (typeof value !== 'number' && typeof value !== 'bigint') { + throw new $TypeError('Assertion failed: `value` must be a Number or a BigInt'); + } + if (typeof isLittleEndian !== 'boolean') { + throw new $TypeError('Assertion failed: `isLittleEndian` must be a Boolean'); + } + + if (type === 'Float32') { // step 1 + return valueToFloat32Bytes(value, isLittleEndian); + } else if (type === 'Float64') { // step 2 + return valueToFloat64Bytes(value, isLittleEndian); + } // step 3 + + var n = tableTAO.size['$' + type]; // step 3.a + + var convOp = TypeToAO['$' + type]; // step 3.b + + var intValue = convOp(value); // step 3.c + + return integerToNBytes(intValue, n, isLittleEndian); // step 3.d, 3.e, 4 +}; diff --git a/node_modules/es-abstract/2021/ObjectDefineProperties.js b/node_modules/es-abstract/2021/ObjectDefineProperties.js new file mode 100644 index 0000000000000000000000000000000000000000..0d41322bcc146b95dea2f81dbb533ed69495414a --- /dev/null +++ b/node_modules/es-abstract/2021/ObjectDefineProperties.js @@ -0,0 +1,37 @@ +'use strict'; + +var DefinePropertyOrThrow = require('./DefinePropertyOrThrow'); +var Get = require('./Get'); +var OrdinaryGetOwnProperty = require('./OrdinaryGetOwnProperty'); +var ToObject = require('./ToObject'); +var ToPropertyDescriptor = require('./ToPropertyDescriptor'); + +var forEach = require('../helpers/forEach'); +var OwnPropertyKeys = require('own-keys'); + +// https://262.ecma-international.org/6.0/#sec-objectdefineproperties + +/** @type { = {}>(O: T, Properties: object) => T} */ +module.exports = function ObjectDefineProperties(O, Properties) { + var props = ToObject(Properties); // step 1 + var keys = OwnPropertyKeys(props); // step 2 + /** @type {[string | symbol, import('../types').Descriptor][]} */ + var descriptors = []; // step 3 + + forEach(keys, function (nextKey) { // step 4 + var propDesc = OrdinaryGetOwnProperty(props, nextKey); // ToPropertyDescriptor(getOwnPropertyDescriptor(props, nextKey)); // step 4.a + if (typeof propDesc !== 'undefined' && propDesc['[[Enumerable]]']) { // step 4.b + var descObj = Get(props, nextKey); // step 4.b.i + var desc = ToPropertyDescriptor(descObj); // step 4.b.ii + descriptors[descriptors.length] = [nextKey, desc]; // step 4.b.iii + } + }); + + forEach(descriptors, function (pair) { // step 5 + var P = pair[0]; // step 5.a + var desc = pair[1]; // step 5.b + DefinePropertyOrThrow(O, P, desc); // step 5.c + }); + + return O; // step 6 +}; diff --git a/node_modules/es-abstract/2021/OrdinaryCreateFromConstructor.js b/node_modules/es-abstract/2021/OrdinaryCreateFromConstructor.js new file mode 100644 index 0000000000000000000000000000000000000000..ac997c828209e0a91a21801f62f206d4dd642c29 --- /dev/null +++ b/node_modules/es-abstract/2021/OrdinaryCreateFromConstructor.js @@ -0,0 +1,20 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); +var $TypeError = require('es-errors/type'); + +var GetPrototypeFromConstructor = require('./GetPrototypeFromConstructor'); +var IsArray = require('./IsArray'); +var OrdinaryObjectCreate = require('./OrdinaryObjectCreate'); + +// https://262.ecma-international.org/6.0/#sec-ordinarycreatefromconstructor + +module.exports = function OrdinaryCreateFromConstructor(constructor, intrinsicDefaultProto) { + GetIntrinsic(intrinsicDefaultProto); // throws if not a valid intrinsic + var proto = GetPrototypeFromConstructor(constructor, intrinsicDefaultProto); + var slots = arguments.length < 3 ? [] : arguments[2]; + if (!IsArray(slots)) { + throw new $TypeError('Assertion failed: if provided, `internalSlotsList` must be a List'); + } + return OrdinaryObjectCreate(proto, slots); +}; diff --git a/node_modules/es-abstract/2021/OrdinaryDefineOwnProperty.js b/node_modules/es-abstract/2021/OrdinaryDefineOwnProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..1a61488c6311f778620cdccb377e0b377040b055 --- /dev/null +++ b/node_modules/es-abstract/2021/OrdinaryDefineOwnProperty.js @@ -0,0 +1,54 @@ +'use strict'; + +var $gOPD = require('gopd'); +var $SyntaxError = require('es-errors/syntax'); +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var isPropertyDescriptor = require('../helpers/records/property-descriptor'); + +var IsAccessorDescriptor = require('./IsAccessorDescriptor'); +var IsExtensible = require('./IsExtensible'); +var isPropertyKey = require('../helpers/isPropertyKey'); +var ToPropertyDescriptor = require('./ToPropertyDescriptor'); +var SameValue = require('./SameValue'); +var ValidateAndApplyPropertyDescriptor = require('./ValidateAndApplyPropertyDescriptor'); + +// https://262.ecma-international.org/6.0/#sec-ordinarydefineownproperty + +module.exports = function OrdinaryDefineOwnProperty(O, P, Desc) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: O must be an Object'); + } + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: P must be a Property Key'); + } + if (!isPropertyDescriptor(Desc)) { + throw new $TypeError('Assertion failed: Desc must be a Property Descriptor'); + } + if (!$gOPD) { + // ES3/IE 8 fallback + if (IsAccessorDescriptor(Desc)) { + throw new $SyntaxError('This environment does not support accessor property descriptors.'); + } + var creatingNormalDataProperty = !(P in O) + && Desc['[[Writable]]'] + && Desc['[[Enumerable]]'] + && Desc['[[Configurable]]'] + && '[[Value]]' in Desc; + var settingExistingDataProperty = (P in O) + && (!('[[Configurable]]' in Desc) || Desc['[[Configurable]]']) + && (!('[[Enumerable]]' in Desc) || Desc['[[Enumerable]]']) + && (!('[[Writable]]' in Desc) || Desc['[[Writable]]']) + && '[[Value]]' in Desc; + if (creatingNormalDataProperty || settingExistingDataProperty) { + O[P] = Desc['[[Value]]']; // eslint-disable-line no-param-reassign + return SameValue(O[P], Desc['[[Value]]']); + } + throw new $SyntaxError('This environment does not support defining non-writable, non-enumerable, or non-configurable properties'); + } + var desc = $gOPD(O, P); + var current = desc && ToPropertyDescriptor(desc); + var extensible = IsExtensible(O); + return ValidateAndApplyPropertyDescriptor(O, P, extensible, Desc, current); +}; diff --git a/node_modules/es-abstract/2021/OrdinaryGetOwnProperty.js b/node_modules/es-abstract/2021/OrdinaryGetOwnProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..e0c9cb1a595d9273e0bbea4f0b6a99918320b7fd --- /dev/null +++ b/node_modules/es-abstract/2021/OrdinaryGetOwnProperty.js @@ -0,0 +1,41 @@ +'use strict'; + +var $gOPD = require('gopd'); +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); +var callBound = require('call-bound'); + +var $isEnumerable = callBound('Object.prototype.propertyIsEnumerable'); + +var hasOwn = require('hasown'); + +var IsArray = require('./IsArray'); +var isPropertyKey = require('../helpers/isPropertyKey'); +var IsRegExp = require('./IsRegExp'); +var ToPropertyDescriptor = require('./ToPropertyDescriptor'); + +// https://262.ecma-international.org/6.0/#sec-ordinarygetownproperty + +module.exports = function OrdinaryGetOwnProperty(O, P) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: O must be an Object'); + } + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: P must be a Property Key'); + } + if (!hasOwn(O, P)) { + return void 0; + } + if (!$gOPD) { + // ES3 / IE 8 fallback + var arrayLength = IsArray(O) && P === 'length'; + var regexLastIndex = IsRegExp(O) && P === 'lastIndex'; + return { + '[[Configurable]]': !(arrayLength || regexLastIndex), + '[[Enumerable]]': $isEnumerable(O, P), + '[[Value]]': O[P], + '[[Writable]]': true + }; + } + return ToPropertyDescriptor($gOPD(O, P)); +}; diff --git a/node_modules/es-abstract/2021/OrdinaryGetPrototypeOf.js b/node_modules/es-abstract/2021/OrdinaryGetPrototypeOf.js new file mode 100644 index 0000000000000000000000000000000000000000..7ef8bee34617c4ecaa2bd4b55cf1eb6a6665fe50 --- /dev/null +++ b/node_modules/es-abstract/2021/OrdinaryGetPrototypeOf.js @@ -0,0 +1,18 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var $getProto = require('get-proto'); + +// https://262.ecma-international.org/7.0/#sec-ordinarygetprototypeof + +module.exports = function OrdinaryGetPrototypeOf(O) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: O must be an Object'); + } + if (!$getProto) { + throw new $TypeError('This environment does not support fetching prototypes.'); + } + return $getProto(O); +}; diff --git a/node_modules/es-abstract/2021/OrdinaryHasInstance.js b/node_modules/es-abstract/2021/OrdinaryHasInstance.js new file mode 100644 index 0000000000000000000000000000000000000000..a0a83e6733a49e898d0f9db5df20a54028ad69e3 --- /dev/null +++ b/node_modules/es-abstract/2021/OrdinaryHasInstance.js @@ -0,0 +1,23 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var Get = require('./Get'); +var IsCallable = require('./IsCallable'); + +// https://262.ecma-international.org/6.0/#sec-ordinaryhasinstance + +module.exports = function OrdinaryHasInstance(C, O) { + if (!IsCallable(C)) { + return false; + } + if (!isObject(O)) { + return false; + } + var P = Get(C, 'prototype'); + if (!isObject(P)) { + throw new $TypeError('OrdinaryHasInstance called on an object with an invalid prototype property.'); + } + return O instanceof C; +}; diff --git a/node_modules/es-abstract/2021/OrdinaryHasProperty.js b/node_modules/es-abstract/2021/OrdinaryHasProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..c6c5c11961374a2c3c4beb751aca52a9973093d6 --- /dev/null +++ b/node_modules/es-abstract/2021/OrdinaryHasProperty.js @@ -0,0 +1,18 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var isPropertyKey = require('../helpers/isPropertyKey'); + +// https://262.ecma-international.org/6.0/#sec-ordinaryhasproperty + +module.exports = function OrdinaryHasProperty(O, P) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: P must be a Property Key'); + } + return P in O; +}; diff --git a/node_modules/es-abstract/2021/OrdinaryObjectCreate.js b/node_modules/es-abstract/2021/OrdinaryObjectCreate.js new file mode 100644 index 0000000000000000000000000000000000000000..aca0ac014fead59cc298b13659179c082a4ae82a --- /dev/null +++ b/node_modules/es-abstract/2021/OrdinaryObjectCreate.js @@ -0,0 +1,56 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $ObjectCreate = GetIntrinsic('%Object.create%', true); +var $TypeError = require('es-errors/type'); +var $SyntaxError = require('es-errors/syntax'); +var isObject = require('es-object-atoms/isObject'); + +var IsArray = require('./IsArray'); + +var forEach = require('../helpers/forEach'); + +var SLOT = require('internal-slot'); + +var hasProto = require('has-proto')(); + +// https://262.ecma-international.org/11.0/#sec-objectcreate + +module.exports = function OrdinaryObjectCreate(proto) { + if (proto !== null && !isObject(proto)) { + throw new $TypeError('Assertion failed: `proto` must be null or an object'); + } + var additionalInternalSlotsList = arguments.length < 2 ? [] : arguments[1]; + if (!IsArray(additionalInternalSlotsList)) { + throw new $TypeError('Assertion failed: `additionalInternalSlotsList` must be an Array'); + } + + // var internalSlotsList = ['[[Prototype]]', '[[Extensible]]']; // step 1 + // internalSlotsList.push(...additionalInternalSlotsList); // step 2 + // var O = MakeBasicObject(internalSlotsList); // step 3 + // setProto(O, proto); // step 4 + // return O; // step 5 + + var O; + if (hasProto) { + O = { __proto__: proto }; + } else if ($ObjectCreate) { + O = $ObjectCreate(proto); + } else { + if (proto === null) { + throw new $SyntaxError('native Object.create support is required to create null objects'); + } + var T = function T() {}; + T.prototype = proto; + O = new T(); + } + + if (additionalInternalSlotsList.length > 0) { + forEach(additionalInternalSlotsList, function (slot) { + SLOT.set(O, slot, void undefined); + }); + } + + return O; +}; diff --git a/node_modules/es-abstract/2021/OrdinarySetPrototypeOf.js b/node_modules/es-abstract/2021/OrdinarySetPrototypeOf.js new file mode 100644 index 0000000000000000000000000000000000000000..b493a442ddd22b125fde2ed40eeebddf2d080a2d --- /dev/null +++ b/node_modules/es-abstract/2021/OrdinarySetPrototypeOf.js @@ -0,0 +1,50 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var $setProto = require('set-proto'); +var isObject = require('es-object-atoms/isObject'); + +var OrdinaryGetPrototypeOf = require('./OrdinaryGetPrototypeOf'); + +// https://262.ecma-international.org/7.0/#sec-ordinarysetprototypeof + +module.exports = function OrdinarySetPrototypeOf(O, V) { + if (V !== null && !isObject(V)) { + throw new $TypeError('Assertion failed: V must be Object or Null'); + } + /* + var extensible = IsExtensible(O); + var current = OrdinaryGetPrototypeOf(O); + if (SameValue(V, current)) { + return true; + } + if (!extensible) { + return false; + } + */ + try { + $setProto(O, V); + } catch (e) { + return false; + } + return OrdinaryGetPrototypeOf(O) === V; + /* + var p = V; + var done = false; + while (!done) { + if (p === null) { + done = true; + } else if (SameValue(p, O)) { + return false; + } else { + if (wat) { + done = true; + } else { + p = p.[[Prototype]]; + } + } + } + O.[[Prototype]] = V; + return true; + */ +}; diff --git a/node_modules/es-abstract/2021/OrdinaryToPrimitive.js b/node_modules/es-abstract/2021/OrdinaryToPrimitive.js new file mode 100644 index 0000000000000000000000000000000000000000..5feb5694e8aba94591eac365aa6bd8a6b985f305 --- /dev/null +++ b/node_modules/es-abstract/2021/OrdinaryToPrimitive.js @@ -0,0 +1,36 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var Call = require('./Call'); +var Get = require('./Get'); +var IsCallable = require('./IsCallable'); + +var inspect = require('object-inspect'); + +// https://262.ecma-international.org/8.0/#sec-ordinarytoprimitive + +module.exports = function OrdinaryToPrimitive(O, hint) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + if (/* typeof hint !== 'string' || */ hint !== 'string' && hint !== 'number') { + throw new $TypeError('Assertion failed: `hint` must be "string" or "number"'); + } + + var methodNames = hint === 'string' ? ['toString', 'valueOf'] : ['valueOf', 'toString']; + + for (var i = 0; i < methodNames.length; i += 1) { + var name = methodNames[i]; + var method = Get(O, name); + if (IsCallable(method)) { + var result = Call(method, O); + if (!isObject(result)) { + return result; + } + } + } + + throw new $TypeError('No primitive value for ' + inspect(O)); +}; diff --git a/node_modules/es-abstract/2021/PromiseResolve.js b/node_modules/es-abstract/2021/PromiseResolve.js new file mode 100644 index 0000000000000000000000000000000000000000..dfb7d82fd2e9a378da3188a73ff006a06ce14463 --- /dev/null +++ b/node_modules/es-abstract/2021/PromiseResolve.js @@ -0,0 +1,18 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); +var callBind = require('call-bind'); +var $SyntaxError = require('es-errors/syntax'); + +var $resolve = GetIntrinsic('%Promise.resolve%', true); +var $PromiseResolve = $resolve && callBind($resolve); + +// https://262.ecma-international.org/9.0/#sec-promise-resolve + +module.exports = function PromiseResolve(C, x) { + if (!$PromiseResolve) { + throw new $SyntaxError('This environment does not support Promises.'); + } + return $PromiseResolve(C, x); +}; + diff --git a/node_modules/es-abstract/2021/QuoteJSONString.js b/node_modules/es-abstract/2021/QuoteJSONString.js new file mode 100644 index 0000000000000000000000000000000000000000..2e0c15b64451c199fdd125d63946025921d9a329 --- /dev/null +++ b/node_modules/es-abstract/2021/QuoteJSONString.js @@ -0,0 +1,52 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var callBound = require('call-bound'); +var forEach = require('../helpers/forEach'); +var isLeadingSurrogate = require('../helpers/isLeadingSurrogate'); +var isTrailingSurrogate = require('../helpers/isTrailingSurrogate'); + +var $charCodeAt = callBound('String.prototype.charCodeAt'); +var $strSplit = callBound('String.prototype.split'); + +var StringToCodePoints = require('./StringToCodePoints'); +var UnicodeEscape = require('./UnicodeEscape'); +var UTF16EncodeCodePoint = require('./UTF16EncodeCodePoint'); + +var hasOwn = require('hasown'); + +// https://262.ecma-international.org/12.0/#sec-quotejsonstring + +var escapes = { + '\u0008': '\\b', + '\u0009': '\\t', + '\u000A': '\\n', + '\u000C': '\\f', + '\u000D': '\\r', + '\u0022': '\\"', + '\u005c': '\\\\' +}; + +module.exports = function QuoteJSONString(value) { + if (typeof value !== 'string') { + throw new $TypeError('Assertion failed: `value` must be a String'); + } + var product = '"'; + if (value) { + forEach($strSplit(StringToCodePoints(value), ''), function (C) { + if (hasOwn(escapes, C)) { + product += escapes[C]; + } else { + var cCharCode = $charCodeAt(C, 0); + if (cCharCode < 0x20 || isLeadingSurrogate(cCharCode) || isTrailingSurrogate(cCharCode)) { + product += UnicodeEscape(C); + } else { + product += UTF16EncodeCodePoint(cCharCode); + } + } + }); + } + product += '"'; + return product; +}; diff --git a/node_modules/es-abstract/2021/RawBytesToNumeric.js b/node_modules/es-abstract/2021/RawBytesToNumeric.js new file mode 100644 index 0000000000000000000000000000000000000000..70c24064ca2c7208f10baec57d50b6a31d4038a2 --- /dev/null +++ b/node_modules/es-abstract/2021/RawBytesToNumeric.js @@ -0,0 +1,67 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); +var callBound = require('call-bound'); + +var $RangeError = require('es-errors/range'); +var $SyntaxError = require('es-errors/syntax'); +var $TypeError = require('es-errors/type'); +var $BigInt = GetIntrinsic('%BigInt%', true); + +var hasOwnProperty = require('./HasOwnProperty'); +var IsArray = require('./IsArray'); +var IsBigIntElementType = require('./IsBigIntElementType'); +var IsUnsignedElementType = require('./IsUnsignedElementType'); + +var bytesAsFloat32 = require('../helpers/bytesAsFloat32'); +var bytesAsFloat64 = require('../helpers/bytesAsFloat64'); +var bytesAsInteger = require('../helpers/bytesAsInteger'); +var every = require('../helpers/every'); +var isByteValue = require('../helpers/isByteValue'); + +var $reverse = callBound('Array.prototype.reverse'); +var $slice = callBound('Array.prototype.slice'); + +var tableTAO = require('./tables/typed-array-objects'); + +// https://262.ecma-international.org/11.0/#sec-rawbytestonumeric + +module.exports = function RawBytesToNumeric(type, rawBytes, isLittleEndian) { + if (typeof type !== 'string' || !hasOwnProperty(tableTAO.size, '$' + type)) { + throw new $TypeError('Assertion failed: `type` must be a TypedArray element type'); + } + if (!IsArray(rawBytes) || !every(rawBytes, isByteValue)) { + throw new $TypeError('Assertion failed: `rawBytes` must be an Array of bytes'); + } + if (typeof isLittleEndian !== 'boolean') { + throw new $TypeError('Assertion failed: `isLittleEndian` must be a Boolean'); + } + + var elementSize = tableTAO.size['$' + type]; // step 1 + + if (rawBytes.length !== elementSize) { + // this assertion is not in the spec, but it'd be an editorial error if it were ever violated + throw new $RangeError('Assertion failed: `rawBytes` must have a length of ' + elementSize + ' for type ' + type); + } + + var isBigInt = IsBigIntElementType(type); + if (isBigInt && !$BigInt) { + throw new $SyntaxError('this environment does not support BigInts'); + } + + // eslint-disable-next-line no-param-reassign + rawBytes = $slice(rawBytes, 0, elementSize); + if (!isLittleEndian) { + $reverse(rawBytes); // step 2 + } + + if (type === 'Float32') { // step 3 + return bytesAsFloat32(rawBytes); + } + + if (type === 'Float64') { // step 4 + return bytesAsFloat64(rawBytes); + } + + return bytesAsInteger(rawBytes, elementSize, IsUnsignedElementType(type), isBigInt); +}; diff --git a/node_modules/es-abstract/2021/RegExpCreate.js b/node_modules/es-abstract/2021/RegExpCreate.js new file mode 100644 index 0000000000000000000000000000000000000000..68e31605ed1764b9e1addddc5b910e9c9d73fba2 --- /dev/null +++ b/node_modules/es-abstract/2021/RegExpCreate.js @@ -0,0 +1,21 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $RegExp = GetIntrinsic('%RegExp%'); + +// var RegExpAlloc = require('./RegExpAlloc'); +// var RegExpInitialize = require('./RegExpInitialize'); +var ToString = require('./ToString'); + +// https://262.ecma-international.org/6.0/#sec-regexpcreate + +module.exports = function RegExpCreate(P, F) { + // var obj = RegExpAlloc($RegExp); + // return RegExpInitialize(obj, P, F); + + // covers spec mechanics; bypass regex brand checking + var pattern = typeof P === 'undefined' ? '' : ToString(P); + var flags = typeof F === 'undefined' ? '' : ToString(F); + return new $RegExp(pattern, flags); +}; diff --git a/node_modules/es-abstract/2021/RegExpExec.js b/node_modules/es-abstract/2021/RegExpExec.js new file mode 100644 index 0000000000000000000000000000000000000000..15762b8343aa380c2c90257eef552a87c56745ae --- /dev/null +++ b/node_modules/es-abstract/2021/RegExpExec.js @@ -0,0 +1,29 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); +var regexExec = require('call-bound')('RegExp.prototype.exec'); + +var Call = require('./Call'); +var Get = require('./Get'); +var IsCallable = require('./IsCallable'); + +// https://262.ecma-international.org/6.0/#sec-regexpexec + +module.exports = function RegExpExec(R, S) { + if (!isObject(R)) { + throw new $TypeError('Assertion failed: `R` must be an Object'); + } + if (typeof S !== 'string') { + throw new $TypeError('Assertion failed: `S` must be a String'); + } + var exec = Get(R, 'exec'); + if (IsCallable(exec)) { + var result = Call(exec, R, [S]); + if (result === null || isObject(result)) { + return result; + } + throw new $TypeError('"exec" method must return `null` or an Object'); + } + return regexExec(R, S); +}; diff --git a/node_modules/es-abstract/2021/RequireObjectCoercible.js b/node_modules/es-abstract/2021/RequireObjectCoercible.js new file mode 100644 index 0000000000000000000000000000000000000000..b816d1f34b01a80352e783672836a17c49cc06f0 --- /dev/null +++ b/node_modules/es-abstract/2021/RequireObjectCoercible.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('es-object-atoms/RequireObjectCoercible'); diff --git a/node_modules/es-abstract/2021/SameValue.js b/node_modules/es-abstract/2021/SameValue.js new file mode 100644 index 0000000000000000000000000000000000000000..d07bbb8a8f3fec5ad22ffdfb617245331fcff412 --- /dev/null +++ b/node_modules/es-abstract/2021/SameValue.js @@ -0,0 +1,13 @@ +'use strict'; + +var $isNaN = require('math-intrinsics/isNaN'); + +// http://262.ecma-international.org/5.1/#sec-9.12 + +module.exports = function SameValue(x, y) { + if (x === y) { // 0 === -0, but they are not identical. + if (x === 0) { return 1 / x === 1 / y; } + return true; + } + return $isNaN(x) && $isNaN(y); +}; diff --git a/node_modules/es-abstract/2021/SameValueNonNumeric.js b/node_modules/es-abstract/2021/SameValueNonNumeric.js new file mode 100644 index 0000000000000000000000000000000000000000..7c28e0f53c57f0fe4587928b6d91850992d91b8f --- /dev/null +++ b/node_modules/es-abstract/2021/SameValueNonNumeric.js @@ -0,0 +1,18 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var SameValue = require('./SameValue'); +var Type = require('./Type'); + +// https://262.ecma-international.org/11.0/#sec-samevaluenonnumeric + +module.exports = function SameValueNonNumeric(x, y) { + if (typeof x === 'number' || typeof x === 'bigint') { + throw new $TypeError('Assertion failed: SameValueNonNumeric does not accept Number or BigInt values'); + } + if (Type(x) !== Type(y)) { + throw new $TypeError('SameValueNonNumeric requires two non-numeric values of the same type.'); + } + return SameValue(x, y); +}; diff --git a/node_modules/es-abstract/2021/SameValueZero.js b/node_modules/es-abstract/2021/SameValueZero.js new file mode 100644 index 0000000000000000000000000000000000000000..8880e915941eeae2d890f2bdeb1bd057516e3d50 --- /dev/null +++ b/node_modules/es-abstract/2021/SameValueZero.js @@ -0,0 +1,9 @@ +'use strict'; + +var $isNaN = require('math-intrinsics/isNaN'); + +// https://262.ecma-international.org/6.0/#sec-samevaluezero + +module.exports = function SameValueZero(x, y) { + return (x === y) || ($isNaN(x) && $isNaN(y)); +}; diff --git a/node_modules/es-abstract/2021/SecFromTime.js b/node_modules/es-abstract/2021/SecFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..fc2e44560240f134cf345e63ab69d5f8a2d8cec1 --- /dev/null +++ b/node_modules/es-abstract/2021/SecFromTime.js @@ -0,0 +1,14 @@ +'use strict'; + +var floor = require('./floor'); +var modulo = require('./modulo'); + +var timeConstants = require('../helpers/timeConstants'); +var msPerSecond = timeConstants.msPerSecond; +var SecondsPerMinute = timeConstants.SecondsPerMinute; + +// https://262.ecma-international.org/5.1/#sec-15.9.1.10 + +module.exports = function SecFromTime(t) { + return modulo(floor(t / msPerSecond), SecondsPerMinute); +}; diff --git a/node_modules/es-abstract/2021/Set.js b/node_modules/es-abstract/2021/Set.js new file mode 100644 index 0000000000000000000000000000000000000000..f814076a8fb813648eb16093fe86a46182c0fccf --- /dev/null +++ b/node_modules/es-abstract/2021/Set.js @@ -0,0 +1,45 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var isPropertyKey = require('../helpers/isPropertyKey'); +var SameValue = require('./SameValue'); + +// IE 9 does not throw in strict mode when writability/configurability/extensibility is violated +var noThrowOnStrictViolation = (function () { + try { + delete [].length; + return true; + } catch (e) { + return false; + } +}()); + +// https://262.ecma-international.org/6.0/#sec-set-o-p-v-throw + +module.exports = function Set(O, P, V, Throw) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: `O` must be an Object'); + } + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: `P` must be a Property Key'); + } + if (typeof Throw !== 'boolean') { + throw new $TypeError('Assertion failed: `Throw` must be a Boolean'); + } + if (Throw) { + O[P] = V; // eslint-disable-line no-param-reassign + if (noThrowOnStrictViolation && !SameValue(O[P], V)) { + throw new $TypeError('Attempted to assign to readonly property.'); + } + return true; + } + try { + O[P] = V; // eslint-disable-line no-param-reassign + return noThrowOnStrictViolation ? SameValue(O[P], V) : true; + } catch (e) { + return false; + } + +}; diff --git a/node_modules/es-abstract/2021/SetFunctionLength.js b/node_modules/es-abstract/2021/SetFunctionLength.js new file mode 100644 index 0000000000000000000000000000000000000000..193be1c6a6d343f59353756163216d4fae5a57ff --- /dev/null +++ b/node_modules/es-abstract/2021/SetFunctionLength.js @@ -0,0 +1,28 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isInteger = require('math-intrinsics/isInteger'); + +var DefinePropertyOrThrow = require('./DefinePropertyOrThrow'); +var HasOwnProperty = require('./HasOwnProperty'); +var IsExtensible = require('./IsExtensible'); + +// https://262.ecma-international.org/12.0/#sec-setfunctionlength + +module.exports = function SetFunctionLength(F, length) { + if (typeof F !== 'function' || !IsExtensible(F) || HasOwnProperty(F, 'length')) { + throw new $TypeError('Assertion failed: `F` must be an extensible function and lack an own `length` property'); + } + if (typeof length !== 'number') { + throw new $TypeError('Assertion failed: `length` must be a Number'); + } + if (length !== Infinity && (!isInteger(length) || length < 0)) { + throw new $TypeError('Assertion failed: `length` must be ∞, or an integer >= 0'); + } + return DefinePropertyOrThrow(F, 'length', { + '[[Configurable]]': true, + '[[Enumerable]]': false, + '[[Value]]': length, + '[[Writable]]': false + }); +}; diff --git a/node_modules/es-abstract/2021/SetFunctionName.js b/node_modules/es-abstract/2021/SetFunctionName.js new file mode 100644 index 0000000000000000000000000000000000000000..9e8511fd46bc115d0459cc66f44bb6560ba2bc3a --- /dev/null +++ b/node_modules/es-abstract/2021/SetFunctionName.js @@ -0,0 +1,40 @@ +'use strict'; + +var hasOwn = require('hasown'); + +var $TypeError = require('es-errors/type'); + +var getSymbolDescription = require('get-symbol-description'); + +var DefinePropertyOrThrow = require('./DefinePropertyOrThrow'); +var IsExtensible = require('./IsExtensible'); + +// https://262.ecma-international.org/6.0/#sec-setfunctionname + +module.exports = function SetFunctionName(F, name) { + if (typeof F !== 'function') { + throw new $TypeError('Assertion failed: `F` must be a function'); + } + if (!IsExtensible(F) || hasOwn(F, 'name')) { + throw new $TypeError('Assertion failed: `F` must be extensible, and must not have a `name` own property'); + } + if (typeof name !== 'symbol' && typeof name !== 'string') { + throw new $TypeError('Assertion failed: `name` must be a Symbol or a String'); + } + if (typeof name === 'symbol') { + var description = getSymbolDescription(name); + // eslint-disable-next-line no-param-reassign + name = typeof description === 'undefined' ? '' : '[' + description + ']'; + } + if (arguments.length > 2) { + var prefix = arguments[2]; + // eslint-disable-next-line no-param-reassign + name = prefix + ' ' + name; + } + return DefinePropertyOrThrow(F, 'name', { + '[[Value]]': name, + '[[Writable]]': false, + '[[Enumerable]]': false, + '[[Configurable]]': true + }); +}; diff --git a/node_modules/es-abstract/2021/SetIntegrityLevel.js b/node_modules/es-abstract/2021/SetIntegrityLevel.js new file mode 100644 index 0000000000000000000000000000000000000000..ad92fb99b004f2b05e23fa0b2ef45dfc3775025e --- /dev/null +++ b/node_modules/es-abstract/2021/SetIntegrityLevel.js @@ -0,0 +1,57 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $SyntaxError = require('es-errors/syntax'); +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); +var $gOPD = require('gopd'); +var $preventExtensions = GetIntrinsic('%Object.preventExtensions%', true); +var $gOPN = GetIntrinsic('%Object.getOwnPropertyNames%', true); + +var forEach = require('../helpers/forEach'); + +var DefinePropertyOrThrow = require('./DefinePropertyOrThrow'); +var IsAccessorDescriptor = require('./IsAccessorDescriptor'); +var ToPropertyDescriptor = require('./ToPropertyDescriptor'); + +// https://262.ecma-international.org/6.0/#sec-setintegritylevel + +module.exports = function SetIntegrityLevel(O, level) { + if (!isObject(O)) { + 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); + if (level === 'sealed') { + forEach(theKeys, function (k) { + 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 (IsAccessorDescriptor(ToPropertyDescriptor(currentDesc))) { + desc = { configurable: false }; + } else { + desc = { configurable: false, writable: false }; + } + DefinePropertyOrThrow(O, k, desc); + } + }); + } + return true; +}; diff --git a/node_modules/es-abstract/2021/SetTypedArrayFromArrayLike.js b/node_modules/es-abstract/2021/SetTypedArrayFromArrayLike.js new file mode 100644 index 0000000000000000000000000000000000000000..2fd7d0190c3f05aa219d8cbc53b7351016b91425 --- /dev/null +++ b/node_modules/es-abstract/2021/SetTypedArrayFromArrayLike.js @@ -0,0 +1,96 @@ +'use strict'; + +var $RangeError = require('es-errors/range'); +var $TypeError = require('es-errors/type'); + +var isTypedArray = require('is-typed-array'); +var typedArrayBuffer = require('typed-array-buffer'); +var typedArrayByteOffset = require('typed-array-byte-offset'); +var typedArrayLength = require('typed-array-length'); +var whichTypedArray = require('which-typed-array'); +var isInteger = require('math-intrinsics/isInteger'); + +var Get = require('./Get'); +var IsBigIntElementType = require('./IsBigIntElementType'); +var IsDetachedBuffer = require('./IsDetachedBuffer'); +var LengthOfArrayLike = require('./LengthOfArrayLike'); +var SetValueInBuffer = require('./SetValueInBuffer'); +var ToBigInt = require('./ToBigInt'); +var ToNumber = require('./ToNumber'); +var ToObject = require('./ToObject'); +var ToString = require('./ToString'); + +var tableTAO = require('./tables/typed-array-objects'); + +// https://262.ecma-international.org/12.0/#sec-settypedarrayfromarraylike + +module.exports = function SetTypedArrayFromArrayLike(target, targetOffset, source) { + var whichTarget = whichTypedArray(target); + if (!whichTarget) { + throw new $TypeError('Assertion failed: target must be a TypedArray instance'); + } + + if (targetOffset !== Infinity && (!isInteger(targetOffset) || targetOffset < 0)) { + throw new $TypeError('Assertion failed: targetOffset must be a non-negative integer or +Infinity'); + } + + if (isTypedArray(source)) { + throw new $TypeError('Assertion failed: source must not be a TypedArray instance'); // step 1 + } + + var targetBuffer = typedArrayBuffer(target); // step 2 + + if (IsDetachedBuffer(targetBuffer)) { + throw new $TypeError('target’s buffer is detached'); // step 3 + } + + var targetLength = typedArrayLength(target); // step 4 + + var targetName = whichTarget; // step 5 + + var targetType = tableTAO.name['$' + targetName]; // step 7 + + var targetElementSize = tableTAO.size['$' + targetType]; // step 6 + + var targetByteOffset = typedArrayByteOffset(target); // step 8 + + var src = ToObject(source); // step 9 + + var srcLength = LengthOfArrayLike(src); // step 10 + + if (targetOffset === Infinity) { + throw new $RangeError('targetOffset must be a finite integer'); // step 11 + } + + if (srcLength + targetOffset > targetLength) { + throw new $RangeError('targetOffset + srcLength must be <= target.length'); // step 12 + } + + var targetByteIndex = (targetOffset * targetElementSize) + targetByteOffset; // step 13 + + var k = 0; // step 14 + + var limit = targetByteIndex + (targetElementSize * srcLength); // step 15 + + while (targetByteIndex < limit) { // step 16 + var Pk = ToString(k); // step 16.a + + var value = Get(src, Pk); // step 16.b + + if (IsBigIntElementType(targetType)) { + value = ToBigInt(value); // step 16.c + } else { + value = ToNumber(value); // step 16.d + } + + if (IsDetachedBuffer(targetBuffer)) { + throw new $TypeError('target’s buffer is detached'); // step 16.e + } + + SetValueInBuffer(targetBuffer, targetByteIndex, targetType, value, true, 'Unordered'); // step 16.f + + k += 1; // step 16.g + + targetByteIndex += targetElementSize; // step 16.h + } +}; diff --git a/node_modules/es-abstract/2021/SetTypedArrayFromTypedArray.js b/node_modules/es-abstract/2021/SetTypedArrayFromTypedArray.js new file mode 100644 index 0000000000000000000000000000000000000000..0ec52546759565e3934404c571c73383629bbf48 --- /dev/null +++ b/node_modules/es-abstract/2021/SetTypedArrayFromTypedArray.js @@ -0,0 +1,138 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $RangeError = require('es-errors/range'); +var $SyntaxError = require('es-errors/syntax'); +var $TypeError = require('es-errors/type'); +var $ArrayBuffer = GetIntrinsic('%ArrayBuffer%', true); + +var typedArrayBuffer = require('typed-array-buffer'); +var typedArrayByteLength = require('typed-array-byte-length'); +var typedArrayByteOffset = require('typed-array-byte-offset'); +var typedArrayLength = require('typed-array-length'); +var whichTypedArray = require('which-typed-array'); +var isInteger = require('math-intrinsics/isInteger'); + +var CloneArrayBuffer = require('./CloneArrayBuffer'); +var GetValueFromBuffer = require('./GetValueFromBuffer'); +var IsDetachedBuffer = require('./IsDetachedBuffer'); +var IsSharedArrayBuffer = require('./IsSharedArrayBuffer'); +var SameValue = require('./SameValue'); +var SetValueInBuffer = require('./SetValueInBuffer'); + +var tableTAO = require('./tables/typed-array-objects'); + +// https://262.ecma-international.org/12.0/#sec-settypedarrayfromtypedarray + +module.exports = function SetTypedArrayFromTypedArray(target, targetOffset, source) { + var whichTarget = whichTypedArray(target); + if (!whichTarget) { + throw new $TypeError('Assertion failed: target must be a TypedArray instance'); + } + + if (targetOffset !== Infinity && (!isInteger(targetOffset) || targetOffset < 0)) { + throw new $TypeError('Assertion failed: targetOffset must be a non-negative integer or +Infinity'); + } + + var whichSource = whichTypedArray(source); + if (!whichSource) { + throw new $TypeError('Assertion failed: source must be a TypedArray instance'); // step 1 + } + + var targetBuffer = typedArrayBuffer(target); // step 2 + + if (IsDetachedBuffer(targetBuffer)) { + throw new $TypeError('target’s buffer is detached'); // step 3 + } + + var targetLength = typedArrayLength(target); // step 4 + + var srcBuffer = typedArrayBuffer(source); // step 5 + + if (IsDetachedBuffer(srcBuffer)) { + throw new $TypeError('source’s buffer is detached'); // step 6 + } + + var targetName = whichTarget; // step 7 + + var targetType = tableTAO.name['$' + targetName]; // step 8 + + var targetElementSize = tableTAO.size['$' + targetType]; // step 9 + + var targetByteOffset = typedArrayByteOffset(target); // step 10 + + var srcName = whichSource; // step 11 + + var srcType = tableTAO.name['$' + srcName]; // step 12 + + var srcElementSize = tableTAO.size['$' + srcType]; // step 13 + + var srcLength = typedArrayLength(source); // step 14 + + var srcByteOffset = typedArrayByteOffset(source); // step 15 + + if (targetOffset === Infinity) { + throw new $RangeError('targetOffset must be a non-negative integer or +Infinity'); // step 16 + } + + if (srcLength + targetOffset > targetLength) { + throw new $RangeError('targetOffset + source.length must not be greater than target.length'); // step 17 + } + + var targetContentType = whichTarget === 'BigInt64Array' || whichTarget === 'BigUint64Array' ? 'BigInt' : 'Number'; + var sourceContentType = whichSource === 'BigInt64Array' || whichSource === 'BigUint64Array' ? 'BigInt' : 'Number'; + if (targetContentType !== sourceContentType) { + throw new $TypeError('source and target must have the same content type'); // step 18 + } + + var same; + if (IsSharedArrayBuffer(srcBuffer) && IsSharedArrayBuffer(targetBuffer)) { // step 19 + // a. If srcBuffer.[[ArrayBufferData]] and targetBuffer.[[ArrayBufferData]] are the same Shared Data Block values, let same be true; else let same be false. + throw new $SyntaxError('SharedArrayBuffer is not supported by this implementation'); + } else { + same = SameValue(srcBuffer, targetBuffer); // step 20 + } + + var srcByteIndex; + if (same) { // step 21 + var srcByteLength = typedArrayByteLength(source); // step 21.a + + srcBuffer = CloneArrayBuffer(srcBuffer, srcByteOffset, srcByteLength, $ArrayBuffer); // step 21.b + + // c. NOTE: %ArrayBuffer% is used to clone srcBuffer because is it known to not have any observable side-effects. + + srcByteIndex = 0; // step 21.d + } else { + srcByteIndex = srcByteOffset; // step 22 + } + + var targetByteIndex = (targetOffset * targetElementSize) + targetByteOffset; // step 23 + + var limit = targetByteIndex + (targetElementSize * srcLength); // step 24 + + var value; + if (srcType === targetType) { // step 25 + // a. NOTE: If srcType and targetType are the same, the transfer must be performed in a manner that preserves the bit-level encoding of the source data. + + while (targetByteIndex < limit) { // step 25.b + value = GetValueFromBuffer(srcBuffer, srcByteIndex, 'Uint8', true, 'Unordered'); // step 25.b.i + + SetValueInBuffer(targetBuffer, targetByteIndex, 'Uint8', value, true, 'Unordered'); // step 25.b.ii + + srcByteIndex += 1; // step 25.b.iii + + targetByteIndex += 1; // step 25.b.iv + } + } else { // step 26 + while (targetByteIndex < limit) { // step 26.a + value = GetValueFromBuffer(srcBuffer, srcByteIndex, srcType, true, 'Unordered'); // step 26.a.i + + SetValueInBuffer(targetBuffer, targetByteIndex, targetType, value, true, 'Unordered'); // step 26.a.ii + + srcByteIndex += srcElementSize; // step 26.a.iii + + targetByteIndex += targetElementSize; // step 26.a.iv + } + } +}; diff --git a/node_modules/es-abstract/2021/SetValueInBuffer.js b/node_modules/es-abstract/2021/SetValueInBuffer.js new file mode 100644 index 0000000000000000000000000000000000000000..c0e65e04ef0e1db888cbd7932faa84073c339754 --- /dev/null +++ b/node_modules/es-abstract/2021/SetValueInBuffer.js @@ -0,0 +1,92 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $SyntaxError = require('es-errors/syntax'); +var $TypeError = require('es-errors/type'); +var isInteger = require('math-intrinsics/isInteger'); +var $Uint8Array = GetIntrinsic('%Uint8Array%', true); + +var IsBigIntElementType = require('./IsBigIntElementType'); +var IsDetachedBuffer = require('./IsDetachedBuffer'); +var NumericToRawBytes = require('./NumericToRawBytes'); + +var isArrayBuffer = require('is-array-buffer'); +var isSharedArrayBuffer = require('is-shared-array-buffer'); +var hasOwn = require('hasown'); + +var tableTAO = require('./tables/typed-array-objects'); + +var defaultEndianness = require('../helpers/defaultEndianness'); +var forEach = require('../helpers/forEach'); + +// https://262.ecma-international.org/12.0/#sec-setvalueinbuffer + +/* eslint max-params: 0 */ + +module.exports = function SetValueInBuffer(arrayBuffer, byteIndex, type, value, isTypedArray, order) { + var isSAB = isSharedArrayBuffer(arrayBuffer); + if (!isArrayBuffer(arrayBuffer) && !isSAB) { + throw new $TypeError('Assertion failed: `arrayBuffer` must be an ArrayBuffer or a SharedArrayBuffer'); + } + + if (!isInteger(byteIndex) || byteIndex < 0) { + throw new $TypeError('Assertion failed: `byteIndex` must be a non-negative integer'); + } + + if (typeof type !== 'string' || !hasOwn(tableTAO.size, '$' + type)) { + throw new $TypeError('Assertion failed: `type` must be one of ' + tableTAO.choices); + } + + if (typeof value !== 'number' && typeof value !== 'bigint') { + throw new $TypeError('Assertion failed: `value` must be a Number or a BigInt'); + } + + if (typeof isTypedArray !== 'boolean') { + throw new $TypeError('Assertion failed: `isTypedArray` must be a boolean'); + } + if (order !== 'SeqCst' && order !== 'Unordered' && order !== 'Init') { + throw new $TypeError('Assertion failed: `order` must be `"SeqCst"`, `"Unordered"`, or `"Init"`'); + } + + if (arguments.length > 6 && typeof arguments[6] !== 'boolean') { + throw new $TypeError('Assertion failed: `isLittleEndian` must be a boolean, if present'); + } + + if (IsDetachedBuffer(arrayBuffer)) { + throw new $TypeError('Assertion failed: ArrayBuffer is detached'); // step 1 + } + + // 2. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type. + + if (IsBigIntElementType(type) ? typeof value !== 'bigint' : typeof value !== 'number') { // step 3 + throw new $TypeError('Assertion failed: `value` must be a BigInt if type is BigInt64 or BigUint64, otherwise a Number'); + } + + // 4. Let block be arrayBuffer’s [[ArrayBufferData]] internal slot. + + var elementSize = tableTAO.size['$' + type]; // step 5 + + // 6. If isLittleEndian is not present, set isLittleEndian to either true or false. The choice is implementation dependent and should be the alternative that is most efficient for the implementation. An implementation must use the same value each time this step is executed and the same value must be used for the corresponding step in the GetValueFromBuffer abstract operation. + var isLittleEndian = arguments.length > 6 ? arguments[6] : defaultEndianness === 'little'; // step 6 + + var rawBytes = NumericToRawBytes(type, value, isLittleEndian); // step 7 + + if (isSAB) { // step 8 + /* + Let execution be the [[CandidateExecution]] field of the surrounding agent's Agent Record. + Let eventList be the [[EventList]] field of the element in execution.[[EventsRecords]] whose [[AgentSignifier]] is AgentSignifier(). + If isTypedArray is true and IsNoTearConfiguration(type, order) is true, let noTear be true; otherwise let noTear be false. + Append WriteSharedMemory { [[Order]]: order, [[NoTear]]: noTear, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize, [[Payload]]: rawBytes } to eventList. + */ + throw new $SyntaxError('SharedArrayBuffer is not supported by this implementation'); + } else { + // 9. Store the individual bytes of rawBytes into block, in order, starting at block[byteIndex]. + var arr = new $Uint8Array(arrayBuffer, byteIndex, elementSize); + forEach(rawBytes, function (rawByte, i) { + arr[i] = rawByte; + }); + } + + // 10. Return NormalCompletion(undefined). +}; diff --git a/node_modules/es-abstract/2021/SpeciesConstructor.js b/node_modules/es-abstract/2021/SpeciesConstructor.js new file mode 100644 index 0000000000000000000000000000000000000000..23e32b443ef3655f56639920d5cf58474500bf67 --- /dev/null +++ b/node_modules/es-abstract/2021/SpeciesConstructor.js @@ -0,0 +1,32 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $species = GetIntrinsic('%Symbol.species%', true); +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var IsConstructor = require('./IsConstructor'); + +// https://262.ecma-international.org/6.0/#sec-speciesconstructor + +module.exports = function SpeciesConstructor(O, defaultConstructor) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + var C = O.constructor; + if (typeof C === 'undefined') { + return defaultConstructor; + } + if (!isObject(C)) { + throw new $TypeError('O.constructor is not an Object'); + } + var S = $species ? C[$species] : void 0; + if (S == null) { + return defaultConstructor; + } + if (IsConstructor(S)) { + return S; + } + throw new $TypeError('no constructor found'); +}; diff --git a/node_modules/es-abstract/2021/SplitMatch.js b/node_modules/es-abstract/2021/SplitMatch.js new file mode 100644 index 0000000000000000000000000000000000000000..3b0c07efb608545a6bdc0d07cda59afb6f412bb0 --- /dev/null +++ b/node_modules/es-abstract/2021/SplitMatch.js @@ -0,0 +1,35 @@ +'use strict'; + +var callBound = require('call-bound'); + +var $TypeError = require('es-errors/type'); +var isInteger = require('math-intrinsics/isInteger'); + +var $charAt = callBound('String.prototype.charAt'); + +// https://262.ecma-international.org/12.0/#sec-splitmatch + +module.exports = function SplitMatch(S, q, R) { + if (typeof S !== 'string') { + throw new $TypeError('Assertion failed: `S` must be a String'); + } + if (!isInteger(q)) { + throw new $TypeError('Assertion failed: `q` must be an integer'); + } + if (typeof R !== 'string') { + throw new $TypeError('Assertion failed: `R` must be a String'); + } + var r = R.length; + var s = S.length; + if (q + r > s) { + return 'not-matched'; + } + + for (var i = 0; i < r; i += 1) { + if ($charAt(S, q + i) !== $charAt(R, i)) { + return 'not-matched'; + } + } + + return q + r; +}; diff --git a/node_modules/es-abstract/2021/StrictEqualityComparison.js b/node_modules/es-abstract/2021/StrictEqualityComparison.js new file mode 100644 index 0000000000000000000000000000000000000000..d056c44e79a546022718908720ab19cd27e7415e --- /dev/null +++ b/node_modules/es-abstract/2021/StrictEqualityComparison.js @@ -0,0 +1,15 @@ +'use strict'; + +var Type = require('./Type'); + +// https://262.ecma-international.org/5.1/#sec-11.9.6 + +module.exports = function StrictEqualityComparison(x, y) { + if (Type(x) !== Type(y)) { + return false; + } + if (typeof x === 'undefined' || x === null) { + return true; + } + return x === y; // shortcut for steps 4-7 +}; diff --git a/node_modules/es-abstract/2021/StringCreate.js b/node_modules/es-abstract/2021/StringCreate.js new file mode 100644 index 0000000000000000000000000000000000000000..3e2aa43c50d8aa6317c0eef7eaf0b87e32916d4d --- /dev/null +++ b/node_modules/es-abstract/2021/StringCreate.js @@ -0,0 +1,38 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $Object = require('es-object-atoms'); +var $StringPrototype = GetIntrinsic('%String.prototype%'); +var $SyntaxError = require('es-errors/syntax'); +var $TypeError = require('es-errors/type'); +var setProto = require('set-proto'); + +var DefinePropertyOrThrow = require('./DefinePropertyOrThrow'); + +// https://262.ecma-international.org/6.0/#sec-stringcreate + +module.exports = function StringCreate(value, prototype) { + if (typeof value !== 'string') { + throw new $TypeError('Assertion failed: `S` must be a String'); + } + + var S = $Object(value); + if (prototype !== $StringPrototype) { + if (setProto) { + setProto(S, prototype); + } else { + throw new $SyntaxError('StringCreate: a `proto` argument that is not `String.prototype` is not supported in an environment that does not support setting the [[Prototype]]'); + } + } + + var length = value.length; + DefinePropertyOrThrow(S, 'length', { + '[[Configurable]]': false, + '[[Enumerable]]': false, + '[[Value]]': length, + '[[Writable]]': false + }); + + return S; +}; diff --git a/node_modules/es-abstract/2021/StringGetOwnProperty.js b/node_modules/es-abstract/2021/StringGetOwnProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..59e8a23f8969db47a1f1eae85a542594c4b64406 --- /dev/null +++ b/node_modules/es-abstract/2021/StringGetOwnProperty.js @@ -0,0 +1,46 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isNegativeZero = require('math-intrinsics/isNegativeZero'); +var isObject = require('es-object-atoms/isObject'); + +var callBound = require('call-bound'); +var $charAt = callBound('String.prototype.charAt'); +var $stringToString = callBound('String.prototype.toString'); + +var CanonicalNumericIndexString = require('./CanonicalNumericIndexString'); + +var isPropertyKey = require('../helpers/isPropertyKey'); +var isInteger = require('math-intrinsics/isInteger'); + +// https://262.ecma-international.org/12.0/#sec-stringgetownproperty + +module.exports = function StringGetOwnProperty(S, P) { + var str; + if (isObject(S)) { + try { + str = $stringToString(S); + } catch (e) { /**/ } + } + if (typeof str !== 'string') { + throw new $TypeError('Assertion failed: `S` must be a boxed string object'); + } + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: P is not a Property Key'); + } + if (typeof P !== 'string') { + return void undefined; + } + var index = CanonicalNumericIndexString(P); + var len = str.length; + if (typeof index === 'undefined' || !isInteger(index) || isNegativeZero(index) || index < 0 || len <= index) { + return void undefined; + } + var resultStr = $charAt(S, index); + return { + '[[Configurable]]': false, + '[[Enumerable]]': true, + '[[Value]]': resultStr, + '[[Writable]]': false + }; +}; diff --git a/node_modules/es-abstract/2021/StringIndexOf.js b/node_modules/es-abstract/2021/StringIndexOf.js new file mode 100644 index 0000000000000000000000000000000000000000..a1fce808019201ec1c5689884e822860c1c75472 --- /dev/null +++ b/node_modules/es-abstract/2021/StringIndexOf.js @@ -0,0 +1,36 @@ +'use strict'; + +var callBound = require('call-bound'); + +var $TypeError = require('es-errors/type'); +var isInteger = require('math-intrinsics/isInteger'); + +var $slice = callBound('String.prototype.slice'); + +// https://262.ecma-international.org/12.0/#sec-stringindexof + +module.exports = function StringIndexOf(string, searchValue, fromIndex) { + if (typeof string !== 'string') { + throw new $TypeError('Assertion failed: `string` must be a String'); + } + if (typeof searchValue !== 'string') { + throw new $TypeError('Assertion failed: `searchValue` must be a String'); + } + if (!isInteger(fromIndex) || fromIndex < 0) { + throw new $TypeError('Assertion failed: `fromIndex` must be a non-negative integer'); + } + + var len = string.length; + if (searchValue === '' && fromIndex <= len) { + return fromIndex; + } + + var searchLen = searchValue.length; + for (var i = fromIndex; i <= (len - searchLen); i += 1) { + var candidate = $slice(string, i, i + searchLen); + if (candidate === searchValue) { + return i; + } + } + return -1; +}; diff --git a/node_modules/es-abstract/2021/StringPad.js b/node_modules/es-abstract/2021/StringPad.js new file mode 100644 index 0000000000000000000000000000000000000000..473b0b7bd490c72f1d1b90bd2a56f6d638fb0000 --- /dev/null +++ b/node_modules/es-abstract/2021/StringPad.js @@ -0,0 +1,41 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var callBound = require('call-bound'); + +var ToLength = require('./ToLength'); +var ToString = require('./ToString'); + +var $strSlice = callBound('String.prototype.slice'); + +// https://262.ecma-international.org/11.0/#sec-stringpad + +module.exports = function StringPad(O, maxLength, fillString, placement) { + if (placement !== 'start' && placement !== 'end') { + throw new $TypeError('Assertion failed: `placement` must be "start" or "end"'); + } + var S = ToString(O); + var intMaxLength = ToLength(maxLength); + var stringLength = S.length; + if (intMaxLength <= stringLength) { + return S; + } + var filler = typeof fillString === 'undefined' ? ' ' : ToString(fillString); + if (filler === '') { + return S; + } + var fillLen = intMaxLength - stringLength; + + // the String value consisting of repeated concatenations of filler truncated to length fillLen. + var truncatedStringFiller = ''; + while (truncatedStringFiller.length < fillLen) { + truncatedStringFiller += filler; + } + truncatedStringFiller = $strSlice(truncatedStringFiller, 0, fillLen); + + if (placement === 'start') { + return truncatedStringFiller + S; + } + return S + truncatedStringFiller; +}; diff --git a/node_modules/es-abstract/2021/StringToBigInt.js b/node_modules/es-abstract/2021/StringToBigInt.js new file mode 100644 index 0000000000000000000000000000000000000000..896c3bdc338a3f569dd7ac3065594be72ea35316 --- /dev/null +++ b/node_modules/es-abstract/2021/StringToBigInt.js @@ -0,0 +1,23 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $BigInt = GetIntrinsic('%BigInt%', true); +var $TypeError = require('es-errors/type'); +var $SyntaxError = require('es-errors/syntax'); + +// https://262.ecma-international.org/11.0/#sec-stringtobigint + +module.exports = function StringToBigInt(argument) { + if (typeof argument !== 'string') { + throw new $TypeError('`argument` must be a string'); + } + if (!$BigInt) { + throw new $SyntaxError('BigInts are not supported in this environment'); + } + try { + return $BigInt(argument); + } catch (e) { + return NaN; + } +}; diff --git a/node_modules/es-abstract/2021/StringToCodePoints.js b/node_modules/es-abstract/2021/StringToCodePoints.js new file mode 100644 index 0000000000000000000000000000000000000000..9a104c41ac2fb5b9d3181d23172df9430c7a3827 --- /dev/null +++ b/node_modules/es-abstract/2021/StringToCodePoints.js @@ -0,0 +1,22 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var CodePointAt = require('./CodePointAt'); + +// https://262.ecma-international.org/12.0/#sec-stringtocodepoints + +module.exports = function StringToCodePoints(string) { + if (typeof string !== 'string') { + throw new $TypeError('Assertion failed: `string` must be a String'); + } + var codePoints = []; + var size = string.length; + var position = 0; + while (position < size) { + var cp = CodePointAt(string, position); + codePoints[codePoints.length] = cp['[[CodePoint]]']; + position += cp['[[CodeUnitCount]]']; + } + return codePoints; +}; diff --git a/node_modules/es-abstract/2021/SymbolDescriptiveString.js b/node_modules/es-abstract/2021/SymbolDescriptiveString.js new file mode 100644 index 0000000000000000000000000000000000000000..444e3f70004626a3053f672a290e5e81b0f5cf51 --- /dev/null +++ b/node_modules/es-abstract/2021/SymbolDescriptiveString.js @@ -0,0 +1,16 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var callBound = require('call-bound'); + +var $SymbolToString = callBound('Symbol.prototype.toString', true); + +// https://262.ecma-international.org/6.0/#sec-symboldescriptivestring + +module.exports = function SymbolDescriptiveString(sym) { + if (typeof sym !== 'symbol') { + throw new $TypeError('Assertion failed: `sym` must be a Symbol'); + } + return $SymbolToString(sym); +}; diff --git a/node_modules/es-abstract/2021/TestIntegrityLevel.js b/node_modules/es-abstract/2021/TestIntegrityLevel.js new file mode 100644 index 0000000000000000000000000000000000000000..0e802f42786f89bac378b6a58e6009c9620be721 --- /dev/null +++ b/node_modules/es-abstract/2021/TestIntegrityLevel.js @@ -0,0 +1,40 @@ +'use strict'; + +var $gOPD = require('gopd'); +var $TypeError = require('es-errors/type'); + +var every = require('../helpers/every'); +var OwnPropertyKeys = require('own-keys'); +var isObject = require('es-object-atoms/isObject'); + +var IsDataDescriptor = require('./IsDataDescriptor'); +var IsExtensible = require('./IsExtensible'); +var ToPropertyDescriptor = require('./ToPropertyDescriptor'); + +// https://262.ecma-international.org/6.0/#sec-testintegritylevel + +module.exports = function TestIntegrityLevel(O, level) { + if (!isObject(O)) { + 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 = IsExtensible(O); + if (status || !$gOPD) { + return false; + } + var theKeys = OwnPropertyKeys(O); + 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' && IsDataDescriptor(ToPropertyDescriptor(currentDesc)) && currentDesc.writable) { + return false; + } + } + return true; + }); +}; diff --git a/node_modules/es-abstract/2021/ThrowCompletion.js b/node_modules/es-abstract/2021/ThrowCompletion.js new file mode 100644 index 0000000000000000000000000000000000000000..b7d388a35292e2a9faf88d4808b74e2c4878bbe7 --- /dev/null +++ b/node_modules/es-abstract/2021/ThrowCompletion.js @@ -0,0 +1,9 @@ +'use strict'; + +var CompletionRecord = require('./CompletionRecord'); + +// https://262.ecma-international.org/9.0/#sec-throwcompletion + +module.exports = function ThrowCompletion(argument) { + return new CompletionRecord('throw', argument); +}; diff --git a/node_modules/es-abstract/2021/TimeClip.js b/node_modules/es-abstract/2021/TimeClip.js new file mode 100644 index 0000000000000000000000000000000000000000..77c8dd4226c4765855024b1784b842f869fa5bfe --- /dev/null +++ b/node_modules/es-abstract/2021/TimeClip.js @@ -0,0 +1,20 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $Date = GetIntrinsic('%Date%'); + +var $isFinite = require('math-intrinsics/isFinite'); +var abs = require('math-intrinsics/abs'); + +var ToNumber = require('./ToNumber'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.14 + +module.exports = function TimeClip(time) { + if (!$isFinite(time) || abs(time) > 8.64e15) { + return NaN; + } + return +new $Date(ToNumber(time)); +}; + diff --git a/node_modules/es-abstract/2021/TimeFromYear.js b/node_modules/es-abstract/2021/TimeFromYear.js new file mode 100644 index 0000000000000000000000000000000000000000..f3518a41a19146c9ba59e1362c3fb33f800daaa1 --- /dev/null +++ b/node_modules/es-abstract/2021/TimeFromYear.js @@ -0,0 +1,11 @@ +'use strict'; + +var msPerDay = require('../helpers/timeConstants').msPerDay; + +var DayFromYear = require('./DayFromYear'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.3 + +module.exports = function TimeFromYear(y) { + return msPerDay * DayFromYear(y); +}; diff --git a/node_modules/es-abstract/2021/TimeString.js b/node_modules/es-abstract/2021/TimeString.js new file mode 100644 index 0000000000000000000000000000000000000000..f79080d6c3523a6d272d53f45a1e1501b655ae75 --- /dev/null +++ b/node_modules/es-abstract/2021/TimeString.js @@ -0,0 +1,22 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var $isNaN = require('math-intrinsics/isNaN'); +var padTimeComponent = require('../helpers/padTimeComponent'); + +var HourFromTime = require('./HourFromTime'); +var MinFromTime = require('./MinFromTime'); +var SecFromTime = require('./SecFromTime'); + +// https://262.ecma-international.org/9.0/#sec-timestring + +module.exports = function TimeString(tv) { + if (typeof tv !== 'number' || $isNaN(tv)) { + throw new $TypeError('Assertion failed: `tv` must be a non-NaN Number'); + } + var hour = HourFromTime(tv); + var minute = MinFromTime(tv); + var second = SecFromTime(tv); + return padTimeComponent(hour) + ':' + padTimeComponent(minute) + ':' + padTimeComponent(second) + '\x20GMT'; +}; diff --git a/node_modules/es-abstract/2021/TimeWithinDay.js b/node_modules/es-abstract/2021/TimeWithinDay.js new file mode 100644 index 0000000000000000000000000000000000000000..2bba83386c141873d3b603ed19d0f37069d1016a --- /dev/null +++ b/node_modules/es-abstract/2021/TimeWithinDay.js @@ -0,0 +1,12 @@ +'use strict'; + +var modulo = require('./modulo'); + +var msPerDay = require('../helpers/timeConstants').msPerDay; + +// https://262.ecma-international.org/5.1/#sec-15.9.1.2 + +module.exports = function TimeWithinDay(t) { + return modulo(t, msPerDay); +}; + diff --git a/node_modules/es-abstract/2021/TimeZoneString.js b/node_modules/es-abstract/2021/TimeZoneString.js new file mode 100644 index 0000000000000000000000000000000000000000..e10e09419a83237d23d9ca335f8cfbd30fb801c0 --- /dev/null +++ b/node_modules/es-abstract/2021/TimeZoneString.js @@ -0,0 +1,38 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $Date = GetIntrinsic('%Date%'); +var $TypeError = require('es-errors/type'); + +var isNaN = require('math-intrinsics/isNaN'); + +var callBound = require('call-bound'); + +var $indexOf = callBound('String.prototype.indexOf'); +var $slice = callBound('String.prototype.slice'); +var $toTimeString = callBound('Date.prototype.toTimeString'); + +// https://262.ecma-international.org/12.0/#sec-timezoneestring + +module.exports = function TimeZoneString(tv) { + if (typeof tv !== 'number' || isNaN(tv)) { + throw new $TypeError('Assertion failed: `tv` must be a non-NaN Number'); // steps 1 - 2 + } + + // 3. Let offset be LocalTZA(tv, true). + // 4. If offset ≥ +0𝔽, then + // a. Let offsetSign be "+". + // b. Let absOffset be offset. + // 5. Else, + // a. Let offsetSign be "-". + // b. Let absOffset be -offset. + // 6. Let offsetMin be the String representation of MinFromTime(absOffset), formatted as a two-digit decimal number, padded to the left with the code unit 0x0030 (DIGIT ZERO) if necessary. + // 7. Let offsetHour be the String representation of HourFromTime(absOffset), formatted as a two-digit decimal number, padded to the left with the code unit 0x0030 (DIGIT ZERO) if necessary. + // 8. Let tzName be an implementation-defined string that is either the empty String or the string-concatenation of the code unit 0x0020 (SPACE), the code unit 0x0028 (LEFT PARENTHESIS), an implementation-defined timezone name, and the code unit 0x0029 (RIGHT PARENTHESIS). + // 9. Return the string-concatenation of offsetSign, offsetHour, offsetMin, and tzName. + + // hack until LocalTZA, and "implementation-defined string" are available + var ts = $toTimeString(new $Date(tv)); + return $slice(ts, $indexOf(ts, '(') + 1, $indexOf(ts, ')')); +}; diff --git a/node_modules/es-abstract/2021/ToBigInt.js b/node_modules/es-abstract/2021/ToBigInt.js new file mode 100644 index 0000000000000000000000000000000000000000..4d1feefd492a36739d908deb6c160f1dedb62359 --- /dev/null +++ b/node_modules/es-abstract/2021/ToBigInt.js @@ -0,0 +1,53 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $BigInt = GetIntrinsic('%BigInt%', true); +var $Number = GetIntrinsic('%Number%'); +var $TypeError = require('es-errors/type'); +var $SyntaxError = require('es-errors/syntax'); + +var StringToBigInt = require('./StringToBigInt'); +var ToPrimitive = require('./ToPrimitive'); + +var isNaN = require('math-intrinsics/isNaN'); + +// https://262.ecma-international.org/11.0/#sec-tobigint + +module.exports = function ToBigInt(argument) { + if (!$BigInt) { + throw new $SyntaxError('BigInts are not supported in this environment'); + } + + var prim = ToPrimitive(argument, $Number); + + if (prim == null) { + throw new $TypeError('Cannot convert null or undefined to a BigInt'); + } + + if (typeof prim === 'boolean') { + return prim ? $BigInt(1) : $BigInt(0); + } + + if (typeof prim === 'number') { + throw new $TypeError('Cannot convert a Number value to a BigInt'); + } + + if (typeof prim === 'string') { + var n = StringToBigInt(prim); + if (isNaN(n)) { + throw new $TypeError('Failed to parse String to BigInt'); + } + return n; + } + + if (typeof prim === 'symbol') { + throw new $TypeError('Cannot convert a Symbol value to a BigInt'); + } + + if (typeof prim !== 'bigint') { + throw new $SyntaxError('Assertion failed: unknown primitive type'); + } + + return prim; +}; diff --git a/node_modules/es-abstract/2021/ToBigInt64.js b/node_modules/es-abstract/2021/ToBigInt64.js new file mode 100644 index 0000000000000000000000000000000000000000..627acba3d06e0e6d1e8b0b91088efbc7d6d42b0a --- /dev/null +++ b/node_modules/es-abstract/2021/ToBigInt64.js @@ -0,0 +1,25 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $BigInt = GetIntrinsic('%BigInt%', true); +var $pow = require('math-intrinsics/pow'); + +var ToBigInt = require('./ToBigInt'); +var BigIntRemainder = require('./BigInt/remainder'); + +var modBigInt = require('../helpers/modBigInt'); + +// BigInt(2**63), but node v10.4-v10.8 have a bug where you can't `BigInt(x)` anything larger than MAX_SAFE_INTEGER +var twoSixtyThree = $BigInt && (BigInt($pow(2, 32)) * BigInt($pow(2, 31))); + +// BigInt(2**64), but node v10.4-v10.8 have a bug where you can't `BigInt(x)` anything larger than MAX_SAFE_INTEGER +var twoSixtyFour = $BigInt && (BigInt($pow(2, 32)) * BigInt($pow(2, 32))); + +// https://262.ecma-international.org/11.0/#sec-tobigint64 + +module.exports = function ToBigInt64(argument) { + var n = ToBigInt(argument); + var int64bit = modBigInt(BigIntRemainder, n, twoSixtyFour); + return int64bit >= twoSixtyThree ? int64bit - twoSixtyFour : int64bit; +}; diff --git a/node_modules/es-abstract/2021/ToBigUint64.js b/node_modules/es-abstract/2021/ToBigUint64.js new file mode 100644 index 0000000000000000000000000000000000000000..f4038dc7bcaceb9b24157f6e6bcdfa286138f785 --- /dev/null +++ b/node_modules/es-abstract/2021/ToBigUint64.js @@ -0,0 +1,23 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $BigInt = GetIntrinsic('%BigInt%', true); + +var $pow = require('math-intrinsics/pow'); + +var ToBigInt = require('./ToBigInt'); +var BigIntRemainder = require('./BigInt/remainder'); + +var modBigInt = require('../helpers/modBigInt'); + +// BigInt(2**64), but node v10.4-v10.8 have a bug where you can't `BigInt(x)` anything larger than MAX_SAFE_INTEGER +var twoSixtyFour = $BigInt && (BigInt($pow(2, 32)) * BigInt($pow(2, 32))); + +// https://262.ecma-international.org/11.0/#sec-tobiguint64 + +module.exports = function ToBigUint64(argument) { + var n = ToBigInt(argument); + var int64bit = modBigInt(BigIntRemainder, n, twoSixtyFour); + return int64bit; +}; diff --git a/node_modules/es-abstract/2021/ToBoolean.js b/node_modules/es-abstract/2021/ToBoolean.js new file mode 100644 index 0000000000000000000000000000000000000000..466404bf9992f0ba636249264c620d6c56215d6a --- /dev/null +++ b/node_modules/es-abstract/2021/ToBoolean.js @@ -0,0 +1,5 @@ +'use strict'; + +// http://262.ecma-international.org/5.1/#sec-9.2 + +module.exports = function ToBoolean(value) { return !!value; }; diff --git a/node_modules/es-abstract/2021/ToDateString.js b/node_modules/es-abstract/2021/ToDateString.js new file mode 100644 index 0000000000000000000000000000000000000000..d9bb434185ca0adfa055d91bf592efdce3ed1d94 --- /dev/null +++ b/node_modules/es-abstract/2021/ToDateString.js @@ -0,0 +1,21 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = require('es-errors/type'); +var $Date = GetIntrinsic('%Date%'); +var $String = GetIntrinsic('%String%'); + +var $isNaN = require('math-intrinsics/isNaN'); + +// https://262.ecma-international.org/6.0/#sec-todatestring + +module.exports = function ToDateString(tv) { + if (typeof tv !== 'number') { + throw new $TypeError('Assertion failed: `tv` must be a Number'); + } + if ($isNaN(tv)) { + return 'Invalid Date'; + } + return $String(new $Date(tv)); +}; diff --git a/node_modules/es-abstract/2021/ToIndex.js b/node_modules/es-abstract/2021/ToIndex.js new file mode 100644 index 0000000000000000000000000000000000000000..4123e71d9afada85ec326d03ea0cdbfbdded2600 --- /dev/null +++ b/node_modules/es-abstract/2021/ToIndex.js @@ -0,0 +1,24 @@ +'use strict'; + +var $RangeError = require('es-errors/range'); + +var ToIntegerOrInfinity = require('./ToIntegerOrInfinity'); +var ToLength = require('./ToLength'); +var SameValue = require('./SameValue'); + +// https://262.ecma-international.org/8.0/#sec-toindex + +module.exports = function ToIndex(value) { + if (typeof value === 'undefined') { + return 0; + } + var integerIndex = ToIntegerOrInfinity(value); + if (integerIndex < 0) { + throw new $RangeError('index must be >= 0'); + } + var index = ToLength(integerIndex); + if (!SameValue(integerIndex, index)) { + throw new $RangeError('index must be >= 0 and < 2 ** 53 - 1'); + } + return index; +}; diff --git a/node_modules/es-abstract/2021/ToInt16.js b/node_modules/es-abstract/2021/ToInt16.js new file mode 100644 index 0000000000000000000000000000000000000000..21694bdeb923cd78791c7c01e242d892b4833af0 --- /dev/null +++ b/node_modules/es-abstract/2021/ToInt16.js @@ -0,0 +1,10 @@ +'use strict'; + +var ToUint16 = require('./ToUint16'); + +// https://262.ecma-international.org/6.0/#sec-toint16 + +module.exports = function ToInt16(argument) { + var int16bit = ToUint16(argument); + return int16bit >= 0x8000 ? int16bit - 0x10000 : int16bit; +}; diff --git a/node_modules/es-abstract/2021/ToInt32.js b/node_modules/es-abstract/2021/ToInt32.js new file mode 100644 index 0000000000000000000000000000000000000000..b879ccc479e039097fa2d1017299579a2d8a8162 --- /dev/null +++ b/node_modules/es-abstract/2021/ToInt32.js @@ -0,0 +1,9 @@ +'use strict'; + +var ToNumber = require('./ToNumber'); + +// http://262.ecma-international.org/5.1/#sec-9.5 + +module.exports = function ToInt32(x) { + return ToNumber(x) >> 0; +}; diff --git a/node_modules/es-abstract/2021/ToInt8.js b/node_modules/es-abstract/2021/ToInt8.js new file mode 100644 index 0000000000000000000000000000000000000000..e223b6c1d352a3432da2d272d0f7e66bbfa818b4 --- /dev/null +++ b/node_modules/es-abstract/2021/ToInt8.js @@ -0,0 +1,10 @@ +'use strict'; + +var ToUint8 = require('./ToUint8'); + +// https://262.ecma-international.org/6.0/#sec-toint8 + +module.exports = function ToInt8(argument) { + var int8bit = ToUint8(argument); + return int8bit >= 0x80 ? int8bit - 0x100 : int8bit; +}; diff --git a/node_modules/es-abstract/2021/ToIntegerOrInfinity.js b/node_modules/es-abstract/2021/ToIntegerOrInfinity.js new file mode 100644 index 0000000000000000000000000000000000000000..c21dc4437085a4d9a157464ee8648ae486d6c48f --- /dev/null +++ b/node_modules/es-abstract/2021/ToIntegerOrInfinity.js @@ -0,0 +1,20 @@ +'use strict'; + +var abs = require('./abs'); +var floor = require('./floor'); +var ToNumber = require('./ToNumber'); + +var $isNaN = require('math-intrinsics/isNaN'); +var $isFinite = require('math-intrinsics/isFinite'); +var $sign = require('math-intrinsics/sign'); + +// https://262.ecma-international.org/12.0/#sec-tointegerorinfinity + +module.exports = function ToIntegerOrInfinity(value) { + var number = ToNumber(value); + if ($isNaN(number) || number === 0) { return 0; } + if (!$isFinite(number)) { return number; } + var integer = floor(abs(number)); + if (integer === 0) { return 0; } + return $sign(number) * integer; +}; diff --git a/node_modules/es-abstract/2021/ToLength.js b/node_modules/es-abstract/2021/ToLength.js new file mode 100644 index 0000000000000000000000000000000000000000..12c9aac8680d49bfe8591a9a5a4a645d6ca9d18e --- /dev/null +++ b/node_modules/es-abstract/2021/ToLength.js @@ -0,0 +1,14 @@ +'use strict'; + +var MAX_SAFE_INTEGER = require('math-intrinsics/constants/maxSafeInteger'); + +var ToIntegerOrInfinity = require('./ToIntegerOrInfinity'); + +// https://262.ecma-international.org/12.0/#sec-tolength + +module.exports = function ToLength(argument) { + var len = ToIntegerOrInfinity(argument); + if (len <= 0) { return 0; } // includes converting -0 to +0 + if (len > MAX_SAFE_INTEGER) { return MAX_SAFE_INTEGER; } + return len; +}; diff --git a/node_modules/es-abstract/2021/ToNumber.js b/node_modules/es-abstract/2021/ToNumber.js new file mode 100644 index 0000000000000000000000000000000000000000..bf3cae3f2b378bdc19eeb7148b9309684fe395e8 --- /dev/null +++ b/node_modules/es-abstract/2021/ToNumber.js @@ -0,0 +1,51 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = require('es-errors/type'); +var $Number = GetIntrinsic('%Number%'); +var $RegExp = GetIntrinsic('%RegExp%'); +var $parseInteger = GetIntrinsic('%parseInt%'); + +var callBound = require('call-bound'); +var regexTester = require('safe-regex-test'); +var isPrimitive = require('../helpers/isPrimitive'); + +var $strSlice = callBound('String.prototype.slice'); +var isBinary = regexTester(/^0b[01]+$/i); +var isOctal = regexTester(/^0o[0-7]+$/i); +var isInvalidHexLiteral = regexTester(/^[-+]0x[0-9a-f]+$/i); +var nonWS = ['\u0085', '\u200b', '\ufffe'].join(''); +var nonWSregex = new $RegExp('[' + nonWS + ']', 'g'); +var hasNonWS = regexTester(nonWSregex); + +var $trim = require('string.prototype.trim'); + +var ToPrimitive = require('./ToPrimitive'); + +// https://262.ecma-international.org/6.0/#sec-tonumber + +module.exports = function ToNumber(argument) { + var value = isPrimitive(argument) ? argument : ToPrimitive(argument, $Number); + if (typeof value === 'symbol') { + throw new $TypeError('Cannot convert a Symbol value to a number'); + } + if (typeof value === 'bigint') { + throw new $TypeError('Conversion from \'BigInt\' to \'number\' is not allowed.'); + } + if (typeof value === 'string') { + if (isBinary(value)) { + return ToNumber($parseInteger($strSlice(value, 2), 2)); + } else if (isOctal(value)) { + return ToNumber($parseInteger($strSlice(value, 2), 8)); + } else if (hasNonWS(value) || isInvalidHexLiteral(value)) { + return NaN; + } + var trimmed = $trim(value); + if (trimmed !== value) { + return ToNumber(trimmed); + } + + } + return +value; +}; diff --git a/node_modules/es-abstract/2021/ToNumeric.js b/node_modules/es-abstract/2021/ToNumeric.js new file mode 100644 index 0000000000000000000000000000000000000000..00a436dc0848803af47df54584e7d851dfe1b4a0 --- /dev/null +++ b/node_modules/es-abstract/2021/ToNumeric.js @@ -0,0 +1,20 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $Number = GetIntrinsic('%Number%'); + +var isPrimitive = require('../helpers/isPrimitive'); + +var ToPrimitive = require('./ToPrimitive'); +var ToNumber = require('./ToNumber'); + +// https://262.ecma-international.org/11.0/#sec-tonumeric + +module.exports = function ToNumeric(argument) { + var primValue = isPrimitive(argument) ? argument : ToPrimitive(argument, $Number); + if (typeof primValue === 'bigint') { + return primValue; + } + return ToNumber(primValue); +}; diff --git a/node_modules/es-abstract/2021/ToObject.js b/node_modules/es-abstract/2021/ToObject.js new file mode 100644 index 0000000000000000000000000000000000000000..70226aaa331e7fd7aa487e680d4aca6bb6874f5b --- /dev/null +++ b/node_modules/es-abstract/2021/ToObject.js @@ -0,0 +1,5 @@ +'use strict'; + +// https://262.ecma-international.org/6.0/#sec-toobject + +module.exports = require('es-object-atoms/ToObject'); diff --git a/node_modules/es-abstract/2021/ToPrimitive.js b/node_modules/es-abstract/2021/ToPrimitive.js new file mode 100644 index 0000000000000000000000000000000000000000..56bcf1aa9eb269d753119497686556384800b092 --- /dev/null +++ b/node_modules/es-abstract/2021/ToPrimitive.js @@ -0,0 +1,12 @@ +'use strict'; + +var toPrimitive = require('es-to-primitive/es2015'); + +// https://262.ecma-international.org/6.0/#sec-toprimitive + +module.exports = function ToPrimitive(input) { + if (arguments.length > 1) { + return toPrimitive(input, arguments[1]); + } + return toPrimitive(input); +}; diff --git a/node_modules/es-abstract/2021/ToPropertyDescriptor.js b/node_modules/es-abstract/2021/ToPropertyDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..017350d593b202573a928ccefeacc7472c803a5e --- /dev/null +++ b/node_modules/es-abstract/2021/ToPropertyDescriptor.js @@ -0,0 +1,50 @@ +'use strict'; + +var hasOwn = require('hasown'); + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var IsCallable = require('./IsCallable'); +var ToBoolean = require('./ToBoolean'); + +// https://262.ecma-international.org/5.1/#sec-8.10.5 + +module.exports = function ToPropertyDescriptor(Obj) { + if (!isObject(Obj)) { + throw new $TypeError('ToPropertyDescriptor requires an object'); + } + + var desc = {}; + if (hasOwn(Obj, 'enumerable')) { + desc['[[Enumerable]]'] = ToBoolean(Obj.enumerable); + } + if (hasOwn(Obj, 'configurable')) { + desc['[[Configurable]]'] = ToBoolean(Obj.configurable); + } + if (hasOwn(Obj, 'value')) { + desc['[[Value]]'] = Obj.value; + } + if (hasOwn(Obj, 'writable')) { + desc['[[Writable]]'] = ToBoolean(Obj.writable); + } + if (hasOwn(Obj, 'get')) { + var getter = Obj.get; + if (typeof getter !== 'undefined' && !IsCallable(getter)) { + throw new $TypeError('getter must be a function'); + } + desc['[[Get]]'] = getter; + } + if (hasOwn(Obj, 'set')) { + var setter = Obj.set; + if (typeof setter !== 'undefined' && !IsCallable(setter)) { + throw new $TypeError('setter must be a function'); + } + desc['[[Set]]'] = setter; + } + + if ((hasOwn(desc, '[[Get]]') || hasOwn(desc, '[[Set]]')) && (hasOwn(desc, '[[Value]]') || hasOwn(desc, '[[Writable]]'))) { + throw new $TypeError('Invalid property descriptor. Cannot both specify accessors and a value or writable attribute'); + } + return desc; +}; diff --git a/node_modules/es-abstract/2021/ToPropertyKey.js b/node_modules/es-abstract/2021/ToPropertyKey.js new file mode 100644 index 0000000000000000000000000000000000000000..e363cd93b1722ddcff99896fb5667079bb95c932 --- /dev/null +++ b/node_modules/es-abstract/2021/ToPropertyKey.js @@ -0,0 +1,15 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $String = GetIntrinsic('%String%'); + +var ToPrimitive = require('./ToPrimitive'); +var ToString = require('./ToString'); + +// https://262.ecma-international.org/6.0/#sec-topropertykey + +module.exports = function ToPropertyKey(argument) { + var key = ToPrimitive(argument, $String); + return typeof key === 'symbol' ? key : ToString(key); +}; diff --git a/node_modules/es-abstract/2021/ToString.js b/node_modules/es-abstract/2021/ToString.js new file mode 100644 index 0000000000000000000000000000000000000000..16b4ccf893640ee9162ff07ad484038311e6210d --- /dev/null +++ b/node_modules/es-abstract/2021/ToString.js @@ -0,0 +1,15 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $String = GetIntrinsic('%String%'); +var $TypeError = require('es-errors/type'); + +// https://262.ecma-international.org/6.0/#sec-tostring + +module.exports = function ToString(argument) { + if (typeof argument === 'symbol') { + throw new $TypeError('Cannot convert a Symbol value to a string'); + } + return $String(argument); +}; diff --git a/node_modules/es-abstract/2021/ToUint16.js b/node_modules/es-abstract/2021/ToUint16.js new file mode 100644 index 0000000000000000000000000000000000000000..117485e616437b348b9b74dddc3fc5e7af9f9ed0 --- /dev/null +++ b/node_modules/es-abstract/2021/ToUint16.js @@ -0,0 +1,19 @@ +'use strict'; + +var modulo = require('./modulo'); +var ToNumber = require('./ToNumber'); + +var abs = require('math-intrinsics/abs'); +var floor = require('math-intrinsics/floor'); +var $isNaN = require('math-intrinsics/isNaN'); +var $isFinite = require('math-intrinsics/isFinite'); +var $sign = require('math-intrinsics/sign'); + +// http://262.ecma-international.org/5.1/#sec-9.7 + +module.exports = function ToUint16(value) { + var number = ToNumber(value); + if ($isNaN(number) || number === 0 || !$isFinite(number)) { return 0; } + var posInt = $sign(number) * floor(abs(number)); + return modulo(posInt, 0x10000); +}; diff --git a/node_modules/es-abstract/2021/ToUint32.js b/node_modules/es-abstract/2021/ToUint32.js new file mode 100644 index 0000000000000000000000000000000000000000..2a8e9dd6a3794a0940b6bae175a99f00c0e2d25d --- /dev/null +++ b/node_modules/es-abstract/2021/ToUint32.js @@ -0,0 +1,9 @@ +'use strict'; + +var ToNumber = require('./ToNumber'); + +// http://262.ecma-international.org/5.1/#sec-9.6 + +module.exports = function ToUint32(x) { + return ToNumber(x) >>> 0; +}; diff --git a/node_modules/es-abstract/2021/ToUint8.js b/node_modules/es-abstract/2021/ToUint8.js new file mode 100644 index 0000000000000000000000000000000000000000..e3af8ede13a7ef1e5e3eb8833701d6497f8611e0 --- /dev/null +++ b/node_modules/es-abstract/2021/ToUint8.js @@ -0,0 +1,19 @@ +'use strict'; + +var ToNumber = require('./ToNumber'); + +var $isNaN = require('math-intrinsics/isNaN'); +var $isFinite = require('math-intrinsics/isFinite'); +var $sign = require('math-intrinsics/sign'); +var abs = require('math-intrinsics/abs'); +var floor = require('math-intrinsics/floor'); +var modulo = require('math-intrinsics/mod'); + +// https://262.ecma-international.org/6.0/#sec-touint8 + +module.exports = function ToUint8(argument) { + var number = ToNumber(argument); + if ($isNaN(number) || number === 0 || !$isFinite(number)) { return 0; } + var posInt = $sign(number) * floor(abs(number)); + return modulo(posInt, 0x100); +}; diff --git a/node_modules/es-abstract/2021/ToUint8Clamp.js b/node_modules/es-abstract/2021/ToUint8Clamp.js new file mode 100644 index 0000000000000000000000000000000000000000..ac1b06e461ba4d562700971000c2d30a9b9dfca4 --- /dev/null +++ b/node_modules/es-abstract/2021/ToUint8Clamp.js @@ -0,0 +1,19 @@ +'use strict'; + +var ToNumber = require('./ToNumber'); +var floor = require('./floor'); + +var $isNaN = require('math-intrinsics/isNaN'); + +// https://262.ecma-international.org/6.0/#sec-touint8clamp + +module.exports = function ToUint8Clamp(argument) { + var number = ToNumber(argument); + if ($isNaN(number) || number <= 0) { return 0; } + if (number >= 0xFF) { return 0xFF; } + var f = floor(number); + if (f + 0.5 < number) { return f + 1; } + if (number < f + 0.5) { return f; } + if (f % 2 !== 0) { return f + 1; } + return f; +}; diff --git a/node_modules/es-abstract/2021/TrimString.js b/node_modules/es-abstract/2021/TrimString.js new file mode 100644 index 0000000000000000000000000000000000000000..516ef254819cc6b4d11788176a2e90b7ca18b7e4 --- /dev/null +++ b/node_modules/es-abstract/2021/TrimString.js @@ -0,0 +1,27 @@ +'use strict'; + +var trimStart = require('string.prototype.trimstart'); +var trimEnd = require('string.prototype.trimend'); + +var $TypeError = require('es-errors/type'); + +var RequireObjectCoercible = require('./RequireObjectCoercible'); +var ToString = require('./ToString'); + +// https://262.ecma-international.org/10.0/#sec-trimstring + +module.exports = function TrimString(string, where) { + var str = RequireObjectCoercible(string); + var S = ToString(str); + var T; + if (where === 'start') { + T = trimStart(S); + } else if (where === 'end') { + T = trimEnd(S); + } else if (where === 'start+end') { + T = trimStart(trimEnd(S)); + } else { + throw new $TypeError('Assertion failed: invalid `where` value; must be "start", "end", or "start+end"'); + } + return T; +}; diff --git a/node_modules/es-abstract/2021/Type.js b/node_modules/es-abstract/2021/Type.js new file mode 100644 index 0000000000000000000000000000000000000000..555ca74ea51969958716accd635da40009319542 --- /dev/null +++ b/node_modules/es-abstract/2021/Type.js @@ -0,0 +1,15 @@ +'use strict'; + +var ES5Type = require('../5/Type'); + +// https://262.ecma-international.org/11.0/#sec-ecmascript-data-types-and-values + +module.exports = function Type(x) { + if (typeof x === 'symbol') { + return 'Symbol'; + } + if (typeof x === 'bigint') { + return 'BigInt'; + } + return ES5Type(x); +}; diff --git a/node_modules/es-abstract/2021/TypedArrayCreate.js b/node_modules/es-abstract/2021/TypedArrayCreate.js new file mode 100644 index 0000000000000000000000000000000000000000..c598dfff9fe1d42461198227a6004e0fe4512226 --- /dev/null +++ b/node_modules/es-abstract/2021/TypedArrayCreate.js @@ -0,0 +1,47 @@ +'use strict'; + +var $SyntaxError = require('es-errors/syntax'); +var $TypeError = require('es-errors/type'); + +var IsArray = require('./IsArray'); +var IsConstructor = require('./IsConstructor'); +var ValidateTypedArray = require('./ValidateTypedArray'); + +var availableTypedArrays = require('available-typed-arrays')(); +var typedArrayLength = require('typed-array-length'); + +// https://262.ecma-international.org/7.0/#typedarray-create + +module.exports = function TypedArrayCreate(constructor, argumentList) { + if (!IsConstructor(constructor)) { + throw new $TypeError('Assertion failed: `constructor` must be a constructor'); + } + if (!IsArray(argumentList)) { + throw new $TypeError('Assertion failed: `argumentList` must be a List'); + } + if (availableTypedArrays.length === 0) { + throw new $SyntaxError('Assertion failed: Typed Arrays are not supported in this environment'); + } + + // var newTypedArray = Construct(constructor, argumentList); // step 1 + var newTypedArray; + if (argumentList.length === 0) { + newTypedArray = new constructor(); + } else if (argumentList.length === 1) { + newTypedArray = new constructor(argumentList[0]); + } else if (argumentList.length === 2) { + newTypedArray = new constructor(argumentList[0], argumentList[1]); + } else { + newTypedArray = new constructor(argumentList[0], argumentList[1], argumentList[2]); + } + + ValidateTypedArray(newTypedArray); // step 2 + + if (argumentList.length === 1 && typeof argumentList[0] === 'number') { // step 3 + if (typedArrayLength(newTypedArray) < argumentList[0]) { + throw new $TypeError('Assertion failed: `argumentList[0]` must be <= `newTypedArray.length`'); // step 3.a + } + } + + return newTypedArray; // step 4 +}; diff --git a/node_modules/es-abstract/2021/TypedArraySpeciesCreate.js b/node_modules/es-abstract/2021/TypedArraySpeciesCreate.js new file mode 100644 index 0000000000000000000000000000000000000000..6c71498a052bbfc121b4887e2aa3fff5572510b2 --- /dev/null +++ b/node_modules/es-abstract/2021/TypedArraySpeciesCreate.js @@ -0,0 +1,37 @@ +'use strict'; + +var $SyntaxError = require('es-errors/syntax'); +var $TypeError = require('es-errors/type'); + +var whichTypedArray = require('which-typed-array'); +var availableTypedArrays = require('available-typed-arrays')(); + +var IsArray = require('./IsArray'); +var SpeciesConstructor = require('./SpeciesConstructor'); +var TypedArrayCreate = require('./TypedArrayCreate'); + +var getConstructor = require('../helpers/typedArrayConstructors'); + +// https://262.ecma-international.org/7.0/#typedarray-species-create + +module.exports = function TypedArraySpeciesCreate(exemplar, argumentList) { + if (availableTypedArrays.length === 0) { + throw new $SyntaxError('Assertion failed: Typed Arrays are not supported in this environment'); + } + + var kind = whichTypedArray(exemplar); + if (!kind) { + throw new $TypeError('Assertion failed: exemplar must be a TypedArray'); // step 1 + } + if (!IsArray(argumentList)) { + throw new $TypeError('Assertion failed: `argumentList` must be a List'); // step 1 + } + + var defaultConstructor = getConstructor(kind); // step 2 + if (typeof defaultConstructor !== 'function') { + throw new $SyntaxError('Assertion failed: `constructor` of `exemplar` (' + kind + ') must exist. Please report this!'); + } + var constructor = SpeciesConstructor(exemplar, defaultConstructor); // step 3 + + return TypedArrayCreate(constructor, argumentList); // step 4 +}; diff --git a/node_modules/es-abstract/2021/UTF16EncodeCodePoint.js b/node_modules/es-abstract/2021/UTF16EncodeCodePoint.js new file mode 100644 index 0000000000000000000000000000000000000000..a35458039fc824e81d2832ac91d1fdb2e67bb621 --- /dev/null +++ b/node_modules/es-abstract/2021/UTF16EncodeCodePoint.js @@ -0,0 +1,25 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = require('es-errors/type'); +var $fromCharCode = GetIntrinsic('%String.fromCharCode%'); + +var floor = require('./floor'); +var modulo = require('./modulo'); + +var isCodePoint = require('../helpers/isCodePoint'); + +// https://262.ecma-international.org/12.0/#sec-utf16encoding + +module.exports = function UTF16EncodeCodePoint(cp) { + if (!isCodePoint(cp)) { + throw new $TypeError('Assertion failed: `cp` must be >= 0 and <= 0x10FFFF'); + } + if (cp <= 65535) { + return $fromCharCode(cp); + } + var cu1 = $fromCharCode(floor((cp - 65536) / 1024) + 0xD800); + var cu2 = $fromCharCode(modulo(cp - 65536, 1024) + 0xDC00); + return cu1 + cu2; +}; diff --git a/node_modules/es-abstract/2021/UTF16SurrogatePairToCodePoint.js b/node_modules/es-abstract/2021/UTF16SurrogatePairToCodePoint.js new file mode 100644 index 0000000000000000000000000000000000000000..d08f7be46a27b03ae34ddb71ef37571ea8f72531 --- /dev/null +++ b/node_modules/es-abstract/2021/UTF16SurrogatePairToCodePoint.js @@ -0,0 +1,19 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = require('es-errors/type'); +var $fromCharCode = GetIntrinsic('%String.fromCharCode%'); + +var isLeadingSurrogate = require('../helpers/isLeadingSurrogate'); +var isTrailingSurrogate = require('../helpers/isTrailingSurrogate'); + +// https://262.ecma-international.org/12.0/#sec-utf16decodesurrogatepair + +module.exports = function UTF16SurrogatePairToCodePoint(lead, trail) { + if (!isLeadingSurrogate(lead) || !isTrailingSurrogate(trail)) { + throw new $TypeError('Assertion failed: `lead` must be a leading surrogate char code, and `trail` must be a trailing surrogate char code'); + } + // var cp = (lead - 0xD800) * 0x400 + (trail - 0xDC00) + 0x10000; + return $fromCharCode(lead) + $fromCharCode(trail); +}; diff --git a/node_modules/es-abstract/2021/UnicodeEscape.js b/node_modules/es-abstract/2021/UnicodeEscape.js new file mode 100644 index 0000000000000000000000000000000000000000..739602cc8352d251c3d89180f3042bb397dabb76 --- /dev/null +++ b/node_modules/es-abstract/2021/UnicodeEscape.js @@ -0,0 +1,25 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var callBound = require('call-bound'); + +var $charCodeAt = callBound('String.prototype.charCodeAt'); +var $numberToString = callBound('Number.prototype.toString'); +var $toLowerCase = callBound('String.prototype.toLowerCase'); + +var StringPad = require('./StringPad'); + +// https://262.ecma-international.org/11.0/#sec-unicodeescape + +module.exports = function UnicodeEscape(C) { + if (typeof C !== 'string' || C.length !== 1) { + throw new $TypeError('Assertion failed: `C` must be a single code unit'); + } + var n = $charCodeAt(C, 0); + if (n > 0xFFFF) { + throw new $TypeError('`Assertion failed: numeric value of `C` must be <= 0xFFFF'); + } + + return '\\u' + StringPad($toLowerCase($numberToString(n, 16)), 4, '0', 'start'); +}; diff --git a/node_modules/es-abstract/2021/ValidateAndApplyPropertyDescriptor.js b/node_modules/es-abstract/2021/ValidateAndApplyPropertyDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..12cab5dff05ac5d79240ac4b40af54aa99c5fd5e --- /dev/null +++ b/node_modules/es-abstract/2021/ValidateAndApplyPropertyDescriptor.js @@ -0,0 +1,159 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var DefineOwnProperty = require('../helpers/DefineOwnProperty'); +var isPropertyDescriptor = require('../helpers/records/property-descriptor'); +var isSamePropertyDescriptor = require('../helpers/isSamePropertyDescriptor'); + +var FromPropertyDescriptor = require('./FromPropertyDescriptor'); +var IsAccessorDescriptor = require('./IsAccessorDescriptor'); +var IsDataDescriptor = require('./IsDataDescriptor'); +var IsGenericDescriptor = require('./IsGenericDescriptor'); +var isPropertyKey = require('../helpers/isPropertyKey'); +var SameValue = require('./SameValue'); + +// https://262.ecma-international.org/6.0/#sec-validateandapplypropertydescriptor +// https://262.ecma-international.org/8.0/#sec-validateandapplypropertydescriptor + +// eslint-disable-next-line max-lines-per-function, max-statements +module.exports = function ValidateAndApplyPropertyDescriptor(O, P, extensible, Desc, current) { + // this uses the ES2017+ logic, since it fixes a number of bugs in the ES2015 logic. + if (typeof O !== 'undefined' && !isObject(O)) { + throw new $TypeError('Assertion failed: O must be undefined or an Object'); + } + if (typeof extensible !== 'boolean') { + throw new $TypeError('Assertion failed: extensible must be a Boolean'); + } + if (!isPropertyDescriptor(Desc)) { + throw new $TypeError('Assertion failed: Desc must be a Property Descriptor'); + } + if (typeof current !== 'undefined' && !isPropertyDescriptor(current)) { + throw new $TypeError('Assertion failed: current must be a Property Descriptor, or undefined'); + } + if (typeof O !== 'undefined' && !isPropertyKey(P)) { + throw new $TypeError('Assertion failed: if O is not undefined, P must be a Property Key'); + } + if (typeof current === 'undefined') { + if (!extensible) { + return false; + } + if (IsGenericDescriptor(Desc) || IsDataDescriptor(Desc)) { + if (typeof O !== 'undefined') { + DefineOwnProperty( + IsDataDescriptor, + SameValue, + FromPropertyDescriptor, + O, + P, + { + '[[Configurable]]': Desc['[[Configurable]]'], + '[[Enumerable]]': Desc['[[Enumerable]]'], + '[[Value]]': Desc['[[Value]]'], + '[[Writable]]': Desc['[[Writable]]'] + } + ); + } + } else { + if (!IsAccessorDescriptor(Desc)) { + throw new $TypeError('Assertion failed: Desc is not an accessor descriptor'); + } + if (typeof O !== 'undefined') { + return DefineOwnProperty( + IsDataDescriptor, + SameValue, + FromPropertyDescriptor, + O, + P, + Desc + ); + } + } + return true; + } + if (IsGenericDescriptor(Desc) && !('[[Configurable]]' in Desc) && !('[[Enumerable]]' in Desc)) { + return true; + } + if (isSamePropertyDescriptor({ SameValue: SameValue }, 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 (IsGenericDescriptor(Desc)) { + // no further validation is required. + } else if (IsDataDescriptor(current) !== IsDataDescriptor(Desc)) { + if (!current['[[Configurable]]']) { + return false; + } + if (IsDataDescriptor(current)) { + if (typeof O !== 'undefined') { + DefineOwnProperty( + IsDataDescriptor, + SameValue, + FromPropertyDescriptor, + O, + P, + { + '[[Configurable]]': current['[[Configurable]]'], + '[[Enumerable]]': current['[[Enumerable]]'], + '[[Get]]': undefined + } + ); + } + } else if (typeof O !== 'undefined') { + DefineOwnProperty( + IsDataDescriptor, + SameValue, + FromPropertyDescriptor, + O, + P, + { + '[[Configurable]]': current['[[Configurable]]'], + '[[Enumerable]]': current['[[Enumerable]]'], + '[[Value]]': undefined + } + ); + } + } else if (IsDataDescriptor(current) && IsDataDescriptor(Desc)) { + if (!current['[[Configurable]]'] && !current['[[Writable]]']) { + if ('[[Writable]]' in Desc && Desc['[[Writable]]']) { + return false; + } + if ('[[Value]]' in Desc && !SameValue(Desc['[[Value]]'], current['[[Value]]'])) { + return false; + } + return true; + } + } else if (IsAccessorDescriptor(current) && IsAccessorDescriptor(Desc)) { + if (!current['[[Configurable]]']) { + if ('[[Set]]' in Desc && !SameValue(Desc['[[Set]]'], current['[[Set]]'])) { + return false; + } + if ('[[Get]]' in Desc && !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 (typeof O !== 'undefined') { + return DefineOwnProperty( + IsDataDescriptor, + SameValue, + FromPropertyDescriptor, + O, + P, + Desc + ); + } + return true; +}; diff --git a/node_modules/es-abstract/2021/ValidateAtomicAccess.js b/node_modules/es-abstract/2021/ValidateAtomicAccess.js new file mode 100644 index 0000000000000000000000000000000000000000..88981f053f3649551d002a874aad0125bf005379 --- /dev/null +++ b/node_modules/es-abstract/2021/ValidateAtomicAccess.js @@ -0,0 +1,45 @@ +'use strict'; + +var $RangeError = require('es-errors/range'); +var $TypeError = require('es-errors/type'); + +var ToIndex = require('./ToIndex'); + +var isTypedArray = require('is-typed-array'); +var typedArrayByteOffset = require('typed-array-byte-offset'); +var typedArrayLength = require('typed-array-length'); +var whichTypedArray = require('which-typed-array'); + +var tableTAO = require('./tables/typed-array-objects'); + +// https://262.ecma-international.org/12.0/#sec-validateatomicaccess + +module.exports = function ValidateAtomicAccess(typedArray, requestIndex) { + if (!isTypedArray(typedArray)) { + throw new $TypeError('Assertion failed: `typedArray` must be a TypedArray'); // step 1 + } + + var length = typedArrayLength(typedArray); // step 2 + + var accessIndex = ToIndex(requestIndex); // step 3 + + /* + // this assertion can never be reached + if (!(accessIndex >= 0)) { + throw new $TypeError('Assertion failed: accessIndex >= 0'); // step 4 + } + */ + + if (accessIndex >= length) { + throw new $RangeError('index out of range'); // step 5 + } + + var arrayTypeName = whichTypedArray(typedArray); // step 6 + + var taType = tableTAO.name['$' + arrayTypeName]; + var elementSize = tableTAO.size['$' + taType]; // step 7 + + var offset = typedArrayByteOffset(typedArray); // step 8 + + return (accessIndex * elementSize) + offset; // step 9 +}; diff --git a/node_modules/es-abstract/2021/ValidateIntegerTypedArray.js b/node_modules/es-abstract/2021/ValidateIntegerTypedArray.js new file mode 100644 index 0000000000000000000000000000000000000000..3289853cfe6ecfa21f3e8a1e8e423d48f152270e --- /dev/null +++ b/node_modules/es-abstract/2021/ValidateIntegerTypedArray.js @@ -0,0 +1,37 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var IsBigIntElementType = require('./IsBigIntElementType'); +var IsUnclampedIntegerElementType = require('./IsUnclampedIntegerElementType'); +var ValidateTypedArray = require('./ValidateTypedArray'); + +var whichTypedArray = require('which-typed-array'); + +// https://262.ecma-international.org/12.0/#sec-validateintegertypedarray + +var tableTAO = require('./tables/typed-array-objects'); + +module.exports = function ValidateIntegerTypedArray(typedArray) { + var waitable = arguments.length > 1 ? arguments[1] : false; // step 1 + + if (typeof waitable !== 'boolean') { + throw new $TypeError('Assertion failed: `waitable` must be a Boolean'); + } + + var buffer = ValidateTypedArray(typedArray); // step 2 + + var typeName = whichTypedArray(typedArray); // step 3 + + var type = tableTAO.name['$' + typeName]; // step 4 + + if (waitable) { // step 5 + if (typeName !== 'Int32Array' && typeName !== 'BigInt64Array') { + throw new $TypeError('Assertion failed: `typedArray` must be an Int32Array or BigInt64Array when `waitable` is true'); // step 5.a + } + } else if (!IsUnclampedIntegerElementType(type) && !IsBigIntElementType(type)) { + throw new $TypeError('Assertion failed: `typedArray` must be an integer TypedArray'); // step 6.a + } + + return buffer; // step 7 +}; diff --git a/node_modules/es-abstract/2021/ValidateTypedArray.js b/node_modules/es-abstract/2021/ValidateTypedArray.js new file mode 100644 index 0000000000000000000000000000000000000000..87fa8d17872f4463582e77a803dc98ff0019f878 --- /dev/null +++ b/node_modules/es-abstract/2021/ValidateTypedArray.js @@ -0,0 +1,28 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var IsDetachedBuffer = require('./IsDetachedBuffer'); + +var isTypedArray = require('is-typed-array'); +var typedArrayBuffer = require('typed-array-buffer'); + +// https://262.ecma-international.org/6.0/#sec-validatetypedarray + +module.exports = function ValidateTypedArray(O) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: `O` must be an Object'); // step 1 + } + if (!isTypedArray(O)) { + throw new $TypeError('Assertion failed: `O` must be a Typed Array'); // steps 2 - 3 + } + + var buffer = typedArrayBuffer(O); // step 4 + + if (IsDetachedBuffer(buffer)) { + throw new $TypeError('`O` must be backed by a non-detached buffer'); // step 5 + } + + return buffer; // step 6 +}; diff --git a/node_modules/es-abstract/2021/WeakRefDeref.js b/node_modules/es-abstract/2021/WeakRefDeref.js new file mode 100644 index 0000000000000000000000000000000000000000..195b654b653be3eb14c01787a9c185e4cea2e5ac --- /dev/null +++ b/node_modules/es-abstract/2021/WeakRefDeref.js @@ -0,0 +1,23 @@ +'use strict'; + +var callBound = require('call-bound'); + +var $TypeError = require('es-errors/type'); +var $deref = callBound('WeakRef.prototype.deref', true); + +var isWeakRef = require('is-weakref'); + +var AddToKeptObjects = require('./AddToKeptObjects'); + +// https://262.ecma-international.org/12.0/#sec-weakrefderef + +module.exports = function WeakRefDeref(weakRef) { + if (!isWeakRef(weakRef)) { + throw new $TypeError('Assertion failed: `weakRef` must be a WeakRef'); + } + var target = $deref(weakRef); + if (target) { + AddToKeptObjects(target); + } + return target; +}; diff --git a/node_modules/es-abstract/2021/WeekDay.js b/node_modules/es-abstract/2021/WeekDay.js new file mode 100644 index 0000000000000000000000000000000000000000..17cf94ca34ce0aae649c1e0236cd18f248d54e3d --- /dev/null +++ b/node_modules/es-abstract/2021/WeekDay.js @@ -0,0 +1,10 @@ +'use strict'; + +var Day = require('./Day'); +var modulo = require('./modulo'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.6 + +module.exports = function WeekDay(t) { + return modulo(Day(t) + 4, 7); +}; diff --git a/node_modules/es-abstract/2021/WordCharacters.js b/node_modules/es-abstract/2021/WordCharacters.js new file mode 100644 index 0000000000000000000000000000000000000000..36532afc9087057ccdf6fb52434e7fe523714f4d --- /dev/null +++ b/node_modules/es-abstract/2021/WordCharacters.js @@ -0,0 +1,46 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var callBound = require('call-bound'); +var $indexOf = callBound('String.prototype.indexOf'); + +var Canonicalize = require('./Canonicalize'); + +var caseFolding = require('../helpers/caseFolding.json'); +var forEach = require('../helpers/forEach'); +var OwnPropertyKeys = require('own-keys'); + +var A = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_'; // step 1 + +// https://262.ecma-international.org/8.0/#sec-runtime-semantics-wordcharacters-abstract-operation + +module.exports = function WordCharacters(IgnoreCase, Unicode) { + if (typeof IgnoreCase !== 'boolean' || typeof Unicode !== 'boolean') { + throw new $TypeError('Assertion failed: `IgnoreCase` and `Unicode` must be booleans'); + } + + var U = ''; + forEach(OwnPropertyKeys(caseFolding.C), function (c) { + if ( + $indexOf(A, c) === -1 // c not in A + && $indexOf(A, Canonicalize(c, IgnoreCase, Unicode)) > -1 // canonicalized c IS in A + ) { + U += caseFolding.C[c]; // step 3 + } + }); + forEach(OwnPropertyKeys(caseFolding.S), function (c) { + if ( + $indexOf(A, c) === -1 // c not in A + && $indexOf(A, Canonicalize(c, IgnoreCase, Unicode)) > -1 // canonicalized c IS in A + ) { + U += caseFolding.S[c]; // step 3 + } + }); + + if ((!Unicode || !IgnoreCase) && U.length > 0) { + throw new $TypeError('Assertion failed: `U` must be empty when `IgnoreCase` and `Unicode` are not both true'); // step 4 + } + + return A + U; // step 5, 6 +}; diff --git a/node_modules/es-abstract/2021/YearFromTime.js b/node_modules/es-abstract/2021/YearFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..18958182021b0ecc71645057fe8ed826ef786586 --- /dev/null +++ b/node_modules/es-abstract/2021/YearFromTime.js @@ -0,0 +1,16 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $Date = GetIntrinsic('%Date%'); + +var callBound = require('call-bound'); + +var $getUTCFullYear = callBound('Date.prototype.getUTCFullYear'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.3 + +module.exports = function YearFromTime(t) { + // largest y such that this.TimeFromYear(y) <= t + return $getUTCFullYear(new $Date(t)); +}; diff --git a/node_modules/es-abstract/2021/abs.js b/node_modules/es-abstract/2021/abs.js new file mode 100644 index 0000000000000000000000000000000000000000..457f2a4a3d48f83c061c763cd26724fd8d4297f3 --- /dev/null +++ b/node_modules/es-abstract/2021/abs.js @@ -0,0 +1,9 @@ +'use strict'; + +var $abs = require('math-intrinsics/abs'); + +// https://262.ecma-international.org/11.0/#eqn-abs + +module.exports = function abs(x) { + return typeof x === 'bigint' ? BigInt($abs(Number(x))) : $abs(x); +}; diff --git a/node_modules/es-abstract/2021/clamp.js b/node_modules/es-abstract/2021/clamp.js new file mode 100644 index 0000000000000000000000000000000000000000..3fda648424302a451ffa63433b7f7933dcc6d13e --- /dev/null +++ b/node_modules/es-abstract/2021/clamp.js @@ -0,0 +1,14 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var max = require('math-intrinsics/max'); +var min = require('math-intrinsics/min'); + +// https://262.ecma-international.org/12.0/#clamping + +module.exports = function clamp(x, lower, upper) { + if (typeof x !== 'number' || typeof lower !== 'number' || typeof upper !== 'number' || !(lower <= upper)) { + throw new $TypeError('Assertion failed: all three arguments must be MVs, and `lower` must be `<= upper`'); + } + return min(max(lower, x), upper); +}; diff --git a/node_modules/es-abstract/2021/floor.js b/node_modules/es-abstract/2021/floor.js new file mode 100644 index 0000000000000000000000000000000000000000..eece19b5cbf2bd71a7655ea6d2f329cc8cd1a11d --- /dev/null +++ b/node_modules/es-abstract/2021/floor.js @@ -0,0 +1,14 @@ +'use strict'; + +// var modulo = require('./modulo'); +var $floor = require('math-intrinsics/floor'); + +// http://262.ecma-international.org/11.0/#eqn-floor + +module.exports = function floor(x) { + // return x - modulo(x, 1); + if (typeof x === 'bigint') { + return x; + } + return $floor(x); +}; diff --git a/node_modules/es-abstract/2021/max.js b/node_modules/es-abstract/2021/max.js new file mode 100644 index 0000000000000000000000000000000000000000..f83b038a221fed3a500c72b41f5fdc31e1100827 --- /dev/null +++ b/node_modules/es-abstract/2021/max.js @@ -0,0 +1,5 @@ +'use strict'; + +// https://262.ecma-international.org/6.0/#sec-algorithm-conventions + +module.exports = require('math-intrinsics/max'); diff --git a/node_modules/es-abstract/2021/min.js b/node_modules/es-abstract/2021/min.js new file mode 100644 index 0000000000000000000000000000000000000000..3a8f50539f0a6519251299edf4169f98a6db0bd9 --- /dev/null +++ b/node_modules/es-abstract/2021/min.js @@ -0,0 +1,5 @@ +'use strict'; + +// https://262.ecma-international.org/6.0/#sec-algorithm-conventions + +module.exports = require('math-intrinsics/min'); diff --git a/node_modules/es-abstract/2021/modulo.js b/node_modules/es-abstract/2021/modulo.js new file mode 100644 index 0000000000000000000000000000000000000000..b94bb52bb3c62e45629a4b1e8f0ebba219d5e41e --- /dev/null +++ b/node_modules/es-abstract/2021/modulo.js @@ -0,0 +1,9 @@ +'use strict'; + +var mod = require('../helpers/mod'); + +// https://262.ecma-international.org/5.1/#sec-5.2 + +module.exports = function modulo(x, y) { + return mod(x, y); +}; diff --git a/node_modules/es-abstract/2021/msFromTime.js b/node_modules/es-abstract/2021/msFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..a6bae767aed31c8a467b8ea1fb2128e64860a972 --- /dev/null +++ b/node_modules/es-abstract/2021/msFromTime.js @@ -0,0 +1,11 @@ +'use strict'; + +var modulo = require('./modulo'); + +var msPerSecond = require('../helpers/timeConstants').msPerSecond; + +// https://262.ecma-international.org/5.1/#sec-15.9.1.10 + +module.exports = function msFromTime(t) { + return modulo(t, msPerSecond); +}; diff --git a/node_modules/es-abstract/2021/substring.js b/node_modules/es-abstract/2021/substring.js new file mode 100644 index 0000000000000000000000000000000000000000..75fbf10e9c5e754041b8b0b509cc61f56b289fe3 --- /dev/null +++ b/node_modules/es-abstract/2021/substring.js @@ -0,0 +1,15 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isInteger = require('math-intrinsics/isInteger'); +var callBound = require('call-bound'); + +var $slice = callBound('String.prototype.slice'); + +// https://262.ecma-international.org/12.0/#substring +module.exports = function substring(S, inclusiveStart, exclusiveEnd) { + if (typeof S !== 'string' || !isInteger(inclusiveStart) || (arguments.length > 2 && !isInteger(exclusiveEnd))) { + throw new $TypeError('`S` must be a String, and `inclusiveStart` and `exclusiveEnd` must be integers'); + } + return $slice(S, inclusiveStart, arguments.length > 2 ? exclusiveEnd : S.length); +}; diff --git a/node_modules/es-abstract/2021/tables/typed-array-objects.js b/node_modules/es-abstract/2021/tables/typed-array-objects.js new file mode 100644 index 0000000000000000000000000000000000000000..8d6c70aba3046702ccb796ad62eb46fc99e038ef --- /dev/null +++ b/node_modules/es-abstract/2021/tables/typed-array-objects.js @@ -0,0 +1,36 @@ +'use strict'; + +// https://262.ecma-international.org/11.0/#table-the-typedarray-constructors + +module.exports = { + __proto__: null, + name: { + __proto__: null, + $Int8Array: 'Int8', + $Uint8Array: 'Uint8', + $Uint8ClampedArray: 'Uint8C', + $Int16Array: 'Int16', + $Uint16Array: 'Uint16', + $Int32Array: 'Int32', + $Uint32Array: 'Uint32', + $BigInt64Array: 'BigInt64', + $BigUint64Array: 'BigUint64', + $Float32Array: 'Float32', + $Float64Array: 'Float64' + }, + size: { + __proto__: null, + $Int8: 1, + $Uint8: 1, + $Uint8C: 1, + $Int16: 2, + $Uint16: 2, + $Int32: 4, + $Uint32: 4, + $BigInt64: 8, + $BigUint64: 8, + $Float32: 4, + $Float64: 8 + }, + choices: '"Int8", "Uint8", "Uint8C", "Int16", "Uint16", "Int32", "Uint32", "BigInt64", "BigUint64", "Float32", or "Float64"' +}; diff --git a/node_modules/es-abstract/2021/thisBigIntValue.js b/node_modules/es-abstract/2021/thisBigIntValue.js new file mode 100644 index 0000000000000000000000000000000000000000..ad281d3d0115e46f8e8accfeac1864be7dfdd459 --- /dev/null +++ b/node_modules/es-abstract/2021/thisBigIntValue.js @@ -0,0 +1,18 @@ +'use strict'; + +var callBound = require('call-bound'); + +var $SyntaxError = require('es-errors/syntax'); +var $bigIntValueOf = callBound('BigInt.prototype.valueOf', true); + +// https://262.ecma-international.org/11.0/#sec-thisbigintvalue + +module.exports = function thisBigIntValue(value) { + if (typeof value === 'bigint') { + return value; + } + if (!$bigIntValueOf) { + throw new $SyntaxError('BigInt is not supported'); + } + return $bigIntValueOf(value); +}; diff --git a/node_modules/es-abstract/2021/thisBooleanValue.js b/node_modules/es-abstract/2021/thisBooleanValue.js new file mode 100644 index 0000000000000000000000000000000000000000..265fff335bed60f2a636b2fa3bf2ac113b896ff7 --- /dev/null +++ b/node_modules/es-abstract/2021/thisBooleanValue.js @@ -0,0 +1,13 @@ +'use strict'; + +var $BooleanValueOf = require('call-bound')('Boolean.prototype.valueOf'); + +// https://262.ecma-international.org/6.0/#sec-properties-of-the-boolean-prototype-object + +module.exports = function thisBooleanValue(value) { + if (typeof value === 'boolean') { + return value; + } + + return $BooleanValueOf(value); +}; diff --git a/node_modules/es-abstract/2021/thisNumberValue.js b/node_modules/es-abstract/2021/thisNumberValue.js new file mode 100644 index 0000000000000000000000000000000000000000..e2457fb3f076d4f8c500d7f5ce7b19ff4846cf2d --- /dev/null +++ b/node_modules/es-abstract/2021/thisNumberValue.js @@ -0,0 +1,16 @@ +'use strict'; + +var callBound = require('call-bound'); + +var $NumberValueOf = callBound('Number.prototype.valueOf'); + +// https://262.ecma-international.org/6.0/#sec-properties-of-the-number-prototype-object + +module.exports = function thisNumberValue(value) { + if (typeof value === 'number') { + return value; + } + + return $NumberValueOf(value); +}; + diff --git a/node_modules/es-abstract/2021/thisStringValue.js b/node_modules/es-abstract/2021/thisStringValue.js new file mode 100644 index 0000000000000000000000000000000000000000..a5c70534670cd719ca425055d597ac6b5f5994c2 --- /dev/null +++ b/node_modules/es-abstract/2021/thisStringValue.js @@ -0,0 +1,13 @@ +'use strict'; + +var $StringValueOf = require('call-bound')('String.prototype.valueOf'); + +// https://262.ecma-international.org/6.0/#sec-properties-of-the-string-prototype-object + +module.exports = function thisStringValue(value) { + if (typeof value === 'string') { + return value; + } + + return $StringValueOf(value); +}; diff --git a/node_modules/es-abstract/2021/thisSymbolValue.js b/node_modules/es-abstract/2021/thisSymbolValue.js new file mode 100644 index 0000000000000000000000000000000000000000..77342ad16a77128cddbb7c79e9eb576bbe6b126c --- /dev/null +++ b/node_modules/es-abstract/2021/thisSymbolValue.js @@ -0,0 +1,20 @@ +'use strict'; + +var $SyntaxError = require('es-errors/syntax'); +var callBound = require('call-bound'); + +var $SymbolValueOf = callBound('Symbol.prototype.valueOf', true); + +// https://262.ecma-international.org/9.0/#sec-thissymbolvalue + +module.exports = function thisSymbolValue(value) { + if (typeof value === 'symbol') { + return value; + } + + if (!$SymbolValueOf) { + throw new $SyntaxError('Symbols are not supported; thisSymbolValue requires that `value` be a Symbol or a Symbol object'); + } + + return $SymbolValueOf(value); +}; diff --git a/node_modules/es-abstract/2021/thisTimeValue.js b/node_modules/es-abstract/2021/thisTimeValue.js new file mode 100644 index 0000000000000000000000000000000000000000..f64be83fcaed6a3766a1397c1c373981c0543b1a --- /dev/null +++ b/node_modules/es-abstract/2021/thisTimeValue.js @@ -0,0 +1,9 @@ +'use strict'; + +var timeValue = require('../helpers/timeValue'); + +// https://262.ecma-international.org/6.0/#sec-properties-of-the-date-prototype-object + +module.exports = function thisTimeValue(value) { + return timeValue(value); +}; diff --git a/node_modules/es-abstract/2022/AddEntriesFromIterable.js b/node_modules/es-abstract/2022/AddEntriesFromIterable.js new file mode 100644 index 0000000000000000000000000000000000000000..8c1c1e60007d69caa21ce9bd420b5a000bcf8a24 --- /dev/null +++ b/node_modules/es-abstract/2022/AddEntriesFromIterable.js @@ -0,0 +1,44 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); +var inspect = require('object-inspect'); + +var Call = require('./Call'); +var Get = require('./Get'); +var GetIterator = require('./GetIterator'); +var IsCallable = require('./IsCallable'); +var IteratorClose = require('./IteratorClose'); +var IteratorStep = require('./IteratorStep'); +var IteratorValue = require('./IteratorValue'); +var ThrowCompletion = require('./ThrowCompletion'); + +// https://262.ecma-international.org/10.0/#sec-add-entries-from-iterable + +module.exports = function AddEntriesFromIterable(target, iterable, adder) { + if (!IsCallable(adder)) { + throw new $TypeError('Assertion failed: `adder` is not callable'); + } + if (iterable == null) { + throw new $TypeError('Assertion failed: `iterable` is present, and not nullish'); + } + var iteratorRecord = GetIterator(iterable); + while (true) { + var next = IteratorStep(iteratorRecord); + if (!next) { + return target; + } + var nextItem = IteratorValue(next); + if (!isObject(nextItem)) { + var error = ThrowCompletion(new $TypeError('iterator next must return an Object, got ' + inspect(nextItem))); + return IteratorClose(iteratorRecord, error); + } + try { + var k = Get(nextItem, '0'); + var v = Get(nextItem, '1'); + Call(adder, target, [k, v]); + } catch (e) { + return IteratorClose(iteratorRecord, ThrowCompletion(e)); + } + } +}; diff --git a/node_modules/es-abstract/2022/AddToKeptObjects.js b/node_modules/es-abstract/2022/AddToKeptObjects.js new file mode 100644 index 0000000000000000000000000000000000000000..cce51955a6db7899e1be22e5077fb91d4f658600 --- /dev/null +++ b/node_modules/es-abstract/2022/AddToKeptObjects.js @@ -0,0 +1,18 @@ +'use strict'; + +var SLOT = require('internal-slot'); + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var ClearKeptObjects = require('./ClearKeptObjects'); + +// https://262.ecma-international.org/12.0/#sec-addtokeptobjects + +module.exports = function AddToKeptObjects(object) { + if (!isObject(object)) { + throw new $TypeError('Assertion failed: `object` must be an Object'); + } + var arr = SLOT.get(ClearKeptObjects, '[[es-abstract internal: KeptAlive]]'); + arr[arr.length] = object; +}; diff --git a/node_modules/es-abstract/2022/AdvanceStringIndex.js b/node_modules/es-abstract/2022/AdvanceStringIndex.js new file mode 100644 index 0000000000000000000000000000000000000000..370917df9dfff158449f930ef7d03643ee38982d --- /dev/null +++ b/node_modules/es-abstract/2022/AdvanceStringIndex.js @@ -0,0 +1,30 @@ +'use strict'; + +var CodePointAt = require('./CodePointAt'); + +var $TypeError = require('es-errors/type'); +var isInteger = require('math-intrinsics/isInteger'); +var MAX_SAFE_INTEGER = require('math-intrinsics/constants/maxSafeInteger'); + +// https://262.ecma-international.org/12.0/#sec-advancestringindex + +module.exports = function AdvanceStringIndex(S, index, unicode) { + if (typeof S !== 'string') { + throw new $TypeError('Assertion failed: `S` must be a String'); + } + if (!isInteger(index) || index < 0 || index > MAX_SAFE_INTEGER) { + throw new $TypeError('Assertion failed: `length` must be an integer >= 0 and <= 2**53'); + } + if (typeof unicode !== 'boolean') { + throw new $TypeError('Assertion failed: `unicode` must be a Boolean'); + } + if (!unicode) { + return index + 1; + } + var length = S.length; + if ((index + 1) >= length) { + return index + 1; + } + var cp = CodePointAt(S, index); + return index + cp['[[CodeUnitCount]]']; +}; diff --git a/node_modules/es-abstract/2022/ApplyStringOrNumericBinaryOperator.js b/node_modules/es-abstract/2022/ApplyStringOrNumericBinaryOperator.js new file mode 100644 index 0000000000000000000000000000000000000000..e65b6b2e79c756dcf2e533624ec8152e8dbfc161 --- /dev/null +++ b/node_modules/es-abstract/2022/ApplyStringOrNumericBinaryOperator.js @@ -0,0 +1,77 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var HasOwnProperty = require('./HasOwnProperty'); +var ToNumeric = require('./ToNumeric'); +var ToPrimitive = require('./ToPrimitive'); +var ToString = require('./ToString'); +var Type = require('./Type'); + +var NumberAdd = require('./Number/add'); +var NumberBitwiseAND = require('./Number/bitwiseAND'); +var NumberBitwiseOR = require('./Number/bitwiseOR'); +var NumberBitwiseXOR = require('./Number/bitwiseXOR'); +var NumberDivide = require('./Number/divide'); +var NumberExponentiate = require('./Number/exponentiate'); +var NumberLeftShift = require('./Number/leftShift'); +var NumberMultiply = require('./Number/multiply'); +var NumberRemainder = require('./Number/remainder'); +var NumberSignedRightShift = require('./Number/signedRightShift'); +var NumberSubtract = require('./Number/subtract'); +var NumberUnsignedRightShift = require('./Number/unsignedRightShift'); +var BigIntAdd = require('./BigInt/add'); +var BigIntBitwiseAND = require('./BigInt/bitwiseAND'); +var BigIntBitwiseOR = require('./BigInt/bitwiseOR'); +var BigIntBitwiseXOR = require('./BigInt/bitwiseXOR'); +var BigIntDivide = require('./BigInt/divide'); +var BigIntExponentiate = require('./BigInt/exponentiate'); +var BigIntLeftShift = require('./BigInt/leftShift'); +var BigIntMultiply = require('./BigInt/multiply'); +var BigIntRemainder = require('./BigInt/remainder'); +var BigIntSignedRightShift = require('./BigInt/signedRightShift'); +var BigIntSubtract = require('./BigInt/subtract'); +var BigIntUnsignedRightShift = require('./BigInt/unsignedRightShift'); + +// https://262.ecma-international.org/12.0/#sec-applystringornumericbinaryoperator + +// https://262.ecma-international.org/12.0/#step-applystringornumericbinaryoperator-operations-table +var table = { + '**': [NumberExponentiate, BigIntExponentiate], + '*': [NumberMultiply, BigIntMultiply], + '/': [NumberDivide, BigIntDivide], + '%': [NumberRemainder, BigIntRemainder], + '+': [NumberAdd, BigIntAdd], + '-': [NumberSubtract, BigIntSubtract], + '<<': [NumberLeftShift, BigIntLeftShift], + '>>': [NumberSignedRightShift, BigIntSignedRightShift], + '>>>': [NumberUnsignedRightShift, BigIntUnsignedRightShift], + '&': [NumberBitwiseAND, BigIntBitwiseAND], + '^': [NumberBitwiseXOR, BigIntBitwiseXOR], + '|': [NumberBitwiseOR, BigIntBitwiseOR] +}; + +module.exports = function ApplyStringOrNumericBinaryOperator(lval, opText, rval) { + if (typeof opText !== 'string' || !HasOwnProperty(table, opText)) { + throw new $TypeError('Assertion failed: `opText` must be a valid operation string'); + } + if (opText === '+') { + var lprim = ToPrimitive(lval); + var rprim = ToPrimitive(rval); + if (typeof lprim === 'string' || typeof rprim === 'string') { + var lstr = ToString(lprim); + var rstr = ToString(rprim); + return lstr + rstr; + } + /* eslint no-param-reassign: 1 */ + lval = lprim; + rval = rprim; + } + var lnum = ToNumeric(lval); + var rnum = ToNumeric(rval); + if (Type(lnum) !== Type(rnum)) { + throw new $TypeError('types of ' + lnum + ' and ' + rnum + ' differ'); + } + var Operation = table[opText][typeof lnum === 'bigint' ? 1 : 0]; + return Operation(lnum, rnum); +}; diff --git a/node_modules/es-abstract/2022/ArrayCreate.js b/node_modules/es-abstract/2022/ArrayCreate.js new file mode 100644 index 0000000000000000000000000000000000000000..568632b8a6d2ef76124399192dee465859e0ed1b --- /dev/null +++ b/node_modules/es-abstract/2022/ArrayCreate.js @@ -0,0 +1,42 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $ArrayPrototype = GetIntrinsic('%Array.prototype%'); +var $RangeError = require('es-errors/range'); +var $SyntaxError = require('es-errors/syntax'); +var $TypeError = require('es-errors/type'); +var isInteger = require('math-intrinsics/isInteger'); +var MAX_ARRAY_LENGTH = require('math-intrinsics/constants/maxArrayLength'); +var $setProto = require('set-proto'); + +// https://262.ecma-international.org/12.0/#sec-arraycreate + +module.exports = function ArrayCreate(length) { + if (!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 3, 5 + if (proto !== $ArrayPrototype) { // step 4 + 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 6 + A.length = length; + } + /* step 6, the above as a shortcut for the below + OrdinaryDefineOwnProperty(A, 'length', { + '[[Configurable]]': false, + '[[Enumerable]]': false, + '[[Value]]': length, + '[[Writable]]': true + }); + */ + return A; +}; diff --git a/node_modules/es-abstract/2022/ArraySetLength.js b/node_modules/es-abstract/2022/ArraySetLength.js new file mode 100644 index 0000000000000000000000000000000000000000..7f7a4339c2af5c8656165189f47c4212732ee1bd --- /dev/null +++ b/node_modules/es-abstract/2022/ArraySetLength.js @@ -0,0 +1,77 @@ +'use strict'; + +var $RangeError = require('es-errors/range'); +var $TypeError = require('es-errors/type'); + +var assign = require('object.assign'); + +var isPropertyDescriptor = require('../helpers/records/property-descriptor'); + +var IsArray = require('./IsArray'); +var IsDataDescriptor = require('./IsDataDescriptor'); +var OrdinaryDefineOwnProperty = require('./OrdinaryDefineOwnProperty'); +var OrdinaryGetOwnProperty = require('./OrdinaryGetOwnProperty'); +var ToNumber = require('./ToNumber'); +var ToString = require('./ToString'); +var ToUint32 = require('./ToUint32'); + +// https://262.ecma-international.org/6.0/#sec-arraysetlength + +// eslint-disable-next-line max-statements, max-lines-per-function +module.exports = function ArraySetLength(A, Desc) { + if (!IsArray(A)) { + throw new $TypeError('Assertion failed: A must be an Array'); + } + if (!isPropertyDescriptor(Desc)) { + throw new $TypeError('Assertion failed: Desc must be a Property Descriptor'); + } + if (!('[[Value]]' in Desc)) { + return OrdinaryDefineOwnProperty(A, 'length', Desc); + } + var newLenDesc = assign({}, Desc); + var newLen = ToUint32(Desc['[[Value]]']); + var numberLen = ToNumber(Desc['[[Value]]']); + if (newLen !== numberLen) { + throw new $RangeError('Invalid array length'); + } + newLenDesc['[[Value]]'] = newLen; + var oldLenDesc = OrdinaryGetOwnProperty(A, 'length'); + if (!IsDataDescriptor(oldLenDesc)) { + throw new $TypeError('Assertion failed: an array had a non-data descriptor on `length`'); + } + var oldLen = oldLenDesc['[[Value]]']; + if (newLen >= oldLen) { + return 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 = OrdinaryDefineOwnProperty(A, 'length', newLenDesc); + if (!succeeded) { + return false; + } + while (newLen < oldLen) { + oldLen -= 1; + // eslint-disable-next-line no-param-reassign + var deleteSucceeded = delete A[ToString(oldLen)]; + if (!deleteSucceeded) { + newLenDesc['[[Value]]'] = oldLen + 1; + if (!newWritable) { + newLenDesc['[[Writable]]'] = false; + OrdinaryDefineOwnProperty(A, 'length', newLenDesc); + return false; + } + } + } + if (!newWritable) { + return OrdinaryDefineOwnProperty(A, 'length', { '[[Writable]]': false }); + } + return true; +}; diff --git a/node_modules/es-abstract/2022/ArraySpeciesCreate.js b/node_modules/es-abstract/2022/ArraySpeciesCreate.js new file mode 100644 index 0000000000000000000000000000000000000000..2589c90787151d6dd4534c32499a6906b982c505 --- /dev/null +++ b/node_modules/es-abstract/2022/ArraySpeciesCreate.js @@ -0,0 +1,48 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $species = GetIntrinsic('%Symbol.species%', true); +var $TypeError = require('es-errors/type'); +var isInteger = require('math-intrinsics/isInteger'); +var isObject = require('es-object-atoms/isObject'); + +var ArrayCreate = require('./ArrayCreate'); +var Get = require('./Get'); +var IsArray = require('./IsArray'); +var IsConstructor = require('./IsConstructor'); + +// https://262.ecma-international.org/12.0/#sec-arrayspeciescreate + +module.exports = function ArraySpeciesCreate(originalArray, length) { + if (!isInteger(length) || length < 0) { + throw new $TypeError('Assertion failed: length must be an integer >= 0'); + } + + var isArray = IsArray(originalArray); + if (!isArray) { + return ArrayCreate(length); + } + + var C = Get(originalArray, 'constructor'); + // TODO: figure out how to make a cross-realm normal Array, a same-realm Array + // if (IsConstructor(C)) { + // if C is another realm's Array, C = undefined + // Object.getPrototypeOf(Object.getPrototypeOf(Object.getPrototypeOf(Array))) === null ? + // } + if ($species && isObject(C)) { + C = Get(C, $species); + if (C === null) { + C = void 0; + } + } + + if (typeof C === 'undefined') { + return ArrayCreate(length); + } + if (!IsConstructor(C)) { + throw new $TypeError('C must be a constructor'); + } + return new C(length); // Construct(C, length); +}; + diff --git a/node_modules/es-abstract/2022/AsyncFromSyncIteratorContinuation.js b/node_modules/es-abstract/2022/AsyncFromSyncIteratorContinuation.js new file mode 100644 index 0000000000000000000000000000000000000000..d545b6bfc70974e44350f20e4ec28812d9cbf9e2 --- /dev/null +++ b/node_modules/es-abstract/2022/AsyncFromSyncIteratorContinuation.js @@ -0,0 +1,45 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $SyntaxError = require('es-errors/syntax'); +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); +var $Promise = GetIntrinsic('%Promise%', true); + +var callBound = require('call-bound'); + +var CreateIterResultObject = require('./CreateIterResultObject'); +var IteratorComplete = require('./IteratorComplete'); +var IteratorValue = require('./IteratorValue'); +var PromiseResolve = require('./PromiseResolve'); + +var $then = callBound('Promise.prototype.then', true); + +// https://262.ecma-international.org/10.0/#sec-asyncfromsynciteratorcontinuation + +module.exports = function AsyncFromSyncIteratorContinuation(result) { + if (!isObject(result)) { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + if (arguments.length > 1) { + throw new $SyntaxError('although AsyncFromSyncIteratorContinuation should take a second argument, it is not used in this implementation'); + } + + if (!$Promise) { + throw new $SyntaxError('This environment does not support Promises.'); + } + + return new $Promise(function (resolve) { + var done = IteratorComplete(result); // step 2 + var value = IteratorValue(result); // step 4 + var valueWrapper = PromiseResolve($Promise, value); // step 6 + + // eslint-disable-next-line no-shadow + var onFulfilled = function (value) { // steps 8-9 + return CreateIterResultObject(value, done); // step 8.a + }; + resolve($then(valueWrapper, onFulfilled)); // step 11 + }); // step 12 +}; diff --git a/node_modules/es-abstract/2022/AsyncIteratorClose.js b/node_modules/es-abstract/2022/AsyncIteratorClose.js new file mode 100644 index 0000000000000000000000000000000000000000..d1cda2a301d35c13bee2a0e343b365fc48023edc --- /dev/null +++ b/node_modules/es-abstract/2022/AsyncIteratorClose.js @@ -0,0 +1,70 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $SyntaxError = require('es-errors/syntax'); +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); +var $Promise = GetIntrinsic('%Promise%', true); + +var Call = require('./Call'); +var CompletionRecord = require('./CompletionRecord'); +var GetMethod = require('./GetMethod'); + +var isIteratorRecord = require('../helpers/records/iterator-record-2023'); + +var callBound = require('call-bound'); + +var $then = callBound('Promise.prototype.then', true); + +// https://262.ecma-international.org/12.0/#sec-asynciteratorclose + +module.exports = function AsyncIteratorClose(iteratorRecord, completion) { + if (!isIteratorRecord(iteratorRecord)) { + throw new $TypeError('Assertion failed: `iteratorRecord` must be an Iterator Record'); // step 1 + } + + if (!(completion instanceof CompletionRecord)) { + throw new $TypeError('Assertion failed: completion is not a Completion Record instance'); // step 2 + } + + if (!$then) { + throw new $SyntaxError('This environment does not support Promises.'); + } + + var iterator = iteratorRecord['[[Iterator]]']; // step 3 + + return $then( + $then( + $then( + new $Promise(function (resolve) { + resolve(GetMethod(iterator, 'return')); // step 4 + // resolve(Call(ret, iterator, [])); // step 6 + }), + function (returnV) { // step 5.a + if (typeof returnV === 'undefined') { + return completion; // step 5.b + } + return Call(returnV, iterator); // step 5.c, 5.d. + } + ), + null, + function (e) { + if (completion.type() === 'throw') { + completion['?'](); // step 6 + } else { + throw e; // step 7 + } + } + ), + function (innerResult) { // step 8 + if (completion.type() === 'throw') { + completion['?'](); // step 6 + } + if (!isObject(innerResult)) { + throw new $TypeError('`innerResult` must be an Object'); // step 10 + } + return completion; + } + ); +}; diff --git a/node_modules/es-abstract/2022/BigInt/add.js b/node_modules/es-abstract/2022/BigInt/add.js new file mode 100644 index 0000000000000000000000000000000000000000..25cc9fa60f58e2433eb392a4cc0e00a0569474ba --- /dev/null +++ b/node_modules/es-abstract/2022/BigInt/add.js @@ -0,0 +1,14 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-add + +module.exports = function BigIntAdd(x, y) { + if (typeof x !== 'bigint' || typeof y !== 'bigint') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + + // shortcut for the actual spec mechanics + return x + y; +}; diff --git a/node_modules/es-abstract/2022/BigInt/bitwiseAND.js b/node_modules/es-abstract/2022/BigInt/bitwiseAND.js new file mode 100644 index 0000000000000000000000000000000000000000..106f4a273945d92cdb34715249ae5a72c1af93d8 --- /dev/null +++ b/node_modules/es-abstract/2022/BigInt/bitwiseAND.js @@ -0,0 +1,14 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var BigIntBitwiseOp = require('../BigIntBitwiseOp'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-bitwiseAND + +module.exports = function BigIntBitwiseAND(x, y) { + if (typeof x !== 'bigint' || typeof y !== 'bigint') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + return BigIntBitwiseOp('&', x, y); +}; diff --git a/node_modules/es-abstract/2022/BigInt/bitwiseNOT.js b/node_modules/es-abstract/2022/BigInt/bitwiseNOT.js new file mode 100644 index 0000000000000000000000000000000000000000..9fe67405f674c3501fe410d55c63c59874841d87 --- /dev/null +++ b/node_modules/es-abstract/2022/BigInt/bitwiseNOT.js @@ -0,0 +1,15 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $BigInt = GetIntrinsic('%BigInt%', true); +var $TypeError = require('es-errors/type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-bitwiseNOT + +module.exports = function BigIntBitwiseNOT(x) { + if (typeof x !== 'bigint') { + throw new $TypeError('Assertion failed: `x` argument must be a BigInt'); + } + return -x - $BigInt(1); +}; diff --git a/node_modules/es-abstract/2022/BigInt/bitwiseOR.js b/node_modules/es-abstract/2022/BigInt/bitwiseOR.js new file mode 100644 index 0000000000000000000000000000000000000000..b0ba812a8a321e0f92a9d446b4e5439ec898fd47 --- /dev/null +++ b/node_modules/es-abstract/2022/BigInt/bitwiseOR.js @@ -0,0 +1,14 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var BigIntBitwiseOp = require('../BigIntBitwiseOp'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-bitwiseOR + +module.exports = function BigIntBitwiseOR(x, y) { + if (typeof x !== 'bigint' || typeof y !== 'bigint') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + return BigIntBitwiseOp('|', x, y); +}; diff --git a/node_modules/es-abstract/2022/BigInt/bitwiseXOR.js b/node_modules/es-abstract/2022/BigInt/bitwiseXOR.js new file mode 100644 index 0000000000000000000000000000000000000000..79ac4a1f4568d559d69b64ba88061aabb1460c57 --- /dev/null +++ b/node_modules/es-abstract/2022/BigInt/bitwiseXOR.js @@ -0,0 +1,14 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var BigIntBitwiseOp = require('../BigIntBitwiseOp'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-bitwiseXOR + +module.exports = function BigIntBitwiseXOR(x, y) { + if (typeof x !== 'bigint' || typeof y !== 'bigint') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + return BigIntBitwiseOp('^', x, y); +}; diff --git a/node_modules/es-abstract/2022/BigInt/divide.js b/node_modules/es-abstract/2022/BigInt/divide.js new file mode 100644 index 0000000000000000000000000000000000000000..a194302eb682514dc75061f391f75fdad1f0da4e --- /dev/null +++ b/node_modules/es-abstract/2022/BigInt/divide.js @@ -0,0 +1,20 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $BigInt = GetIntrinsic('%BigInt%', true); +var $RangeError = require('es-errors/range'); +var $TypeError = require('es-errors/type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-divide + +module.exports = function BigIntDivide(x, y) { + if (typeof x !== 'bigint' || typeof y !== 'bigint') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + if (y === $BigInt(0)) { + throw new $RangeError('Division by zero'); + } + // shortcut for the actual spec mechanics + return x / y; +}; diff --git a/node_modules/es-abstract/2022/BigInt/equal.js b/node_modules/es-abstract/2022/BigInt/equal.js new file mode 100644 index 0000000000000000000000000000000000000000..d6b36a2551cb08160a812a8bab4dc3a63e751a8b --- /dev/null +++ b/node_modules/es-abstract/2022/BigInt/equal.js @@ -0,0 +1,13 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-equal + +module.exports = function BigIntEqual(x, y) { + if (typeof x !== 'bigint' || typeof y !== 'bigint') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + // shortcut for the actual spec mechanics + return x === y; +}; diff --git a/node_modules/es-abstract/2022/BigInt/exponentiate.js b/node_modules/es-abstract/2022/BigInt/exponentiate.js new file mode 100644 index 0000000000000000000000000000000000000000..f5bcdc148af1bc7658596120cbf5d72f7036c599 --- /dev/null +++ b/node_modules/es-abstract/2022/BigInt/exponentiate.js @@ -0,0 +1,29 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $BigInt = GetIntrinsic('%BigInt%', true); +var $RangeError = require('es-errors/range'); +var $TypeError = require('es-errors/type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-exponentiate + +module.exports = function BigIntExponentiate(base, exponent) { + if (typeof base !== 'bigint' || typeof exponent !== 'bigint') { + throw new $TypeError('Assertion failed: `base` and `exponent` arguments must be BigInts'); + } + if (exponent < $BigInt(0)) { + throw new $RangeError('Exponent must be positive'); + } + if (/* base === $BigInt(0) && */ exponent === $BigInt(0)) { + return $BigInt(1); + } + + var square = base; + var remaining = exponent; + while (remaining > $BigInt(0)) { + square += exponent; + --remaining; // eslint-disable-line no-plusplus + } + return square; +}; diff --git a/node_modules/es-abstract/2022/BigInt/index.js b/node_modules/es-abstract/2022/BigInt/index.js new file mode 100644 index 0000000000000000000000000000000000000000..63ec52da69e285d605f9f5db2ffe69ed4af591f2 --- /dev/null +++ b/node_modules/es-abstract/2022/BigInt/index.js @@ -0,0 +1,43 @@ +'use strict'; + +var add = require('./add'); +var bitwiseAND = require('./bitwiseAND'); +var bitwiseNOT = require('./bitwiseNOT'); +var bitwiseOR = require('./bitwiseOR'); +var bitwiseXOR = require('./bitwiseXOR'); +var divide = require('./divide'); +var equal = require('./equal'); +var exponentiate = require('./exponentiate'); +var leftShift = require('./leftShift'); +var lessThan = require('./lessThan'); +var multiply = require('./multiply'); +var remainder = require('./remainder'); +var sameValue = require('./sameValue'); +var sameValueZero = require('./sameValueZero'); +var signedRightShift = require('./signedRightShift'); +var subtract = require('./subtract'); +var toString = require('./toString'); +var unaryMinus = require('./unaryMinus'); +var unsignedRightShift = require('./unsignedRightShift'); + +module.exports = { + add: add, + bitwiseAND: bitwiseAND, + bitwiseNOT: bitwiseNOT, + bitwiseOR: bitwiseOR, + bitwiseXOR: bitwiseXOR, + divide: divide, + equal: equal, + exponentiate: exponentiate, + leftShift: leftShift, + lessThan: lessThan, + multiply: multiply, + remainder: remainder, + sameValue: sameValue, + sameValueZero: sameValueZero, + signedRightShift: signedRightShift, + subtract: subtract, + toString: toString, + unaryMinus: unaryMinus, + unsignedRightShift: unsignedRightShift +}; diff --git a/node_modules/es-abstract/2022/BigInt/leftShift.js b/node_modules/es-abstract/2022/BigInt/leftShift.js new file mode 100644 index 0000000000000000000000000000000000000000..327592ea62472441e0750d4a6e5bccc81a7a5c71 --- /dev/null +++ b/node_modules/es-abstract/2022/BigInt/leftShift.js @@ -0,0 +1,14 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-leftShift + +module.exports = function BigIntLeftShift(x, y) { + if (typeof x !== 'bigint' || typeof y !== 'bigint') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + + // shortcut for the actual spec mechanics + return x << y; +}; diff --git a/node_modules/es-abstract/2022/BigInt/lessThan.js b/node_modules/es-abstract/2022/BigInt/lessThan.js new file mode 100644 index 0000000000000000000000000000000000000000..612f2dbbc4ea4aa7e5b27781f68071baa10f8727 --- /dev/null +++ b/node_modules/es-abstract/2022/BigInt/lessThan.js @@ -0,0 +1,14 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-lessThan + +module.exports = function BigIntLessThan(x, y) { + if (typeof x !== 'bigint' || typeof y !== 'bigint') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + + // shortcut for the actual spec mechanics + return x < y; +}; diff --git a/node_modules/es-abstract/2022/BigInt/multiply.js b/node_modules/es-abstract/2022/BigInt/multiply.js new file mode 100644 index 0000000000000000000000000000000000000000..a9bfbd5936a77ce9ddaec1e442a36fc2c4eb96de --- /dev/null +++ b/node_modules/es-abstract/2022/BigInt/multiply.js @@ -0,0 +1,14 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-multiply + +module.exports = function BigIntMultiply(x, y) { + if (typeof x !== 'bigint' || typeof y !== 'bigint') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + + // shortcut for the actual spec mechanics + return x * y; +}; diff --git a/node_modules/es-abstract/2022/BigInt/remainder.js b/node_modules/es-abstract/2022/BigInt/remainder.js new file mode 100644 index 0000000000000000000000000000000000000000..60346ecdeec72fc2f63f823c80fea5a45208abab --- /dev/null +++ b/node_modules/es-abstract/2022/BigInt/remainder.js @@ -0,0 +1,28 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $BigInt = GetIntrinsic('%BigInt%', true); +var $RangeError = require('es-errors/range'); +var $TypeError = require('es-errors/type'); + +var zero = $BigInt && $BigInt(0); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-remainder + +module.exports = function BigIntRemainder(n, d) { + if (typeof n !== 'bigint' || typeof d !== 'bigint') { + throw new $TypeError('Assertion failed: `n` and `d` arguments must be BigInts'); + } + + if (d === zero) { + throw new $RangeError('Division by zero'); + } + + if (n === zero) { + return zero; + } + + // shortcut for the actual spec mechanics + return n % d; +}; diff --git a/node_modules/es-abstract/2022/BigInt/sameValue.js b/node_modules/es-abstract/2022/BigInt/sameValue.js new file mode 100644 index 0000000000000000000000000000000000000000..c4851a067c23ab5b48214b51dd6cc0744f1798ef --- /dev/null +++ b/node_modules/es-abstract/2022/BigInt/sameValue.js @@ -0,0 +1,15 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var BigIntEqual = require('./equal'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-sameValue + +module.exports = function BigIntSameValue(x, y) { + if (typeof x !== 'bigint' || typeof y !== 'bigint') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + + return BigIntEqual(x, y); +}; diff --git a/node_modules/es-abstract/2022/BigInt/sameValueZero.js b/node_modules/es-abstract/2022/BigInt/sameValueZero.js new file mode 100644 index 0000000000000000000000000000000000000000..0505ca376eb92ac77300bc70ec8c99f12bb90dc8 --- /dev/null +++ b/node_modules/es-abstract/2022/BigInt/sameValueZero.js @@ -0,0 +1,15 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var BigIntEqual = require('./equal'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-sameValueZero + +module.exports = function BigIntSameValueZero(x, y) { + if (typeof x !== 'bigint' || typeof y !== 'bigint') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + + return BigIntEqual(x, y); +}; diff --git a/node_modules/es-abstract/2022/BigInt/signedRightShift.js b/node_modules/es-abstract/2022/BigInt/signedRightShift.js new file mode 100644 index 0000000000000000000000000000000000000000..90967d66e622397fc8e7cd54ee6e1f7c5426b786 --- /dev/null +++ b/node_modules/es-abstract/2022/BigInt/signedRightShift.js @@ -0,0 +1,15 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var BigIntLeftShift = require('./leftShift'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-signedRightShift + +module.exports = function BigIntSignedRightShift(x, y) { + if (typeof x !== 'bigint' || typeof y !== 'bigint') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + + return BigIntLeftShift(x, -y); +}; diff --git a/node_modules/es-abstract/2022/BigInt/subtract.js b/node_modules/es-abstract/2022/BigInt/subtract.js new file mode 100644 index 0000000000000000000000000000000000000000..32de730a3cbea3a14df35755a24c54dcb9e5de9f --- /dev/null +++ b/node_modules/es-abstract/2022/BigInt/subtract.js @@ -0,0 +1,14 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-subtract + +module.exports = function BigIntSubtract(x, y) { + if (typeof x !== 'bigint' || typeof y !== 'bigint') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + + // shortcut for the actual spec mechanics + return x - y; +}; diff --git a/node_modules/es-abstract/2022/BigInt/toString.js b/node_modules/es-abstract/2022/BigInt/toString.js new file mode 100644 index 0000000000000000000000000000000000000000..5dc8a6a672c957e7c54eca452857436ff5794c9d --- /dev/null +++ b/node_modules/es-abstract/2022/BigInt/toString.js @@ -0,0 +1,16 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $String = GetIntrinsic('%String%'); +var $TypeError = require('es-errors/type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-tostring + +module.exports = function BigIntToString(x) { + if (typeof x !== 'bigint') { + throw new $TypeError('Assertion failed: `x` must be a BigInt'); + } + + return $String(x); +}; diff --git a/node_modules/es-abstract/2022/BigInt/unaryMinus.js b/node_modules/es-abstract/2022/BigInt/unaryMinus.js new file mode 100644 index 0000000000000000000000000000000000000000..161f02fbdba7eca7078ee2a2404f646e03b4d0be --- /dev/null +++ b/node_modules/es-abstract/2022/BigInt/unaryMinus.js @@ -0,0 +1,22 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $BigInt = GetIntrinsic('%BigInt%', true); +var $TypeError = require('es-errors/type'); + +var zero = $BigInt && $BigInt(0); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-unaryMinus + +module.exports = function BigIntUnaryMinus(x) { + if (typeof x !== 'bigint') { + throw new $TypeError('Assertion failed: `x` argument must be a BigInt'); + } + + if (x === zero) { + return zero; + } + + return -x; +}; diff --git a/node_modules/es-abstract/2022/BigInt/unsignedRightShift.js b/node_modules/es-abstract/2022/BigInt/unsignedRightShift.js new file mode 100644 index 0000000000000000000000000000000000000000..d695cb43beb3716c8015d4b83f93d6fc7307da73 --- /dev/null +++ b/node_modules/es-abstract/2022/BigInt/unsignedRightShift.js @@ -0,0 +1,13 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-unsignedRightShift + +module.exports = function BigIntUnsignedRightShift(x, y) { + if (typeof x !== 'bigint' || typeof y !== 'bigint') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + + throw new $TypeError('BigInts have no unsigned right shift, use >> instead'); +}; diff --git a/node_modules/es-abstract/2022/BigIntBitwiseOp.js b/node_modules/es-abstract/2022/BigIntBitwiseOp.js new file mode 100644 index 0000000000000000000000000000000000000000..40e1a13185c4a1b7273f3e53a48f04f9ec5161b6 --- /dev/null +++ b/node_modules/es-abstract/2022/BigIntBitwiseOp.js @@ -0,0 +1,63 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +// var $BigInt = GetIntrinsic('%BigInt%', true); +// var $pow = require('math-intrinsics/pow'); + +// var BinaryAnd = require('./BinaryAnd'); +// var BinaryOr = require('./BinaryOr'); +// var BinaryXor = require('./BinaryXor'); +// var modulo = require('./modulo'); + +// var zero = $BigInt && $BigInt(0); +// var negOne = $BigInt && $BigInt(-1); +// var two = $BigInt && $BigInt(2); + +// https://262.ecma-international.org/11.0/#sec-bigintbitwiseop + +module.exports = function BigIntBitwiseOp(op, x, y) { + if (op !== '&' && op !== '|' && op !== '^') { + throw new $TypeError('Assertion failed: `op` must be `&`, `|`, or `^`'); + } + if (typeof x !== 'bigint' || typeof y !== 'bigint') { + throw new $TypeError('`x` and `y` must be BigInts'); + } + + if (op === '&') { + return x & y; + } + if (op === '|') { + return x | y; + } + return x ^ y; + /* + var result = zero; + var shift = 0; + while (x !== zero && x !== negOne && y !== zero && y !== negOne) { + var xDigit = modulo(x, two); + var yDigit = modulo(y, two); + if (op === '&') { + result += $pow(2, shift) * BinaryAnd(xDigit, yDigit); + } else if (op === '|') { + result += $pow(2, shift) * BinaryOr(xDigit, yDigit); + } else if (op === '^') { + result += $pow(2, shift) * BinaryXor(xDigit, yDigit); + } + shift += 1; + x = (x - xDigit) / two; + y = (y - yDigit) / two; + } + var tmp; + if (op === '&') { + tmp = BinaryAnd(modulo(x, two), modulo(y, two)); + } else if (op === '|') { + tmp = BinaryAnd(modulo(x, two), modulo(y, two)); + } else { + tmp = BinaryXor(modulo(x, two), modulo(y, two)); + } + if (tmp !== 0) { + result -= $pow(2, shift); + } + return result; + */ +}; diff --git a/node_modules/es-abstract/2022/BinaryAnd.js b/node_modules/es-abstract/2022/BinaryAnd.js new file mode 100644 index 0000000000000000000000000000000000000000..bb361dea6141f1b0d447cb06b5ee18e96ea426ce --- /dev/null +++ b/node_modules/es-abstract/2022/BinaryAnd.js @@ -0,0 +1,12 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +// https://262.ecma-international.org/11.0/#sec-binaryand + +module.exports = function BinaryAnd(x, y) { + if ((x !== 0 && x !== 1) || (y !== 0 && y !== 1)) { + throw new $TypeError('Assertion failed: `x` and `y` must be either 0 or 1'); + } + return x & y; +}; diff --git a/node_modules/es-abstract/2022/BinaryOr.js b/node_modules/es-abstract/2022/BinaryOr.js new file mode 100644 index 0000000000000000000000000000000000000000..76200f8744087b5c72020f4826d5bc8f55bd3886 --- /dev/null +++ b/node_modules/es-abstract/2022/BinaryOr.js @@ -0,0 +1,12 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +// https://262.ecma-international.org/11.0/#sec-binaryor + +module.exports = function BinaryOr(x, y) { + if ((x !== 0 && x !== 1) || (y !== 0 && y !== 1)) { + throw new $TypeError('Assertion failed: `x` and `y` must be either 0 or 1'); + } + return x | y; +}; diff --git a/node_modules/es-abstract/2022/BinaryXor.js b/node_modules/es-abstract/2022/BinaryXor.js new file mode 100644 index 0000000000000000000000000000000000000000..c1da53b26c67c6379ceaa50349f7861827eb6e10 --- /dev/null +++ b/node_modules/es-abstract/2022/BinaryXor.js @@ -0,0 +1,12 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +// https://262.ecma-international.org/11.0/#sec-binaryxor + +module.exports = function BinaryXor(x, y) { + if ((x !== 0 && x !== 1) || (y !== 0 && y !== 1)) { + throw new $TypeError('Assertion failed: `x` and `y` must be either 0 or 1'); + } + return x ^ y; +}; diff --git a/node_modules/es-abstract/2022/ByteListBitwiseOp.js b/node_modules/es-abstract/2022/ByteListBitwiseOp.js new file mode 100644 index 0000000000000000000000000000000000000000..7aba5bc6346a74cdb51b6070e1e6a8159783fce0 --- /dev/null +++ b/node_modules/es-abstract/2022/ByteListBitwiseOp.js @@ -0,0 +1,39 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var IsArray = require('./IsArray'); + +var isByteValue = require('../helpers/isByteValue'); + +// https://262.ecma-international.org/12.0/#sec-bytelistbitwiseop + +module.exports = function ByteListBitwiseOp(op, xBytes, yBytes) { + if (op !== '&' && op !== '^' && op !== '|') { + throw new $TypeError('Assertion failed: `op` must be `&`, `^`, or `|`'); + } + if (!IsArray(xBytes) || !IsArray(yBytes) || xBytes.length !== yBytes.length) { + throw new $TypeError('Assertion failed: `xBytes` and `yBytes` must be same-length sequences of byte values (an integer 0-255, inclusive)'); + } + + var result = []; + + for (var i = 0; i < xBytes.length; i += 1) { + var xByte = xBytes[i]; + var yByte = yBytes[i]; + if (!isByteValue(xByte) || !isByteValue(yByte)) { + throw new $TypeError('Assertion failed: `xBytes` and `yBytes` must be same-length sequences of byte values (an integer 0-255, inclusive)'); + } + var resultByte; + if (op === '&') { + resultByte = xByte & yByte; + } else if (op === '^') { + resultByte = xByte ^ yByte; + } else { + resultByte = xByte | yByte; + } + result[result.length] = resultByte; + } + + return result; +}; diff --git a/node_modules/es-abstract/2022/ByteListEqual.js b/node_modules/es-abstract/2022/ByteListEqual.js new file mode 100644 index 0000000000000000000000000000000000000000..b581cbba25a97b6211880bf53391bfcde3986715 --- /dev/null +++ b/node_modules/es-abstract/2022/ByteListEqual.js @@ -0,0 +1,31 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var IsArray = require('./IsArray'); + +var isByteValue = require('../helpers/isByteValue'); + +// https://262.ecma-international.org/12.0/#sec-bytelistequal + +module.exports = function ByteListEqual(xBytes, yBytes) { + if (!IsArray(xBytes) || !IsArray(yBytes)) { + throw new $TypeError('Assertion failed: `xBytes` and `yBytes` must be sequences of byte values (an integer 0-255, inclusive)'); + } + + if (xBytes.length !== yBytes.length) { + return false; + } + + for (var i = 0; i < xBytes.length; i += 1) { + var xByte = xBytes[i]; + var yByte = yBytes[i]; + if (!isByteValue(xByte) || !isByteValue(yByte)) { + throw new $TypeError('Assertion failed: `xBytes` and `yBytes` must be sequences of byte values (an integer 0-255, inclusive)'); + } + if (xByte !== yByte) { + return false; + } + } + return true; +}; diff --git a/node_modules/es-abstract/2022/Call.js b/node_modules/es-abstract/2022/Call.js new file mode 100644 index 0000000000000000000000000000000000000000..90b3519cb954848f531c4921eaa79ec7d37d06bd --- /dev/null +++ b/node_modules/es-abstract/2022/Call.js @@ -0,0 +1,20 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); +var callBound = require('call-bound'); + +var $TypeError = require('es-errors/type'); + +var IsArray = require('./IsArray'); + +var $apply = GetIntrinsic('%Reflect.apply%', true) || callBound('Function.prototype.apply'); + +// https://262.ecma-international.org/6.0/#sec-call + +module.exports = function Call(F, V) { + var argumentsList = arguments.length > 2 ? arguments[2] : []; + if (!IsArray(argumentsList)) { + throw new $TypeError('Assertion failed: optional `argumentsList`, if provided, must be a List'); + } + return $apply(F, V, argumentsList); +}; diff --git a/node_modules/es-abstract/2022/CanonicalNumericIndexString.js b/node_modules/es-abstract/2022/CanonicalNumericIndexString.js new file mode 100644 index 0000000000000000000000000000000000000000..74ed02f050d21c13dbfc06c80c21ae20a8e530ee --- /dev/null +++ b/node_modules/es-abstract/2022/CanonicalNumericIndexString.js @@ -0,0 +1,19 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var SameValue = require('./SameValue'); +var ToNumber = require('./ToNumber'); +var ToString = require('./ToString'); + +// https://262.ecma-international.org/6.0/#sec-canonicalnumericindexstring + +module.exports = function CanonicalNumericIndexString(argument) { + if (typeof argument !== 'string') { + throw new $TypeError('Assertion failed: `argument` must be a String'); + } + if (argument === '-0') { return -0; } + var n = ToNumber(argument); + if (SameValue(ToString(n), argument)) { return n; } + return void 0; +}; diff --git a/node_modules/es-abstract/2022/Canonicalize.js b/node_modules/es-abstract/2022/Canonicalize.js new file mode 100644 index 0000000000000000000000000000000000000000..63a58c4028e12d41fc2775615441ea23228b6719 --- /dev/null +++ b/node_modules/es-abstract/2022/Canonicalize.js @@ -0,0 +1,51 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var callBound = require('call-bound'); +var hasOwn = require('hasown'); + +var $charCodeAt = callBound('String.prototype.charCodeAt'); +var $toUpperCase = callBound('String.prototype.toUpperCase'); + +var caseFolding = require('../helpers/caseFolding.json'); + +// https://262.ecma-international.org/6.0/#sec-runtime-semantics-canonicalize-ch + +module.exports = function Canonicalize(ch, IgnoreCase, Unicode) { + if (typeof ch !== 'string') { + throw new $TypeError('Assertion failed: `ch` must be a character'); + } + + if (typeof IgnoreCase !== 'boolean' || typeof Unicode !== 'boolean') { + throw new $TypeError('Assertion failed: `IgnoreCase` and `Unicode` must be Booleans'); + } + + if (!IgnoreCase) { + return ch; // step 1 + } + + if (Unicode) { // step 2 + if (hasOwn(caseFolding.C, ch)) { + return caseFolding.C[ch]; + } + if (hasOwn(caseFolding.S, ch)) { + return caseFolding.S[ch]; + } + return ch; // step 2.b + } + + var u = $toUpperCase(ch); // step 2 + + if (u.length !== 1) { + return ch; // step 3 + } + + var cu = u; // step 4 + + if ($charCodeAt(ch, 0) >= 128 && $charCodeAt(cu, 0) < 128) { + return ch; // step 5 + } + + return cu; +}; diff --git a/node_modules/es-abstract/2022/CharacterRange.js b/node_modules/es-abstract/2022/CharacterRange.js new file mode 100644 index 0000000000000000000000000000000000000000..e41cb7870a7411344a21dfe7fbfc7cd6888b7c9e --- /dev/null +++ b/node_modules/es-abstract/2022/CharacterRange.js @@ -0,0 +1,53 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); +var callBound = require('call-bound'); + +var $fromCharCode = GetIntrinsic('%String.fromCharCode%'); +var $TypeError = require('es-errors/type'); +var $charCodeAt = callBound('String.prototype.charCodeAt'); + +var CharSet = require('../helpers/CharSet').CharSet; + +module.exports = function CharacterRange(A, B) { + var a; + var b; + + if (A instanceof CharSet || B instanceof CharSet) { + if (!(A instanceof CharSet) || !(B instanceof CharSet)) { + throw new $TypeError('Assertion failed: CharSets A and B are not both CharSets'); + } + + A.yield(function (c) { + if (typeof a !== 'undefined') { + throw new $TypeError('Assertion failed: CharSet A has more than one character'); + } + a = c; + }); + B.yield(function (c) { + if (typeof b !== 'undefined') { + throw new $TypeError('Assertion failed: CharSet B has more than one character'); + } + b = c; + }); + } else { + if (A.length !== 1 || B.length !== 1) { + throw new $TypeError('Assertion failed: CharSets A and B contain exactly one character'); + } + a = A[0]; + b = B[0]; + } + + var i = $charCodeAt(a, 0); + var j = $charCodeAt(b, 0); + + if (!(i <= j)) { + throw new $TypeError('Assertion failed: i is not <= j'); + } + + var arr = []; + for (var k = i; k <= j; k += 1) { + arr[arr.length] = $fromCharCode(k); + } + return arr; +}; diff --git a/node_modules/es-abstract/2022/ClearKeptObjects.js b/node_modules/es-abstract/2022/ClearKeptObjects.js new file mode 100644 index 0000000000000000000000000000000000000000..50bd4a5da4199b973650ca675584246ef492edac --- /dev/null +++ b/node_modules/es-abstract/2022/ClearKeptObjects.js @@ -0,0 +1,12 @@ +'use strict'; + +var SLOT = require('internal-slot'); +var keptObjects = []; + +// https://262.ecma-international.org/12.0/#sec-clear-kept-objects + +module.exports = function ClearKeptObjects() { + keptObjects.length = 0; +}; + +SLOT.set(module.exports, '[[es-abstract internal: KeptAlive]]', keptObjects); diff --git a/node_modules/es-abstract/2022/CloneArrayBuffer.js b/node_modules/es-abstract/2022/CloneArrayBuffer.js new file mode 100644 index 0000000000000000000000000000000000000000..27c8ba96184211b7d06388f9f7302f8f4e293638 --- /dev/null +++ b/node_modules/es-abstract/2022/CloneArrayBuffer.js @@ -0,0 +1,46 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var GetPrototypeFromConstructor = require('./GetPrototypeFromConstructor'); +var IsConstructor = require('./IsConstructor'); +var IsDetachedBuffer = require('./IsDetachedBuffer'); +var OrdinarySetPrototypeOf = require('./OrdinarySetPrototypeOf'); + +var isInteger = require('math-intrinsics/isInteger'); +var isArrayBuffer = require('is-array-buffer'); +var arrayBufferSlice = require('arraybuffer.prototype.slice'); + +// https://262.ecma-international.org/12.0/#sec-clonearraybuffer + +module.exports = function CloneArrayBuffer(srcBuffer, srcByteOffset, srcLength, cloneConstructor) { + if (!isArrayBuffer(srcBuffer)) { + throw new $TypeError('Assertion failed: `srcBuffer` must be an ArrayBuffer instance'); + } + if (!isInteger(srcByteOffset) || srcByteOffset < 0) { + throw new $TypeError('Assertion failed: `srcByteOffset` must be a non-negative integer'); + } + if (!isInteger(srcLength) || srcLength < 0) { + throw new $TypeError('Assertion failed: `srcLength` must be a non-negative integer'); + } + if (!IsConstructor(cloneConstructor)) { + throw new $TypeError('Assertion failed: `cloneConstructor` must be a constructor'); + } + + // 3. Let targetBuffer be ? AllocateArrayBuffer(cloneConstructor, srcLength). + var proto = GetPrototypeFromConstructor(cloneConstructor, '%ArrayBufferPrototype%'); // step 3, kinda + + if (IsDetachedBuffer(srcBuffer)) { + throw new $TypeError('`srcBuffer` must not be a detached ArrayBuffer'); // step 4 + } + + /* + 5. Let srcBlock be srcBuffer.[[ArrayBufferData]]. + 6. Let targetBlock be targetBuffer.[[ArrayBufferData]]. + 7. Perform CopyDataBlockBytes(targetBlock, 0, srcBlock, srcByteOffset, srcLength). + */ + var targetBuffer = arrayBufferSlice(srcBuffer, srcByteOffset, srcByteOffset + srcLength); // steps 5-7 + OrdinarySetPrototypeOf(targetBuffer, proto); // step 3 + + return targetBuffer; // step 8 +}; diff --git a/node_modules/es-abstract/2022/CodePointAt.js b/node_modules/es-abstract/2022/CodePointAt.js new file mode 100644 index 0000000000000000000000000000000000000000..466d11cb64df54d4dd73c331b83903069323e526 --- /dev/null +++ b/node_modules/es-abstract/2022/CodePointAt.js @@ -0,0 +1,55 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var callBound = require('call-bound'); +var isLeadingSurrogate = require('../helpers/isLeadingSurrogate'); +var isTrailingSurrogate = require('../helpers/isTrailingSurrogate'); + +var UTF16SurrogatePairToCodePoint = require('./UTF16SurrogatePairToCodePoint'); + +var $charAt = callBound('String.prototype.charAt'); +var $charCodeAt = callBound('String.prototype.charCodeAt'); + +// https://262.ecma-international.org/12.0/#sec-codepointat + +module.exports = function CodePointAt(string, position) { + if (typeof string !== 'string') { + throw new $TypeError('Assertion failed: `string` must be a String'); + } + var size = string.length; + if (position < 0 || position >= size) { + throw new $TypeError('Assertion failed: `position` must be >= 0, and < the length of `string`'); + } + var first = $charCodeAt(string, position); + var cp = $charAt(string, position); + var firstIsLeading = isLeadingSurrogate(first); + var firstIsTrailing = isTrailingSurrogate(first); + if (!firstIsLeading && !firstIsTrailing) { + return { + '[[CodePoint]]': cp, + '[[CodeUnitCount]]': 1, + '[[IsUnpairedSurrogate]]': false + }; + } + if (firstIsTrailing || (position + 1 === size)) { + return { + '[[CodePoint]]': cp, + '[[CodeUnitCount]]': 1, + '[[IsUnpairedSurrogate]]': true + }; + } + var second = $charCodeAt(string, position + 1); + if (!isTrailingSurrogate(second)) { + return { + '[[CodePoint]]': cp, + '[[CodeUnitCount]]': 1, + '[[IsUnpairedSurrogate]]': true + }; + } + + return { + '[[CodePoint]]': UTF16SurrogatePairToCodePoint(first, second), + '[[CodeUnitCount]]': 2, + '[[IsUnpairedSurrogate]]': false + }; +}; diff --git a/node_modules/es-abstract/2022/CodePointsToString.js b/node_modules/es-abstract/2022/CodePointsToString.js new file mode 100644 index 0000000000000000000000000000000000000000..c15bcb4c93be5996162f356749622a1d104de7af --- /dev/null +++ b/node_modules/es-abstract/2022/CodePointsToString.js @@ -0,0 +1,25 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var UTF16EncodeCodePoint = require('./UTF16EncodeCodePoint'); +var IsArray = require('./IsArray'); + +var forEach = require('../helpers/forEach'); +var isCodePoint = require('../helpers/isCodePoint'); + +// https://262.ecma-international.org/12.0/#sec-codepointstostring + +module.exports = function CodePointsToString(text) { + if (!IsArray(text)) { + throw new $TypeError('Assertion failed: `text` must be a sequence of Unicode Code Points'); + } + var result = ''; + forEach(text, function (cp) { + if (!isCodePoint(cp)) { + throw new $TypeError('Assertion failed: `text` must be a sequence of Unicode Code Points'); + } + result += UTF16EncodeCodePoint(cp); + }); + return result; +}; diff --git a/node_modules/es-abstract/2022/CompletePropertyDescriptor.js b/node_modules/es-abstract/2022/CompletePropertyDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..8c9e3f441111638a3b3c9fd69857d3da22c779ee --- /dev/null +++ b/node_modules/es-abstract/2022/CompletePropertyDescriptor.js @@ -0,0 +1,43 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var hasOwn = require('hasown'); + +var IsDataDescriptor = require('./IsDataDescriptor'); +var IsGenericDescriptor = require('./IsGenericDescriptor'); + +var isPropertyDescriptor = require('../helpers/records/property-descriptor'); + +// https://262.ecma-international.org/6.0/#sec-completepropertydescriptor + +module.exports = function CompletePropertyDescriptor(Desc) { + if (!isPropertyDescriptor(Desc)) { + throw new $TypeError('Assertion failed: `Desc` must be a Property Descriptor'); + } + + /* eslint no-param-reassign: 0 */ + + if (IsGenericDescriptor(Desc) || IsDataDescriptor(Desc)) { + if (!hasOwn(Desc, '[[Value]]')) { + Desc['[[Value]]'] = void 0; + } + if (!hasOwn(Desc, '[[Writable]]')) { + Desc['[[Writable]]'] = false; + } + } else { + if (!hasOwn(Desc, '[[Get]]')) { + Desc['[[Get]]'] = void 0; + } + if (!hasOwn(Desc, '[[Set]]')) { + Desc['[[Set]]'] = void 0; + } + } + if (!hasOwn(Desc, '[[Enumerable]]')) { + Desc['[[Enumerable]]'] = false; + } + if (!hasOwn(Desc, '[[Configurable]]')) { + Desc['[[Configurable]]'] = false; + } + return Desc; +}; diff --git a/node_modules/es-abstract/2022/CompletionRecord.js b/node_modules/es-abstract/2022/CompletionRecord.js new file mode 100644 index 0000000000000000000000000000000000000000..0a7a6817c87e69578cfbc5546901b1c4dba112a9 --- /dev/null +++ b/node_modules/es-abstract/2022/CompletionRecord.js @@ -0,0 +1,48 @@ +'use strict'; + +var $SyntaxError = require('es-errors/syntax'); + +var SLOT = require('internal-slot'); + +// https://262.ecma-international.org/7.0/#sec-completion-record-specification-type + +var CompletionRecord = function CompletionRecord(type, value) { + if (!(this instanceof CompletionRecord)) { + return new CompletionRecord(type, value); + } + if (type !== 'normal' && type !== 'break' && type !== 'continue' && type !== 'return' && type !== 'throw') { + throw new $SyntaxError('Assertion failed: `type` must be one of "normal", "break", "continue", "return", or "throw"'); + } + SLOT.set(this, '[[Type]]', type); + SLOT.set(this, '[[Value]]', value); + // [[Target]] slot? +}; + +CompletionRecord.prototype.type = function Type() { + return SLOT.get(this, '[[Type]]'); +}; + +CompletionRecord.prototype.value = function Value() { + return SLOT.get(this, '[[Value]]'); +}; + +CompletionRecord.prototype['?'] = function ReturnIfAbrupt() { + var type = SLOT.get(this, '[[Type]]'); + var value = SLOT.get(this, '[[Value]]'); + + if (type === 'throw') { + throw value; + } + return value; +}; + +CompletionRecord.prototype['!'] = function assert() { + var type = SLOT.get(this, '[[Type]]'); + + if (type !== 'normal') { + throw new $SyntaxError('Assertion failed: Completion Record is not of type "normal"'); + } + return SLOT.get(this, '[[Value]]'); +}; + +module.exports = CompletionRecord; diff --git a/node_modules/es-abstract/2022/CopyDataProperties.js b/node_modules/es-abstract/2022/CopyDataProperties.js new file mode 100644 index 0000000000000000000000000000000000000000..182720710e8b97fc0ed0f09cb7743aeb4baae938 --- /dev/null +++ b/node_modules/es-abstract/2022/CopyDataProperties.js @@ -0,0 +1,69 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); +var callBound = require('call-bound'); +var OwnPropertyKeys = require('own-keys'); + +var forEach = require('../helpers/forEach'); +var every = require('../helpers/every'); +var some = require('../helpers/some'); + +var $isEnumerable = callBound('Object.prototype.propertyIsEnumerable'); + +var CreateDataPropertyOrThrow = require('./CreateDataPropertyOrThrow'); +var Get = require('./Get'); +var IsArray = require('./IsArray'); +var isPropertyKey = require('../helpers/isPropertyKey'); +var SameValue = require('./SameValue'); +var ToNumber = require('./ToNumber'); +var ToObject = require('./ToObject'); + +var isInteger = require('math-intrinsics/isInteger'); + +// https://262.ecma-international.org/12.0/#sec-copydataproperties + +module.exports = function CopyDataProperties(target, source, excludedItems) { + if (!isObject(target)) { + throw new $TypeError('Assertion failed: "target" must be an Object'); + } + + if (!IsArray(excludedItems) || !every(excludedItems, isPropertyKey)) { + throw new $TypeError('Assertion failed: "excludedItems" must be a List of Property Keys'); + } + + if (typeof source === 'undefined' || source === null) { + return target; + } + + var from = ToObject(source); + + var keys = OwnPropertyKeys(from); + forEach(keys, function (nextKey) { + var excluded = some(excludedItems, function (e) { + return SameValue(e, nextKey) === true; + }); + /* + var excluded = false; + + forEach(excludedItems, function (e) { + if (SameValue(e, nextKey) === true) { + excluded = true; + } + }); + */ + + var enumerable = $isEnumerable(from, nextKey) || ( + // this is to handle string keys being non-enumerable in older engines + typeof source === 'string' + && nextKey >= 0 + && isInteger(ToNumber(nextKey)) + ); + if (excluded === false && enumerable) { + var propValue = Get(from, nextKey); + CreateDataPropertyOrThrow(target, nextKey, propValue); + } + }); + + return target; +}; diff --git a/node_modules/es-abstract/2022/CreateAsyncFromSyncIterator.js b/node_modules/es-abstract/2022/CreateAsyncFromSyncIterator.js new file mode 100644 index 0000000000000000000000000000000000000000..33c02bebc80cfdf01f16758e05a21b6d1ff7720c --- /dev/null +++ b/node_modules/es-abstract/2022/CreateAsyncFromSyncIterator.js @@ -0,0 +1,137 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $SyntaxError = require('es-errors/syntax'); +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); +var $Promise = GetIntrinsic('%Promise%', true); + +var AsyncFromSyncIteratorContinuation = require('./AsyncFromSyncIteratorContinuation'); +var Call = require('./Call'); +var CreateIterResultObject = require('./CreateIterResultObject'); +var Get = require('./Get'); +var GetMethod = require('./GetMethod'); +var IteratorNext = require('./IteratorNext'); +var OrdinaryObjectCreate = require('./OrdinaryObjectCreate'); + +var isIteratorRecord = require('../helpers/records/iterator-record-2023'); + +var SLOT = require('internal-slot'); + +var $AsyncFromSyncIteratorPrototype = GetIntrinsic('%AsyncFromSyncIteratorPrototype%', true) || { + next: function next(value) { + if (!$Promise) { + throw new $SyntaxError('This environment does not support Promises.'); + } + + var O = this; // step 1 + + SLOT.assert(O, '[[SyncIteratorRecord]]'); // step 2 + + var argsLength = arguments.length; + + return new $Promise(function (resolve) { // step 3 + var syncIteratorRecord = SLOT.get(O, '[[SyncIteratorRecord]]'); // step 4 + var result; + if (argsLength > 0) { + result = IteratorNext(syncIteratorRecord['[[Iterator]]'], value); // step 5.a + } else { // step 6 + result = IteratorNext(syncIteratorRecord['[[Iterator]]']);// step 6.a + } + resolve(AsyncFromSyncIteratorContinuation(result)); // step 8 + }); + }, + 'return': function () { + if (!$Promise) { + throw new $SyntaxError('This environment does not support Promises.'); + } + + var O = this; // step 1 + + SLOT.assert(O, '[[SyncIteratorRecord]]'); // step 2 + + var valueIsPresent = arguments.length > 0; + var value = valueIsPresent ? arguments[0] : void undefined; + + return new $Promise(function (resolve, reject) { // step 3 + var syncIterator = SLOT.get(O, '[[SyncIteratorRecord]]')['[[Iterator]]']; // step 4 + var iteratorReturn = GetMethod(syncIterator, 'return'); // step 5 + + if (typeof iteratorReturn === 'undefined') { // step 7 + var iterResult = CreateIterResultObject(value, true); // step 7.a + Call(resolve, undefined, [iterResult]); // step 7.b + return; + } + var result; + if (valueIsPresent) { // step 8 + result = Call(iteratorReturn, syncIterator, [value]); // step 8.a + } else { // step 9 + result = Call(iteratorReturn, syncIterator); // step 9.a + } + if (!isObject(result)) { // step 11 + Call(reject, undefined, [new $TypeError('Iterator `return` method returned a non-object value.')]); // step 11.a + return; + } + + resolve(AsyncFromSyncIteratorContinuation(result)); // step 12 + }); + }, + 'throw': function () { + if (!$Promise) { + throw new $SyntaxError('This environment does not support Promises.'); + } + + var O = this; // step 1 + + SLOT.assert(O, '[[SyncIteratorRecord]]'); // step 2 + + var valueIsPresent = arguments.length > 0; + var value = valueIsPresent ? arguments[0] : void undefined; + + return new $Promise(function (resolve, reject) { // step 3 + var syncIterator = SLOT.get(O, '[[SyncIteratorRecord]]')['[[Iterator]]']; // step 4 + + var throwMethod = GetMethod(syncIterator, 'throw'); // step 5 + + if (typeof throwMethod === 'undefined') { // step 7 + Call(reject, undefined, [value]); // step 7.a + return; + } + + var result; + if (valueIsPresent) { // step 8 + result = Call(throwMethod, syncIterator, [value]); // step 8.a + } else { // step 9 + result = Call(throwMethod, syncIterator); // step 9.a + } + if (!isObject(result)) { // step 11 + Call(reject, undefined, [new $TypeError('Iterator `throw` method returned a non-object value.')]); // step 11.a + return; + } + + resolve(AsyncFromSyncIteratorContinuation(result/* , promiseCapability */)); // step 12 + }); + } +}; + +// https://262.ecma-international.org/11.0/#sec-createasyncfromsynciterator + +module.exports = function CreateAsyncFromSyncIterator(syncIteratorRecord) { + if (!isIteratorRecord(syncIteratorRecord)) { + throw new $TypeError('Assertion failed: `syncIteratorRecord` must be an Iterator Record'); + } + + // var asyncIterator = OrdinaryObjectCreate(%AsyncFromSyncIteratorPrototype%, « [[SyncIteratorRecord]] »); // step 1 + var asyncIterator = OrdinaryObjectCreate($AsyncFromSyncIteratorPrototype); + + SLOT.set(asyncIterator, '[[SyncIteratorRecord]]', syncIteratorRecord); // step 2 + + var nextMethod = Get(asyncIterator, 'next'); // step 3 + + return { // steps 3-4 + '[[Iterator]]': asyncIterator, + '[[NextMethod]]': nextMethod, + '[[Done]]': false + }; +}; diff --git a/node_modules/es-abstract/2022/CreateDataProperty.js b/node_modules/es-abstract/2022/CreateDataProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..897617c0ca1e0365cb55a83855b0983550e3e298 --- /dev/null +++ b/node_modules/es-abstract/2022/CreateDataProperty.js @@ -0,0 +1,25 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var isPropertyKey = require('../helpers/isPropertyKey'); +var OrdinaryDefineOwnProperty = require('./OrdinaryDefineOwnProperty'); + +// https://262.ecma-international.org/6.0/#sec-createdataproperty + +module.exports = function CreateDataProperty(O, P, V) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: P is not a Property Key'); + } + var newDesc = { + '[[Configurable]]': true, + '[[Enumerable]]': true, + '[[Value]]': V, + '[[Writable]]': true + }; + return OrdinaryDefineOwnProperty(O, P, newDesc); +}; diff --git a/node_modules/es-abstract/2022/CreateDataPropertyOrThrow.js b/node_modules/es-abstract/2022/CreateDataPropertyOrThrow.js new file mode 100644 index 0000000000000000000000000000000000000000..42327aaef58a8ffc3c320851135e886106dcbad6 --- /dev/null +++ b/node_modules/es-abstract/2022/CreateDataPropertyOrThrow.js @@ -0,0 +1,24 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var CreateDataProperty = require('./CreateDataProperty'); + +var isPropertyKey = require('../helpers/isPropertyKey'); + +// // https://262.ecma-international.org/6.0/#sec-createdatapropertyorthrow + +module.exports = function CreateDataPropertyOrThrow(O, P, V) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: P is not a Property Key'); + } + var success = CreateDataProperty(O, P, V); + if (!success) { + throw new $TypeError('unable to create data property'); + } + return success; +}; diff --git a/node_modules/es-abstract/2022/CreateHTML.js b/node_modules/es-abstract/2022/CreateHTML.js new file mode 100644 index 0000000000000000000000000000000000000000..25630f43085954792b398e93a870ac78b46e3fc4 --- /dev/null +++ b/node_modules/es-abstract/2022/CreateHTML.js @@ -0,0 +1,27 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var callBound = require('call-bound'); + +var $replace = callBound('String.prototype.replace'); + +var RequireObjectCoercible = require('./RequireObjectCoercible'); +var ToString = require('./ToString'); + +// https://262.ecma-international.org/6.0/#sec-createhtml + +module.exports = function CreateHTML(string, tag, attribute, value) { + if (typeof tag !== 'string' || typeof attribute !== 'string') { + throw new $TypeError('Assertion failed: `tag` and `attribute` must be strings'); + } + var str = RequireObjectCoercible(string); + var S = ToString(str); + var p1 = '<' + tag; + if (attribute !== '') { + var V = ToString(value); + var escapedV = $replace(V, /\x22/g, '"'); + p1 += '\x20' + attribute + '\x3D\x22' + escapedV + '\x22'; + } + return p1 + '>' + S + ''; +}; diff --git a/node_modules/es-abstract/2022/CreateIterResultObject.js b/node_modules/es-abstract/2022/CreateIterResultObject.js new file mode 100644 index 0000000000000000000000000000000000000000..679bdf00ea851b40cce0dc9e6d55526aa9d5c5d7 --- /dev/null +++ b/node_modules/es-abstract/2022/CreateIterResultObject.js @@ -0,0 +1,15 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +// https://262.ecma-international.org/6.0/#sec-createiterresultobject + +module.exports = function CreateIterResultObject(value, done) { + if (typeof done !== 'boolean') { + throw new $TypeError('Assertion failed: Type(done) is not Boolean'); + } + return { + value: value, + done: done + }; +}; diff --git a/node_modules/es-abstract/2022/CreateListFromArrayLike.js b/node_modules/es-abstract/2022/CreateListFromArrayLike.js new file mode 100644 index 0000000000000000000000000000000000000000..3cd2d5c27a0867bd7a1fef684d6915a516544e32 --- /dev/null +++ b/node_modules/es-abstract/2022/CreateListFromArrayLike.js @@ -0,0 +1,44 @@ +'use strict'; + +var callBound = require('call-bound'); + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); +var $indexOf = callBound('Array.prototype.indexOf', true) || callBound('String.prototype.indexOf'); + +var Get = require('./Get'); +var IsArray = require('./IsArray'); +var LengthOfArrayLike = require('./LengthOfArrayLike'); +var ToString = require('./ToString'); +var Type = require('./Type'); + +var defaultElementTypes = ['Undefined', 'Null', 'Boolean', 'String', 'Symbol', 'Number', 'BigInt', 'Object']; + +// https://262.ecma-international.org/11.0/#sec-createlistfromarraylike + +module.exports = function CreateListFromArrayLike(obj) { + var elementTypes = arguments.length > 1 + ? arguments[1] + : defaultElementTypes; + + if (!isObject(obj)) { + throw new $TypeError('Assertion failed: `obj` must be an Object'); + } + if (!IsArray(elementTypes)) { + throw new $TypeError('Assertion failed: `elementTypes`, if provided, must be an array'); + } + var len = LengthOfArrayLike(obj); + var list = []; + var index = 0; + while (index < len) { + var indexName = ToString(index); + var next = Get(obj, indexName); + var nextType = Type(next); + if ($indexOf(elementTypes, nextType) < 0) { + throw new $TypeError('item type ' + nextType + ' is not a valid elementType'); + } + list[list.length] = next; + index += 1; + } + return list; +}; diff --git a/node_modules/es-abstract/2022/CreateMethodProperty.js b/node_modules/es-abstract/2022/CreateMethodProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..4c53a40986ad2c0f6678b161465bca1ba569dd21 --- /dev/null +++ b/node_modules/es-abstract/2022/CreateMethodProperty.js @@ -0,0 +1,38 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var DefineOwnProperty = require('../helpers/DefineOwnProperty'); + +var FromPropertyDescriptor = require('./FromPropertyDescriptor'); +var IsDataDescriptor = require('./IsDataDescriptor'); +var isPropertyKey = require('../helpers/isPropertyKey'); +var SameValue = require('./SameValue'); + +// https://262.ecma-international.org/6.0/#sec-createmethodproperty + +module.exports = function CreateMethodProperty(O, P, V) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: P is not a Property Key'); + } + + var newDesc = { + '[[Configurable]]': true, + '[[Enumerable]]': false, + '[[Value]]': V, + '[[Writable]]': true + }; + return DefineOwnProperty( + IsDataDescriptor, + SameValue, + FromPropertyDescriptor, + O, + P, + newDesc + ); +}; diff --git a/node_modules/es-abstract/2022/CreateNonEnumerableDataPropertyOrThrow.js b/node_modules/es-abstract/2022/CreateNonEnumerableDataPropertyOrThrow.js new file mode 100644 index 0000000000000000000000000000000000000000..5fc18ac2e0e9e296821337593b2568e4884b605d --- /dev/null +++ b/node_modules/es-abstract/2022/CreateNonEnumerableDataPropertyOrThrow.js @@ -0,0 +1,28 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var DefinePropertyOrThrow = require('./DefinePropertyOrThrow'); + +var isPropertyKey = require('../helpers/isPropertyKey'); + +// https://262.ecma-international.org/13.0/#sec-createnonenumerabledatapropertyorthrow + +module.exports = function CreateNonEnumerableDataPropertyOrThrow(O, P, V) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: P is not a Property Key'); + } + + var newDesc = { + '[[Configurable]]': true, + '[[Enumerable]]': false, + '[[Value]]': V, + '[[Writable]]': true + }; + return DefinePropertyOrThrow(O, P, newDesc); +}; diff --git a/node_modules/es-abstract/2022/CreateRegExpStringIterator.js b/node_modules/es-abstract/2022/CreateRegExpStringIterator.js new file mode 100644 index 0000000000000000000000000000000000000000..d7cc09963e2b8c33147bd8285d986e86d80201ea --- /dev/null +++ b/node_modules/es-abstract/2022/CreateRegExpStringIterator.js @@ -0,0 +1,100 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); +var hasSymbols = require('has-symbols')(); + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); +var IteratorPrototype = GetIntrinsic('%IteratorPrototype%', true); + +var AdvanceStringIndex = require('./AdvanceStringIndex'); +var CreateIterResultObject = require('./CreateIterResultObject'); +var CreateMethodProperty = require('./CreateMethodProperty'); +var Get = require('./Get'); +var OrdinaryObjectCreate = require('./OrdinaryObjectCreate'); +var RegExpExec = require('./RegExpExec'); +var Set = require('./Set'); +var ToLength = require('./ToLength'); +var ToString = require('./ToString'); + +var SLOT = require('internal-slot'); +var setToStringTag = require('es-set-tostringtag'); + +var RegExpStringIterator = function RegExpStringIterator(R, S, global, fullUnicode) { + if (typeof S !== 'string') { + throw new $TypeError('`S` must be a string'); + } + if (typeof global !== 'boolean') { + throw new $TypeError('`global` must be a boolean'); + } + if (typeof fullUnicode !== 'boolean') { + throw new $TypeError('`fullUnicode` must be a boolean'); + } + SLOT.set(this, '[[IteratingRegExp]]', R); + SLOT.set(this, '[[IteratedString]]', S); + SLOT.set(this, '[[Global]]', global); + SLOT.set(this, '[[Unicode]]', fullUnicode); + SLOT.set(this, '[[Done]]', false); +}; + +if (IteratorPrototype) { + RegExpStringIterator.prototype = OrdinaryObjectCreate(IteratorPrototype); +} + +var RegExpStringIteratorNext = function next() { + var O = this; + if (!isObject(O)) { + throw new $TypeError('receiver must be an object'); + } + if ( + !(O instanceof RegExpStringIterator) + || !SLOT.has(O, '[[IteratingRegExp]]') + || !SLOT.has(O, '[[IteratedString]]') + || !SLOT.has(O, '[[Global]]') + || !SLOT.has(O, '[[Unicode]]') + || !SLOT.has(O, '[[Done]]') + ) { + throw new $TypeError('"this" value must be a RegExpStringIterator instance'); + } + if (SLOT.get(O, '[[Done]]')) { + return CreateIterResultObject(undefined, true); + } + var R = SLOT.get(O, '[[IteratingRegExp]]'); + var S = SLOT.get(O, '[[IteratedString]]'); + var global = SLOT.get(O, '[[Global]]'); + var fullUnicode = SLOT.get(O, '[[Unicode]]'); + var match = RegExpExec(R, S); + if (match === null) { + SLOT.set(O, '[[Done]]', true); + return CreateIterResultObject(undefined, true); + } + if (global) { + var matchStr = ToString(Get(match, '0')); + if (matchStr === '') { + var thisIndex = ToLength(Get(R, 'lastIndex')); + var nextIndex = AdvanceStringIndex(S, thisIndex, fullUnicode); + Set(R, 'lastIndex', nextIndex, true); + } + return CreateIterResultObject(match, false); + } + SLOT.set(O, '[[Done]]', true); + return CreateIterResultObject(match, false); +}; +CreateMethodProperty(RegExpStringIterator.prototype, 'next', RegExpStringIteratorNext); + +if (hasSymbols) { + setToStringTag(RegExpStringIterator.prototype, 'RegExp String Iterator'); + + if (Symbol.iterator && typeof RegExpStringIterator.prototype[Symbol.iterator] !== 'function') { + var iteratorFn = function SymbolIterator() { + return this; + }; + CreateMethodProperty(RegExpStringIterator.prototype, Symbol.iterator, iteratorFn); + } +} + +// https://262.ecma-international.org/11.0/#sec-createregexpstringiterator +module.exports = function CreateRegExpStringIterator(R, S, global, fullUnicode) { + // assert R.global === global && R.unicode === fullUnicode? + return new RegExpStringIterator(R, S, global, fullUnicode); +}; diff --git a/node_modules/es-abstract/2022/DateFromTime.js b/node_modules/es-abstract/2022/DateFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..ec7edcd295f8bdd79eb60e44d8a17bb0b90fd80d --- /dev/null +++ b/node_modules/es-abstract/2022/DateFromTime.js @@ -0,0 +1,52 @@ +'use strict'; + +var $EvalError = require('es-errors/eval'); + +var DayWithinYear = require('./DayWithinYear'); +var InLeapYear = require('./InLeapYear'); +var MonthFromTime = require('./MonthFromTime'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.5 + +module.exports = function DateFromTime(t) { + var m = MonthFromTime(t); + var d = DayWithinYear(t); + if (m === 0) { + return d + 1; + } + if (m === 1) { + return d - 30; + } + var leap = InLeapYear(t); + if (m === 2) { + return d - 58 - leap; + } + if (m === 3) { + return d - 89 - leap; + } + if (m === 4) { + return d - 119 - leap; + } + if (m === 5) { + return d - 150 - leap; + } + if (m === 6) { + return d - 180 - leap; + } + if (m === 7) { + return d - 211 - leap; + } + if (m === 8) { + return d - 242 - leap; + } + if (m === 9) { + return d - 272 - leap; + } + if (m === 10) { + return d - 303 - leap; + } + if (m === 11) { + return d - 333 - leap; + } + throw new $EvalError('Assertion failed: MonthFromTime returned an impossible value: ' + m); +}; diff --git a/node_modules/es-abstract/2022/DateString.js b/node_modules/es-abstract/2022/DateString.js new file mode 100644 index 0000000000000000000000000000000000000000..8106127a7d9e7708279035a2488e66cd49bbd5cb --- /dev/null +++ b/node_modules/es-abstract/2022/DateString.js @@ -0,0 +1,27 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var weekdays = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']; +var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; + +var $isNaN = require('math-intrinsics/isNaN'); +var padTimeComponent = require('../helpers/padTimeComponent'); + +var DateFromTime = require('./DateFromTime'); +var MonthFromTime = require('./MonthFromTime'); +var WeekDay = require('./WeekDay'); +var YearFromTime = require('./YearFromTime'); + +// https://262.ecma-international.org/9.0/#sec-datestring + +module.exports = function DateString(tv) { + if (typeof tv !== 'number' || $isNaN(tv)) { + throw new $TypeError('Assertion failed: `tv` must be a non-NaN Number'); + } + var weekday = weekdays[WeekDay(tv)]; + var month = months[MonthFromTime(tv)]; + var day = padTimeComponent(DateFromTime(tv)); + var year = padTimeComponent(YearFromTime(tv), 4); + return weekday + '\x20' + month + '\x20' + day + '\x20' + year; +}; diff --git a/node_modules/es-abstract/2022/Day.js b/node_modules/es-abstract/2022/Day.js new file mode 100644 index 0000000000000000000000000000000000000000..51d01033c81cbd356ff4da8010c166137364237d --- /dev/null +++ b/node_modules/es-abstract/2022/Day.js @@ -0,0 +1,11 @@ +'use strict'; + +var floor = require('./floor'); + +var msPerDay = require('../helpers/timeConstants').msPerDay; + +// https://262.ecma-international.org/5.1/#sec-15.9.1.2 + +module.exports = function Day(t) { + return floor(t / msPerDay); +}; diff --git a/node_modules/es-abstract/2022/DayFromYear.js b/node_modules/es-abstract/2022/DayFromYear.js new file mode 100644 index 0000000000000000000000000000000000000000..341bf22a6c19352ec6225944fb49adeed22983e8 --- /dev/null +++ b/node_modules/es-abstract/2022/DayFromYear.js @@ -0,0 +1,10 @@ +'use strict'; + +var floor = require('./floor'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.3 + +module.exports = function DayFromYear(y) { + return (365 * (y - 1970)) + floor((y - 1969) / 4) - floor((y - 1901) / 100) + floor((y - 1601) / 400); +}; + diff --git a/node_modules/es-abstract/2022/DayWithinYear.js b/node_modules/es-abstract/2022/DayWithinYear.js new file mode 100644 index 0000000000000000000000000000000000000000..4c580940a58c58dcc3f7c2f96c5bca8e8237ebfc --- /dev/null +++ b/node_modules/es-abstract/2022/DayWithinYear.js @@ -0,0 +1,11 @@ +'use strict'; + +var Day = require('./Day'); +var DayFromYear = require('./DayFromYear'); +var YearFromTime = require('./YearFromTime'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.4 + +module.exports = function DayWithinYear(t) { + return Day(t) - DayFromYear(YearFromTime(t)); +}; diff --git a/node_modules/es-abstract/2022/DaysInYear.js b/node_modules/es-abstract/2022/DaysInYear.js new file mode 100644 index 0000000000000000000000000000000000000000..7116c69027022323e41130f384db7cc3d35709f9 --- /dev/null +++ b/node_modules/es-abstract/2022/DaysInYear.js @@ -0,0 +1,18 @@ +'use strict'; + +var modulo = require('./modulo'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.3 + +module.exports = function DaysInYear(y) { + if (modulo(y, 4) !== 0) { + return 365; + } + if (modulo(y, 100) !== 0) { + return 366; + } + if (modulo(y, 400) !== 0) { + return 365; + } + return 366; +}; diff --git a/node_modules/es-abstract/2022/DefineMethodProperty.js b/node_modules/es-abstract/2022/DefineMethodProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..f6eb168d4edebc7af367a994242bdd56f5f240e9 --- /dev/null +++ b/node_modules/es-abstract/2022/DefineMethodProperty.js @@ -0,0 +1,42 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var DefinePropertyOrThrow = require('./DefinePropertyOrThrow'); +var IsExtensible = require('./IsExtensible'); + +var isPropertyKey = require('../helpers/isPropertyKey'); + +// https://262.ecma-international.org/13.0/#sec-definemethodproperty + +module.exports = function DefineMethodProperty(homeObject, key, closure, enumerable) { + if (!isObject(homeObject)) { + throw new $TypeError('Assertion failed: `homeObject` is not an Object'); + } + if (!isPropertyKey(key)) { + throw new $TypeError('Assertion failed: `key` is not a Property Key or a Private Name'); + } + if (typeof closure !== 'function') { + throw new $TypeError('Assertion failed: `closure` is not a function'); + } + if (typeof enumerable !== 'boolean') { + throw new $TypeError('Assertion failed: `enumerable` is not a Boolean'); + } + + // 1. Assert: homeObject is an ordinary, extensible object with no non-configurable properties. + if (!IsExtensible(homeObject)) { + throw new $TypeError('Assertion failed: `homeObject` is not an ordinary, extensible object, with no non-configurable properties'); + } + + // 2. If key is a Private Name, then + // a. Return PrivateElement { [[Key]]: key, [[Kind]]: method, [[Value]]: closure }. + // 3. Else, + var desc = { // step 3.a + '[[Value]]': closure, + '[[Writable]]': true, + '[[Enumerable]]': enumerable, + '[[Configurable]]': true + }; + DefinePropertyOrThrow(homeObject, key, desc); // step 3.b +}; diff --git a/node_modules/es-abstract/2022/DefinePropertyOrThrow.js b/node_modules/es-abstract/2022/DefinePropertyOrThrow.js new file mode 100644 index 0000000000000000000000000000000000000000..ff6683c3dc954ec27c072032bfcc0cfd70936587 --- /dev/null +++ b/node_modules/es-abstract/2022/DefinePropertyOrThrow.js @@ -0,0 +1,39 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var isPropertyDescriptor = require('../helpers/records/property-descriptor'); +var DefineOwnProperty = require('../helpers/DefineOwnProperty'); + +var FromPropertyDescriptor = require('./FromPropertyDescriptor'); +var IsDataDescriptor = require('./IsDataDescriptor'); +var isPropertyKey = require('../helpers/isPropertyKey'); +var SameValue = require('./SameValue'); +var ToPropertyDescriptor = require('./ToPropertyDescriptor'); + +// https://262.ecma-international.org/6.0/#sec-definepropertyorthrow + +module.exports = function DefinePropertyOrThrow(O, P, desc) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: P is not a Property Key'); + } + + var Desc = isPropertyDescriptor(desc) ? desc : ToPropertyDescriptor(desc); + if (!isPropertyDescriptor(Desc)) { + throw new $TypeError('Assertion failed: Desc is not a valid Property Descriptor'); + } + + return DefineOwnProperty( + IsDataDescriptor, + SameValue, + FromPropertyDescriptor, + O, + P, + Desc + ); +}; diff --git a/node_modules/es-abstract/2022/DeletePropertyOrThrow.js b/node_modules/es-abstract/2022/DeletePropertyOrThrow.js new file mode 100644 index 0000000000000000000000000000000000000000..8841fda81f7663673367bdfc1af99794fb0ef747 --- /dev/null +++ b/node_modules/es-abstract/2022/DeletePropertyOrThrow.js @@ -0,0 +1,25 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var isPropertyKey = require('../helpers/isPropertyKey'); + +// https://262.ecma-international.org/6.0/#sec-deletepropertyorthrow + +module.exports = function DeletePropertyOrThrow(O, P) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: P is not a Property Key'); + } + + // eslint-disable-next-line no-param-reassign + var success = delete O[P]; + if (!success) { + throw new $TypeError('Attempt to delete property failed.'); + } + return success; +}; diff --git a/node_modules/es-abstract/2022/DetachArrayBuffer.js b/node_modules/es-abstract/2022/DetachArrayBuffer.js new file mode 100644 index 0000000000000000000000000000000000000000..6ded9de5652c4483ba14060ba82380eb3e63d92a --- /dev/null +++ b/node_modules/es-abstract/2022/DetachArrayBuffer.js @@ -0,0 +1,46 @@ +'use strict'; + +var $SyntaxError = require('es-errors/syntax'); +var $TypeError = require('es-errors/type'); + +var IsDetachedBuffer = require('./IsDetachedBuffer'); + +var isArrayBuffer = require('is-array-buffer'); +var isSharedArrayBuffer = require('is-shared-array-buffer'); + +var MessageChannel; +try { + // eslint-disable-next-line global-require + MessageChannel = require('worker_threads').MessageChannel; +} catch (e) { /**/ } + +// https://262.ecma-international.org/9.0/#sec-detacharraybuffer + +/* globals postMessage */ + +module.exports = function DetachArrayBuffer(arrayBuffer) { + if (!isArrayBuffer(arrayBuffer) || isSharedArrayBuffer(arrayBuffer)) { + throw new $TypeError('Assertion failed: `arrayBuffer` must be an Object with an [[ArrayBufferData]] internal slot, and not a Shared Array Buffer'); + } + + // commented out since there's no way to set or access this key + // var key = arguments.length > 1 ? arguments[1] : void undefined; + + // if (!SameValue(arrayBuffer[[ArrayBufferDetachKey]], key)) { + // throw new $TypeError('Assertion failed: `key` must be the value of the [[ArrayBufferDetachKey]] internal slot of `arrayBuffer`'); + // } + + if (!IsDetachedBuffer(arrayBuffer)) { // node v21.0.0+ throws when you structuredClone a detached buffer + if (typeof structuredClone === 'function') { + structuredClone(arrayBuffer, { transfer: [arrayBuffer] }); + } else if (typeof postMessage === 'function') { + postMessage('', '/', [arrayBuffer]); // TODO: see if this might trigger listeners + } else if (MessageChannel) { + (new MessageChannel()).port1.postMessage(null, [arrayBuffer]); + } else { + throw new $SyntaxError('DetachArrayBuffer is not supported in this environment'); + } + } + + return null; +}; diff --git a/node_modules/es-abstract/2022/EnumerableOwnPropertyNames.js b/node_modules/es-abstract/2022/EnumerableOwnPropertyNames.js new file mode 100644 index 0000000000000000000000000000000000000000..f08d846e95148ddd0b96f0475ea6d1ae3554e704 --- /dev/null +++ b/node_modules/es-abstract/2022/EnumerableOwnPropertyNames.js @@ -0,0 +1,37 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var objectKeys = require('object-keys'); +var safePushApply = require('safe-push-apply'); +var callBound = require('call-bound'); + +var $isEnumerable = callBound('Object.prototype.propertyIsEnumerable'); + +var forEach = require('../helpers/forEach'); + +// https://262.ecma-international.org/8.0/#sec-enumerableownproperties + +module.exports = function EnumerableOwnPropertyNames(O, kind) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + var keys = objectKeys(O); + if (kind === 'key') { + return keys; + } + if (kind === 'value' || kind === 'key+value') { + var results = []; + forEach(keys, function (key) { + if ($isEnumerable(O, key)) { + safePushApply(results, [ + kind === 'value' ? O[key] : [key, O[key]] + ]); + } + }); + return results; + } + throw new $TypeError('Assertion failed: "kind" is not "key", "value", or "key+value": ' + kind); +}; diff --git a/node_modules/es-abstract/2022/FlattenIntoArray.js b/node_modules/es-abstract/2022/FlattenIntoArray.js new file mode 100644 index 0000000000000000000000000000000000000000..78dc57c8cc90f0c0a60adb32fc7f41c230c4a591 --- /dev/null +++ b/node_modules/es-abstract/2022/FlattenIntoArray.js @@ -0,0 +1,55 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var MAX_SAFE_INTEGER = require('math-intrinsics/constants/maxSafeInteger'); + +var Call = require('./Call'); +var CreateDataPropertyOrThrow = require('./CreateDataPropertyOrThrow'); +var Get = require('./Get'); +var HasProperty = require('./HasProperty'); +var IsArray = require('./IsArray'); +var LengthOfArrayLike = require('./LengthOfArrayLike'); +var ToString = require('./ToString'); + +// https://262.ecma-international.org/11.0/#sec-flattenintoarray + +module.exports = function FlattenIntoArray(target, source, sourceLen, start, depth) { + var mapperFunction; + if (arguments.length > 5) { + mapperFunction = arguments[5]; + } + + var targetIndex = start; + var sourceIndex = 0; + while (sourceIndex < sourceLen) { + var P = ToString(sourceIndex); + var exists = HasProperty(source, P); + if (exists === true) { + var element = Get(source, P); + if (typeof mapperFunction !== 'undefined') { + if (arguments.length <= 6) { + throw new $TypeError('Assertion failed: thisArg is required when mapperFunction is provided'); + } + element = Call(mapperFunction, arguments[6], [element, sourceIndex, source]); + } + var shouldFlatten = false; + if (depth > 0) { + shouldFlatten = IsArray(element); + } + if (shouldFlatten) { + var elementLen = LengthOfArrayLike(element); + targetIndex = FlattenIntoArray(target, element, elementLen, targetIndex, depth - 1); + } else { + if (targetIndex >= MAX_SAFE_INTEGER) { + throw new $TypeError('index too large'); + } + CreateDataPropertyOrThrow(target, ToString(targetIndex), element); + targetIndex += 1; + } + } + sourceIndex += 1; + } + + return targetIndex; +}; diff --git a/node_modules/es-abstract/2022/FromPropertyDescriptor.js b/node_modules/es-abstract/2022/FromPropertyDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..45b6379f1214c415e1e43b855db01f18b3566cba --- /dev/null +++ b/node_modules/es-abstract/2022/FromPropertyDescriptor.js @@ -0,0 +1,16 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var isPropertyDescriptor = require('../helpers/records/property-descriptor'); +var fromPropertyDescriptor = require('../helpers/fromPropertyDescriptor'); + +// https://262.ecma-international.org/6.0/#sec-frompropertydescriptor + +module.exports = function FromPropertyDescriptor(Desc) { + if (typeof Desc !== 'undefined' && !isPropertyDescriptor(Desc)) { + throw new $TypeError('Assertion failed: `Desc` must be a Property Descriptor'); + } + + return fromPropertyDescriptor(Desc); +}; diff --git a/node_modules/es-abstract/2022/Get.js b/node_modules/es-abstract/2022/Get.js new file mode 100644 index 0000000000000000000000000000000000000000..42f7a14d853e05735d4166708590df2743cfa74c --- /dev/null +++ b/node_modules/es-abstract/2022/Get.js @@ -0,0 +1,24 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var inspect = require('object-inspect'); + +var isPropertyKey = require('../helpers/isPropertyKey'); + +var isObject = require('es-object-atoms/isObject'); + +// https://262.ecma-international.org/6.0/#sec-get-o-p + +module.exports = function Get(O, P) { + // 7.3.1.1 + if (!isObject(O)) { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + // 7.3.1.2 + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: P is not a Property Key, got ' + inspect(P)); + } + // 7.3.1.3 + return O[P]; +}; diff --git a/node_modules/es-abstract/2022/GetGlobalObject.js b/node_modules/es-abstract/2022/GetGlobalObject.js new file mode 100644 index 0000000000000000000000000000000000000000..0541ede0c48889fefe9a137e0e37a2e13573c091 --- /dev/null +++ b/node_modules/es-abstract/2022/GetGlobalObject.js @@ -0,0 +1,9 @@ +'use strict'; + +var getGlobal = require('globalthis/polyfill'); + +// https://262.ecma-international.org/6.0/#sec-getglobalobject + +module.exports = function GetGlobalObject() { + return getGlobal(); +}; diff --git a/node_modules/es-abstract/2022/GetIterator.js b/node_modules/es-abstract/2022/GetIterator.js new file mode 100644 index 0000000000000000000000000000000000000000..9c7bdfce51f79e2501c0a15702476bd78458028f --- /dev/null +++ b/node_modules/es-abstract/2022/GetIterator.js @@ -0,0 +1,63 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = require('es-errors/type'); +var $SyntaxError = require('es-errors/syntax'); +var isObject = require('es-object-atoms/isObject'); +var $asyncIterator = GetIntrinsic('%Symbol.asyncIterator%', true); + +var inspect = require('object-inspect'); +var hasSymbols = require('has-symbols')(); + +var getIteratorMethod = require('../helpers/getIteratorMethod'); +var AdvanceStringIndex = require('./AdvanceStringIndex'); +var Call = require('./Call'); +var GetMethod = require('./GetMethod'); + +var ES = { + AdvanceStringIndex: AdvanceStringIndex, + GetMethod: GetMethod +}; + +// https://262.ecma-international.org/9.0/#sec-getiterator + +module.exports = function GetIterator(obj, hint, method) { + var actualHint = hint; + if (arguments.length < 2) { + actualHint = 'sync'; + } + if (actualHint !== 'sync' && actualHint !== 'async') { + throw new $TypeError("Assertion failed: `hint` must be one of 'sync' or 'async', got " + inspect(hint)); + } + + var actualMethod = method; + if (arguments.length < 3) { + if (actualHint === 'async') { + if (hasSymbols && $asyncIterator) { + actualMethod = GetMethod(obj, $asyncIterator); + } + if (actualMethod === undefined) { + throw new $SyntaxError("async from sync iterators aren't currently supported"); + } + } else { + actualMethod = getIteratorMethod(ES, obj); + } + } + var iterator = Call(actualMethod, obj); + if (!isObject(iterator)) { + throw new $TypeError('iterator must return an object'); + } + + return iterator; + + // TODO: This should return an IteratorRecord + /* + var nextMethod = GetV(iterator, 'next'); + return { + '[[Iterator]]': iterator, + '[[NextMethod]]': nextMethod, + '[[Done]]': false + }; + */ +}; diff --git a/node_modules/es-abstract/2022/GetMatchIndexPair.js b/node_modules/es-abstract/2022/GetMatchIndexPair.js new file mode 100644 index 0000000000000000000000000000000000000000..76cda5d841f9ac233954d221eee40c7a06bacc3a --- /dev/null +++ b/node_modules/es-abstract/2022/GetMatchIndexPair.js @@ -0,0 +1,24 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var isMatchRecord = require('../helpers/records/match-record'); + +// https://262.ecma-international.org/13.0/#sec-getmatchindexpair + +module.exports = function GetMatchIndexPair(S, match) { + if (typeof S !== 'string') { + throw new $TypeError('Assertion failed: `S` must be a String'); + } + if (!isMatchRecord(match)) { + throw new $TypeError('Assertion failed: `match` must be a Match Record'); + } + + if (!(match['[[StartIndex]]'] <= S.length)) { + throw new $TypeError('`match` [[StartIndex]] must be a non-negative integer <= the length of S'); + } + if (!(match['[[EndIndex]]'] <= S.length)) { + throw new $TypeError('`match` [[EndIndex]] must be an integer between [[StartIndex]] and the length of S, inclusive'); + } + return [match['[[StartIndex]]'], match['[[EndIndex]]']]; +}; diff --git a/node_modules/es-abstract/2022/GetMatchString.js b/node_modules/es-abstract/2022/GetMatchString.js new file mode 100644 index 0000000000000000000000000000000000000000..7fddd4ea202f7482baaa85b582a8fcbe069caa12 --- /dev/null +++ b/node_modules/es-abstract/2022/GetMatchString.js @@ -0,0 +1,26 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var substring = require('./substring'); + +var isMatchRecord = require('../helpers/records/match-record'); + +// https://262.ecma-international.org/13.0/#sec-getmatchstring + +module.exports = function GetMatchString(S, match) { + if (typeof S !== 'string') { + throw new $TypeError('Assertion failed: `S` must be a String'); + } + if (!isMatchRecord(match)) { + throw new $TypeError('Assertion failed: `match` must be a Match Record'); + } + + if (!(match['[[StartIndex]]'] <= S.length)) { + throw new $TypeError('`match` [[StartIndex]] must be a non-negative integer <= the length of S'); + } + if (!(match['[[EndIndex]]'] <= S.length)) { + throw new $TypeError('`match` [[EndIndex]] must be an integer between [[StartIndex]] and the length of S, inclusive'); + } + return substring(S, match['[[StartIndex]]'], match['[[EndIndex]]']); +}; diff --git a/node_modules/es-abstract/2022/GetMethod.js b/node_modules/es-abstract/2022/GetMethod.js new file mode 100644 index 0000000000000000000000000000000000000000..e28bb1501fc8e4d4a67250c5110cba73bbcba385 --- /dev/null +++ b/node_modules/es-abstract/2022/GetMethod.js @@ -0,0 +1,34 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var GetV = require('./GetV'); +var IsCallable = require('./IsCallable'); +var isPropertyKey = require('../helpers/isPropertyKey'); + +var inspect = require('object-inspect'); + +// https://262.ecma-international.org/6.0/#sec-getmethod + +module.exports = function GetMethod(O, P) { + // 7.3.9.1 + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: P is not a Property Key'); + } + + // 7.3.9.2 + var func = GetV(O, P); + + // 7.3.9.4 + if (func == null) { + return void 0; + } + + // 7.3.9.5 + if (!IsCallable(func)) { + throw new $TypeError(inspect(P) + ' is not a function: ' + inspect(func)); + } + + // 7.3.9.6 + return func; +}; diff --git a/node_modules/es-abstract/2022/GetOwnPropertyKeys.js b/node_modules/es-abstract/2022/GetOwnPropertyKeys.js new file mode 100644 index 0000000000000000000000000000000000000000..e9b50d744a5fdf42221ad18e6674e777fa3b0a47 --- /dev/null +++ b/node_modules/es-abstract/2022/GetOwnPropertyKeys.js @@ -0,0 +1,30 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var hasSymbols = require('has-symbols')(); + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var $gOPN = GetIntrinsic('%Object.getOwnPropertyNames%', true); +var $gOPS = hasSymbols && GetIntrinsic('%Object.getOwnPropertySymbols%', true); +var keys = require('object-keys'); + +// https://262.ecma-international.org/6.0/#sec-getownpropertykeys + +module.exports = function GetOwnPropertyKeys(O, Type) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + if (Type === 'Symbol') { + return $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"`'); +}; diff --git a/node_modules/es-abstract/2022/GetPromiseResolve.js b/node_modules/es-abstract/2022/GetPromiseResolve.js new file mode 100644 index 0000000000000000000000000000000000000000..7c9d9a945a0c268fa7558eec169a2cee0e903b86 --- /dev/null +++ b/node_modules/es-abstract/2022/GetPromiseResolve.js @@ -0,0 +1,20 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var Get = require('./Get'); +var IsCallable = require('./IsCallable'); +var IsConstructor = require('./IsConstructor'); + +// https://262.ecma-international.org/12.0/#sec-getpromiseresolve + +module.exports = function GetPromiseResolve(promiseConstructor) { + if (!IsConstructor(promiseConstructor)) { + throw new $TypeError('Assertion failed: `promiseConstructor` must be a constructor'); + } + var promiseResolve = Get(promiseConstructor, 'resolve'); + if (IsCallable(promiseResolve) === false) { + throw new $TypeError('`resolve` method is not callable'); + } + return promiseResolve; +}; diff --git a/node_modules/es-abstract/2022/GetPrototypeFromConstructor.js b/node_modules/es-abstract/2022/GetPrototypeFromConstructor.js new file mode 100644 index 0000000000000000000000000000000000000000..687f6ef200fb11a3dc97a27533d15430c305fb3b --- /dev/null +++ b/node_modules/es-abstract/2022/GetPrototypeFromConstructor.js @@ -0,0 +1,33 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $Function = GetIntrinsic('%Function%'); +var $TypeError = require('es-errors/type'); +var $SyntaxError = require('es-errors/syntax'); + +var Get = require('./Get'); +var IsConstructor = require('./IsConstructor'); + +var isObject = require('es-object-atoms/isObject'); + +// https://262.ecma-international.org/6.0/#sec-getprototypefromconstructor + +module.exports = function GetPrototypeFromConstructor(constructor, intrinsicDefaultProto) { + var intrinsic = GetIntrinsic(intrinsicDefaultProto); // throws if not a valid intrinsic + if (!isObject(intrinsic)) { + throw new $TypeError('intrinsicDefaultProto must be an object'); + } + if (!IsConstructor(constructor)) { + throw new $TypeError('Assertion failed: `constructor` must be a constructor'); + } + var proto = Get(constructor, 'prototype'); + if (!isObject(proto)) { + if (!(constructor instanceof $Function)) { + // ignore other realms, for now + throw new $SyntaxError('cross-realm constructors not currently supported'); + } + proto = intrinsic; + } + return proto; +}; diff --git a/node_modules/es-abstract/2022/GetStringIndex.js b/node_modules/es-abstract/2022/GetStringIndex.js new file mode 100644 index 0000000000000000000000000000000000000000..101198ff01a6d832dbc8f84c0ff574944e67a8b6 --- /dev/null +++ b/node_modules/es-abstract/2022/GetStringIndex.js @@ -0,0 +1,27 @@ +'use strict'; + +var callBound = require('call-bound'); +var $TypeError = require('es-errors/type'); +var isInteger = require('math-intrinsics/isInteger'); + +var StringToCodePoints = require('./StringToCodePoints'); + +var $indexOf = callBound('String.prototype.indexOf'); + +// https://262.ecma-international.org/13.0/#sec-getstringindex + +module.exports = function GetStringIndex(S, e) { + if (typeof S !== 'string') { + throw new $TypeError('Assertion failed: `S` must be a String'); + } + if (!isInteger(e) || e < 0) { + throw new $TypeError('Assertion failed: `e` must be a non-negative integer'); + } + + if (S === '') { + return 0; + } + var codepoints = StringToCodePoints(S); + var eUTF = e >= codepoints.length ? S.length : $indexOf(S, codepoints[e]); + return eUTF; +}; diff --git a/node_modules/es-abstract/2022/GetSubstitution.js b/node_modules/es-abstract/2022/GetSubstitution.js new file mode 100644 index 0000000000000000000000000000000000000000..e01641c7813d8bf1695b1d423731013e3f8f2177 --- /dev/null +++ b/node_modules/es-abstract/2022/GetSubstitution.js @@ -0,0 +1,137 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); +var regexTester = require('safe-regex-test'); +var inspect = require('object-inspect'); +var isInteger = require('math-intrinsics/isInteger'); + +var Get = require('./Get'); +var IsArray = require('./IsArray'); +var min = require('./min'); +var StringIndexOf = require('./StringIndexOf'); +var StringToNumber = require('./StringToNumber'); +var substring = require('./substring'); +var ToString = require('./ToString'); + +var every = require('../helpers/every'); +var isPrefixOf = require('../helpers/isPrefixOf'); +var isStringOrUndefined = require('../helpers/isStringOrUndefined'); + +var startsWithDollarDigit = regexTester(/^\$[0-9]/); + +// http://www.ecma-international.org/ecma-262/13.0/#sec-getsubstitution + +// eslint-disable-next-line max-statements, max-params, max-lines-per-function +module.exports = function GetSubstitution(matched, str, position, captures, namedCaptures, replacementTemplate) { + if (typeof matched !== 'string') { + throw new $TypeError('Assertion failed: `matched` must be a String'); + } + + if (typeof str !== 'string') { + throw new $TypeError('Assertion failed: `str` must be a String'); + } + + if (!isInteger(position) || position < 0) { + throw new $TypeError('Assertion failed: `position` must be a nonnegative integer, got ' + inspect(position)); + } + + if (!IsArray(captures) || !every(captures, isStringOrUndefined)) { + throw new $TypeError('Assertion failed: `captures` must be a possibly-empty List of Strings or `undefined`, got ' + inspect(captures)); + } + + if (typeof namedCaptures !== 'undefined' && !isObject(namedCaptures)) { + throw new $TypeError('Assertion failed: `namedCaptures` must be `undefined` or an Object'); + } + + if (typeof replacementTemplate !== 'string') { + throw new $TypeError('Assertion failed: `replacementTemplate` must be a String'); + } + + var stringLength = str.length; // step 1 + + if (position > stringLength) { + throw new $TypeError('Assertion failed: position > stringLength, got ' + inspect(position)); // step 2 + } + + var templateRemainder = replacementTemplate; // step 3 + + var result = ''; // step 4 + + while (templateRemainder !== '') { // step 5 + // 5.a NOTE: The following steps isolate ref (a prefix of templateRemainder), determine refReplacement (its replacement), and then append that replacement to result. + + var ref, refReplacement, found, capture; + if (isPrefixOf('$$', templateRemainder)) { // step 5.b + ref = '$$'; // step 5.b.i + refReplacement = '$'; // step 5.b.ii + } else if (isPrefixOf('$`', templateRemainder)) { // step 5.c + ref = '$`'; // step 5.c.i + refReplacement = substring(str, 0, position); // step 5.c.ii + } else if (isPrefixOf('$&', templateRemainder)) { // step 5.d + ref = '$&'; // step 5.d.i + refReplacement = matched; // step 5.d.ii + } else if (isPrefixOf('$\'', templateRemainder)) { // step 5.e + ref = '$\''; // step 5.e.i + var matchLength = matched.length; // step 5.e.ii + var tailPos = position + matchLength; // step 5.e.iii + refReplacement = substring(str, min(tailPos, stringLength)); // step 5.e.iv + // 5.e.v NOTE: tailPos can exceed stringLength only if this abstract operation was invoked by a call to the intrinsic @@replace method of %RegExp.prototype% on an object whose "exec" property is not the intrinsic %RegExp.prototype.exec%. + } else if (startsWithDollarDigit(templateRemainder)) { // step 5.f + found = false; // step 5.f.i + for (var d = 2; d > 0; d -= 1) { // step 5.f.ii + // If found is false and templateRemainder starts with "$" followed by d or more decimal digits, then + if (!found) { // step 5.f.ii.1 + found = true; // step 5.f.ii.1.a + ref = substring(templateRemainder, 0, 1 + d); // step 5.f.ii.1.b + var digits = substring(templateRemainder, 1, 1 + d); // step 5.f.ii.1.c + var index = StringToNumber(digits); // step 5.f.ii.1.d + if (index < 0 || index > 99) { + throw new $TypeError('Assertion failed: `index` must be >= 0 and <= 99'); // step 5.f.ii.1.e + } + if (index === 0) { // step 5.f.ii.1.f + refReplacement = ref; + } else if (index <= captures.length) { // step 5.f.ii.1.g + capture = captures[index - 1]; // step 5.f.ii.1.g.i + if (typeof capture === 'undefined') { // step 5.f.ii.1.g.ii + refReplacement = ''; // step 5.f.ii.1.g.ii.i + } else { // step 5.f.ii.1.g.iii + refReplacement = capture; // step 5.f.ii.1.g.iii.i + } + } else { // step 5.f.ii.1.h + refReplacement = ref; // step 5.f.ii.1.h.i + } + } + } + } else if (isPrefixOf('$<', templateRemainder)) { // step 5.g + var gtPos = StringIndexOf(templateRemainder, '>', 0); // step 5.g.i + if (gtPos === -1 || typeof namedCaptures === 'undefined') { // step 5.g.ii + ref = '$<'; // step 5.g.ii.1 + refReplacement = ref; // step 5.g.ii.2 + } else { // step 5.g.iii + ref = substring(templateRemainder, 0, gtPos + 1); // step 5.g.iii.1 + var groupName = substring(templateRemainder, 2, gtPos); // step 5.g.iii.2 + if (!isObject(namedCaptures)) { + throw new $TypeError('Assertion failed: Type(namedCaptures) is not Object'); // step 5.g.iii.3 + } + capture = Get(namedCaptures, groupName); // step 5.g.iii.4 + if (typeof capture === 'undefined') { // step 5.g.iii.5 + refReplacement = ''; // step 5.g.iii.5.a + } else { // step 5.g.iii.6 + refReplacement = ToString(capture); // step 5.g.iii.6.a + } + } + } else { // step 5.h + ref = substring(templateRemainder, 0, 1); // step 5.h.i + refReplacement = ref; // step 5.h.ii + } + + var refLength = ref.length; // step 5.i + + templateRemainder = substring(templateRemainder, refLength); // step 5.j + + result += refReplacement; // step 5.k + } + + return result; // step 6 +}; diff --git a/node_modules/es-abstract/2022/GetV.js b/node_modules/es-abstract/2022/GetV.js new file mode 100644 index 0000000000000000000000000000000000000000..920dec3c4a4eac8aa63678c2afa5683e79e3337f --- /dev/null +++ b/node_modules/es-abstract/2022/GetV.js @@ -0,0 +1,23 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var inspect = require('object-inspect'); + +var isPropertyKey = require('../helpers/isPropertyKey'); +// var ToObject = require('./ToObject'); + +// https://262.ecma-international.org/6.0/#sec-getv + +module.exports = function GetV(V, P) { + // 7.3.2.1 + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: P is not a Property Key, got ' + inspect(P)); + } + + // 7.3.2.2-3 + // var O = ToObject(V); + + // 7.3.2.4 + return V[P]; +}; diff --git a/node_modules/es-abstract/2022/GetValueFromBuffer.js b/node_modules/es-abstract/2022/GetValueFromBuffer.js new file mode 100644 index 0000000000000000000000000000000000000000..0519a10e9aacb656f66b4a875b0ce98b8695c474 --- /dev/null +++ b/node_modules/es-abstract/2022/GetValueFromBuffer.js @@ -0,0 +1,96 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $SyntaxError = require('es-errors/syntax'); +var $TypeError = require('es-errors/type'); +var $Uint8Array = GetIntrinsic('%Uint8Array%', true); +var isInteger = require('math-intrinsics/isInteger'); + +var callBound = require('call-bound'); + +var $slice = callBound('Array.prototype.slice'); + +var IsDetachedBuffer = require('./IsDetachedBuffer'); +var RawBytesToNumeric = require('./RawBytesToNumeric'); + +var isArrayBuffer = require('is-array-buffer'); +var isSharedArrayBuffer = require('is-shared-array-buffer'); +var safeConcat = require('safe-array-concat'); + +var tableTAO = require('./tables/typed-array-objects'); + +var defaultEndianness = require('../helpers/defaultEndianness'); + +// https://262.ecma-international.org/11.0/#sec-getvaluefrombuffer + +module.exports = function GetValueFromBuffer(arrayBuffer, byteIndex, type, isTypedArray, order) { + var isSAB = isSharedArrayBuffer(arrayBuffer); + if (!isArrayBuffer(arrayBuffer) && !isSAB) { + throw new $TypeError('Assertion failed: `arrayBuffer` must be an ArrayBuffer or a SharedArrayBuffer'); + } + + if (!isInteger(byteIndex)) { + throw new $TypeError('Assertion failed: `byteIndex` must be an integer'); + } + + if (typeof type !== 'string' || typeof tableTAO.size['$' + type] !== 'number') { + throw new $TypeError('Assertion failed: `type` must be one of ' + tableTAO.choices); + } + + if (typeof isTypedArray !== 'boolean') { + throw new $TypeError('Assertion failed: `isTypedArray` must be a boolean'); + } + + if (order !== 'SeqCst' && order !== 'Unordered') { + throw new $TypeError('Assertion failed: `order` must be either `SeqCst` or `Unordered`'); + } + + if (arguments.length > 5 && typeof arguments[5] !== 'boolean') { + throw new $TypeError('Assertion failed: `isLittleEndian` must be a boolean, if present'); + } + + if (IsDetachedBuffer(arrayBuffer)) { + throw new $TypeError('Assertion failed: `arrayBuffer` is detached'); // step 1 + } + + // 2. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type. + + if (byteIndex < 0) { + throw new $TypeError('Assertion failed: `byteIndex` must be non-negative'); // step 3 + } + + // 4. Let block be arrayBuffer.[[ArrayBufferData]]. + + var elementSize = tableTAO.size['$' + type]; // step 5 + if (!elementSize) { + throw new $TypeError('Assertion failed: `type` must be one of ' + tableTAO.choices); + } + + var rawValue; + if (isSAB) { // step 6 + /* + a. Let execution be the [[CandidateExecution]] field of the surrounding agent's Agent Record. + b. Let eventList be the [[EventList]] field of the element in execution.[[EventLists]] whose [[AgentSignifier]] is AgentSignifier(). + c. If isTypedArray is true and type is "Int8", "Uint8", "Int16", "Uint16", "Int32", or "Uint32", let noTear be true; otherwise let noTear be false. + d. Let rawValue be a List of length elementSize of nondeterministically chosen byte values. + e. NOTE: In implementations, rawValue is the result of a non-atomic or atomic read instruction on the underlying hardware. The nondeterminism is a semantic prescription of the memory model to describe observable behaviour of hardware with weak consistency. + f. Let readEvent be ReadSharedMemory{ [[Order]]: order, [[NoTear]]: noTear, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize }. + g. Append readEvent to eventList. + h. Append Chosen Value Record { [[Event]]: readEvent, [[ChosenValue]]: rawValue } to execution.[[ChosenValues]]. + */ + throw new $SyntaxError('SharedArrayBuffer is not supported by this implementation'); + } else { + // 7. Let rawValue be a List of elementSize containing, in order, the elementSize sequence of bytes starting with block[byteIndex]. + rawValue = $slice(new $Uint8Array(arrayBuffer, byteIndex), 0, elementSize); // step 6 + } + + // 8. If isLittleEndian is not present, set isLittleEndian to either true or false. The choice is implementation dependent and should be the alternative that is most efficient for the implementation. An implementation must use the same value each time this step is executed and the same value must be used for the corresponding step in the SetValueInBuffer abstract operation. + var isLittleEndian = arguments.length > 5 ? arguments[5] : defaultEndianness === 'little'; // step 8 + + var bytes = isLittleEndian + ? $slice(safeConcat([0, 0, 0, 0, 0, 0, 0, 0], rawValue), -elementSize) + : $slice(safeConcat(rawValue, [0, 0, 0, 0, 0, 0, 0, 0]), 0, elementSize); + + return RawBytesToNumeric(type, bytes, isLittleEndian); +}; diff --git a/node_modules/es-abstract/2022/HasOwnProperty.js b/node_modules/es-abstract/2022/HasOwnProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..617f0b856e81f2518d2c03bf72b367eea50eb6ef --- /dev/null +++ b/node_modules/es-abstract/2022/HasOwnProperty.js @@ -0,0 +1,20 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var hasOwn = require('hasown'); +var isObject = require('es-object-atoms/isObject'); + +var isPropertyKey = require('../helpers/isPropertyKey'); + +// https://262.ecma-international.org/6.0/#sec-hasownproperty + +module.exports = function HasOwnProperty(O, P) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: `O` must be an Object'); + } + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: `P` must be a Property Key'); + } + return hasOwn(O, P); +}; diff --git a/node_modules/es-abstract/2022/HasProperty.js b/node_modules/es-abstract/2022/HasProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..eb66ca9853ec09c092d87f10333fcdb19a882c83 --- /dev/null +++ b/node_modules/es-abstract/2022/HasProperty.js @@ -0,0 +1,18 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var isPropertyKey = require('../helpers/isPropertyKey'); + +// https://262.ecma-international.org/6.0/#sec-hasproperty + +module.exports = function HasProperty(O, P) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: `O` must be an Object'); + } + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: `P` must be a Property Key'); + } + return P in O; +}; diff --git a/node_modules/es-abstract/2022/HourFromTime.js b/node_modules/es-abstract/2022/HourFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..f963bfb68540ba21f46be00b623cb89db98d63f5 --- /dev/null +++ b/node_modules/es-abstract/2022/HourFromTime.js @@ -0,0 +1,14 @@ +'use strict'; + +var floor = require('./floor'); +var modulo = require('./modulo'); + +var timeConstants = require('../helpers/timeConstants'); +var msPerHour = timeConstants.msPerHour; +var HoursPerDay = timeConstants.HoursPerDay; + +// https://262.ecma-international.org/5.1/#sec-15.9.1.10 + +module.exports = function HourFromTime(t) { + return modulo(floor(t / msPerHour), HoursPerDay); +}; diff --git a/node_modules/es-abstract/2022/InLeapYear.js b/node_modules/es-abstract/2022/InLeapYear.js new file mode 100644 index 0000000000000000000000000000000000000000..4a283a4b6097f4b2c4e872b0cc775024ff517b77 --- /dev/null +++ b/node_modules/es-abstract/2022/InLeapYear.js @@ -0,0 +1,19 @@ +'use strict'; + +var $EvalError = require('es-errors/eval'); + +var DaysInYear = require('./DaysInYear'); +var YearFromTime = require('./YearFromTime'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.3 + +module.exports = function InLeapYear(t) { + var days = DaysInYear(YearFromTime(t)); + if (days === 365) { + return 0; + } + if (days === 366) { + return 1; + } + throw new $EvalError('Assertion failed: there are not 365 or 366 days in a year, got: ' + days); +}; diff --git a/node_modules/es-abstract/2022/InstallErrorCause.js b/node_modules/es-abstract/2022/InstallErrorCause.js new file mode 100644 index 0000000000000000000000000000000000000000..c740a5d6c22e58e2c9d630595c0e25ff92f9356e --- /dev/null +++ b/node_modules/es-abstract/2022/InstallErrorCause.js @@ -0,0 +1,21 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var CreateNonEnumerableDataPropertyOrThrow = require('./CreateNonEnumerableDataPropertyOrThrow'); +var Get = require('./Get'); +var HasProperty = require('./HasProperty'); + +// https://262.ecma-international.org/13.0/#sec-installerrorcause + +module.exports = function InstallErrorCause(O, options) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + if (isObject(options) && HasProperty(options, 'cause')) { + var cause = Get(options, 'cause'); + CreateNonEnumerableDataPropertyOrThrow(O, 'cause', cause); + } +}; diff --git a/node_modules/es-abstract/2022/InstanceofOperator.js b/node_modules/es-abstract/2022/InstanceofOperator.js new file mode 100644 index 0000000000000000000000000000000000000000..5dd7d04a4c16b423b1613070585b864e22b2dc9e --- /dev/null +++ b/node_modules/es-abstract/2022/InstanceofOperator.js @@ -0,0 +1,30 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var $hasInstance = GetIntrinsic('%Symbol.hasInstance%', true); + +var Call = require('./Call'); +var GetMethod = require('./GetMethod'); +var IsCallable = require('./IsCallable'); +var OrdinaryHasInstance = require('./OrdinaryHasInstance'); +var ToBoolean = require('./ToBoolean'); + +// https://262.ecma-international.org/6.0/#sec-instanceofoperator + +module.exports = function InstanceofOperator(O, C) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + var instOfHandler = $hasInstance ? GetMethod(C, $hasInstance) : void 0; + if (typeof instOfHandler !== 'undefined') { + return ToBoolean(Call(instOfHandler, C, [O])); + } + if (!IsCallable(C)) { + throw new $TypeError('`C` is not Callable'); + } + return OrdinaryHasInstance(C, O); +}; diff --git a/node_modules/es-abstract/2022/IntegerIndexedElementGet.js b/node_modules/es-abstract/2022/IntegerIndexedElementGet.js new file mode 100644 index 0000000000000000000000000000000000000000..cf8ff308d3f15c601c1e3dc92e7737cab110eb74 --- /dev/null +++ b/node_modules/es-abstract/2022/IntegerIndexedElementGet.js @@ -0,0 +1,38 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var GetValueFromBuffer = require('./GetValueFromBuffer'); +var IsValidIntegerIndex = require('./IsValidIntegerIndex'); +var TypedArrayElementSize = require('./TypedArrayElementSize'); +var TypedArrayElementType = require('./TypedArrayElementType'); + +var isTypedArray = require('is-typed-array'); +var typedArrayBuffer = require('typed-array-buffer'); +var typedArrayByteOffset = require('typed-array-byte-offset'); + +// https://262.ecma-international.org/13.0/#sec-integerindexedelementget + +module.exports = function IntegerIndexedElementGet(O, index) { + if (!isTypedArray(O)) { + throw new $TypeError('Assertion failed: `O` must be a TypedArray'); + } + + if (typeof index !== 'number') { + throw new $TypeError('Assertion failed: `index` must be a Number'); + } + + if (!IsValidIntegerIndex(O, index)) { + return void undefined; // step 1 + } + + var offset = typedArrayByteOffset(O); // step 2 + + var elementSize = TypedArrayElementSize(O); // step 3 + + var indexedPosition = (index * elementSize) + offset; // step 4 + + var elementType = TypedArrayElementType(O); // step 5 + + return GetValueFromBuffer(typedArrayBuffer(O), indexedPosition, elementType, true, 'Unordered'); // step 11 +}; diff --git a/node_modules/es-abstract/2022/IntegerIndexedElementSet.js b/node_modules/es-abstract/2022/IntegerIndexedElementSet.js new file mode 100644 index 0000000000000000000000000000000000000000..4edac7d7552c6cbfd2132f6e5a121f57a8ab3367 --- /dev/null +++ b/node_modules/es-abstract/2022/IntegerIndexedElementSet.js @@ -0,0 +1,42 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var IsValidIntegerIndex = require('./IsValidIntegerIndex'); +var SetValueInBuffer = require('./SetValueInBuffer'); +var ToBigInt = require('./ToBigInt'); +var ToNumber = require('./ToNumber'); +var TypedArrayElementSize = require('./TypedArrayElementSize'); +var TypedArrayElementType = require('./TypedArrayElementType'); + +var typedArrayBuffer = require('typed-array-buffer'); +var typedArrayByteOffset = require('typed-array-byte-offset'); +var whichTypedArray = require('which-typed-array'); + +// https://262.ecma-international.org/13.0/#sec-integerindexedelementset + +module.exports = function IntegerIndexedElementSet(O, index, value) { + var arrayTypeName = whichTypedArray(O); + if (!arrayTypeName) { + throw new $TypeError('Assertion failed: `O` must be a TypedArray'); + } + + if (typeof index !== 'number') { + throw new $TypeError('Assertion failed: `index` must be a Number'); + } + + var contentType = arrayTypeName === 'BigInt64Array' || arrayTypeName === 'BigUint64Array' ? 'BigInt' : 'Number'; + var numValue = contentType === 'BigInt' ? ToBigInt(value) : ToNumber(value); // steps 1 - 2 + + if (IsValidIntegerIndex(O, index)) { // step 3 + var offset = typedArrayByteOffset(O); // step 3.a + + var elementSize = TypedArrayElementSize(O); // step 3.b + + var indexedPosition = (index * elementSize) + offset; // step 3.c + + var elementType = TypedArrayElementType(O); // step 3.d + + SetValueInBuffer(typedArrayBuffer(O), indexedPosition, elementType, numValue, true, 'Unordered'); // step 3.e + } +}; diff --git a/node_modules/es-abstract/2022/InternalizeJSONProperty.js b/node_modules/es-abstract/2022/InternalizeJSONProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..cb474bfdeee90929c20e26a2fd28ae9928428fab --- /dev/null +++ b/node_modules/es-abstract/2022/InternalizeJSONProperty.js @@ -0,0 +1,66 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var Call = require('./Call'); +var CreateDataProperty = require('./CreateDataProperty'); +var EnumerableOwnPropertyNames = require('./EnumerableOwnPropertyNames'); +var Get = require('./Get'); +var IsArray = require('./IsArray'); +var LengthOfArrayLike = require('./LengthOfArrayLike'); +var ToString = require('./ToString'); + +var forEach = require('../helpers/forEach'); + +// https://262.ecma-international.org/11.0/#sec-internalizejsonproperty + +module.exports = function InternalizeJSONProperty(holder, name, reviver) { + if (!isObject(holder)) { + throw new $TypeError('Assertion failed: `holder` is not an Object'); + } + if (typeof name !== 'string') { + throw new $TypeError('Assertion failed: `name` is not a String'); + } + if (typeof reviver !== 'function') { + throw new $TypeError('Assertion failed: `reviver` is not a Function'); + } + + var val = Get(holder, name); // step 1 + + if (isObject(val)) { // step 2 + var isArray = IsArray(val); // step 2.a + if (isArray) { // step 2.b + var I = 0; // step 2.b.i + + var len = LengthOfArrayLike(val, 'length'); // step 2.b.ii + + while (I < len) { // step 2.b.iii + var newElement = InternalizeJSONProperty(val, ToString(I), reviver); // step 2.b.iv.1 + + if (typeof newElement === 'undefined') { // step 2.b.iii.2 + delete val[ToString(I)]; // step 2.b.iii.2.a + } else { // step 2.b.iii.3 + CreateDataProperty(val, ToString(I), newElement); // step 2.b.iii.3.a + } + + I += 1; // step 2.b.iii.4 + } + } else { // step 2.c + var keys = EnumerableOwnPropertyNames(val, 'key'); // step 2.c.i + + forEach(keys, function (P) { // step 2.c.ii + // eslint-disable-next-line no-shadow + var newElement = InternalizeJSONProperty(val, P, reviver); // step 2.c.ii.1 + + if (typeof newElement === 'undefined') { // step 2.c.ii.2 + delete val[P]; // step 2.c.ii.2.a + } else { // step 2.c.ii.3 + CreateDataProperty(val, P, newElement); // step 2.c.ii.3.a + } + }); + } + } + + return Call(reviver, holder, [name, val]); // step 3 +}; diff --git a/node_modules/es-abstract/2022/Invoke.js b/node_modules/es-abstract/2022/Invoke.js new file mode 100644 index 0000000000000000000000000000000000000000..57bca8ebc3dcb6172949cb3bef6f134dacabbf4b --- /dev/null +++ b/node_modules/es-abstract/2022/Invoke.js @@ -0,0 +1,22 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var Call = require('./Call'); +var IsArray = require('./IsArray'); +var GetV = require('./GetV'); +var isPropertyKey = require('../helpers/isPropertyKey'); + +// https://262.ecma-international.org/6.0/#sec-invoke + +module.exports = function Invoke(O, P) { + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: P must be a Property Key'); + } + var argumentsList = arguments.length > 2 ? arguments[2] : []; + if (!IsArray(argumentsList)) { + throw new $TypeError('Assertion failed: optional `argumentsList`, if provided, must be a List'); + } + var func = GetV(O, P); + return Call(func, O, argumentsList); +}; diff --git a/node_modules/es-abstract/2022/IsAccessorDescriptor.js b/node_modules/es-abstract/2022/IsAccessorDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..f7bf73afb1c1617b04596a6e2af6d1617857bf1e --- /dev/null +++ b/node_modules/es-abstract/2022/IsAccessorDescriptor.js @@ -0,0 +1,25 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var hasOwn = require('hasown'); + +var isPropertyDescriptor = require('../helpers/records/property-descriptor'); + +// https://262.ecma-international.org/5.1/#sec-8.10.1 + +module.exports = function IsAccessorDescriptor(Desc) { + if (typeof Desc === 'undefined') { + return false; + } + + if (!isPropertyDescriptor(Desc)) { + throw new $TypeError('Assertion failed: `Desc` must be a Property Descriptor'); + } + + if (!hasOwn(Desc, '[[Get]]') && !hasOwn(Desc, '[[Set]]')) { + return false; + } + + return true; +}; diff --git a/node_modules/es-abstract/2022/IsArray.js b/node_modules/es-abstract/2022/IsArray.js new file mode 100644 index 0000000000000000000000000000000000000000..c2c48c1f233c058c691d45d7587f1b58d3de5eb2 --- /dev/null +++ b/node_modules/es-abstract/2022/IsArray.js @@ -0,0 +1,4 @@ +'use strict'; + +// https://262.ecma-international.org/6.0/#sec-isarray +module.exports = require('../helpers/IsArray'); diff --git a/node_modules/es-abstract/2022/IsBigIntElementType.js b/node_modules/es-abstract/2022/IsBigIntElementType.js new file mode 100644 index 0000000000000000000000000000000000000000..e3f58a949b3cabcde8a8078afb501cd872820398 --- /dev/null +++ b/node_modules/es-abstract/2022/IsBigIntElementType.js @@ -0,0 +1,7 @@ +'use strict'; + +// https://262.ecma-international.org/11.0/#sec-isbigintelementtype + +module.exports = function IsBigIntElementType(type) { + return type === 'BigUint64' || type === 'BigInt64'; +}; diff --git a/node_modules/es-abstract/2022/IsCallable.js b/node_modules/es-abstract/2022/IsCallable.js new file mode 100644 index 0000000000000000000000000000000000000000..3a69b19267dff33491a84421b667a0d82cba21f9 --- /dev/null +++ b/node_modules/es-abstract/2022/IsCallable.js @@ -0,0 +1,5 @@ +'use strict'; + +// http://262.ecma-international.org/5.1/#sec-9.11 + +module.exports = require('is-callable'); diff --git a/node_modules/es-abstract/2022/IsCompatiblePropertyDescriptor.js b/node_modules/es-abstract/2022/IsCompatiblePropertyDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..48e719f3c1e515175311d0f2fe599b4743f43062 --- /dev/null +++ b/node_modules/es-abstract/2022/IsCompatiblePropertyDescriptor.js @@ -0,0 +1,9 @@ +'use strict'; + +var ValidateAndApplyPropertyDescriptor = require('./ValidateAndApplyPropertyDescriptor'); + +// https://262.ecma-international.org/13.0/#sec-iscompatiblepropertydescriptor + +module.exports = function IsCompatiblePropertyDescriptor(Extensible, Desc, Current) { + return ValidateAndApplyPropertyDescriptor(undefined, '', Extensible, Desc, Current); +}; diff --git a/node_modules/es-abstract/2022/IsConcatSpreadable.js b/node_modules/es-abstract/2022/IsConcatSpreadable.js new file mode 100644 index 0000000000000000000000000000000000000000..ace2695309292c91b185505f63da3cc942534bd2 --- /dev/null +++ b/node_modules/es-abstract/2022/IsConcatSpreadable.js @@ -0,0 +1,26 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $isConcatSpreadable = GetIntrinsic('%Symbol.isConcatSpreadable%', true); + +var Get = require('./Get'); +var IsArray = require('./IsArray'); +var ToBoolean = require('./ToBoolean'); + +var isObject = require('es-object-atoms/isObject'); + +// https://262.ecma-international.org/6.0/#sec-isconcatspreadable + +module.exports = function IsConcatSpreadable(O) { + if (!isObject(O)) { + return false; + } + if ($isConcatSpreadable) { + var spreadable = Get(O, $isConcatSpreadable); + if (typeof spreadable !== 'undefined') { + return ToBoolean(spreadable); + } + } + return IsArray(O); +}; diff --git a/node_modules/es-abstract/2022/IsConstructor.js b/node_modules/es-abstract/2022/IsConstructor.js new file mode 100644 index 0000000000000000000000000000000000000000..62ac47f6a3d262927a9b147ee0057dfba9664b24 --- /dev/null +++ b/node_modules/es-abstract/2022/IsConstructor.js @@ -0,0 +1,40 @@ +'use strict'; + +var GetIntrinsic = require('../GetIntrinsic.js'); + +var $construct = GetIntrinsic('%Reflect.construct%', true); + +var DefinePropertyOrThrow = require('./DefinePropertyOrThrow'); +try { + DefinePropertyOrThrow({}, '', { '[[Get]]': function () {} }); +} catch (e) { + // Accessor properties aren't supported + DefinePropertyOrThrow = null; +} + +// https://262.ecma-international.org/6.0/#sec-isconstructor + +if (DefinePropertyOrThrow && $construct) { + var isConstructorMarker = {}; + var badArrayLike = {}; + DefinePropertyOrThrow(badArrayLike, 'length', { + '[[Get]]': function () { + throw isConstructorMarker; + }, + '[[Enumerable]]': true + }); + + module.exports = function IsConstructor(argument) { + try { + // `Reflect.construct` invokes `IsConstructor(target)` before `Get(args, 'length')`: + $construct(argument, badArrayLike); + } catch (err) { + return err === isConstructorMarker; + } + }; +} else { + module.exports = function IsConstructor(argument) { + // unfortunately there's no way to truly check this without try/catch `new argument` in old environments + return typeof argument === 'function' && !!argument.prototype; + }; +} diff --git a/node_modules/es-abstract/2022/IsDataDescriptor.js b/node_modules/es-abstract/2022/IsDataDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..d56bd36d4294369f6486f6dfc5d60dada2cc410a --- /dev/null +++ b/node_modules/es-abstract/2022/IsDataDescriptor.js @@ -0,0 +1,25 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var hasOwn = require('hasown'); + +var isPropertyDescriptor = require('../helpers/records/property-descriptor'); + +// https://262.ecma-international.org/5.1/#sec-8.10.2 + +module.exports = function IsDataDescriptor(Desc) { + if (typeof Desc === 'undefined') { + return false; + } + + if (!isPropertyDescriptor(Desc)) { + throw new $TypeError('Assertion failed: `Desc` must be a Property Descriptor'); + } + + if (!hasOwn(Desc, '[[Value]]') && !hasOwn(Desc, '[[Writable]]')) { + return false; + } + + return true; +}; diff --git a/node_modules/es-abstract/2022/IsDetachedBuffer.js b/node_modules/es-abstract/2022/IsDetachedBuffer.js new file mode 100644 index 0000000000000000000000000000000000000000..71c4f6be8d20b02a92a6721c7ae2833adf21150e --- /dev/null +++ b/node_modules/es-abstract/2022/IsDetachedBuffer.js @@ -0,0 +1,28 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var $byteLength = require('array-buffer-byte-length'); +var availableTypedArrays = require('available-typed-arrays')(); +var callBound = require('call-bound'); +var isArrayBuffer = require('is-array-buffer'); +var isSharedArrayBuffer = require('is-shared-array-buffer'); + +var $sabByteLength = callBound('SharedArrayBuffer.prototype.byteLength', true); + +// https://262.ecma-international.org/8.0/#sec-isdetachedbuffer + +module.exports = function IsDetachedBuffer(arrayBuffer) { + var isSAB = isSharedArrayBuffer(arrayBuffer); + if (!isArrayBuffer(arrayBuffer) && !isSAB) { + throw new $TypeError('Assertion failed: `arrayBuffer` must be an Object with an [[ArrayBufferData]] internal slot'); + } + if ((isSAB ? $sabByteLength : $byteLength)(arrayBuffer) === 0) { + try { + new global[availableTypedArrays[0]](arrayBuffer); // eslint-disable-line no-new + } catch (error) { + return !!error && error.name === 'TypeError'; + } + } + return false; +}; diff --git a/node_modules/es-abstract/2022/IsExtensible.js b/node_modules/es-abstract/2022/IsExtensible.js new file mode 100644 index 0000000000000000000000000000000000000000..aa19b914c2d3dc31c1215e2b203dc3ffbb78746c --- /dev/null +++ b/node_modules/es-abstract/2022/IsExtensible.js @@ -0,0 +1,18 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $preventExtensions = GetIntrinsic('%Object.preventExtensions%', true); +var $isExtensible = GetIntrinsic('%Object.isExtensible%', true); + +var isPrimitive = require('../helpers/isPrimitive'); + +// https://262.ecma-international.org/6.0/#sec-isextensible-o + +module.exports = $preventExtensions + ? function IsExtensible(obj) { + return !isPrimitive(obj) && $isExtensible(obj); + } + : function IsExtensible(obj) { + return !isPrimitive(obj); + }; diff --git a/node_modules/es-abstract/2022/IsGenericDescriptor.js b/node_modules/es-abstract/2022/IsGenericDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..9f6ef045ee44e9eaea4506a234f0e41e0bd1bac9 --- /dev/null +++ b/node_modules/es-abstract/2022/IsGenericDescriptor.js @@ -0,0 +1,26 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var IsAccessorDescriptor = require('./IsAccessorDescriptor'); +var IsDataDescriptor = require('./IsDataDescriptor'); + +var isPropertyDescriptor = require('../helpers/records/property-descriptor'); + +// https://262.ecma-international.org/6.0/#sec-isgenericdescriptor + +module.exports = function IsGenericDescriptor(Desc) { + if (typeof Desc === 'undefined') { + return false; + } + + if (!isPropertyDescriptor(Desc)) { + throw new $TypeError('Assertion failed: `Desc` must be a Property Descriptor'); + } + + if (!IsAccessorDescriptor(Desc) && !IsDataDescriptor(Desc)) { + return true; + } + + return false; +}; diff --git a/node_modules/es-abstract/2022/IsIntegralNumber.js b/node_modules/es-abstract/2022/IsIntegralNumber.js new file mode 100644 index 0000000000000000000000000000000000000000..df4240f9f74b4881cf5c8e13b8df9820f8ebabe1 --- /dev/null +++ b/node_modules/es-abstract/2022/IsIntegralNumber.js @@ -0,0 +1,9 @@ +'use strict'; + +var isInteger = require('math-intrinsics/isInteger'); + +// https://262.ecma-international.org/12.0/#sec-isinteger + +module.exports = function IsIntegralNumber(argument) { + return isInteger(argument); +}; diff --git a/node_modules/es-abstract/2022/IsLessThan.js b/node_modules/es-abstract/2022/IsLessThan.js new file mode 100644 index 0000000000000000000000000000000000000000..e0ffe47a19a2d281209c71c7187f4d9ed264ca58 --- /dev/null +++ b/node_modules/es-abstract/2022/IsLessThan.js @@ -0,0 +1,87 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $Number = GetIntrinsic('%Number%'); +var $TypeError = require('es-errors/type'); + +var $isNaN = require('math-intrinsics/isNaN'); + +var IsStringPrefix = require('./IsStringPrefix'); +var StringToBigInt = require('./StringToBigInt'); +var ToNumeric = require('./ToNumeric'); +var ToPrimitive = require('./ToPrimitive'); + +var BigIntLessThan = require('./BigInt/lessThan'); +var NumberLessThan = require('./Number/lessThan'); + +// https://262.ecma-international.org/13.0/#sec-islessthan + +// eslint-disable-next-line max-statements, max-lines-per-function +module.exports = function IsLessThan(x, y, LeftFirst) { + if (typeof LeftFirst !== 'boolean') { + throw new $TypeError('Assertion failed: LeftFirst argument must be a Boolean'); + } + var px; + var py; + if (LeftFirst) { + px = ToPrimitive(x, $Number); + py = ToPrimitive(y, $Number); + } else { + py = ToPrimitive(y, $Number); + px = ToPrimitive(x, $Number); + } + + if (typeof px === 'string' && typeof py === 'string') { + if (IsStringPrefix(py, px)) { + return false; + } + if (IsStringPrefix(px, py)) { + return true; + } + /* + c. Let k be the smallest non-negative integer such that the code unit at index k within px is different from the code unit at index k within py. (There must be such a k, for neither String is a prefix of the other.) + d. Let m be the integer that is the numeric value of the code unit at index k within px. + e. Let n be the integer that is the numeric value of the code unit at index k within py. + f. If m < n, return true. Otherwise, return false. + */ + return px < py; // both strings, neither a prefix of the other. shortcut for steps 3 c-f + } + + var nx; + var ny; + if (typeof px === 'bigint' && typeof py === 'string') { + ny = StringToBigInt(py); + if (typeof ny === 'undefined') { + return void undefined; + } + return BigIntLessThan(px, ny); + } + if (typeof px === 'string' && typeof py === 'bigint') { + nx = StringToBigInt(px); + if (typeof nx === 'undefined') { + return void undefined; + } + return BigIntLessThan(nx, py); + } + + nx = ToNumeric(px); + ny = ToNumeric(py); + + if (typeof nx === typeof ny) { + return typeof nx === 'number' ? NumberLessThan(nx, ny) : BigIntLessThan(nx, ny); + } + + if ($isNaN(nx) || $isNaN(ny)) { + return void undefined; + } + + if (nx === -Infinity || ny === Infinity) { + return true; + } + if (nx === Infinity || ny === -Infinity) { + return false; + } + + return nx < ny; // by now, these are both finite, and the same type +}; diff --git a/node_modules/es-abstract/2022/IsLooselyEqual.js b/node_modules/es-abstract/2022/IsLooselyEqual.js new file mode 100644 index 0000000000000000000000000000000000000000..c7bb047f55d337b5ca46405cc07a284d5843d71a --- /dev/null +++ b/node_modules/es-abstract/2022/IsLooselyEqual.js @@ -0,0 +1,58 @@ +'use strict'; + +var isFinite = require('math-intrinsics/isFinite'); +var isObject = require('es-object-atoms/isObject'); + +var IsStrictlyEqual = require('./IsStrictlyEqual'); +var StringToBigInt = require('./StringToBigInt'); +var ToNumber = require('./ToNumber'); +var ToPrimitive = require('./ToPrimitive'); + +var isSameType = require('../helpers/isSameType'); + +// https://262.ecma-international.org/13.0/#sec-islooselyequal + +module.exports = function IsLooselyEqual(x, y) { + if (isSameType(x, y)) { + return IsStrictlyEqual(x, y); + } + if (x == null && y == null) { + return true; + } + if (typeof x === 'number' && typeof y === 'string') { + return IsLooselyEqual(x, ToNumber(y)); + } + if (typeof x === 'string' && typeof y === 'number') { + return IsLooselyEqual(ToNumber(x), y); + } + if (typeof x === 'bigint' && typeof y === 'string') { + var n = StringToBigInt(y); + if (typeof n === 'undefined') { + return false; + } + return IsLooselyEqual(x, n); + } + if (typeof x === 'string' && typeof y === 'bigint') { + return IsLooselyEqual(y, x); + } + if (typeof x === 'boolean') { + return IsLooselyEqual(ToNumber(x), y); + } + if (typeof y === 'boolean') { + return IsLooselyEqual(x, ToNumber(y)); + } + if ((typeof x === 'string' || typeof x === 'number' || typeof x === 'symbol' || typeof x === 'bigint') && isObject(y)) { + return IsLooselyEqual(x, ToPrimitive(y)); + } + if (isObject(x) && (typeof y === 'string' || typeof y === 'number' || typeof y === 'symbol' || typeof y === 'bigint')) { + return IsLooselyEqual(ToPrimitive(x), y); + } + if ((typeof x === 'bigint' && typeof y === 'number') || (typeof x === 'number' && typeof y === 'bigint')) { + if (!isFinite(x) || !isFinite(y)) { + return false; + } + // eslint-disable-next-line eqeqeq + return x == y; // shortcut for step 13.b. + } + return false; +}; diff --git a/node_modules/es-abstract/2022/IsNoTearConfiguration.js b/node_modules/es-abstract/2022/IsNoTearConfiguration.js new file mode 100644 index 0000000000000000000000000000000000000000..f0d2808737ac6c853571ca68c94f57f7ee4cb59b --- /dev/null +++ b/node_modules/es-abstract/2022/IsNoTearConfiguration.js @@ -0,0 +1,16 @@ +'use strict'; + +var IsUnclampedIntegerElementType = require('./IsUnclampedIntegerElementType'); +var IsBigIntElementType = require('./IsBigIntElementType'); + +// https://262.ecma-international.org/11.0/#sec-isnotearconfiguration + +module.exports = function IsNoTearConfiguration(type, order) { + if (IsUnclampedIntegerElementType(type)) { + return true; + } + if (IsBigIntElementType(type) && order !== 'Init' && order !== 'Unordered') { + return true; + } + return false; +}; diff --git a/node_modules/es-abstract/2022/IsPromise.js b/node_modules/es-abstract/2022/IsPromise.js new file mode 100644 index 0000000000000000000000000000000000000000..f3d67b1c7045d7657ec74a6d084dc088aadb5ff4 --- /dev/null +++ b/node_modules/es-abstract/2022/IsPromise.js @@ -0,0 +1,24 @@ +'use strict'; + +var callBound = require('call-bound'); + +var $PromiseThen = callBound('Promise.prototype.then', true); + +var isObject = require('es-object-atoms/isObject'); + +// https://262.ecma-international.org/6.0/#sec-ispromise + +module.exports = function IsPromise(x) { + if (!isObject(x)) { + return false; + } + if (!$PromiseThen) { // Promises are not supported + return false; + } + try { + $PromiseThen(x); // throws if not a promise + } catch (e) { + return false; + } + return true; +}; diff --git a/node_modules/es-abstract/2022/IsPropertyKey.js b/node_modules/es-abstract/2022/IsPropertyKey.js new file mode 100644 index 0000000000000000000000000000000000000000..4b1c9c71461ca474f34b517c0bc04e5d700280f2 --- /dev/null +++ b/node_modules/es-abstract/2022/IsPropertyKey.js @@ -0,0 +1,9 @@ +'use strict'; + +var isPropertyKey = require('../helpers/isPropertyKey'); + +// https://262.ecma-international.org/6.0/#sec-ispropertykey + +module.exports = function IsPropertyKey(argument) { + return isPropertyKey(argument); +}; diff --git a/node_modules/es-abstract/2022/IsRegExp.js b/node_modules/es-abstract/2022/IsRegExp.js new file mode 100644 index 0000000000000000000000000000000000000000..8855492d58ded3c061b84be35e962fe32c8de53e --- /dev/null +++ b/node_modules/es-abstract/2022/IsRegExp.js @@ -0,0 +1,25 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $match = GetIntrinsic('%Symbol.match%', true); + +var hasRegExpMatcher = require('is-regex'); +var isObject = require('es-object-atoms/isObject'); + +var ToBoolean = require('./ToBoolean'); + +// https://262.ecma-international.org/6.0/#sec-isregexp + +module.exports = function IsRegExp(argument) { + if (!isObject(argument)) { + return false; + } + if ($match) { + var isRegExp = argument[$match]; + if (typeof isRegExp !== 'undefined') { + return ToBoolean(isRegExp); + } + } + return hasRegExpMatcher(argument); +}; diff --git a/node_modules/es-abstract/2022/IsSharedArrayBuffer.js b/node_modules/es-abstract/2022/IsSharedArrayBuffer.js new file mode 100644 index 0000000000000000000000000000000000000000..41d61b116db4b3aabf7dde87e6b46cc5aa378d99 --- /dev/null +++ b/node_modules/es-abstract/2022/IsSharedArrayBuffer.js @@ -0,0 +1,16 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var isSharedArrayBuffer = require('is-shared-array-buffer'); + +// https://262.ecma-international.org/8.0/#sec-issharedarraybuffer + +module.exports = function IsSharedArrayBuffer(obj) { + if (!isObject(obj)) { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + return isSharedArrayBuffer(obj); +}; diff --git a/node_modules/es-abstract/2022/IsStrictlyEqual.js b/node_modules/es-abstract/2022/IsStrictlyEqual.js new file mode 100644 index 0000000000000000000000000000000000000000..e457c2cffadabb50a69e42b0b9c760ef1608beed --- /dev/null +++ b/node_modules/es-abstract/2022/IsStrictlyEqual.js @@ -0,0 +1,18 @@ +'use strict'; + +var SameValueNonNumeric = require('./SameValueNonNumeric'); +var Type = require('./Type'); +var BigIntEqual = require('./BigInt/equal'); +var NumberEqual = require('./Number/equal'); + +// https://262.ecma-international.org/13.0/#sec-isstrictlyequal + +module.exports = function IsStrictlyEqual(x, y) { + if (Type(x) !== Type(y)) { + return false; + } + if (typeof x === 'number' || typeof x === 'bigint') { + return typeof x === 'number' ? NumberEqual(x, y) : BigIntEqual(x, y); + } + return SameValueNonNumeric(x, y); +}; diff --git a/node_modules/es-abstract/2022/IsStringPrefix.js b/node_modules/es-abstract/2022/IsStringPrefix.js new file mode 100644 index 0000000000000000000000000000000000000000..713c8b6fc045c1b78d9805a8785a34e7a0aaa0db --- /dev/null +++ b/node_modules/es-abstract/2022/IsStringPrefix.js @@ -0,0 +1,19 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var StringIndexOf = require('./StringIndexOf'); + +// https://262.ecma-international.org/13.0/#sec-isstringprefix + +module.exports = function IsStringPrefix(p, q) { + if (typeof p !== 'string') { + throw new $TypeError('Assertion failed: "p" must be a String'); + } + + if (typeof q !== 'string') { + throw new $TypeError('Assertion failed: "q" must be a String'); + } + + return StringIndexOf(q, p, 0) === 0; +}; diff --git a/node_modules/es-abstract/2022/IsStringWellFormedUnicode.js b/node_modules/es-abstract/2022/IsStringWellFormedUnicode.js new file mode 100644 index 0000000000000000000000000000000000000000..0cbd46413358e59d0e5e00a8200bd9c0e74c4a5b --- /dev/null +++ b/node_modules/es-abstract/2022/IsStringWellFormedUnicode.js @@ -0,0 +1,23 @@ +'use strict'; + +var CodePointAt = require('./CodePointAt'); + +var $TypeError = require('es-errors/type'); + +// https://262.ecma-international.org/13.0/#sec-isstringwellformedunicode + +module.exports = function IsStringWellFormedUnicode(string) { + if (typeof string !== 'string') { + throw new $TypeError('Assertion failed: `string` must be a String'); + } + var strLen = string.length; // step 1 + var k = 0; // step 2 + while (k !== strLen) { // step 3 + var cp = CodePointAt(string, k); // step 3.a + if (cp['[[IsUnpairedSurrogate]]']) { + return false; // step 3.b + } + k += cp['[[CodeUnitCount]]']; // step 3.c + } + return true; // step 4 +}; diff --git a/node_modules/es-abstract/2022/IsUnclampedIntegerElementType.js b/node_modules/es-abstract/2022/IsUnclampedIntegerElementType.js new file mode 100644 index 0000000000000000000000000000000000000000..4e3a38425d65f2320b3e72bc16d3bf6b38ae3f38 --- /dev/null +++ b/node_modules/es-abstract/2022/IsUnclampedIntegerElementType.js @@ -0,0 +1,12 @@ +'use strict'; + +// https://262.ecma-international.org/11.0/#sec-isunclampedintegerelementtype + +module.exports = function IsUnclampedIntegerElementType(type) { + return type === 'Int8' + || type === 'Uint8' + || type === 'Int16' + || type === 'Uint16' + || type === 'Int32' + || type === 'Uint32'; +}; diff --git a/node_modules/es-abstract/2022/IsUnsignedElementType.js b/node_modules/es-abstract/2022/IsUnsignedElementType.js new file mode 100644 index 0000000000000000000000000000000000000000..b1ff194d73916d487ce951d1c7553b7aa5ab34cf --- /dev/null +++ b/node_modules/es-abstract/2022/IsUnsignedElementType.js @@ -0,0 +1,11 @@ +'use strict'; + +// https://262.ecma-international.org/11.0/#sec-isunsignedelementtype + +module.exports = function IsUnsignedElementType(type) { + return type === 'Uint8' + || type === 'Uint8C' + || type === 'Uint16' + || type === 'Uint32' + || type === 'BigUint64'; +}; diff --git a/node_modules/es-abstract/2022/IsValidIntegerIndex.js b/node_modules/es-abstract/2022/IsValidIntegerIndex.js new file mode 100644 index 0000000000000000000000000000000000000000..d5deae7a72ff0e4bad585acc679453c2f22538e9 --- /dev/null +++ b/node_modules/es-abstract/2022/IsValidIntegerIndex.js @@ -0,0 +1,30 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isNegativeZero = require('math-intrinsics/isNegativeZero'); + +var IsDetachedBuffer = require('./IsDetachedBuffer'); + +var isInteger = require('math-intrinsics/isInteger'); +var typedArrayBuffer = require('typed-array-buffer'); + +// https://262.ecma-international.org/12.0/#sec-isvalidintegerindex + +module.exports = function IsValidIntegerIndex(O, index) { + // Assert: O is an Integer-Indexed exotic object. + var buffer = typedArrayBuffer(O); // step 1 + + if (typeof index !== 'number') { + throw new $TypeError('Assertion failed: Type(index) is not Number'); + } + + if (IsDetachedBuffer(buffer)) { return false; } // step 2 + + if (!isInteger(index)) { return false; } // step 3 + + if (isNegativeZero(index)) { return false; } // step 4 + + if (index < 0 || index >= O.length) { return false; } // step 5 + + return true; // step 6 +}; diff --git a/node_modules/es-abstract/2022/IsWordChar.js b/node_modules/es-abstract/2022/IsWordChar.js new file mode 100644 index 0000000000000000000000000000000000000000..c976c7166bd12f2e85b3d2264a1332440d2709ce --- /dev/null +++ b/node_modules/es-abstract/2022/IsWordChar.js @@ -0,0 +1,46 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var callBound = require('call-bound'); + +var $indexOf = callBound('String.prototype.indexOf'); + +var IsArray = require('./IsArray'); +var WordCharacters = require('./WordCharacters'); + +var every = require('../helpers/every'); + +var isInteger = require('math-intrinsics/isInteger'); + +var isChar = function isChar(c) { + return typeof c === 'string'; +}; + +// https://262.ecma-international.org/12.0/#sec-runtime-semantics-iswordchar-abstract-operation + +// note: prior to ES2023, this AO erroneously omitted the latter of its arguments. +module.exports = function IsWordChar(e, InputLength, Input, IgnoreCase, Unicode) { + if (!isInteger(e)) { + throw new $TypeError('Assertion failed: `e` must be an integer'); + } + if (!isInteger(InputLength)) { + throw new $TypeError('Assertion failed: `InputLength` must be an integer'); + } + if (!IsArray(Input) || !every(Input, isChar)) { + throw new $TypeError('Assertion failed: `Input` must be a List of characters'); + } + if (typeof IgnoreCase !== 'boolean' || typeof Unicode !== 'boolean') { + throw new $TypeError('Assertion failed: `IgnoreCase` and `Unicode` must be booleans'); + } + + if (e === -1 || e === InputLength) { + return false; // step 1 + } + + var c = Input[e]; // step 2 + + var wordChars = WordCharacters(IgnoreCase, Unicode); + + return $indexOf(wordChars, c) > -1; // steps 3-4 +}; diff --git a/node_modules/es-abstract/2022/IterableToList.js b/node_modules/es-abstract/2022/IterableToList.js new file mode 100644 index 0000000000000000000000000000000000000000..a4c3394156609058a701d0384daa973cfc8bc04c --- /dev/null +++ b/node_modules/es-abstract/2022/IterableToList.js @@ -0,0 +1,26 @@ +'use strict'; + +var GetIterator = require('./GetIterator'); +var IteratorStep = require('./IteratorStep'); +var IteratorValue = require('./IteratorValue'); + +// https://262.ecma-international.org/12.0/#sec-iterabletolist + +module.exports = function IterableToList(items) { + var iterator; + if (arguments.length > 1) { + iterator = GetIterator(items, 'sync', arguments[1]); + } else { + iterator = GetIterator(items, 'sync'); + } + var values = []; + var next = true; + while (next) { + next = IteratorStep(iterator); + if (next) { + var nextValue = IteratorValue(next); + values[values.length] = nextValue; + } + } + return values; +}; diff --git a/node_modules/es-abstract/2022/IteratorClose.js b/node_modules/es-abstract/2022/IteratorClose.js new file mode 100644 index 0000000000000000000000000000000000000000..c28373b5df19807503f12da511643f30b72ad786 --- /dev/null +++ b/node_modules/es-abstract/2022/IteratorClose.js @@ -0,0 +1,51 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var Call = require('./Call'); +var CompletionRecord = require('./CompletionRecord'); +var GetMethod = require('./GetMethod'); +var IsCallable = require('./IsCallable'); + +// https://262.ecma-international.org/6.0/#sec-iteratorclose + +module.exports = function IteratorClose(iterator, completion) { + if (!isObject(iterator)) { + throw new $TypeError('Assertion failed: Type(iterator) is not Object'); + } + if (!IsCallable(completion) && !(completion instanceof CompletionRecord)) { + throw new $TypeError('Assertion failed: completion is not a thunk representing a Completion Record, nor a Completion Record instance'); + } + var completionThunk = completion instanceof CompletionRecord ? function () { return completion['?'](); } : completion; + + var iteratorReturn = GetMethod(iterator, 'return'); + + if (typeof iteratorReturn === 'undefined') { + return completionThunk(); + } + + var completionRecord; + try { + var innerResult = Call(iteratorReturn, iterator, []); + } catch (e) { + // if we hit here, then "e" is the innerResult completion that needs re-throwing + + // if the completion is of type "throw", this will throw. + completionThunk(); + // eslint-disable-next-line no-useless-assignment + completionThunk = null; // ensure it's not called twice. + + // if not, then return the innerResult completion + throw e; + } + completionRecord = completionThunk(); // if innerResult worked, then throw if the completion does + // eslint-disable-next-line no-useless-assignment + completionThunk = null; // ensure it's not called twice. + + if (!isObject(innerResult)) { + throw new $TypeError('iterator .return must return an object'); + } + + return completionRecord; +}; diff --git a/node_modules/es-abstract/2022/IteratorComplete.js b/node_modules/es-abstract/2022/IteratorComplete.js new file mode 100644 index 0000000000000000000000000000000000000000..c8a0d67c244bbec3d032bb8a4cc5597b7419d97b --- /dev/null +++ b/node_modules/es-abstract/2022/IteratorComplete.js @@ -0,0 +1,16 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var Get = require('./Get'); +var ToBoolean = require('./ToBoolean'); + +// https://262.ecma-international.org/6.0/#sec-iteratorcomplete + +module.exports = function IteratorComplete(iterResult) { + if (!isObject(iterResult)) { + throw new $TypeError('Assertion failed: Type(iterResult) is not Object'); + } + return ToBoolean(Get(iterResult, 'done')); +}; diff --git a/node_modules/es-abstract/2022/IteratorNext.js b/node_modules/es-abstract/2022/IteratorNext.js new file mode 100644 index 0000000000000000000000000000000000000000..b6bd71c68fca61d152bbf420aa5fdfb2feeab854 --- /dev/null +++ b/node_modules/es-abstract/2022/IteratorNext.js @@ -0,0 +1,16 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var Invoke = require('./Invoke'); + +// https://262.ecma-international.org/6.0/#sec-iteratornext + +module.exports = function IteratorNext(iterator, value) { + var result = Invoke(iterator, 'next', arguments.length < 2 ? [] : [value]); + if (!isObject(result)) { + throw new $TypeError('iterator next must return an object'); + } + return result; +}; diff --git a/node_modules/es-abstract/2022/IteratorStep.js b/node_modules/es-abstract/2022/IteratorStep.js new file mode 100644 index 0000000000000000000000000000000000000000..85bcd95c0410f7efd79ae16b91b0a513d404a64a --- /dev/null +++ b/node_modules/es-abstract/2022/IteratorStep.js @@ -0,0 +1,13 @@ +'use strict'; + +var IteratorComplete = require('./IteratorComplete'); +var IteratorNext = require('./IteratorNext'); + +// https://262.ecma-international.org/6.0/#sec-iteratorstep + +module.exports = function IteratorStep(iterator) { + var result = IteratorNext(iterator); + var done = IteratorComplete(result); + return done === true ? false : result; +}; + diff --git a/node_modules/es-abstract/2022/IteratorValue.js b/node_modules/es-abstract/2022/IteratorValue.js new file mode 100644 index 0000000000000000000000000000000000000000..016ddfbd4f01381dd13487740d6806003449d4b1 --- /dev/null +++ b/node_modules/es-abstract/2022/IteratorValue.js @@ -0,0 +1,16 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var Get = require('./Get'); + +// https://262.ecma-international.org/6.0/#sec-iteratorvalue + +module.exports = function IteratorValue(iterResult) { + if (!isObject(iterResult)) { + throw new $TypeError('Assertion failed: Type(iterResult) is not Object'); + } + return Get(iterResult, 'value'); +}; + diff --git a/node_modules/es-abstract/2022/LengthOfArrayLike.js b/node_modules/es-abstract/2022/LengthOfArrayLike.js new file mode 100644 index 0000000000000000000000000000000000000000..437bcd86c93b2ea23f727bb18c83ae4b58fe7e2b --- /dev/null +++ b/node_modules/es-abstract/2022/LengthOfArrayLike.js @@ -0,0 +1,18 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var Get = require('./Get'); +var ToLength = require('./ToLength'); + +// https://262.ecma-international.org/11.0/#sec-lengthofarraylike + +module.exports = function LengthOfArrayLike(obj) { + if (!isObject(obj)) { + throw new $TypeError('Assertion failed: `obj` must be an Object'); + } + return ToLength(Get(obj, 'length')); +}; + +// TODO: use this all over diff --git a/node_modules/es-abstract/2022/MakeDate.js b/node_modules/es-abstract/2022/MakeDate.js new file mode 100644 index 0000000000000000000000000000000000000000..3256ae1092afd21a469f4ca086dc028a73ecaa52 --- /dev/null +++ b/node_modules/es-abstract/2022/MakeDate.js @@ -0,0 +1,14 @@ +'use strict'; + +var $isFinite = require('math-intrinsics/isFinite'); + +var msPerDay = require('../helpers/timeConstants').msPerDay; + +// https://262.ecma-international.org/5.1/#sec-15.9.1.13 + +module.exports = function MakeDate(day, time) { + if (!$isFinite(day) || !$isFinite(time)) { + return NaN; + } + return (day * msPerDay) + time; +}; diff --git a/node_modules/es-abstract/2022/MakeDay.js b/node_modules/es-abstract/2022/MakeDay.js new file mode 100644 index 0000000000000000000000000000000000000000..3e5a91e6d1696ed0b1ede1140b517182ab10c84a --- /dev/null +++ b/node_modules/es-abstract/2022/MakeDay.js @@ -0,0 +1,36 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $DateUTC = GetIntrinsic('%Date.UTC%'); + +var $isFinite = require('math-intrinsics/isFinite'); + +var DateFromTime = require('./DateFromTime'); +var Day = require('./Day'); +var floor = require('./floor'); +var modulo = require('./modulo'); +var MonthFromTime = require('./MonthFromTime'); +var ToIntegerOrInfinity = require('./ToIntegerOrInfinity'); +var YearFromTime = require('./YearFromTime'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.12 + +module.exports = function MakeDay(year, month, date) { + if (!$isFinite(year) || !$isFinite(month) || !$isFinite(date)) { + return NaN; + } + var y = ToIntegerOrInfinity(year); + var m = ToIntegerOrInfinity(month); + var dt = ToIntegerOrInfinity(date); + var ym = y + floor(m / 12); + if (!$isFinite(ym)) { + return NaN; + } + var mn = modulo(m, 12); + var t = $DateUTC(ym, mn, 1); + if (YearFromTime(t) !== ym || MonthFromTime(t) !== mn || DateFromTime(t) !== 1) { + return NaN; + } + return Day(t) + dt - 1; +}; diff --git a/node_modules/es-abstract/2022/MakeMatchIndicesIndexPairArray.js b/node_modules/es-abstract/2022/MakeMatchIndicesIndexPairArray.js new file mode 100644 index 0000000000000000000000000000000000000000..eeb5b39020f0188982d6924e7d7479df06aa39c6 --- /dev/null +++ b/node_modules/es-abstract/2022/MakeMatchIndicesIndexPairArray.js @@ -0,0 +1,66 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var ArrayCreate = require('./ArrayCreate'); +var CreateDataPropertyOrThrow = require('./CreateDataPropertyOrThrow'); +var GetMatchIndexPair = require('./GetMatchIndexPair'); +var IsArray = require('./IsArray'); +var OrdinaryObjectCreate = require('./OrdinaryObjectCreate'); +var ToString = require('./ToString'); + +var every = require('../helpers/every'); +var isMatchRecord = require('../helpers/records/match-record'); + +var isStringOrUndefined = function isStringOrUndefined(s) { + return typeof s === 'undefined' || typeof s === 'string'; +}; + +var isMatchRecordOrUndefined = function isMatchRecordOrUndefined(m) { + return typeof m === 'undefined' || isMatchRecord(m); +}; + +var MAX_ARRAY_LENGTH = require('math-intrinsics/constants/maxArrayLength'); + +// https://262.ecma-international.org/13.0/#sec-getmatchindexpair + +module.exports = function MakeMatchIndicesIndexPairArray(S, indices, groupNames, hasGroups) { + if (typeof S !== 'string') { + throw new $TypeError('Assertion failed: `S` must be a String'); + } + if (!IsArray(indices) || !every(indices, isMatchRecordOrUndefined)) { + throw new $TypeError('Assertion failed: `indices` must be a List of either Match Records or `undefined`'); + } + if (!IsArray(groupNames) || !every(groupNames, isStringOrUndefined)) { + throw new $TypeError('Assertion failed: `groupNames` must be a List of either Strings or `undefined`'); + } + if (typeof hasGroups !== 'boolean') { + throw new $TypeError('Assertion failed: `hasGroups` must be a Boolean'); + } + + var n = indices.length; // step 1 + if (!(n < MAX_ARRAY_LENGTH)) { + throw new $TypeError('Assertion failed: `indices` length must be less than the max array size, 2**32 - 1'); + } + if (groupNames.length !== n - 1) { + throw new $TypeError('Assertion failed: `groupNames` must have exactly one fewer item than `indices`'); + } + + var A = ArrayCreate(n); // step 5 + var groups = hasGroups ? OrdinaryObjectCreate(null) : void undefined; // step 6-7 + CreateDataPropertyOrThrow(A, 'groups', groups); // step 8 + + for (var i = 0; i < n; i += 1) { // step 9 + var matchIndices = indices[i]; // step 9.a + // eslint-disable-next-line no-negated-condition + var matchIndexPair = typeof matchIndices !== 'undefined' ? GetMatchIndexPair(S, matchIndices) : void undefined; // step 9.b-9.c + CreateDataPropertyOrThrow(A, ToString(i), matchIndexPair); // step 9.d + if (i > 0 && typeof groupNames[i - 1] !== 'undefined') { // step 9.e + if (!groups) { + throw new $TypeError('if `hasGroups` is `false`, `groupNames` can only contain `undefined` values'); + } + CreateDataPropertyOrThrow(groups, groupNames[i - 1], matchIndexPair); // step 9.e.i + } + } + return A; // step 10 +}; diff --git a/node_modules/es-abstract/2022/MakeTime.js b/node_modules/es-abstract/2022/MakeTime.js new file mode 100644 index 0000000000000000000000000000000000000000..ac7d81f7aeb735f350796f6f1e12bce24c8eb114 --- /dev/null +++ b/node_modules/es-abstract/2022/MakeTime.js @@ -0,0 +1,23 @@ +'use strict'; + +var $isFinite = require('math-intrinsics/isFinite'); +var timeConstants = require('../helpers/timeConstants'); +var msPerSecond = timeConstants.msPerSecond; +var msPerMinute = timeConstants.msPerMinute; +var msPerHour = timeConstants.msPerHour; + +var ToIntegerOrInfinity = require('./ToIntegerOrInfinity'); + +// https://262.ecma-international.org/12.0/#sec-maketime + +module.exports = function MakeTime(hour, min, sec, ms) { + if (!$isFinite(hour) || !$isFinite(min) || !$isFinite(sec) || !$isFinite(ms)) { + return NaN; + } + var h = ToIntegerOrInfinity(hour); + var m = ToIntegerOrInfinity(min); + var s = ToIntegerOrInfinity(sec); + var milli = ToIntegerOrInfinity(ms); + var t = (h * msPerHour) + (m * msPerMinute) + (s * msPerSecond) + milli; + return t; +}; diff --git a/node_modules/es-abstract/2022/MinFromTime.js b/node_modules/es-abstract/2022/MinFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..a0c631d4cc56cb21e15712def6008d5623edd0f9 --- /dev/null +++ b/node_modules/es-abstract/2022/MinFromTime.js @@ -0,0 +1,14 @@ +'use strict'; + +var floor = require('./floor'); +var modulo = require('./modulo'); + +var timeConstants = require('../helpers/timeConstants'); +var msPerMinute = timeConstants.msPerMinute; +var MinutesPerHour = timeConstants.MinutesPerHour; + +// https://262.ecma-international.org/5.1/#sec-15.9.1.10 + +module.exports = function MinFromTime(t) { + return modulo(floor(t / msPerMinute), MinutesPerHour); +}; diff --git a/node_modules/es-abstract/2022/MonthFromTime.js b/node_modules/es-abstract/2022/MonthFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..e551ee2be6da5cc49c7da94be78095c0803c53d9 --- /dev/null +++ b/node_modules/es-abstract/2022/MonthFromTime.js @@ -0,0 +1,51 @@ +'use strict'; + +var $RangeError = require('es-errors/range'); + +var DayWithinYear = require('./DayWithinYear'); +var InLeapYear = require('./InLeapYear'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.4 + +module.exports = function MonthFromTime(t) { + var day = DayWithinYear(t); + if (0 <= day && day < 31) { + return 0; + } + var leap = InLeapYear(t); + if (31 <= day && day < (59 + leap)) { + return 1; + } + if ((59 + leap) <= day && day < (90 + leap)) { + return 2; + } + if ((90 + leap) <= day && day < (120 + leap)) { + return 3; + } + if ((120 + leap) <= day && day < (151 + leap)) { + return 4; + } + if ((151 + leap) <= day && day < (181 + leap)) { + return 5; + } + if ((181 + leap) <= day && day < (212 + leap)) { + return 6; + } + if ((212 + leap) <= day && day < (243 + leap)) { + return 7; + } + if ((243 + leap) <= day && day < (273 + leap)) { + return 8; + } + if ((273 + leap) <= day && day < (304 + leap)) { + return 9; + } + if ((304 + leap) <= day && day < (334 + leap)) { + return 10; + } + if ((334 + leap) <= day && day < (365 + leap)) { + return 11; + } + + throw new $RangeError('Assertion failed: `day` is out of range'); +}; diff --git a/node_modules/es-abstract/2022/NewPromiseCapability.js b/node_modules/es-abstract/2022/NewPromiseCapability.js new file mode 100644 index 0000000000000000000000000000000000000000..893266fe9f8da7b032d6fc835750a07c30086179 --- /dev/null +++ b/node_modules/es-abstract/2022/NewPromiseCapability.js @@ -0,0 +1,34 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var IsCallable = require('./IsCallable'); +var IsConstructor = require('./IsConstructor'); + +// https://262.ecma-international.org/6.0/#sec-newpromisecapability + +module.exports = function NewPromiseCapability(C) { + if (!IsConstructor(C)) { + throw new $TypeError('C must be a constructor'); // step 1 + } + + var resolvingFunctions = { '[[Resolve]]': void undefined, '[[Reject]]': void undefined }; // step 3 + + var promise = new C(function (resolve, reject) { // steps 4-5 + if (typeof resolvingFunctions['[[Resolve]]'] !== 'undefined' || typeof resolvingFunctions['[[Reject]]'] !== 'undefined') { + throw new $TypeError('executor has already been called'); // step 4.a, 4.b + } + resolvingFunctions['[[Resolve]]'] = resolve; // step 4.c + resolvingFunctions['[[Reject]]'] = reject; // step 4.d + }); // step 4-6 + + if (!IsCallable(resolvingFunctions['[[Resolve]]']) || !IsCallable(resolvingFunctions['[[Reject]]'])) { + throw new $TypeError('executor must provide valid resolve and reject functions'); // steps 7-8 + } + + return { + '[[Promise]]': promise, + '[[Resolve]]': resolvingFunctions['[[Resolve]]'], + '[[Reject]]': resolvingFunctions['[[Reject]]'] + }; // step 9 +}; diff --git a/node_modules/es-abstract/2022/NormalCompletion.js b/node_modules/es-abstract/2022/NormalCompletion.js new file mode 100644 index 0000000000000000000000000000000000000000..1e429dd65cfaded0bd09155819605198a45c628d --- /dev/null +++ b/node_modules/es-abstract/2022/NormalCompletion.js @@ -0,0 +1,9 @@ +'use strict'; + +var CompletionRecord = require('./CompletionRecord'); + +// https://262.ecma-international.org/6.0/#sec-normalcompletion + +module.exports = function NormalCompletion(value) { + return new CompletionRecord('normal', value); +}; diff --git a/node_modules/es-abstract/2022/Number/add.js b/node_modules/es-abstract/2022/Number/add.js new file mode 100644 index 0000000000000000000000000000000000000000..eead1f19fec68bed3c141340b4318116f7e9ec06 --- /dev/null +++ b/node_modules/es-abstract/2022/Number/add.js @@ -0,0 +1,31 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isFinite = require('math-intrinsics/isFinite'); +var isNaN = require('math-intrinsics/isNaN'); + +// https://262.ecma-international.org/12.0/#sec-numeric-types-number-add + +module.exports = function NumberAdd(x, y) { + if (typeof x !== 'number' || typeof y !== 'number') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be Numbers'); + } + + if (isNaN(x) || isNaN(y) || (x === Infinity && y === -Infinity) || (x === -Infinity && y === Infinity)) { + return NaN; + } + + if (!isFinite(x)) { + return x; + } + if (!isFinite(y)) { + return y; + } + + if (x === y && x === 0) { // both zeroes + return Infinity / x === -Infinity && Infinity / y === -Infinity ? -0 : +0; + } + + // shortcut for the actual spec mechanics + return x + y; +}; diff --git a/node_modules/es-abstract/2022/Number/bitwiseAND.js b/node_modules/es-abstract/2022/Number/bitwiseAND.js new file mode 100644 index 0000000000000000000000000000000000000000..d85d0f6f6a657b4afcbb3abd8c655d9e5a247400 --- /dev/null +++ b/node_modules/es-abstract/2022/Number/bitwiseAND.js @@ -0,0 +1,14 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var NumberBitwiseOp = require('../NumberBitwiseOp'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-number-bitwiseAND + +module.exports = function NumberBitwiseAND(x, y) { + if (typeof x !== 'number' || typeof y !== 'number') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be Numbers'); + } + return NumberBitwiseOp('&', x, y); +}; diff --git a/node_modules/es-abstract/2022/Number/bitwiseNOT.js b/node_modules/es-abstract/2022/Number/bitwiseNOT.js new file mode 100644 index 0000000000000000000000000000000000000000..7e3035e879df0d334dab28b00d3f07c1583c0429 --- /dev/null +++ b/node_modules/es-abstract/2022/Number/bitwiseNOT.js @@ -0,0 +1,16 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var ToInt32 = require('../ToInt32'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-number-bitwiseNOT + +module.exports = function NumberBitwiseNOT(x) { + if (typeof x !== 'number') { + throw new $TypeError('Assertion failed: `x` argument must be a Number'); + } + var oldValue = ToInt32(x); + // Return the result of applying the bitwise operator op to lnum and rnum. The result is a signed 32-bit integer. + return ~oldValue; +}; diff --git a/node_modules/es-abstract/2022/Number/bitwiseOR.js b/node_modules/es-abstract/2022/Number/bitwiseOR.js new file mode 100644 index 0000000000000000000000000000000000000000..2930a61222f9cc53559ffceac2865b5fdabfeea4 --- /dev/null +++ b/node_modules/es-abstract/2022/Number/bitwiseOR.js @@ -0,0 +1,14 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var NumberBitwiseOp = require('../NumberBitwiseOp'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-number-bitwiseOR + +module.exports = function NumberBitwiseOR(x, y) { + if (typeof x !== 'number' || typeof y !== 'number') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be Numbers'); + } + return NumberBitwiseOp('|', x, y); +}; diff --git a/node_modules/es-abstract/2022/Number/bitwiseXOR.js b/node_modules/es-abstract/2022/Number/bitwiseXOR.js new file mode 100644 index 0000000000000000000000000000000000000000..fab4baae216a9c35ef1eb20fc941aca98028cb21 --- /dev/null +++ b/node_modules/es-abstract/2022/Number/bitwiseXOR.js @@ -0,0 +1,14 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var NumberBitwiseOp = require('../NumberBitwiseOp'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-number-bitwiseXOR + +module.exports = function NumberBitwiseXOR(x, y) { + if (typeof x !== 'number' || typeof y !== 'number') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be Numbers'); + } + return NumberBitwiseOp('^', x, y); +}; diff --git a/node_modules/es-abstract/2022/Number/divide.js b/node_modules/es-abstract/2022/Number/divide.js new file mode 100644 index 0000000000000000000000000000000000000000..12ec011c993217453e4633d626e47d3baf134beb --- /dev/null +++ b/node_modules/es-abstract/2022/Number/divide.js @@ -0,0 +1,18 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isFinite = require('math-intrinsics/isFinite'); +var isNaN = require('math-intrinsics/isNaN'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-number-divide + +module.exports = function NumberDivide(x, y) { + if (typeof x !== 'number' || typeof y !== 'number') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be Numbers'); + } + if (isNaN(x) || isNaN(y) || (!isFinite(x) && !isFinite(y))) { + return NaN; + } + // shortcut for the actual spec mechanics + return x / y; +}; diff --git a/node_modules/es-abstract/2022/Number/equal.js b/node_modules/es-abstract/2022/Number/equal.js new file mode 100644 index 0000000000000000000000000000000000000000..ebd9f7463a062a0b95d80a80e4ef2cbd8efc648e --- /dev/null +++ b/node_modules/es-abstract/2022/Number/equal.js @@ -0,0 +1,18 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var isNaN = require('../../helpers/isNaN'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-number-equal + +module.exports = function NumberEqual(x, y) { + if (typeof x !== 'number' || typeof y !== 'number') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be Numbers'); + } + if (isNaN(x) || isNaN(y)) { + return false; + } + // shortcut for the actual spec mechanics + return x === y; +}; diff --git a/node_modules/es-abstract/2022/Number/exponentiate.js b/node_modules/es-abstract/2022/Number/exponentiate.js new file mode 100644 index 0000000000000000000000000000000000000000..37812d85bccd0b0438c66595e1e6d5aef4c94bc7 --- /dev/null +++ b/node_modules/es-abstract/2022/Number/exponentiate.js @@ -0,0 +1,74 @@ +'use strict'; + +// var isNegativeZero = require('math-intrinsics/isNegativeZero'); +var $pow = require('math-intrinsics/pow'); + +var $TypeError = require('es-errors/type'); + +/* +var abs = require('math-intrinsics/abs'); +var isFinite = require('math-intrinsics/isFinite'); +var isNaN = require('math-intrinsics/isNaN'); + +var IsInteger = require('math-intrinsics/isInteger'); +*/ + +// https://262.ecma-international.org/11.0/#sec-numeric-types-number-exponentiate + +/* eslint max-lines-per-function: 0, max-statements: 0 */ + +module.exports = function NumberExponentiate(base, exponent) { + if (typeof base !== 'number' || typeof exponent !== 'number') { + throw new $TypeError('Assertion failed: `base` and `exponent` arguments must be Numbers'); + } + return $pow(base, exponent); + /* + if (isNaN(exponent)) { + return NaN; + } + if (exponent === 0) { + return 1; + } + if (isNaN(base)) { + return NaN; + } + var aB = abs(base); + if (aB > 1 && exponent === Infinity) { + return Infinity; + } + if (aB > 1 && exponent === -Infinity) { + return 0; + } + if (aB === 1 && (exponent === Infinity || exponent === -Infinity)) { + return NaN; + } + if (aB < 1 && exponent === Infinity) { + return +0; + } + if (aB < 1 && exponent === -Infinity) { + return Infinity; + } + if (base === Infinity) { + return exponent > 0 ? Infinity : 0; + } + if (base === -Infinity) { + var isOdd = true; + if (exponent > 0) { + return isOdd ? -Infinity : Infinity; + } + return isOdd ? -0 : 0; + } + if (exponent > 0) { + return isNegativeZero(base) ? Infinity : 0; + } + if (isNegativeZero(base)) { + if (exponent > 0) { + return isOdd ? -0 : 0; + } + return isOdd ? -Infinity : Infinity; + } + if (base < 0 && isFinite(base) && isFinite(exponent) && !IsInteger(exponent)) { + return NaN; + } + */ +}; diff --git a/node_modules/es-abstract/2022/Number/index.js b/node_modules/es-abstract/2022/Number/index.js new file mode 100644 index 0000000000000000000000000000000000000000..63ec52da69e285d605f9f5db2ffe69ed4af591f2 --- /dev/null +++ b/node_modules/es-abstract/2022/Number/index.js @@ -0,0 +1,43 @@ +'use strict'; + +var add = require('./add'); +var bitwiseAND = require('./bitwiseAND'); +var bitwiseNOT = require('./bitwiseNOT'); +var bitwiseOR = require('./bitwiseOR'); +var bitwiseXOR = require('./bitwiseXOR'); +var divide = require('./divide'); +var equal = require('./equal'); +var exponentiate = require('./exponentiate'); +var leftShift = require('./leftShift'); +var lessThan = require('./lessThan'); +var multiply = require('./multiply'); +var remainder = require('./remainder'); +var sameValue = require('./sameValue'); +var sameValueZero = require('./sameValueZero'); +var signedRightShift = require('./signedRightShift'); +var subtract = require('./subtract'); +var toString = require('./toString'); +var unaryMinus = require('./unaryMinus'); +var unsignedRightShift = require('./unsignedRightShift'); + +module.exports = { + add: add, + bitwiseAND: bitwiseAND, + bitwiseNOT: bitwiseNOT, + bitwiseOR: bitwiseOR, + bitwiseXOR: bitwiseXOR, + divide: divide, + equal: equal, + exponentiate: exponentiate, + leftShift: leftShift, + lessThan: lessThan, + multiply: multiply, + remainder: remainder, + sameValue: sameValue, + sameValueZero: sameValueZero, + signedRightShift: signedRightShift, + subtract: subtract, + toString: toString, + unaryMinus: unaryMinus, + unsignedRightShift: unsignedRightShift +}; diff --git a/node_modules/es-abstract/2022/Number/leftShift.js b/node_modules/es-abstract/2022/Number/leftShift.js new file mode 100644 index 0000000000000000000000000000000000000000..bbaffae5d3e3bca167fbf5e501f43beece5b2e7f --- /dev/null +++ b/node_modules/es-abstract/2022/Number/leftShift.js @@ -0,0 +1,22 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var ToInt32 = require('../ToInt32'); +var ToUint32 = require('../ToUint32'); +var modulo = require('../modulo'); + +// https://262.ecma-international.org/12.0/#sec-numeric-types-number-leftShift + +module.exports = function NumberLeftShift(x, y) { + if (typeof x !== 'number' || typeof y !== 'number') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be Numbers'); + } + + var lnum = ToInt32(x); + var rnum = ToUint32(y); + + var shiftCount = modulo(rnum, 32); + + return lnum << shiftCount; +}; diff --git a/node_modules/es-abstract/2022/Number/lessThan.js b/node_modules/es-abstract/2022/Number/lessThan.js new file mode 100644 index 0000000000000000000000000000000000000000..538174306dd342a14dc82f25f2b8e5a56c9e6a32 --- /dev/null +++ b/node_modules/es-abstract/2022/Number/lessThan.js @@ -0,0 +1,22 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var isNaN = require('../../helpers/isNaN'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-number-lessThan + +module.exports = function NumberLessThan(x, y) { + if (typeof x !== 'number' || typeof y !== 'number') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be Numbers'); + } + + // If x is NaN, return undefined. + // If y is NaN, return undefined. + if (isNaN(x) || isNaN(y)) { + return void undefined; + } + + // shortcut for the actual spec mechanics + return x < y; +}; diff --git a/node_modules/es-abstract/2022/Number/multiply.js b/node_modules/es-abstract/2022/Number/multiply.js new file mode 100644 index 0000000000000000000000000000000000000000..318787cbab9b472dca1f47e18c0faec44c4da1c3 --- /dev/null +++ b/node_modules/es-abstract/2022/Number/multiply.js @@ -0,0 +1,29 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var isNaN = require('../../helpers/isNaN'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-number-multiply + +module.exports = function NumberMultiply(x, y) { + if (typeof x !== 'number' || typeof y !== 'number') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be Numbers'); + } + + if (isNaN(x) || isNaN(y) || (x === 0 && !isFinite(y)) || (!isFinite(x) && y === 0)) { + return NaN; + } + if (!isFinite(x) && !isFinite(y)) { + return x === y ? Infinity : -Infinity; + } + if (!isFinite(x) && y !== 0) { + return x > 0 ? Infinity : -Infinity; + } + if (!isFinite(y) && x !== 0) { + return y > 0 ? Infinity : -Infinity; + } + + // shortcut for the actual spec mechanics + return x * y; +}; diff --git a/node_modules/es-abstract/2022/Number/remainder.js b/node_modules/es-abstract/2022/Number/remainder.js new file mode 100644 index 0000000000000000000000000000000000000000..8d1b1790fe607ba4f26936946224277dfe137072 --- /dev/null +++ b/node_modules/es-abstract/2022/Number/remainder.js @@ -0,0 +1,28 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var isNaN = require('../../helpers/isNaN'); + +// https://262.ecma-international.org/12.0/#sec-numeric-types-number-remainder + +module.exports = function NumberRemainder(n, d) { + if (typeof n !== 'number' || typeof d !== 'number') { + throw new $TypeError('Assertion failed: `n` and `d` arguments must be Numbers'); + } + + // If either operand is NaN, the result is NaN. + // If the dividend is an infinity, or the divisor is a zero, or both, the result is NaN. + if (isNaN(n) || isNaN(d) || !isFinite(n) || d === 0) { + return NaN; + } + + // If the dividend is finite and the divisor is an infinity, the result equals the dividend. + // If the dividend is a zero and the divisor is nonzero and finite, the result is the same as the dividend. + if (!isFinite(d) || n === 0) { + return n; + } + + // In the remaining cases, where neither an infinity, nor a zero, nor NaN is involved… + return n % d; +}; diff --git a/node_modules/es-abstract/2022/Number/sameValue.js b/node_modules/es-abstract/2022/Number/sameValue.js new file mode 100644 index 0000000000000000000000000000000000000000..f7c6f78a4afc352f3ead59cd4ffc866dadc74130 --- /dev/null +++ b/node_modules/es-abstract/2022/Number/sameValue.js @@ -0,0 +1,18 @@ +'use strict'; + +var isNegativeZero = require('math-intrinsics/isNegativeZero'); +var $TypeError = require('es-errors/type'); + +var NumberSameValueZero = require('./sameValueZero'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-number-sameValue + +module.exports = function NumberSameValue(x, y) { + if (typeof x !== 'number' || typeof y !== 'number') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be Numbers'); + } + if (x === 0 && y === 0) { + return !(isNegativeZero(x) ^ isNegativeZero(y)); + } + return NumberSameValueZero(x, y); +}; diff --git a/node_modules/es-abstract/2022/Number/sameValueZero.js b/node_modules/es-abstract/2022/Number/sameValueZero.js new file mode 100644 index 0000000000000000000000000000000000000000..383ab82f70c8612fed5287ec4b0b0b5814f48750 --- /dev/null +++ b/node_modules/es-abstract/2022/Number/sameValueZero.js @@ -0,0 +1,20 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var isNaN = require('../../helpers/isNaN'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-number-sameValueZero + +module.exports = function NumberSameValueZero(x, y) { + if (typeof x !== 'number' || typeof y !== 'number') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be Numbers'); + } + + var xNaN = isNaN(x); + var yNaN = isNaN(y); + if (xNaN || yNaN) { + return xNaN === yNaN; + } + return x === y; +}; diff --git a/node_modules/es-abstract/2022/Number/signedRightShift.js b/node_modules/es-abstract/2022/Number/signedRightShift.js new file mode 100644 index 0000000000000000000000000000000000000000..b22775b14f06bec9ec6e4e1b53096d9e69740327 --- /dev/null +++ b/node_modules/es-abstract/2022/Number/signedRightShift.js @@ -0,0 +1,22 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var ToInt32 = require('../ToInt32'); +var ToUint32 = require('../ToUint32'); +var modulo = require('../modulo'); + +// https://262.ecma-international.org/12.0/#sec-numeric-types-number-signedRightShift + +module.exports = function NumberSignedRightShift(x, y) { + if (typeof x !== 'number' || typeof y !== 'number') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be Numbers'); + } + + var lnum = ToInt32(x); + var rnum = ToUint32(y); + + var shiftCount = modulo(rnum, 32); + + return lnum >> shiftCount; +}; diff --git a/node_modules/es-abstract/2022/Number/subtract.js b/node_modules/es-abstract/2022/Number/subtract.js new file mode 100644 index 0000000000000000000000000000000000000000..9f66df451ff8029461369d79f81debc17766379a --- /dev/null +++ b/node_modules/es-abstract/2022/Number/subtract.js @@ -0,0 +1,15 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var NumberAdd = require('./add'); +var NumberUnaryMinus = require('./unaryMinus'); + +// https://262.ecma-international.org/12.0/#sec-numeric-types-number-subtract + +module.exports = function NumberSubtract(x, y) { + if (typeof x !== 'number' || typeof y !== 'number') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be Numbers'); + } + return NumberAdd(x, NumberUnaryMinus(y)); +}; diff --git a/node_modules/es-abstract/2022/Number/toString.js b/node_modules/es-abstract/2022/Number/toString.js new file mode 100644 index 0000000000000000000000000000000000000000..833353dc3bce29b8b8a7fe2cbf7b10185a3b149d --- /dev/null +++ b/node_modules/es-abstract/2022/Number/toString.js @@ -0,0 +1,16 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $String = GetIntrinsic('%String%'); +var $TypeError = require('es-errors/type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-number-tostring + +module.exports = function NumberToString(x) { + if (typeof x !== 'number') { + throw new $TypeError('Assertion failed: `x` must be a Number'); + } + + return $String(x); +}; diff --git a/node_modules/es-abstract/2022/Number/unaryMinus.js b/node_modules/es-abstract/2022/Number/unaryMinus.js new file mode 100644 index 0000000000000000000000000000000000000000..ab4ed98b2db294cfcd12edd31d9a7fd06649b9dd --- /dev/null +++ b/node_modules/es-abstract/2022/Number/unaryMinus.js @@ -0,0 +1,17 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var isNaN = require('../../helpers/isNaN'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-number-unaryMinus + +module.exports = function NumberUnaryMinus(x) { + if (typeof x !== 'number') { + throw new $TypeError('Assertion failed: `x` argument must be a Number'); + } + if (isNaN(x)) { + return NaN; + } + return -x; +}; diff --git a/node_modules/es-abstract/2022/Number/unsignedRightShift.js b/node_modules/es-abstract/2022/Number/unsignedRightShift.js new file mode 100644 index 0000000000000000000000000000000000000000..70334bd60c5a4417c07b2a5f51ba942fc8731d8f --- /dev/null +++ b/node_modules/es-abstract/2022/Number/unsignedRightShift.js @@ -0,0 +1,22 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var ToInt32 = require('../ToInt32'); +var ToUint32 = require('../ToUint32'); +var modulo = require('../modulo'); + +// https://262.ecma-international.org/12.0/#sec-numeric-types-number-unsignedRightShift + +module.exports = function NumberUnsignedRightShift(x, y) { + if (typeof x !== 'number' || typeof y !== 'number') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be Numbers'); + } + + var lnum = ToInt32(x); + var rnum = ToUint32(y); + + var shiftCount = modulo(rnum, 32); + + return lnum >>> shiftCount; +}; diff --git a/node_modules/es-abstract/2022/NumberBitwiseOp.js b/node_modules/es-abstract/2022/NumberBitwiseOp.js new file mode 100644 index 0000000000000000000000000000000000000000..769d1fa15aee1ba5ee58abd4f96579f9ba38138f --- /dev/null +++ b/node_modules/es-abstract/2022/NumberBitwiseOp.js @@ -0,0 +1,26 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var ToInt32 = require('./ToInt32'); +var ToUint32 = require('./ToUint32'); + +// https://262.ecma-international.org/11.0/#sec-numberbitwiseop + +module.exports = function NumberBitwiseOp(op, x, y) { + if (op !== '&' && op !== '|' && op !== '^') { + throw new $TypeError('Assertion failed: `op` must be `&`, `|`, or `^`'); + } + if (typeof x !== 'number' || typeof y !== 'number') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be Numbers'); + } + var lnum = ToInt32(x); + var rnum = ToUint32(y); + if (op === '&') { + return lnum & rnum; + } + if (op === '|') { + return lnum | rnum; + } + return lnum ^ rnum; +}; diff --git a/node_modules/es-abstract/2022/NumberToBigInt.js b/node_modules/es-abstract/2022/NumberToBigInt.js new file mode 100644 index 0000000000000000000000000000000000000000..27fb6682301aaeb4a93dfad4ed9bcbdbaa24f6c2 --- /dev/null +++ b/node_modules/es-abstract/2022/NumberToBigInt.js @@ -0,0 +1,25 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $BigInt = GetIntrinsic('%BigInt%', true); +var $RangeError = require('es-errors/range'); +var $SyntaxError = require('es-errors/syntax'); +var $TypeError = require('es-errors/type'); + +var isInteger = require('math-intrinsics/isInteger'); + +// https://262.ecma-international.org/12.0/#sec-numbertobigint + +module.exports = function NumberToBigInt(number) { + if (typeof number !== 'number') { + throw new $TypeError('Assertion failed: `number` must be a String'); + } + if (!isInteger(number)) { + throw new $RangeError('The number ' + number + ' cannot be converted to a BigInt because it is not an integer'); + } + if (!$BigInt) { + throw new $SyntaxError('BigInts are not supported in this environment'); + } + return $BigInt(number); +}; diff --git a/node_modules/es-abstract/2022/NumericToRawBytes.js b/node_modules/es-abstract/2022/NumericToRawBytes.js new file mode 100644 index 0000000000000000000000000000000000000000..db42a4fbb0951c865b5c3d85a9cbb874b825a3c6 --- /dev/null +++ b/node_modules/es-abstract/2022/NumericToRawBytes.js @@ -0,0 +1,62 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var hasOwnProperty = require('./HasOwnProperty'); +var ToBigInt64 = require('./ToBigInt64'); +var ToBigUint64 = require('./ToBigUint64'); +var ToInt16 = require('./ToInt16'); +var ToInt32 = require('./ToInt32'); +var ToInt8 = require('./ToInt8'); +var ToUint16 = require('./ToUint16'); +var ToUint32 = require('./ToUint32'); +var ToUint8 = require('./ToUint8'); +var ToUint8Clamp = require('./ToUint8Clamp'); + +var valueToFloat32Bytes = require('../helpers/valueToFloat32Bytes'); +var valueToFloat64Bytes = require('../helpers/valueToFloat64Bytes'); +var integerToNBytes = require('../helpers/integerToNBytes'); + +var tableTAO = require('./tables/typed-array-objects'); + +// https://262.ecma-international.org/11.0/#table-the-typedarray-constructors +var TypeToAO = { + __proto__: null, + $Int8: ToInt8, + $Uint8: ToUint8, + $Uint8C: ToUint8Clamp, + $Int16: ToInt16, + $Uint16: ToUint16, + $Int32: ToInt32, + $Uint32: ToUint32, + $BigInt64: ToBigInt64, + $BigUint64: ToBigUint64 +}; + +// https://262.ecma-international.org/11.0/#sec-numerictorawbytes + +module.exports = function NumericToRawBytes(type, value, isLittleEndian) { + if (typeof type !== 'string' || !hasOwnProperty(tableTAO.size, '$' + type)) { + throw new $TypeError('Assertion failed: `type` must be a TypedArray element type'); + } + if (typeof value !== 'number' && typeof value !== 'bigint') { + throw new $TypeError('Assertion failed: `value` must be a Number or a BigInt'); + } + if (typeof isLittleEndian !== 'boolean') { + throw new $TypeError('Assertion failed: `isLittleEndian` must be a Boolean'); + } + + if (type === 'Float32') { // step 1 + return valueToFloat32Bytes(value, isLittleEndian); + } else if (type === 'Float64') { // step 2 + return valueToFloat64Bytes(value, isLittleEndian); + } // step 3 + + var n = tableTAO.size['$' + type]; // step 3.a + + var convOp = TypeToAO['$' + type]; // step 3.b + + var intValue = convOp(value); // step 3.c + + return integerToNBytes(intValue, n, isLittleEndian); // step 3.d, 3.e, 4 +}; diff --git a/node_modules/es-abstract/2022/ObjectDefineProperties.js b/node_modules/es-abstract/2022/ObjectDefineProperties.js new file mode 100644 index 0000000000000000000000000000000000000000..0d41322bcc146b95dea2f81dbb533ed69495414a --- /dev/null +++ b/node_modules/es-abstract/2022/ObjectDefineProperties.js @@ -0,0 +1,37 @@ +'use strict'; + +var DefinePropertyOrThrow = require('./DefinePropertyOrThrow'); +var Get = require('./Get'); +var OrdinaryGetOwnProperty = require('./OrdinaryGetOwnProperty'); +var ToObject = require('./ToObject'); +var ToPropertyDescriptor = require('./ToPropertyDescriptor'); + +var forEach = require('../helpers/forEach'); +var OwnPropertyKeys = require('own-keys'); + +// https://262.ecma-international.org/6.0/#sec-objectdefineproperties + +/** @type { = {}>(O: T, Properties: object) => T} */ +module.exports = function ObjectDefineProperties(O, Properties) { + var props = ToObject(Properties); // step 1 + var keys = OwnPropertyKeys(props); // step 2 + /** @type {[string | symbol, import('../types').Descriptor][]} */ + var descriptors = []; // step 3 + + forEach(keys, function (nextKey) { // step 4 + var propDesc = OrdinaryGetOwnProperty(props, nextKey); // ToPropertyDescriptor(getOwnPropertyDescriptor(props, nextKey)); // step 4.a + if (typeof propDesc !== 'undefined' && propDesc['[[Enumerable]]']) { // step 4.b + var descObj = Get(props, nextKey); // step 4.b.i + var desc = ToPropertyDescriptor(descObj); // step 4.b.ii + descriptors[descriptors.length] = [nextKey, desc]; // step 4.b.iii + } + }); + + forEach(descriptors, function (pair) { // step 5 + var P = pair[0]; // step 5.a + var desc = pair[1]; // step 5.b + DefinePropertyOrThrow(O, P, desc); // step 5.c + }); + + return O; // step 6 +}; diff --git a/node_modules/es-abstract/2022/OrdinaryCreateFromConstructor.js b/node_modules/es-abstract/2022/OrdinaryCreateFromConstructor.js new file mode 100644 index 0000000000000000000000000000000000000000..ac997c828209e0a91a21801f62f206d4dd642c29 --- /dev/null +++ b/node_modules/es-abstract/2022/OrdinaryCreateFromConstructor.js @@ -0,0 +1,20 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); +var $TypeError = require('es-errors/type'); + +var GetPrototypeFromConstructor = require('./GetPrototypeFromConstructor'); +var IsArray = require('./IsArray'); +var OrdinaryObjectCreate = require('./OrdinaryObjectCreate'); + +// https://262.ecma-international.org/6.0/#sec-ordinarycreatefromconstructor + +module.exports = function OrdinaryCreateFromConstructor(constructor, intrinsicDefaultProto) { + GetIntrinsic(intrinsicDefaultProto); // throws if not a valid intrinsic + var proto = GetPrototypeFromConstructor(constructor, intrinsicDefaultProto); + var slots = arguments.length < 3 ? [] : arguments[2]; + if (!IsArray(slots)) { + throw new $TypeError('Assertion failed: if provided, `internalSlotsList` must be a List'); + } + return OrdinaryObjectCreate(proto, slots); +}; diff --git a/node_modules/es-abstract/2022/OrdinaryDefineOwnProperty.js b/node_modules/es-abstract/2022/OrdinaryDefineOwnProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..1a61488c6311f778620cdccb377e0b377040b055 --- /dev/null +++ b/node_modules/es-abstract/2022/OrdinaryDefineOwnProperty.js @@ -0,0 +1,54 @@ +'use strict'; + +var $gOPD = require('gopd'); +var $SyntaxError = require('es-errors/syntax'); +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var isPropertyDescriptor = require('../helpers/records/property-descriptor'); + +var IsAccessorDescriptor = require('./IsAccessorDescriptor'); +var IsExtensible = require('./IsExtensible'); +var isPropertyKey = require('../helpers/isPropertyKey'); +var ToPropertyDescriptor = require('./ToPropertyDescriptor'); +var SameValue = require('./SameValue'); +var ValidateAndApplyPropertyDescriptor = require('./ValidateAndApplyPropertyDescriptor'); + +// https://262.ecma-international.org/6.0/#sec-ordinarydefineownproperty + +module.exports = function OrdinaryDefineOwnProperty(O, P, Desc) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: O must be an Object'); + } + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: P must be a Property Key'); + } + if (!isPropertyDescriptor(Desc)) { + throw new $TypeError('Assertion failed: Desc must be a Property Descriptor'); + } + if (!$gOPD) { + // ES3/IE 8 fallback + if (IsAccessorDescriptor(Desc)) { + throw new $SyntaxError('This environment does not support accessor property descriptors.'); + } + var creatingNormalDataProperty = !(P in O) + && Desc['[[Writable]]'] + && Desc['[[Enumerable]]'] + && Desc['[[Configurable]]'] + && '[[Value]]' in Desc; + var settingExistingDataProperty = (P in O) + && (!('[[Configurable]]' in Desc) || Desc['[[Configurable]]']) + && (!('[[Enumerable]]' in Desc) || Desc['[[Enumerable]]']) + && (!('[[Writable]]' in Desc) || Desc['[[Writable]]']) + && '[[Value]]' in Desc; + if (creatingNormalDataProperty || settingExistingDataProperty) { + O[P] = Desc['[[Value]]']; // eslint-disable-line no-param-reassign + return SameValue(O[P], Desc['[[Value]]']); + } + throw new $SyntaxError('This environment does not support defining non-writable, non-enumerable, or non-configurable properties'); + } + var desc = $gOPD(O, P); + var current = desc && ToPropertyDescriptor(desc); + var extensible = IsExtensible(O); + return ValidateAndApplyPropertyDescriptor(O, P, extensible, Desc, current); +}; diff --git a/node_modules/es-abstract/2022/OrdinaryGetOwnProperty.js b/node_modules/es-abstract/2022/OrdinaryGetOwnProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..e0c9cb1a595d9273e0bbea4f0b6a99918320b7fd --- /dev/null +++ b/node_modules/es-abstract/2022/OrdinaryGetOwnProperty.js @@ -0,0 +1,41 @@ +'use strict'; + +var $gOPD = require('gopd'); +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); +var callBound = require('call-bound'); + +var $isEnumerable = callBound('Object.prototype.propertyIsEnumerable'); + +var hasOwn = require('hasown'); + +var IsArray = require('./IsArray'); +var isPropertyKey = require('../helpers/isPropertyKey'); +var IsRegExp = require('./IsRegExp'); +var ToPropertyDescriptor = require('./ToPropertyDescriptor'); + +// https://262.ecma-international.org/6.0/#sec-ordinarygetownproperty + +module.exports = function OrdinaryGetOwnProperty(O, P) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: O must be an Object'); + } + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: P must be a Property Key'); + } + if (!hasOwn(O, P)) { + return void 0; + } + if (!$gOPD) { + // ES3 / IE 8 fallback + var arrayLength = IsArray(O) && P === 'length'; + var regexLastIndex = IsRegExp(O) && P === 'lastIndex'; + return { + '[[Configurable]]': !(arrayLength || regexLastIndex), + '[[Enumerable]]': $isEnumerable(O, P), + '[[Value]]': O[P], + '[[Writable]]': true + }; + } + return ToPropertyDescriptor($gOPD(O, P)); +}; diff --git a/node_modules/es-abstract/2022/OrdinaryGetPrototypeOf.js b/node_modules/es-abstract/2022/OrdinaryGetPrototypeOf.js new file mode 100644 index 0000000000000000000000000000000000000000..7ef8bee34617c4ecaa2bd4b55cf1eb6a6665fe50 --- /dev/null +++ b/node_modules/es-abstract/2022/OrdinaryGetPrototypeOf.js @@ -0,0 +1,18 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var $getProto = require('get-proto'); + +// https://262.ecma-international.org/7.0/#sec-ordinarygetprototypeof + +module.exports = function OrdinaryGetPrototypeOf(O) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: O must be an Object'); + } + if (!$getProto) { + throw new $TypeError('This environment does not support fetching prototypes.'); + } + return $getProto(O); +}; diff --git a/node_modules/es-abstract/2022/OrdinaryHasInstance.js b/node_modules/es-abstract/2022/OrdinaryHasInstance.js new file mode 100644 index 0000000000000000000000000000000000000000..a0a83e6733a49e898d0f9db5df20a54028ad69e3 --- /dev/null +++ b/node_modules/es-abstract/2022/OrdinaryHasInstance.js @@ -0,0 +1,23 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var Get = require('./Get'); +var IsCallable = require('./IsCallable'); + +// https://262.ecma-international.org/6.0/#sec-ordinaryhasinstance + +module.exports = function OrdinaryHasInstance(C, O) { + if (!IsCallable(C)) { + return false; + } + if (!isObject(O)) { + return false; + } + var P = Get(C, 'prototype'); + if (!isObject(P)) { + throw new $TypeError('OrdinaryHasInstance called on an object with an invalid prototype property.'); + } + return O instanceof C; +}; diff --git a/node_modules/es-abstract/2022/OrdinaryHasProperty.js b/node_modules/es-abstract/2022/OrdinaryHasProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..c6c5c11961374a2c3c4beb751aca52a9973093d6 --- /dev/null +++ b/node_modules/es-abstract/2022/OrdinaryHasProperty.js @@ -0,0 +1,18 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var isPropertyKey = require('../helpers/isPropertyKey'); + +// https://262.ecma-international.org/6.0/#sec-ordinaryhasproperty + +module.exports = function OrdinaryHasProperty(O, P) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: P must be a Property Key'); + } + return P in O; +}; diff --git a/node_modules/es-abstract/2022/OrdinaryObjectCreate.js b/node_modules/es-abstract/2022/OrdinaryObjectCreate.js new file mode 100644 index 0000000000000000000000000000000000000000..aca0ac014fead59cc298b13659179c082a4ae82a --- /dev/null +++ b/node_modules/es-abstract/2022/OrdinaryObjectCreate.js @@ -0,0 +1,56 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $ObjectCreate = GetIntrinsic('%Object.create%', true); +var $TypeError = require('es-errors/type'); +var $SyntaxError = require('es-errors/syntax'); +var isObject = require('es-object-atoms/isObject'); + +var IsArray = require('./IsArray'); + +var forEach = require('../helpers/forEach'); + +var SLOT = require('internal-slot'); + +var hasProto = require('has-proto')(); + +// https://262.ecma-international.org/11.0/#sec-objectcreate + +module.exports = function OrdinaryObjectCreate(proto) { + if (proto !== null && !isObject(proto)) { + throw new $TypeError('Assertion failed: `proto` must be null or an object'); + } + var additionalInternalSlotsList = arguments.length < 2 ? [] : arguments[1]; + if (!IsArray(additionalInternalSlotsList)) { + throw new $TypeError('Assertion failed: `additionalInternalSlotsList` must be an Array'); + } + + // var internalSlotsList = ['[[Prototype]]', '[[Extensible]]']; // step 1 + // internalSlotsList.push(...additionalInternalSlotsList); // step 2 + // var O = MakeBasicObject(internalSlotsList); // step 3 + // setProto(O, proto); // step 4 + // return O; // step 5 + + var O; + if (hasProto) { + O = { __proto__: proto }; + } else if ($ObjectCreate) { + O = $ObjectCreate(proto); + } else { + if (proto === null) { + throw new $SyntaxError('native Object.create support is required to create null objects'); + } + var T = function T() {}; + T.prototype = proto; + O = new T(); + } + + if (additionalInternalSlotsList.length > 0) { + forEach(additionalInternalSlotsList, function (slot) { + SLOT.set(O, slot, void undefined); + }); + } + + return O; +}; diff --git a/node_modules/es-abstract/2022/OrdinarySetPrototypeOf.js b/node_modules/es-abstract/2022/OrdinarySetPrototypeOf.js new file mode 100644 index 0000000000000000000000000000000000000000..b493a442ddd22b125fde2ed40eeebddf2d080a2d --- /dev/null +++ b/node_modules/es-abstract/2022/OrdinarySetPrototypeOf.js @@ -0,0 +1,50 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var $setProto = require('set-proto'); +var isObject = require('es-object-atoms/isObject'); + +var OrdinaryGetPrototypeOf = require('./OrdinaryGetPrototypeOf'); + +// https://262.ecma-international.org/7.0/#sec-ordinarysetprototypeof + +module.exports = function OrdinarySetPrototypeOf(O, V) { + if (V !== null && !isObject(V)) { + throw new $TypeError('Assertion failed: V must be Object or Null'); + } + /* + var extensible = IsExtensible(O); + var current = OrdinaryGetPrototypeOf(O); + if (SameValue(V, current)) { + return true; + } + if (!extensible) { + return false; + } + */ + try { + $setProto(O, V); + } catch (e) { + return false; + } + return OrdinaryGetPrototypeOf(O) === V; + /* + var p = V; + var done = false; + while (!done) { + if (p === null) { + done = true; + } else if (SameValue(p, O)) { + return false; + } else { + if (wat) { + done = true; + } else { + p = p.[[Prototype]]; + } + } + } + O.[[Prototype]] = V; + return true; + */ +}; diff --git a/node_modules/es-abstract/2022/OrdinaryToPrimitive.js b/node_modules/es-abstract/2022/OrdinaryToPrimitive.js new file mode 100644 index 0000000000000000000000000000000000000000..5feb5694e8aba94591eac365aa6bd8a6b985f305 --- /dev/null +++ b/node_modules/es-abstract/2022/OrdinaryToPrimitive.js @@ -0,0 +1,36 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var Call = require('./Call'); +var Get = require('./Get'); +var IsCallable = require('./IsCallable'); + +var inspect = require('object-inspect'); + +// https://262.ecma-international.org/8.0/#sec-ordinarytoprimitive + +module.exports = function OrdinaryToPrimitive(O, hint) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + if (/* typeof hint !== 'string' || */ hint !== 'string' && hint !== 'number') { + throw new $TypeError('Assertion failed: `hint` must be "string" or "number"'); + } + + var methodNames = hint === 'string' ? ['toString', 'valueOf'] : ['valueOf', 'toString']; + + for (var i = 0; i < methodNames.length; i += 1) { + var name = methodNames[i]; + var method = Get(O, name); + if (IsCallable(method)) { + var result = Call(method, O); + if (!isObject(result)) { + return result; + } + } + } + + throw new $TypeError('No primitive value for ' + inspect(O)); +}; diff --git a/node_modules/es-abstract/2022/PromiseResolve.js b/node_modules/es-abstract/2022/PromiseResolve.js new file mode 100644 index 0000000000000000000000000000000000000000..dfb7d82fd2e9a378da3188a73ff006a06ce14463 --- /dev/null +++ b/node_modules/es-abstract/2022/PromiseResolve.js @@ -0,0 +1,18 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); +var callBind = require('call-bind'); +var $SyntaxError = require('es-errors/syntax'); + +var $resolve = GetIntrinsic('%Promise.resolve%', true); +var $PromiseResolve = $resolve && callBind($resolve); + +// https://262.ecma-international.org/9.0/#sec-promise-resolve + +module.exports = function PromiseResolve(C, x) { + if (!$PromiseResolve) { + throw new $SyntaxError('This environment does not support Promises.'); + } + return $PromiseResolve(C, x); +}; + diff --git a/node_modules/es-abstract/2022/QuoteJSONString.js b/node_modules/es-abstract/2022/QuoteJSONString.js new file mode 100644 index 0000000000000000000000000000000000000000..2e0c15b64451c199fdd125d63946025921d9a329 --- /dev/null +++ b/node_modules/es-abstract/2022/QuoteJSONString.js @@ -0,0 +1,52 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var callBound = require('call-bound'); +var forEach = require('../helpers/forEach'); +var isLeadingSurrogate = require('../helpers/isLeadingSurrogate'); +var isTrailingSurrogate = require('../helpers/isTrailingSurrogate'); + +var $charCodeAt = callBound('String.prototype.charCodeAt'); +var $strSplit = callBound('String.prototype.split'); + +var StringToCodePoints = require('./StringToCodePoints'); +var UnicodeEscape = require('./UnicodeEscape'); +var UTF16EncodeCodePoint = require('./UTF16EncodeCodePoint'); + +var hasOwn = require('hasown'); + +// https://262.ecma-international.org/12.0/#sec-quotejsonstring + +var escapes = { + '\u0008': '\\b', + '\u0009': '\\t', + '\u000A': '\\n', + '\u000C': '\\f', + '\u000D': '\\r', + '\u0022': '\\"', + '\u005c': '\\\\' +}; + +module.exports = function QuoteJSONString(value) { + if (typeof value !== 'string') { + throw new $TypeError('Assertion failed: `value` must be a String'); + } + var product = '"'; + if (value) { + forEach($strSplit(StringToCodePoints(value), ''), function (C) { + if (hasOwn(escapes, C)) { + product += escapes[C]; + } else { + var cCharCode = $charCodeAt(C, 0); + if (cCharCode < 0x20 || isLeadingSurrogate(cCharCode) || isTrailingSurrogate(cCharCode)) { + product += UnicodeEscape(C); + } else { + product += UTF16EncodeCodePoint(cCharCode); + } + } + }); + } + product += '"'; + return product; +}; diff --git a/node_modules/es-abstract/2022/RawBytesToNumeric.js b/node_modules/es-abstract/2022/RawBytesToNumeric.js new file mode 100644 index 0000000000000000000000000000000000000000..70c24064ca2c7208f10baec57d50b6a31d4038a2 --- /dev/null +++ b/node_modules/es-abstract/2022/RawBytesToNumeric.js @@ -0,0 +1,67 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); +var callBound = require('call-bound'); + +var $RangeError = require('es-errors/range'); +var $SyntaxError = require('es-errors/syntax'); +var $TypeError = require('es-errors/type'); +var $BigInt = GetIntrinsic('%BigInt%', true); + +var hasOwnProperty = require('./HasOwnProperty'); +var IsArray = require('./IsArray'); +var IsBigIntElementType = require('./IsBigIntElementType'); +var IsUnsignedElementType = require('./IsUnsignedElementType'); + +var bytesAsFloat32 = require('../helpers/bytesAsFloat32'); +var bytesAsFloat64 = require('../helpers/bytesAsFloat64'); +var bytesAsInteger = require('../helpers/bytesAsInteger'); +var every = require('../helpers/every'); +var isByteValue = require('../helpers/isByteValue'); + +var $reverse = callBound('Array.prototype.reverse'); +var $slice = callBound('Array.prototype.slice'); + +var tableTAO = require('./tables/typed-array-objects'); + +// https://262.ecma-international.org/11.0/#sec-rawbytestonumeric + +module.exports = function RawBytesToNumeric(type, rawBytes, isLittleEndian) { + if (typeof type !== 'string' || !hasOwnProperty(tableTAO.size, '$' + type)) { + throw new $TypeError('Assertion failed: `type` must be a TypedArray element type'); + } + if (!IsArray(rawBytes) || !every(rawBytes, isByteValue)) { + throw new $TypeError('Assertion failed: `rawBytes` must be an Array of bytes'); + } + if (typeof isLittleEndian !== 'boolean') { + throw new $TypeError('Assertion failed: `isLittleEndian` must be a Boolean'); + } + + var elementSize = tableTAO.size['$' + type]; // step 1 + + if (rawBytes.length !== elementSize) { + // this assertion is not in the spec, but it'd be an editorial error if it were ever violated + throw new $RangeError('Assertion failed: `rawBytes` must have a length of ' + elementSize + ' for type ' + type); + } + + var isBigInt = IsBigIntElementType(type); + if (isBigInt && !$BigInt) { + throw new $SyntaxError('this environment does not support BigInts'); + } + + // eslint-disable-next-line no-param-reassign + rawBytes = $slice(rawBytes, 0, elementSize); + if (!isLittleEndian) { + $reverse(rawBytes); // step 2 + } + + if (type === 'Float32') { // step 3 + return bytesAsFloat32(rawBytes); + } + + if (type === 'Float64') { // step 4 + return bytesAsFloat64(rawBytes); + } + + return bytesAsInteger(rawBytes, elementSize, IsUnsignedElementType(type), isBigInt); +}; diff --git a/node_modules/es-abstract/2022/RegExpCreate.js b/node_modules/es-abstract/2022/RegExpCreate.js new file mode 100644 index 0000000000000000000000000000000000000000..68e31605ed1764b9e1addddc5b910e9c9d73fba2 --- /dev/null +++ b/node_modules/es-abstract/2022/RegExpCreate.js @@ -0,0 +1,21 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $RegExp = GetIntrinsic('%RegExp%'); + +// var RegExpAlloc = require('./RegExpAlloc'); +// var RegExpInitialize = require('./RegExpInitialize'); +var ToString = require('./ToString'); + +// https://262.ecma-international.org/6.0/#sec-regexpcreate + +module.exports = function RegExpCreate(P, F) { + // var obj = RegExpAlloc($RegExp); + // return RegExpInitialize(obj, P, F); + + // covers spec mechanics; bypass regex brand checking + var pattern = typeof P === 'undefined' ? '' : ToString(P); + var flags = typeof F === 'undefined' ? '' : ToString(F); + return new $RegExp(pattern, flags); +}; diff --git a/node_modules/es-abstract/2022/RegExpExec.js b/node_modules/es-abstract/2022/RegExpExec.js new file mode 100644 index 0000000000000000000000000000000000000000..15762b8343aa380c2c90257eef552a87c56745ae --- /dev/null +++ b/node_modules/es-abstract/2022/RegExpExec.js @@ -0,0 +1,29 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); +var regexExec = require('call-bound')('RegExp.prototype.exec'); + +var Call = require('./Call'); +var Get = require('./Get'); +var IsCallable = require('./IsCallable'); + +// https://262.ecma-international.org/6.0/#sec-regexpexec + +module.exports = function RegExpExec(R, S) { + if (!isObject(R)) { + throw new $TypeError('Assertion failed: `R` must be an Object'); + } + if (typeof S !== 'string') { + throw new $TypeError('Assertion failed: `S` must be a String'); + } + var exec = Get(R, 'exec'); + if (IsCallable(exec)) { + var result = Call(exec, R, [S]); + if (result === null || isObject(result)) { + return result; + } + throw new $TypeError('"exec" method must return `null` or an Object'); + } + return regexExec(R, S); +}; diff --git a/node_modules/es-abstract/2022/RegExpHasFlag.js b/node_modules/es-abstract/2022/RegExpHasFlag.js new file mode 100644 index 0000000000000000000000000000000000000000..a1f06ce29172dfbdb155c0307a422851141db649 --- /dev/null +++ b/node_modules/es-abstract/2022/RegExpHasFlag.js @@ -0,0 +1,38 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); +var callBound = require('call-bound'); + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); +var $RegExpPrototype = GetIntrinsic('%RegExp.prototype%'); + +var SameValue = require('./SameValue'); + +var $indexOf = callBound('String.prototype.indexOf'); + +var hasRegExpMatcher = require('is-regex'); +var getFlags = require('regexp.prototype.flags'); + +// https://262.ecma-international.org/13.0/#sec-regexphasflag + +module.exports = function RegExpHasFlag(R, codeUnit) { + if (typeof codeUnit !== 'string' || codeUnit.length !== 1) { + throw new $TypeError('Assertion failed: `string` must be a code unit - a String of length 1'); + } + + if (!isObject(R)) { + throw new $TypeError('Assertion failed: Type(R) is not Object'); + } + + if (!hasRegExpMatcher(R)) { // step 2 + if (SameValue(R, $RegExpPrototype)) { + return void undefined; // step 2.a + } + throw new $TypeError('`R` must be a RegExp object'); // step 2.b + } + + var flags = getFlags(R); // step 3 + + return $indexOf(flags, codeUnit) > -1; // steps 4-5 +}; diff --git a/node_modules/es-abstract/2022/RequireObjectCoercible.js b/node_modules/es-abstract/2022/RequireObjectCoercible.js new file mode 100644 index 0000000000000000000000000000000000000000..b816d1f34b01a80352e783672836a17c49cc06f0 --- /dev/null +++ b/node_modules/es-abstract/2022/RequireObjectCoercible.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('es-object-atoms/RequireObjectCoercible'); diff --git a/node_modules/es-abstract/2022/SameValue.js b/node_modules/es-abstract/2022/SameValue.js new file mode 100644 index 0000000000000000000000000000000000000000..d07bbb8a8f3fec5ad22ffdfb617245331fcff412 --- /dev/null +++ b/node_modules/es-abstract/2022/SameValue.js @@ -0,0 +1,13 @@ +'use strict'; + +var $isNaN = require('math-intrinsics/isNaN'); + +// http://262.ecma-international.org/5.1/#sec-9.12 + +module.exports = function SameValue(x, y) { + if (x === y) { // 0 === -0, but they are not identical. + if (x === 0) { return 1 / x === 1 / y; } + return true; + } + return $isNaN(x) && $isNaN(y); +}; diff --git a/node_modules/es-abstract/2022/SameValueNonNumeric.js b/node_modules/es-abstract/2022/SameValueNonNumeric.js new file mode 100644 index 0000000000000000000000000000000000000000..7c28e0f53c57f0fe4587928b6d91850992d91b8f --- /dev/null +++ b/node_modules/es-abstract/2022/SameValueNonNumeric.js @@ -0,0 +1,18 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var SameValue = require('./SameValue'); +var Type = require('./Type'); + +// https://262.ecma-international.org/11.0/#sec-samevaluenonnumeric + +module.exports = function SameValueNonNumeric(x, y) { + if (typeof x === 'number' || typeof x === 'bigint') { + throw new $TypeError('Assertion failed: SameValueNonNumeric does not accept Number or BigInt values'); + } + if (Type(x) !== Type(y)) { + throw new $TypeError('SameValueNonNumeric requires two non-numeric values of the same type.'); + } + return SameValue(x, y); +}; diff --git a/node_modules/es-abstract/2022/SameValueZero.js b/node_modules/es-abstract/2022/SameValueZero.js new file mode 100644 index 0000000000000000000000000000000000000000..8880e915941eeae2d890f2bdeb1bd057516e3d50 --- /dev/null +++ b/node_modules/es-abstract/2022/SameValueZero.js @@ -0,0 +1,9 @@ +'use strict'; + +var $isNaN = require('math-intrinsics/isNaN'); + +// https://262.ecma-international.org/6.0/#sec-samevaluezero + +module.exports = function SameValueZero(x, y) { + return (x === y) || ($isNaN(x) && $isNaN(y)); +}; diff --git a/node_modules/es-abstract/2022/SecFromTime.js b/node_modules/es-abstract/2022/SecFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..fc2e44560240f134cf345e63ab69d5f8a2d8cec1 --- /dev/null +++ b/node_modules/es-abstract/2022/SecFromTime.js @@ -0,0 +1,14 @@ +'use strict'; + +var floor = require('./floor'); +var modulo = require('./modulo'); + +var timeConstants = require('../helpers/timeConstants'); +var msPerSecond = timeConstants.msPerSecond; +var SecondsPerMinute = timeConstants.SecondsPerMinute; + +// https://262.ecma-international.org/5.1/#sec-15.9.1.10 + +module.exports = function SecFromTime(t) { + return modulo(floor(t / msPerSecond), SecondsPerMinute); +}; diff --git a/node_modules/es-abstract/2022/Set.js b/node_modules/es-abstract/2022/Set.js new file mode 100644 index 0000000000000000000000000000000000000000..f814076a8fb813648eb16093fe86a46182c0fccf --- /dev/null +++ b/node_modules/es-abstract/2022/Set.js @@ -0,0 +1,45 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var isPropertyKey = require('../helpers/isPropertyKey'); +var SameValue = require('./SameValue'); + +// IE 9 does not throw in strict mode when writability/configurability/extensibility is violated +var noThrowOnStrictViolation = (function () { + try { + delete [].length; + return true; + } catch (e) { + return false; + } +}()); + +// https://262.ecma-international.org/6.0/#sec-set-o-p-v-throw + +module.exports = function Set(O, P, V, Throw) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: `O` must be an Object'); + } + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: `P` must be a Property Key'); + } + if (typeof Throw !== 'boolean') { + throw new $TypeError('Assertion failed: `Throw` must be a Boolean'); + } + if (Throw) { + O[P] = V; // eslint-disable-line no-param-reassign + if (noThrowOnStrictViolation && !SameValue(O[P], V)) { + throw new $TypeError('Attempted to assign to readonly property.'); + } + return true; + } + try { + O[P] = V; // eslint-disable-line no-param-reassign + return noThrowOnStrictViolation ? SameValue(O[P], V) : true; + } catch (e) { + return false; + } + +}; diff --git a/node_modules/es-abstract/2022/SetFunctionLength.js b/node_modules/es-abstract/2022/SetFunctionLength.js new file mode 100644 index 0000000000000000000000000000000000000000..193be1c6a6d343f59353756163216d4fae5a57ff --- /dev/null +++ b/node_modules/es-abstract/2022/SetFunctionLength.js @@ -0,0 +1,28 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isInteger = require('math-intrinsics/isInteger'); + +var DefinePropertyOrThrow = require('./DefinePropertyOrThrow'); +var HasOwnProperty = require('./HasOwnProperty'); +var IsExtensible = require('./IsExtensible'); + +// https://262.ecma-international.org/12.0/#sec-setfunctionlength + +module.exports = function SetFunctionLength(F, length) { + if (typeof F !== 'function' || !IsExtensible(F) || HasOwnProperty(F, 'length')) { + throw new $TypeError('Assertion failed: `F` must be an extensible function and lack an own `length` property'); + } + if (typeof length !== 'number') { + throw new $TypeError('Assertion failed: `length` must be a Number'); + } + if (length !== Infinity && (!isInteger(length) || length < 0)) { + throw new $TypeError('Assertion failed: `length` must be ∞, or an integer >= 0'); + } + return DefinePropertyOrThrow(F, 'length', { + '[[Configurable]]': true, + '[[Enumerable]]': false, + '[[Value]]': length, + '[[Writable]]': false + }); +}; diff --git a/node_modules/es-abstract/2022/SetFunctionName.js b/node_modules/es-abstract/2022/SetFunctionName.js new file mode 100644 index 0000000000000000000000000000000000000000..9e8511fd46bc115d0459cc66f44bb6560ba2bc3a --- /dev/null +++ b/node_modules/es-abstract/2022/SetFunctionName.js @@ -0,0 +1,40 @@ +'use strict'; + +var hasOwn = require('hasown'); + +var $TypeError = require('es-errors/type'); + +var getSymbolDescription = require('get-symbol-description'); + +var DefinePropertyOrThrow = require('./DefinePropertyOrThrow'); +var IsExtensible = require('./IsExtensible'); + +// https://262.ecma-international.org/6.0/#sec-setfunctionname + +module.exports = function SetFunctionName(F, name) { + if (typeof F !== 'function') { + throw new $TypeError('Assertion failed: `F` must be a function'); + } + if (!IsExtensible(F) || hasOwn(F, 'name')) { + throw new $TypeError('Assertion failed: `F` must be extensible, and must not have a `name` own property'); + } + if (typeof name !== 'symbol' && typeof name !== 'string') { + throw new $TypeError('Assertion failed: `name` must be a Symbol or a String'); + } + if (typeof name === 'symbol') { + var description = getSymbolDescription(name); + // eslint-disable-next-line no-param-reassign + name = typeof description === 'undefined' ? '' : '[' + description + ']'; + } + if (arguments.length > 2) { + var prefix = arguments[2]; + // eslint-disable-next-line no-param-reassign + name = prefix + ' ' + name; + } + return DefinePropertyOrThrow(F, 'name', { + '[[Value]]': name, + '[[Writable]]': false, + '[[Enumerable]]': false, + '[[Configurable]]': true + }); +}; diff --git a/node_modules/es-abstract/2022/SetIntegrityLevel.js b/node_modules/es-abstract/2022/SetIntegrityLevel.js new file mode 100644 index 0000000000000000000000000000000000000000..ad92fb99b004f2b05e23fa0b2ef45dfc3775025e --- /dev/null +++ b/node_modules/es-abstract/2022/SetIntegrityLevel.js @@ -0,0 +1,57 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $SyntaxError = require('es-errors/syntax'); +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); +var $gOPD = require('gopd'); +var $preventExtensions = GetIntrinsic('%Object.preventExtensions%', true); +var $gOPN = GetIntrinsic('%Object.getOwnPropertyNames%', true); + +var forEach = require('../helpers/forEach'); + +var DefinePropertyOrThrow = require('./DefinePropertyOrThrow'); +var IsAccessorDescriptor = require('./IsAccessorDescriptor'); +var ToPropertyDescriptor = require('./ToPropertyDescriptor'); + +// https://262.ecma-international.org/6.0/#sec-setintegritylevel + +module.exports = function SetIntegrityLevel(O, level) { + if (!isObject(O)) { + 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); + if (level === 'sealed') { + forEach(theKeys, function (k) { + 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 (IsAccessorDescriptor(ToPropertyDescriptor(currentDesc))) { + desc = { configurable: false }; + } else { + desc = { configurable: false, writable: false }; + } + DefinePropertyOrThrow(O, k, desc); + } + }); + } + return true; +}; diff --git a/node_modules/es-abstract/2022/SetTypedArrayFromArrayLike.js b/node_modules/es-abstract/2022/SetTypedArrayFromArrayLike.js new file mode 100644 index 0000000000000000000000000000000000000000..a23db8bb9bc4b0f6d0f6e36c27a873a422c3c489 --- /dev/null +++ b/node_modules/es-abstract/2022/SetTypedArrayFromArrayLike.js @@ -0,0 +1,94 @@ +'use strict'; + +var $RangeError = require('es-errors/range'); +var $TypeError = require('es-errors/type'); + +var isInteger = require('math-intrinsics/isInteger'); +var isTypedArray = require('is-typed-array'); +var typedArrayBuffer = require('typed-array-buffer'); +var typedArrayByteOffset = require('typed-array-byte-offset'); +var typedArrayLength = require('typed-array-length'); +var whichTypedArray = require('which-typed-array'); + +var Get = require('./Get'); +var IsBigIntElementType = require('./IsBigIntElementType'); +var IsDetachedBuffer = require('./IsDetachedBuffer'); +var LengthOfArrayLike = require('./LengthOfArrayLike'); +var SetValueInBuffer = require('./SetValueInBuffer'); +var ToBigInt = require('./ToBigInt'); +var ToNumber = require('./ToNumber'); +var ToObject = require('./ToObject'); +var ToString = require('./ToString'); +var TypedArrayElementSize = require('./TypedArrayElementSize'); +var TypedArrayElementType = require('./TypedArrayElementType'); + +// https://262.ecma-international.org/13.0/#sec-settypedarrayfromarraylike + +module.exports = function SetTypedArrayFromArrayLike(target, targetOffset, source) { + var whichTarget = whichTypedArray(target); + if (!whichTarget) { + throw new $TypeError('Assertion failed: target must be a TypedArray instance'); + } + + if (targetOffset !== Infinity && (!isInteger(targetOffset) || targetOffset < 0)) { + throw new $TypeError('Assertion failed: targetOffset must be a non-negative integer or +Infinity'); + } + + if (isTypedArray(source)) { + throw new $TypeError('Assertion failed: source must not be a TypedArray instance'); + } + + var targetBuffer = typedArrayBuffer(target); // step 1 + + if (IsDetachedBuffer(targetBuffer)) { + throw new $TypeError('target’s buffer is detached'); // step 2 + } + + var targetLength = typedArrayLength(target); // step 3 + + var targetElementSize = TypedArrayElementSize(target); // step 4 + + var targetType = TypedArrayElementType(target); // step 5 + + var targetByteOffset = typedArrayByteOffset(target); // step 6 + + var src = ToObject(source); // step 7 + + var srcLength = LengthOfArrayLike(src); // step 8 + + if (targetOffset === Infinity) { + throw new $RangeError('targetOffset must be a finite integer'); // step 9 + } + + if (srcLength + targetOffset > targetLength) { + throw new $RangeError('targetOffset + srcLength must be <= target.length'); // step 10 + } + + var targetByteIndex = (targetOffset * targetElementSize) + targetByteOffset; // step 11 + + var k = 0; // step 12 + + var limit = targetByteIndex + (targetElementSize * srcLength); // step 13 + + while (targetByteIndex < limit) { // step 14 + var Pk = ToString(k); // step 14.a + + var value = Get(src, Pk); // step 14.b + + if (IsBigIntElementType(targetType)) { + value = ToBigInt(value); // step 14.c + } else { + value = ToNumber(value); // step 14.d + } + + if (IsDetachedBuffer(targetBuffer)) { + throw new $TypeError('target’s buffer is detached'); // step 14.e + } + + SetValueInBuffer(targetBuffer, targetByteIndex, targetType, value, true, 'Unordered'); // step 14.f + + k += 1; // step 14.g + + targetByteIndex += targetElementSize; // step 14.h + } +}; diff --git a/node_modules/es-abstract/2022/SetTypedArrayFromTypedArray.js b/node_modules/es-abstract/2022/SetTypedArrayFromTypedArray.js new file mode 100644 index 0000000000000000000000000000000000000000..b1d2ff9dac561ebdaf29fd582b8abd8b2fe757d5 --- /dev/null +++ b/node_modules/es-abstract/2022/SetTypedArrayFromTypedArray.js @@ -0,0 +1,134 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $RangeError = require('es-errors/range'); +var $SyntaxError = require('es-errors/syntax'); +var $TypeError = require('es-errors/type'); +var $ArrayBuffer = GetIntrinsic('%ArrayBuffer%', true); + +var typedArrayBuffer = require('typed-array-buffer'); +var typedArrayByteLength = require('typed-array-byte-length'); +var typedArrayByteOffset = require('typed-array-byte-offset'); +var typedArrayLength = require('typed-array-length'); +var whichTypedArray = require('which-typed-array'); +var isInteger = require('math-intrinsics/isInteger'); + +var CloneArrayBuffer = require('./CloneArrayBuffer'); +var GetValueFromBuffer = require('./GetValueFromBuffer'); +var IsDetachedBuffer = require('./IsDetachedBuffer'); +var IsSharedArrayBuffer = require('./IsSharedArrayBuffer'); +var SameValue = require('./SameValue'); +var SetValueInBuffer = require('./SetValueInBuffer'); +var TypedArrayElementSize = require('./TypedArrayElementSize'); +var TypedArrayElementType = require('./TypedArrayElementType'); + +// https://262.ecma-international.org/13.0/#sec-settypedarrayfromtypedarray + +module.exports = function SetTypedArrayFromTypedArray(target, targetOffset, source) { + var whichTarget = whichTypedArray(target); + if (!whichTarget) { + throw new $TypeError('Assertion failed: target must be a TypedArray instance'); + } + + if (targetOffset !== Infinity && (!isInteger(targetOffset) || targetOffset < 0)) { + throw new $TypeError('Assertion failed: targetOffset must be a non-negative integer or +Infinity'); + } + + var whichSource = whichTypedArray(source); + if (!whichSource) { + throw new $TypeError('Assertion failed: source must be a TypedArray instance'); + } + + var targetBuffer = typedArrayBuffer(target); // step 1 + + if (IsDetachedBuffer(targetBuffer)) { + throw new $TypeError('target’s buffer is detached'); // step 2 + } + + var targetLength = typedArrayLength(target); // step 3 + + var srcBuffer = typedArrayBuffer(source); // step 4 + + if (IsDetachedBuffer(srcBuffer)) { + throw new $TypeError('source’s buffer is detached'); // step 5 + } + + var targetType = TypedArrayElementType(target); // step 6 + + var targetElementSize = TypedArrayElementSize(target); // step 7 + + var targetByteOffset = typedArrayByteOffset(target); // step 8 + + var srcType = TypedArrayElementType(source); // step 9 + + var srcElementSize = TypedArrayElementSize(source); // step 10 + + var srcLength = typedArrayLength(source); // step 11 + + var srcByteOffset = typedArrayByteOffset(source); // step 12 + + if (targetOffset === Infinity) { + throw new $RangeError('targetOffset must be a non-negative integer or +Infinity'); // step 13 + } + + if (srcLength + targetOffset > targetLength) { + throw new $RangeError('targetOffset + source.length must not be greater than target.length'); // step 14 + } + + var targetContentType = whichTarget === 'BigInt64Array' || whichTarget === 'BigUint64Array' ? 'BigInt' : 'Number'; + var sourceContentType = whichSource === 'BigInt64Array' || whichSource === 'BigUint64Array' ? 'BigInt' : 'Number'; + if (targetContentType !== sourceContentType) { + throw new $TypeError('source and target must have the same content type'); // step 15 + } + + var same; + if (IsSharedArrayBuffer(srcBuffer) && IsSharedArrayBuffer(targetBuffer)) { // step 16 + // a. If srcBuffer.[[ArrayBufferData]] and targetBuffer.[[ArrayBufferData]] are the same Shared Data Block values, let same be true; else let same be false. + throw new $SyntaxError('SharedArrayBuffer is not supported by this implementation'); + } else { + same = SameValue(srcBuffer, targetBuffer); // step 17 + } + + var srcByteIndex; + if (same) { // step 18 + var srcByteLength = typedArrayByteLength(source); // step 18.a + + srcBuffer = CloneArrayBuffer(srcBuffer, srcByteOffset, srcByteLength, $ArrayBuffer); // step 18.b + + // c. NOTE: %ArrayBuffer% is used to clone srcBuffer because is it known to not have any observable side-effects. + + srcByteIndex = 0; // step 18.d + } else { + srcByteIndex = srcByteOffset; // step 19 + } + + var targetByteIndex = (targetOffset * targetElementSize) + targetByteOffset; // step 20 + + var limit = targetByteIndex + (targetElementSize * srcLength); // step 21 + + var value; + if (srcType === targetType) { // step 22 + // a. NOTE: If srcType and targetType are the same, the transfer must be performed in a manner that preserves the bit-level encoding of the source data. + + while (targetByteIndex < limit) { // step 22.b + value = GetValueFromBuffer(srcBuffer, srcByteIndex, 'Uint8', true, 'Unordered'); // step 22.b.i + + SetValueInBuffer(targetBuffer, targetByteIndex, 'Uint8', value, true, 'Unordered'); // step 22.b.ii + + srcByteIndex += 1; // step 22.b.iii + + targetByteIndex += 1; // step 22.b.iv + } + } else { // step 23 + while (targetByteIndex < limit) { // step 23.a + value = GetValueFromBuffer(srcBuffer, srcByteIndex, srcType, true, 'Unordered'); // step 23.a.i + + SetValueInBuffer(targetBuffer, targetByteIndex, targetType, value, true, 'Unordered'); // step 23.a.ii + + srcByteIndex += srcElementSize; // step 23.a.iii + + targetByteIndex += targetElementSize; // step 23.a.iv + } + } +}; diff --git a/node_modules/es-abstract/2022/SetValueInBuffer.js b/node_modules/es-abstract/2022/SetValueInBuffer.js new file mode 100644 index 0000000000000000000000000000000000000000..c0e65e04ef0e1db888cbd7932faa84073c339754 --- /dev/null +++ b/node_modules/es-abstract/2022/SetValueInBuffer.js @@ -0,0 +1,92 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $SyntaxError = require('es-errors/syntax'); +var $TypeError = require('es-errors/type'); +var isInteger = require('math-intrinsics/isInteger'); +var $Uint8Array = GetIntrinsic('%Uint8Array%', true); + +var IsBigIntElementType = require('./IsBigIntElementType'); +var IsDetachedBuffer = require('./IsDetachedBuffer'); +var NumericToRawBytes = require('./NumericToRawBytes'); + +var isArrayBuffer = require('is-array-buffer'); +var isSharedArrayBuffer = require('is-shared-array-buffer'); +var hasOwn = require('hasown'); + +var tableTAO = require('./tables/typed-array-objects'); + +var defaultEndianness = require('../helpers/defaultEndianness'); +var forEach = require('../helpers/forEach'); + +// https://262.ecma-international.org/12.0/#sec-setvalueinbuffer + +/* eslint max-params: 0 */ + +module.exports = function SetValueInBuffer(arrayBuffer, byteIndex, type, value, isTypedArray, order) { + var isSAB = isSharedArrayBuffer(arrayBuffer); + if (!isArrayBuffer(arrayBuffer) && !isSAB) { + throw new $TypeError('Assertion failed: `arrayBuffer` must be an ArrayBuffer or a SharedArrayBuffer'); + } + + if (!isInteger(byteIndex) || byteIndex < 0) { + throw new $TypeError('Assertion failed: `byteIndex` must be a non-negative integer'); + } + + if (typeof type !== 'string' || !hasOwn(tableTAO.size, '$' + type)) { + throw new $TypeError('Assertion failed: `type` must be one of ' + tableTAO.choices); + } + + if (typeof value !== 'number' && typeof value !== 'bigint') { + throw new $TypeError('Assertion failed: `value` must be a Number or a BigInt'); + } + + if (typeof isTypedArray !== 'boolean') { + throw new $TypeError('Assertion failed: `isTypedArray` must be a boolean'); + } + if (order !== 'SeqCst' && order !== 'Unordered' && order !== 'Init') { + throw new $TypeError('Assertion failed: `order` must be `"SeqCst"`, `"Unordered"`, or `"Init"`'); + } + + if (arguments.length > 6 && typeof arguments[6] !== 'boolean') { + throw new $TypeError('Assertion failed: `isLittleEndian` must be a boolean, if present'); + } + + if (IsDetachedBuffer(arrayBuffer)) { + throw new $TypeError('Assertion failed: ArrayBuffer is detached'); // step 1 + } + + // 2. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type. + + if (IsBigIntElementType(type) ? typeof value !== 'bigint' : typeof value !== 'number') { // step 3 + throw new $TypeError('Assertion failed: `value` must be a BigInt if type is BigInt64 or BigUint64, otherwise a Number'); + } + + // 4. Let block be arrayBuffer’s [[ArrayBufferData]] internal slot. + + var elementSize = tableTAO.size['$' + type]; // step 5 + + // 6. If isLittleEndian is not present, set isLittleEndian to either true or false. The choice is implementation dependent and should be the alternative that is most efficient for the implementation. An implementation must use the same value each time this step is executed and the same value must be used for the corresponding step in the GetValueFromBuffer abstract operation. + var isLittleEndian = arguments.length > 6 ? arguments[6] : defaultEndianness === 'little'; // step 6 + + var rawBytes = NumericToRawBytes(type, value, isLittleEndian); // step 7 + + if (isSAB) { // step 8 + /* + Let execution be the [[CandidateExecution]] field of the surrounding agent's Agent Record. + Let eventList be the [[EventList]] field of the element in execution.[[EventsRecords]] whose [[AgentSignifier]] is AgentSignifier(). + If isTypedArray is true and IsNoTearConfiguration(type, order) is true, let noTear be true; otherwise let noTear be false. + Append WriteSharedMemory { [[Order]]: order, [[NoTear]]: noTear, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize, [[Payload]]: rawBytes } to eventList. + */ + throw new $SyntaxError('SharedArrayBuffer is not supported by this implementation'); + } else { + // 9. Store the individual bytes of rawBytes into block, in order, starting at block[byteIndex]. + var arr = new $Uint8Array(arrayBuffer, byteIndex, elementSize); + forEach(rawBytes, function (rawByte, i) { + arr[i] = rawByte; + }); + } + + // 10. Return NormalCompletion(undefined). +}; diff --git a/node_modules/es-abstract/2022/SortIndexedProperties.js b/node_modules/es-abstract/2022/SortIndexedProperties.js new file mode 100644 index 0000000000000000000000000000000000000000..102bd2882eae9d66b3f4f60db1eacefd4bcd494c --- /dev/null +++ b/node_modules/es-abstract/2022/SortIndexedProperties.js @@ -0,0 +1,62 @@ +'use strict'; + +var callBound = require('call-bound'); + +var $TypeError = require('es-errors/type'); +var isInteger = require('math-intrinsics/isInteger'); +var isObject = require('es-object-atoms/isObject'); + +var DeletePropertyOrThrow = require('./DeletePropertyOrThrow'); +var Get = require('./Get'); +var HasProperty = require('./HasProperty'); +var Set = require('./Set'); +var ToString = require('./ToString'); + +var isAbstractClosure = require('../helpers/isAbstractClosure'); + +var $sort = callBound('Array.prototype.sort'); + +// https://262.ecma-international.org/13.0/#sec-sortindexedproperties + +module.exports = function SortIndexedProperties(obj, len, SortCompare) { + if (!isObject(obj)) { + throw new $TypeError('Assertion failed: Type(obj) is not Object'); + } + if (!isInteger(len) || len < 0) { + throw new $TypeError('Assertion failed: `len` must be an integer >= 0'); + } + if (!isAbstractClosure(SortCompare) || SortCompare.length !== 2) { + throw new $TypeError('Assertion failed: `SortCompare` must be an abstract closure taking 2 arguments'); + } + + var items = []; // step 1 + + var k = 0; // step 2 + + while (k < len) { // step 3 + var Pk = ToString(k); + var kPresent = HasProperty(obj, Pk); + if (kPresent) { + var kValue = Get(obj, Pk); + items[items.length] = kValue; + } + k += 1; + } + + var itemCount = items.length; // step 4 + + $sort(items, SortCompare); // step 5 + + var j = 0; // step 6 + + while (j < itemCount) { // step 7 + Set(obj, ToString(j), items[j], true); + j += 1; + } + + while (j < len) { // step 8 + DeletePropertyOrThrow(obj, ToString(j)); + j += 1; + } + return obj; // step 9 +}; diff --git a/node_modules/es-abstract/2022/SpeciesConstructor.js b/node_modules/es-abstract/2022/SpeciesConstructor.js new file mode 100644 index 0000000000000000000000000000000000000000..23e32b443ef3655f56639920d5cf58474500bf67 --- /dev/null +++ b/node_modules/es-abstract/2022/SpeciesConstructor.js @@ -0,0 +1,32 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $species = GetIntrinsic('%Symbol.species%', true); +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var IsConstructor = require('./IsConstructor'); + +// https://262.ecma-international.org/6.0/#sec-speciesconstructor + +module.exports = function SpeciesConstructor(O, defaultConstructor) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + var C = O.constructor; + if (typeof C === 'undefined') { + return defaultConstructor; + } + if (!isObject(C)) { + throw new $TypeError('O.constructor is not an Object'); + } + var S = $species ? C[$species] : void 0; + if (S == null) { + return defaultConstructor; + } + if (IsConstructor(S)) { + return S; + } + throw new $TypeError('no constructor found'); +}; diff --git a/node_modules/es-abstract/2022/StringCreate.js b/node_modules/es-abstract/2022/StringCreate.js new file mode 100644 index 0000000000000000000000000000000000000000..3e2aa43c50d8aa6317c0eef7eaf0b87e32916d4d --- /dev/null +++ b/node_modules/es-abstract/2022/StringCreate.js @@ -0,0 +1,38 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $Object = require('es-object-atoms'); +var $StringPrototype = GetIntrinsic('%String.prototype%'); +var $SyntaxError = require('es-errors/syntax'); +var $TypeError = require('es-errors/type'); +var setProto = require('set-proto'); + +var DefinePropertyOrThrow = require('./DefinePropertyOrThrow'); + +// https://262.ecma-international.org/6.0/#sec-stringcreate + +module.exports = function StringCreate(value, prototype) { + if (typeof value !== 'string') { + throw new $TypeError('Assertion failed: `S` must be a String'); + } + + var S = $Object(value); + if (prototype !== $StringPrototype) { + if (setProto) { + setProto(S, prototype); + } else { + throw new $SyntaxError('StringCreate: a `proto` argument that is not `String.prototype` is not supported in an environment that does not support setting the [[Prototype]]'); + } + } + + var length = value.length; + DefinePropertyOrThrow(S, 'length', { + '[[Configurable]]': false, + '[[Enumerable]]': false, + '[[Value]]': length, + '[[Writable]]': false + }); + + return S; +}; diff --git a/node_modules/es-abstract/2022/StringGetOwnProperty.js b/node_modules/es-abstract/2022/StringGetOwnProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..59e8a23f8969db47a1f1eae85a542594c4b64406 --- /dev/null +++ b/node_modules/es-abstract/2022/StringGetOwnProperty.js @@ -0,0 +1,46 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isNegativeZero = require('math-intrinsics/isNegativeZero'); +var isObject = require('es-object-atoms/isObject'); + +var callBound = require('call-bound'); +var $charAt = callBound('String.prototype.charAt'); +var $stringToString = callBound('String.prototype.toString'); + +var CanonicalNumericIndexString = require('./CanonicalNumericIndexString'); + +var isPropertyKey = require('../helpers/isPropertyKey'); +var isInteger = require('math-intrinsics/isInteger'); + +// https://262.ecma-international.org/12.0/#sec-stringgetownproperty + +module.exports = function StringGetOwnProperty(S, P) { + var str; + if (isObject(S)) { + try { + str = $stringToString(S); + } catch (e) { /**/ } + } + if (typeof str !== 'string') { + throw new $TypeError('Assertion failed: `S` must be a boxed string object'); + } + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: P is not a Property Key'); + } + if (typeof P !== 'string') { + return void undefined; + } + var index = CanonicalNumericIndexString(P); + var len = str.length; + if (typeof index === 'undefined' || !isInteger(index) || isNegativeZero(index) || index < 0 || len <= index) { + return void undefined; + } + var resultStr = $charAt(S, index); + return { + '[[Configurable]]': false, + '[[Enumerable]]': true, + '[[Value]]': resultStr, + '[[Writable]]': false + }; +}; diff --git a/node_modules/es-abstract/2022/StringIndexOf.js b/node_modules/es-abstract/2022/StringIndexOf.js new file mode 100644 index 0000000000000000000000000000000000000000..a1fce808019201ec1c5689884e822860c1c75472 --- /dev/null +++ b/node_modules/es-abstract/2022/StringIndexOf.js @@ -0,0 +1,36 @@ +'use strict'; + +var callBound = require('call-bound'); + +var $TypeError = require('es-errors/type'); +var isInteger = require('math-intrinsics/isInteger'); + +var $slice = callBound('String.prototype.slice'); + +// https://262.ecma-international.org/12.0/#sec-stringindexof + +module.exports = function StringIndexOf(string, searchValue, fromIndex) { + if (typeof string !== 'string') { + throw new $TypeError('Assertion failed: `string` must be a String'); + } + if (typeof searchValue !== 'string') { + throw new $TypeError('Assertion failed: `searchValue` must be a String'); + } + if (!isInteger(fromIndex) || fromIndex < 0) { + throw new $TypeError('Assertion failed: `fromIndex` must be a non-negative integer'); + } + + var len = string.length; + if (searchValue === '' && fromIndex <= len) { + return fromIndex; + } + + var searchLen = searchValue.length; + for (var i = fromIndex; i <= (len - searchLen); i += 1) { + var candidate = $slice(string, i, i + searchLen); + if (candidate === searchValue) { + return i; + } + } + return -1; +}; diff --git a/node_modules/es-abstract/2022/StringPad.js b/node_modules/es-abstract/2022/StringPad.js new file mode 100644 index 0000000000000000000000000000000000000000..473b0b7bd490c72f1d1b90bd2a56f6d638fb0000 --- /dev/null +++ b/node_modules/es-abstract/2022/StringPad.js @@ -0,0 +1,41 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var callBound = require('call-bound'); + +var ToLength = require('./ToLength'); +var ToString = require('./ToString'); + +var $strSlice = callBound('String.prototype.slice'); + +// https://262.ecma-international.org/11.0/#sec-stringpad + +module.exports = function StringPad(O, maxLength, fillString, placement) { + if (placement !== 'start' && placement !== 'end') { + throw new $TypeError('Assertion failed: `placement` must be "start" or "end"'); + } + var S = ToString(O); + var intMaxLength = ToLength(maxLength); + var stringLength = S.length; + if (intMaxLength <= stringLength) { + return S; + } + var filler = typeof fillString === 'undefined' ? ' ' : ToString(fillString); + if (filler === '') { + return S; + } + var fillLen = intMaxLength - stringLength; + + // the String value consisting of repeated concatenations of filler truncated to length fillLen. + var truncatedStringFiller = ''; + while (truncatedStringFiller.length < fillLen) { + truncatedStringFiller += filler; + } + truncatedStringFiller = $strSlice(truncatedStringFiller, 0, fillLen); + + if (placement === 'start') { + return truncatedStringFiller + S; + } + return S + truncatedStringFiller; +}; diff --git a/node_modules/es-abstract/2022/StringToBigInt.js b/node_modules/es-abstract/2022/StringToBigInt.js new file mode 100644 index 0000000000000000000000000000000000000000..1cf9856a24538efe8dbefd9374da40dacebcd008 --- /dev/null +++ b/node_modules/es-abstract/2022/StringToBigInt.js @@ -0,0 +1,23 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $BigInt = GetIntrinsic('%BigInt%', true); +var $TypeError = require('es-errors/type'); +var $SyntaxError = require('es-errors/syntax'); + +// https://262.ecma-international.org/14.0/#sec-stringtobigint + +module.exports = function StringToBigInt(argument) { + if (typeof argument !== 'string') { + throw new $TypeError('`argument` must be a string'); + } + if (!$BigInt) { + throw new $SyntaxError('BigInts are not supported in this environment'); + } + try { + return $BigInt(argument); + } catch (e) { + return void undefined; + } +}; diff --git a/node_modules/es-abstract/2022/StringToCodePoints.js b/node_modules/es-abstract/2022/StringToCodePoints.js new file mode 100644 index 0000000000000000000000000000000000000000..9a104c41ac2fb5b9d3181d23172df9430c7a3827 --- /dev/null +++ b/node_modules/es-abstract/2022/StringToCodePoints.js @@ -0,0 +1,22 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var CodePointAt = require('./CodePointAt'); + +// https://262.ecma-international.org/12.0/#sec-stringtocodepoints + +module.exports = function StringToCodePoints(string) { + if (typeof string !== 'string') { + throw new $TypeError('Assertion failed: `string` must be a String'); + } + var codePoints = []; + var size = string.length; + var position = 0; + while (position < size) { + var cp = CodePointAt(string, position); + codePoints[codePoints.length] = cp['[[CodePoint]]']; + position += cp['[[CodeUnitCount]]']; + } + return codePoints; +}; diff --git a/node_modules/es-abstract/2022/StringToNumber.js b/node_modules/es-abstract/2022/StringToNumber.js new file mode 100644 index 0000000000000000000000000000000000000000..e9b4a8b3368ac9f42ea786e90828a27733c259cd --- /dev/null +++ b/node_modules/es-abstract/2022/StringToNumber.js @@ -0,0 +1,42 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $RegExp = GetIntrinsic('%RegExp%'); +var $TypeError = require('es-errors/type'); +var $parseInteger = GetIntrinsic('%parseInt%'); + +var callBound = require('call-bound'); +var regexTester = require('safe-regex-test'); + +var $strSlice = callBound('String.prototype.slice'); +var isBinary = regexTester(/^0b[01]+$/i); +var isOctal = regexTester(/^0o[0-7]+$/i); +var isInvalidHexLiteral = regexTester(/^[-+]0x[0-9a-f]+$/i); +var nonWS = ['\u0085', '\u200b', '\ufffe'].join(''); +var nonWSregex = new $RegExp('[' + nonWS + ']', 'g'); +var hasNonWS = regexTester(nonWSregex); + +var $trim = require('string.prototype.trim'); + +// https://262.ecma-international.org/13.0/#sec-stringtonumber + +module.exports = function StringToNumber(argument) { + if (typeof argument !== 'string') { + throw new $TypeError('Assertion failed: `argument` is not a String'); + } + if (isBinary(argument)) { + return +$parseInteger($strSlice(argument, 2), 2); + } + if (isOctal(argument)) { + return +$parseInteger($strSlice(argument, 2), 8); + } + if (hasNonWS(argument) || isInvalidHexLiteral(argument)) { + return NaN; + } + var trimmed = $trim(argument); + if (trimmed !== argument) { + return StringToNumber(trimmed); + } + return +argument; +}; diff --git a/node_modules/es-abstract/2022/SymbolDescriptiveString.js b/node_modules/es-abstract/2022/SymbolDescriptiveString.js new file mode 100644 index 0000000000000000000000000000000000000000..444e3f70004626a3053f672a290e5e81b0f5cf51 --- /dev/null +++ b/node_modules/es-abstract/2022/SymbolDescriptiveString.js @@ -0,0 +1,16 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var callBound = require('call-bound'); + +var $SymbolToString = callBound('Symbol.prototype.toString', true); + +// https://262.ecma-international.org/6.0/#sec-symboldescriptivestring + +module.exports = function SymbolDescriptiveString(sym) { + if (typeof sym !== 'symbol') { + throw new $TypeError('Assertion failed: `sym` must be a Symbol'); + } + return $SymbolToString(sym); +}; diff --git a/node_modules/es-abstract/2022/TestIntegrityLevel.js b/node_modules/es-abstract/2022/TestIntegrityLevel.js new file mode 100644 index 0000000000000000000000000000000000000000..0e802f42786f89bac378b6a58e6009c9620be721 --- /dev/null +++ b/node_modules/es-abstract/2022/TestIntegrityLevel.js @@ -0,0 +1,40 @@ +'use strict'; + +var $gOPD = require('gopd'); +var $TypeError = require('es-errors/type'); + +var every = require('../helpers/every'); +var OwnPropertyKeys = require('own-keys'); +var isObject = require('es-object-atoms/isObject'); + +var IsDataDescriptor = require('./IsDataDescriptor'); +var IsExtensible = require('./IsExtensible'); +var ToPropertyDescriptor = require('./ToPropertyDescriptor'); + +// https://262.ecma-international.org/6.0/#sec-testintegritylevel + +module.exports = function TestIntegrityLevel(O, level) { + if (!isObject(O)) { + 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 = IsExtensible(O); + if (status || !$gOPD) { + return false; + } + var theKeys = OwnPropertyKeys(O); + 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' && IsDataDescriptor(ToPropertyDescriptor(currentDesc)) && currentDesc.writable) { + return false; + } + } + return true; + }); +}; diff --git a/node_modules/es-abstract/2022/ThrowCompletion.js b/node_modules/es-abstract/2022/ThrowCompletion.js new file mode 100644 index 0000000000000000000000000000000000000000..b7d388a35292e2a9faf88d4808b74e2c4878bbe7 --- /dev/null +++ b/node_modules/es-abstract/2022/ThrowCompletion.js @@ -0,0 +1,9 @@ +'use strict'; + +var CompletionRecord = require('./CompletionRecord'); + +// https://262.ecma-international.org/9.0/#sec-throwcompletion + +module.exports = function ThrowCompletion(argument) { + return new CompletionRecord('throw', argument); +}; diff --git a/node_modules/es-abstract/2022/TimeClip.js b/node_modules/es-abstract/2022/TimeClip.js new file mode 100644 index 0000000000000000000000000000000000000000..77c8dd4226c4765855024b1784b842f869fa5bfe --- /dev/null +++ b/node_modules/es-abstract/2022/TimeClip.js @@ -0,0 +1,20 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $Date = GetIntrinsic('%Date%'); + +var $isFinite = require('math-intrinsics/isFinite'); +var abs = require('math-intrinsics/abs'); + +var ToNumber = require('./ToNumber'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.14 + +module.exports = function TimeClip(time) { + if (!$isFinite(time) || abs(time) > 8.64e15) { + return NaN; + } + return +new $Date(ToNumber(time)); +}; + diff --git a/node_modules/es-abstract/2022/TimeFromYear.js b/node_modules/es-abstract/2022/TimeFromYear.js new file mode 100644 index 0000000000000000000000000000000000000000..f3518a41a19146c9ba59e1362c3fb33f800daaa1 --- /dev/null +++ b/node_modules/es-abstract/2022/TimeFromYear.js @@ -0,0 +1,11 @@ +'use strict'; + +var msPerDay = require('../helpers/timeConstants').msPerDay; + +var DayFromYear = require('./DayFromYear'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.3 + +module.exports = function TimeFromYear(y) { + return msPerDay * DayFromYear(y); +}; diff --git a/node_modules/es-abstract/2022/TimeString.js b/node_modules/es-abstract/2022/TimeString.js new file mode 100644 index 0000000000000000000000000000000000000000..4cc6c6acdc23bda39dc6fe862f23aa35dcfbfb6b --- /dev/null +++ b/node_modules/es-abstract/2022/TimeString.js @@ -0,0 +1,26 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var $isNaN = require('math-intrinsics/isNaN'); + +var HourFromTime = require('./HourFromTime'); +var MinFromTime = require('./MinFromTime'); +var SecFromTime = require('./SecFromTime'); +var ToZeroPaddedDecimalString = require('./ToZeroPaddedDecimalString'); + +// https://262.ecma-international.org/13.0/#sec-timestring + +module.exports = function TimeString(tv) { + if (typeof tv !== 'number' || $isNaN(tv)) { + throw new $TypeError('Assertion failed: `tv` must be a non-NaN Number'); + } + + var hour = ToZeroPaddedDecimalString(HourFromTime(tv), 2); // step 1 + + var minute = ToZeroPaddedDecimalString(MinFromTime(tv), 2); // step 2 + + var second = ToZeroPaddedDecimalString(SecFromTime(tv), 2); // step 3 + + return hour + ':' + minute + ':' + second + ' GMT'; // step 4 +}; diff --git a/node_modules/es-abstract/2022/TimeWithinDay.js b/node_modules/es-abstract/2022/TimeWithinDay.js new file mode 100644 index 0000000000000000000000000000000000000000..2bba83386c141873d3b603ed19d0f37069d1016a --- /dev/null +++ b/node_modules/es-abstract/2022/TimeWithinDay.js @@ -0,0 +1,12 @@ +'use strict'; + +var modulo = require('./modulo'); + +var msPerDay = require('../helpers/timeConstants').msPerDay; + +// https://262.ecma-international.org/5.1/#sec-15.9.1.2 + +module.exports = function TimeWithinDay(t) { + return modulo(t, msPerDay); +}; + diff --git a/node_modules/es-abstract/2022/TimeZoneString.js b/node_modules/es-abstract/2022/TimeZoneString.js new file mode 100644 index 0000000000000000000000000000000000000000..1a2742baff65072c24eefc5f4f7be95d1a6a5d7a --- /dev/null +++ b/node_modules/es-abstract/2022/TimeZoneString.js @@ -0,0 +1,38 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $Date = GetIntrinsic('%Date%'); +var $TypeError = require('es-errors/type'); + +var isNaN = require('math-intrinsics/isNaN'); + +var callBound = require('call-bound'); + +var $indexOf = callBound('String.prototype.indexOf'); +var $slice = callBound('String.prototype.slice'); +var $toTimeString = callBound('Date.prototype.toTimeString'); + +// https://262.ecma-international.org/13.0/#sec-timezoneestring + +module.exports = function TimeZoneString(tv) { + if (typeof tv !== 'number' || isNaN(tv)) { + throw new $TypeError('Assertion failed: `tv` must be a non-NaN Number'); + } + + // 1. Let offset be LocalTZA(tv, true). + // 2. If offset is +0𝔽 or offset > +0𝔽, then + // a. Let offsetSign be "+". + // b. Let absOffset be offset. + // 3. Else, + // a. Let offsetSign be "-". + // b. Let absOffset be -offset. + // 4. Let offsetMin be ToZeroPaddedDecimalString(ℝ(MinFromTime(absOffset)), 2). + // 5. Let offsetHour be ToZeroPaddedDecimalString(ℝ(HourFromTime(absOffset)), 2). + // 6. Let tzName be an implementation-defined string that is either the empty String or the string-concatenation of the code unit 0x0020 (SPACE), the code unit 0x0028 (LEFT PARENTHESIS), an implementation-defined timezone name, and the code unit 0x0029 (RIGHT PARENTHESIS). + // 7. Return the string-concatenation of offsetSign, offsetHour, offsetMin, and tzName. + + // hack until LocalTZA, and "implementation-defined string" are available + var ts = $toTimeString(new $Date(tv)); + return $slice(ts, $indexOf(ts, '(') + 1, $indexOf(ts, ')')); +}; diff --git a/node_modules/es-abstract/2022/ToBigInt.js b/node_modules/es-abstract/2022/ToBigInt.js new file mode 100644 index 0000000000000000000000000000000000000000..d6638104de25470c4bbc8a8102c8cd35617eebb6 --- /dev/null +++ b/node_modules/es-abstract/2022/ToBigInt.js @@ -0,0 +1,51 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $BigInt = GetIntrinsic('%BigInt%', true); +var $Number = GetIntrinsic('%Number%'); +var $TypeError = require('es-errors/type'); +var $SyntaxError = require('es-errors/syntax'); + +var StringToBigInt = require('./StringToBigInt'); +var ToPrimitive = require('./ToPrimitive'); + +// https://262.ecma-international.org/13.0/#sec-tobigint + +module.exports = function ToBigInt(argument) { + if (!$BigInt) { + throw new $SyntaxError('BigInts are not supported in this environment'); + } + + var prim = ToPrimitive(argument, $Number); + + if (prim == null) { + throw new $TypeError('Cannot convert null or undefined to a BigInt'); + } + + if (typeof prim === 'boolean') { + return prim ? $BigInt(1) : $BigInt(0); + } + + if (typeof prim === 'number') { + throw new $TypeError('Cannot convert a Number value to a BigInt'); + } + + if (typeof prim === 'string') { + var n = StringToBigInt(prim); + if (typeof n === 'undefined') { + throw new $TypeError('Failed to parse String to BigInt'); + } + return n; + } + + if (typeof prim === 'symbol') { + throw new $TypeError('Cannot convert a Symbol value to a BigInt'); + } + + if (typeof prim !== 'bigint') { + throw new $SyntaxError('Assertion failed: unknown primitive type'); + } + + return prim; +}; diff --git a/node_modules/es-abstract/2022/ToBigInt64.js b/node_modules/es-abstract/2022/ToBigInt64.js new file mode 100644 index 0000000000000000000000000000000000000000..627acba3d06e0e6d1e8b0b91088efbc7d6d42b0a --- /dev/null +++ b/node_modules/es-abstract/2022/ToBigInt64.js @@ -0,0 +1,25 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $BigInt = GetIntrinsic('%BigInt%', true); +var $pow = require('math-intrinsics/pow'); + +var ToBigInt = require('./ToBigInt'); +var BigIntRemainder = require('./BigInt/remainder'); + +var modBigInt = require('../helpers/modBigInt'); + +// BigInt(2**63), but node v10.4-v10.8 have a bug where you can't `BigInt(x)` anything larger than MAX_SAFE_INTEGER +var twoSixtyThree = $BigInt && (BigInt($pow(2, 32)) * BigInt($pow(2, 31))); + +// BigInt(2**64), but node v10.4-v10.8 have a bug where you can't `BigInt(x)` anything larger than MAX_SAFE_INTEGER +var twoSixtyFour = $BigInt && (BigInt($pow(2, 32)) * BigInt($pow(2, 32))); + +// https://262.ecma-international.org/11.0/#sec-tobigint64 + +module.exports = function ToBigInt64(argument) { + var n = ToBigInt(argument); + var int64bit = modBigInt(BigIntRemainder, n, twoSixtyFour); + return int64bit >= twoSixtyThree ? int64bit - twoSixtyFour : int64bit; +}; diff --git a/node_modules/es-abstract/2022/ToBigUint64.js b/node_modules/es-abstract/2022/ToBigUint64.js new file mode 100644 index 0000000000000000000000000000000000000000..f4038dc7bcaceb9b24157f6e6bcdfa286138f785 --- /dev/null +++ b/node_modules/es-abstract/2022/ToBigUint64.js @@ -0,0 +1,23 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $BigInt = GetIntrinsic('%BigInt%', true); + +var $pow = require('math-intrinsics/pow'); + +var ToBigInt = require('./ToBigInt'); +var BigIntRemainder = require('./BigInt/remainder'); + +var modBigInt = require('../helpers/modBigInt'); + +// BigInt(2**64), but node v10.4-v10.8 have a bug where you can't `BigInt(x)` anything larger than MAX_SAFE_INTEGER +var twoSixtyFour = $BigInt && (BigInt($pow(2, 32)) * BigInt($pow(2, 32))); + +// https://262.ecma-international.org/11.0/#sec-tobiguint64 + +module.exports = function ToBigUint64(argument) { + var n = ToBigInt(argument); + var int64bit = modBigInt(BigIntRemainder, n, twoSixtyFour); + return int64bit; +}; diff --git a/node_modules/es-abstract/2022/ToBoolean.js b/node_modules/es-abstract/2022/ToBoolean.js new file mode 100644 index 0000000000000000000000000000000000000000..466404bf9992f0ba636249264c620d6c56215d6a --- /dev/null +++ b/node_modules/es-abstract/2022/ToBoolean.js @@ -0,0 +1,5 @@ +'use strict'; + +// http://262.ecma-international.org/5.1/#sec-9.2 + +module.exports = function ToBoolean(value) { return !!value; }; diff --git a/node_modules/es-abstract/2022/ToDateString.js b/node_modules/es-abstract/2022/ToDateString.js new file mode 100644 index 0000000000000000000000000000000000000000..d9bb434185ca0adfa055d91bf592efdce3ed1d94 --- /dev/null +++ b/node_modules/es-abstract/2022/ToDateString.js @@ -0,0 +1,21 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = require('es-errors/type'); +var $Date = GetIntrinsic('%Date%'); +var $String = GetIntrinsic('%String%'); + +var $isNaN = require('math-intrinsics/isNaN'); + +// https://262.ecma-international.org/6.0/#sec-todatestring + +module.exports = function ToDateString(tv) { + if (typeof tv !== 'number') { + throw new $TypeError('Assertion failed: `tv` must be a Number'); + } + if ($isNaN(tv)) { + return 'Invalid Date'; + } + return $String(new $Date(tv)); +}; diff --git a/node_modules/es-abstract/2022/ToIndex.js b/node_modules/es-abstract/2022/ToIndex.js new file mode 100644 index 0000000000000000000000000000000000000000..4123e71d9afada85ec326d03ea0cdbfbdded2600 --- /dev/null +++ b/node_modules/es-abstract/2022/ToIndex.js @@ -0,0 +1,24 @@ +'use strict'; + +var $RangeError = require('es-errors/range'); + +var ToIntegerOrInfinity = require('./ToIntegerOrInfinity'); +var ToLength = require('./ToLength'); +var SameValue = require('./SameValue'); + +// https://262.ecma-international.org/8.0/#sec-toindex + +module.exports = function ToIndex(value) { + if (typeof value === 'undefined') { + return 0; + } + var integerIndex = ToIntegerOrInfinity(value); + if (integerIndex < 0) { + throw new $RangeError('index must be >= 0'); + } + var index = ToLength(integerIndex); + if (!SameValue(integerIndex, index)) { + throw new $RangeError('index must be >= 0 and < 2 ** 53 - 1'); + } + return index; +}; diff --git a/node_modules/es-abstract/2022/ToInt16.js b/node_modules/es-abstract/2022/ToInt16.js new file mode 100644 index 0000000000000000000000000000000000000000..21694bdeb923cd78791c7c01e242d892b4833af0 --- /dev/null +++ b/node_modules/es-abstract/2022/ToInt16.js @@ -0,0 +1,10 @@ +'use strict'; + +var ToUint16 = require('./ToUint16'); + +// https://262.ecma-international.org/6.0/#sec-toint16 + +module.exports = function ToInt16(argument) { + var int16bit = ToUint16(argument); + return int16bit >= 0x8000 ? int16bit - 0x10000 : int16bit; +}; diff --git a/node_modules/es-abstract/2022/ToInt32.js b/node_modules/es-abstract/2022/ToInt32.js new file mode 100644 index 0000000000000000000000000000000000000000..b879ccc479e039097fa2d1017299579a2d8a8162 --- /dev/null +++ b/node_modules/es-abstract/2022/ToInt32.js @@ -0,0 +1,9 @@ +'use strict'; + +var ToNumber = require('./ToNumber'); + +// http://262.ecma-international.org/5.1/#sec-9.5 + +module.exports = function ToInt32(x) { + return ToNumber(x) >> 0; +}; diff --git a/node_modules/es-abstract/2022/ToInt8.js b/node_modules/es-abstract/2022/ToInt8.js new file mode 100644 index 0000000000000000000000000000000000000000..e223b6c1d352a3432da2d272d0f7e66bbfa818b4 --- /dev/null +++ b/node_modules/es-abstract/2022/ToInt8.js @@ -0,0 +1,10 @@ +'use strict'; + +var ToUint8 = require('./ToUint8'); + +// https://262.ecma-international.org/6.0/#sec-toint8 + +module.exports = function ToInt8(argument) { + var int8bit = ToUint8(argument); + return int8bit >= 0x80 ? int8bit - 0x100 : int8bit; +}; diff --git a/node_modules/es-abstract/2022/ToIntegerOrInfinity.js b/node_modules/es-abstract/2022/ToIntegerOrInfinity.js new file mode 100644 index 0000000000000000000000000000000000000000..c21dc4437085a4d9a157464ee8648ae486d6c48f --- /dev/null +++ b/node_modules/es-abstract/2022/ToIntegerOrInfinity.js @@ -0,0 +1,20 @@ +'use strict'; + +var abs = require('./abs'); +var floor = require('./floor'); +var ToNumber = require('./ToNumber'); + +var $isNaN = require('math-intrinsics/isNaN'); +var $isFinite = require('math-intrinsics/isFinite'); +var $sign = require('math-intrinsics/sign'); + +// https://262.ecma-international.org/12.0/#sec-tointegerorinfinity + +module.exports = function ToIntegerOrInfinity(value) { + var number = ToNumber(value); + if ($isNaN(number) || number === 0) { return 0; } + if (!$isFinite(number)) { return number; } + var integer = floor(abs(number)); + if (integer === 0) { return 0; } + return $sign(number) * integer; +}; diff --git a/node_modules/es-abstract/2022/ToLength.js b/node_modules/es-abstract/2022/ToLength.js new file mode 100644 index 0000000000000000000000000000000000000000..12c9aac8680d49bfe8591a9a5a4a645d6ca9d18e --- /dev/null +++ b/node_modules/es-abstract/2022/ToLength.js @@ -0,0 +1,14 @@ +'use strict'; + +var MAX_SAFE_INTEGER = require('math-intrinsics/constants/maxSafeInteger'); + +var ToIntegerOrInfinity = require('./ToIntegerOrInfinity'); + +// https://262.ecma-international.org/12.0/#sec-tolength + +module.exports = function ToLength(argument) { + var len = ToIntegerOrInfinity(argument); + if (len <= 0) { return 0; } // includes converting -0 to +0 + if (len > MAX_SAFE_INTEGER) { return MAX_SAFE_INTEGER; } + return len; +}; diff --git a/node_modules/es-abstract/2022/ToNumber.js b/node_modules/es-abstract/2022/ToNumber.js new file mode 100644 index 0000000000000000000000000000000000000000..2e7dc51676b6f2dcbaead28a8b7b6a2abcb1685e --- /dev/null +++ b/node_modules/es-abstract/2022/ToNumber.js @@ -0,0 +1,26 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = require('es-errors/type'); +var $Number = GetIntrinsic('%Number%'); +var isPrimitive = require('../helpers/isPrimitive'); + +var ToPrimitive = require('./ToPrimitive'); +var StringToNumber = require('./StringToNumber'); + +// https://262.ecma-international.org/13.0/#sec-tonumber + +module.exports = function ToNumber(argument) { + var value = isPrimitive(argument) ? argument : ToPrimitive(argument, $Number); + if (typeof value === 'symbol') { + throw new $TypeError('Cannot convert a Symbol value to a number'); + } + if (typeof value === 'bigint') { + throw new $TypeError('Conversion from \'BigInt\' to \'number\' is not allowed.'); + } + if (typeof value === 'string') { + return StringToNumber(value); + } + return +value; +}; diff --git a/node_modules/es-abstract/2022/ToNumeric.js b/node_modules/es-abstract/2022/ToNumeric.js new file mode 100644 index 0000000000000000000000000000000000000000..00a436dc0848803af47df54584e7d851dfe1b4a0 --- /dev/null +++ b/node_modules/es-abstract/2022/ToNumeric.js @@ -0,0 +1,20 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $Number = GetIntrinsic('%Number%'); + +var isPrimitive = require('../helpers/isPrimitive'); + +var ToPrimitive = require('./ToPrimitive'); +var ToNumber = require('./ToNumber'); + +// https://262.ecma-international.org/11.0/#sec-tonumeric + +module.exports = function ToNumeric(argument) { + var primValue = isPrimitive(argument) ? argument : ToPrimitive(argument, $Number); + if (typeof primValue === 'bigint') { + return primValue; + } + return ToNumber(primValue); +}; diff --git a/node_modules/es-abstract/2022/ToObject.js b/node_modules/es-abstract/2022/ToObject.js new file mode 100644 index 0000000000000000000000000000000000000000..70226aaa331e7fd7aa487e680d4aca6bb6874f5b --- /dev/null +++ b/node_modules/es-abstract/2022/ToObject.js @@ -0,0 +1,5 @@ +'use strict'; + +// https://262.ecma-international.org/6.0/#sec-toobject + +module.exports = require('es-object-atoms/ToObject'); diff --git a/node_modules/es-abstract/2022/ToPrimitive.js b/node_modules/es-abstract/2022/ToPrimitive.js new file mode 100644 index 0000000000000000000000000000000000000000..56bcf1aa9eb269d753119497686556384800b092 --- /dev/null +++ b/node_modules/es-abstract/2022/ToPrimitive.js @@ -0,0 +1,12 @@ +'use strict'; + +var toPrimitive = require('es-to-primitive/es2015'); + +// https://262.ecma-international.org/6.0/#sec-toprimitive + +module.exports = function ToPrimitive(input) { + if (arguments.length > 1) { + return toPrimitive(input, arguments[1]); + } + return toPrimitive(input); +}; diff --git a/node_modules/es-abstract/2022/ToPropertyDescriptor.js b/node_modules/es-abstract/2022/ToPropertyDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..017350d593b202573a928ccefeacc7472c803a5e --- /dev/null +++ b/node_modules/es-abstract/2022/ToPropertyDescriptor.js @@ -0,0 +1,50 @@ +'use strict'; + +var hasOwn = require('hasown'); + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var IsCallable = require('./IsCallable'); +var ToBoolean = require('./ToBoolean'); + +// https://262.ecma-international.org/5.1/#sec-8.10.5 + +module.exports = function ToPropertyDescriptor(Obj) { + if (!isObject(Obj)) { + throw new $TypeError('ToPropertyDescriptor requires an object'); + } + + var desc = {}; + if (hasOwn(Obj, 'enumerable')) { + desc['[[Enumerable]]'] = ToBoolean(Obj.enumerable); + } + if (hasOwn(Obj, 'configurable')) { + desc['[[Configurable]]'] = ToBoolean(Obj.configurable); + } + if (hasOwn(Obj, 'value')) { + desc['[[Value]]'] = Obj.value; + } + if (hasOwn(Obj, 'writable')) { + desc['[[Writable]]'] = ToBoolean(Obj.writable); + } + if (hasOwn(Obj, 'get')) { + var getter = Obj.get; + if (typeof getter !== 'undefined' && !IsCallable(getter)) { + throw new $TypeError('getter must be a function'); + } + desc['[[Get]]'] = getter; + } + if (hasOwn(Obj, 'set')) { + var setter = Obj.set; + if (typeof setter !== 'undefined' && !IsCallable(setter)) { + throw new $TypeError('setter must be a function'); + } + desc['[[Set]]'] = setter; + } + + if ((hasOwn(desc, '[[Get]]') || hasOwn(desc, '[[Set]]')) && (hasOwn(desc, '[[Value]]') || hasOwn(desc, '[[Writable]]'))) { + throw new $TypeError('Invalid property descriptor. Cannot both specify accessors and a value or writable attribute'); + } + return desc; +}; diff --git a/node_modules/es-abstract/2022/ToPropertyKey.js b/node_modules/es-abstract/2022/ToPropertyKey.js new file mode 100644 index 0000000000000000000000000000000000000000..e363cd93b1722ddcff99896fb5667079bb95c932 --- /dev/null +++ b/node_modules/es-abstract/2022/ToPropertyKey.js @@ -0,0 +1,15 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $String = GetIntrinsic('%String%'); + +var ToPrimitive = require('./ToPrimitive'); +var ToString = require('./ToString'); + +// https://262.ecma-international.org/6.0/#sec-topropertykey + +module.exports = function ToPropertyKey(argument) { + var key = ToPrimitive(argument, $String); + return typeof key === 'symbol' ? key : ToString(key); +}; diff --git a/node_modules/es-abstract/2022/ToString.js b/node_modules/es-abstract/2022/ToString.js new file mode 100644 index 0000000000000000000000000000000000000000..16b4ccf893640ee9162ff07ad484038311e6210d --- /dev/null +++ b/node_modules/es-abstract/2022/ToString.js @@ -0,0 +1,15 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $String = GetIntrinsic('%String%'); +var $TypeError = require('es-errors/type'); + +// https://262.ecma-international.org/6.0/#sec-tostring + +module.exports = function ToString(argument) { + if (typeof argument === 'symbol') { + throw new $TypeError('Cannot convert a Symbol value to a string'); + } + return $String(argument); +}; diff --git a/node_modules/es-abstract/2022/ToUint16.js b/node_modules/es-abstract/2022/ToUint16.js new file mode 100644 index 0000000000000000000000000000000000000000..117485e616437b348b9b74dddc3fc5e7af9f9ed0 --- /dev/null +++ b/node_modules/es-abstract/2022/ToUint16.js @@ -0,0 +1,19 @@ +'use strict'; + +var modulo = require('./modulo'); +var ToNumber = require('./ToNumber'); + +var abs = require('math-intrinsics/abs'); +var floor = require('math-intrinsics/floor'); +var $isNaN = require('math-intrinsics/isNaN'); +var $isFinite = require('math-intrinsics/isFinite'); +var $sign = require('math-intrinsics/sign'); + +// http://262.ecma-international.org/5.1/#sec-9.7 + +module.exports = function ToUint16(value) { + var number = ToNumber(value); + if ($isNaN(number) || number === 0 || !$isFinite(number)) { return 0; } + var posInt = $sign(number) * floor(abs(number)); + return modulo(posInt, 0x10000); +}; diff --git a/node_modules/es-abstract/2022/ToUint32.js b/node_modules/es-abstract/2022/ToUint32.js new file mode 100644 index 0000000000000000000000000000000000000000..2a8e9dd6a3794a0940b6bae175a99f00c0e2d25d --- /dev/null +++ b/node_modules/es-abstract/2022/ToUint32.js @@ -0,0 +1,9 @@ +'use strict'; + +var ToNumber = require('./ToNumber'); + +// http://262.ecma-international.org/5.1/#sec-9.6 + +module.exports = function ToUint32(x) { + return ToNumber(x) >>> 0; +}; diff --git a/node_modules/es-abstract/2022/ToUint8.js b/node_modules/es-abstract/2022/ToUint8.js new file mode 100644 index 0000000000000000000000000000000000000000..e3af8ede13a7ef1e5e3eb8833701d6497f8611e0 --- /dev/null +++ b/node_modules/es-abstract/2022/ToUint8.js @@ -0,0 +1,19 @@ +'use strict'; + +var ToNumber = require('./ToNumber'); + +var $isNaN = require('math-intrinsics/isNaN'); +var $isFinite = require('math-intrinsics/isFinite'); +var $sign = require('math-intrinsics/sign'); +var abs = require('math-intrinsics/abs'); +var floor = require('math-intrinsics/floor'); +var modulo = require('math-intrinsics/mod'); + +// https://262.ecma-international.org/6.0/#sec-touint8 + +module.exports = function ToUint8(argument) { + var number = ToNumber(argument); + if ($isNaN(number) || number === 0 || !$isFinite(number)) { return 0; } + var posInt = $sign(number) * floor(abs(number)); + return modulo(posInt, 0x100); +}; diff --git a/node_modules/es-abstract/2022/ToUint8Clamp.js b/node_modules/es-abstract/2022/ToUint8Clamp.js new file mode 100644 index 0000000000000000000000000000000000000000..ac1b06e461ba4d562700971000c2d30a9b9dfca4 --- /dev/null +++ b/node_modules/es-abstract/2022/ToUint8Clamp.js @@ -0,0 +1,19 @@ +'use strict'; + +var ToNumber = require('./ToNumber'); +var floor = require('./floor'); + +var $isNaN = require('math-intrinsics/isNaN'); + +// https://262.ecma-international.org/6.0/#sec-touint8clamp + +module.exports = function ToUint8Clamp(argument) { + var number = ToNumber(argument); + if ($isNaN(number) || number <= 0) { return 0; } + if (number >= 0xFF) { return 0xFF; } + var f = floor(number); + if (f + 0.5 < number) { return f + 1; } + if (number < f + 0.5) { return f; } + if (f % 2 !== 0) { return f + 1; } + return f; +}; diff --git a/node_modules/es-abstract/2022/ToZeroPaddedDecimalString.js b/node_modules/es-abstract/2022/ToZeroPaddedDecimalString.js new file mode 100644 index 0000000000000000000000000000000000000000..899863782f720219d850860c324f360d729f2fd3 --- /dev/null +++ b/node_modules/es-abstract/2022/ToZeroPaddedDecimalString.js @@ -0,0 +1,19 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $String = GetIntrinsic('%String%'); +var $RangeError = require('es-errors/range'); +var isInteger = require('math-intrinsics/isInteger'); + +var StringPad = require('./StringPad'); + +// https://262.ecma-international.org/13.0/#sec-tozeropaddeddecimalstring + +module.exports = function ToZeroPaddedDecimalString(n, minLength) { + if (!isInteger(n) || n < 0) { + throw new $RangeError('Assertion failed: `q` must be a non-negative integer'); + } + var S = $String(n); + return StringPad(S, minLength, '0', 'start'); +}; diff --git a/node_modules/es-abstract/2022/TrimString.js b/node_modules/es-abstract/2022/TrimString.js new file mode 100644 index 0000000000000000000000000000000000000000..516ef254819cc6b4d11788176a2e90b7ca18b7e4 --- /dev/null +++ b/node_modules/es-abstract/2022/TrimString.js @@ -0,0 +1,27 @@ +'use strict'; + +var trimStart = require('string.prototype.trimstart'); +var trimEnd = require('string.prototype.trimend'); + +var $TypeError = require('es-errors/type'); + +var RequireObjectCoercible = require('./RequireObjectCoercible'); +var ToString = require('./ToString'); + +// https://262.ecma-international.org/10.0/#sec-trimstring + +module.exports = function TrimString(string, where) { + var str = RequireObjectCoercible(string); + var S = ToString(str); + var T; + if (where === 'start') { + T = trimStart(S); + } else if (where === 'end') { + T = trimEnd(S); + } else if (where === 'start+end') { + T = trimStart(trimEnd(S)); + } else { + throw new $TypeError('Assertion failed: invalid `where` value; must be "start", "end", or "start+end"'); + } + return T; +}; diff --git a/node_modules/es-abstract/2022/Type.js b/node_modules/es-abstract/2022/Type.js new file mode 100644 index 0000000000000000000000000000000000000000..555ca74ea51969958716accd635da40009319542 --- /dev/null +++ b/node_modules/es-abstract/2022/Type.js @@ -0,0 +1,15 @@ +'use strict'; + +var ES5Type = require('../5/Type'); + +// https://262.ecma-international.org/11.0/#sec-ecmascript-data-types-and-values + +module.exports = function Type(x) { + if (typeof x === 'symbol') { + return 'Symbol'; + } + if (typeof x === 'bigint') { + return 'BigInt'; + } + return ES5Type(x); +}; diff --git a/node_modules/es-abstract/2022/TypedArrayCreate.js b/node_modules/es-abstract/2022/TypedArrayCreate.js new file mode 100644 index 0000000000000000000000000000000000000000..c598dfff9fe1d42461198227a6004e0fe4512226 --- /dev/null +++ b/node_modules/es-abstract/2022/TypedArrayCreate.js @@ -0,0 +1,47 @@ +'use strict'; + +var $SyntaxError = require('es-errors/syntax'); +var $TypeError = require('es-errors/type'); + +var IsArray = require('./IsArray'); +var IsConstructor = require('./IsConstructor'); +var ValidateTypedArray = require('./ValidateTypedArray'); + +var availableTypedArrays = require('available-typed-arrays')(); +var typedArrayLength = require('typed-array-length'); + +// https://262.ecma-international.org/7.0/#typedarray-create + +module.exports = function TypedArrayCreate(constructor, argumentList) { + if (!IsConstructor(constructor)) { + throw new $TypeError('Assertion failed: `constructor` must be a constructor'); + } + if (!IsArray(argumentList)) { + throw new $TypeError('Assertion failed: `argumentList` must be a List'); + } + if (availableTypedArrays.length === 0) { + throw new $SyntaxError('Assertion failed: Typed Arrays are not supported in this environment'); + } + + // var newTypedArray = Construct(constructor, argumentList); // step 1 + var newTypedArray; + if (argumentList.length === 0) { + newTypedArray = new constructor(); + } else if (argumentList.length === 1) { + newTypedArray = new constructor(argumentList[0]); + } else if (argumentList.length === 2) { + newTypedArray = new constructor(argumentList[0], argumentList[1]); + } else { + newTypedArray = new constructor(argumentList[0], argumentList[1], argumentList[2]); + } + + ValidateTypedArray(newTypedArray); // step 2 + + if (argumentList.length === 1 && typeof argumentList[0] === 'number') { // step 3 + if (typedArrayLength(newTypedArray) < argumentList[0]) { + throw new $TypeError('Assertion failed: `argumentList[0]` must be <= `newTypedArray.length`'); // step 3.a + } + } + + return newTypedArray; // step 4 +}; diff --git a/node_modules/es-abstract/2022/TypedArrayElementSize.js b/node_modules/es-abstract/2022/TypedArrayElementSize.js new file mode 100644 index 0000000000000000000000000000000000000000..1885af5141b51dd024c1230408987d8bf870d98d --- /dev/null +++ b/node_modules/es-abstract/2022/TypedArrayElementSize.js @@ -0,0 +1,23 @@ +'use strict'; + +var $SyntaxError = require('es-errors/syntax'); +var $TypeError = require('es-errors/type'); +var isInteger = require('math-intrinsics/isInteger'); +var whichTypedArray = require('which-typed-array'); + +// https://262.ecma-international.org/13.0/#sec-typedarrayelementsize + +var tableTAO = require('./tables/typed-array-objects'); + +module.exports = function TypedArrayElementSize(O) { + var type = whichTypedArray(O); + if (!type) { + throw new $TypeError('Assertion failed: `O` must be a TypedArray'); + } + var size = tableTAO.size['$' + tableTAO.name['$' + type]]; + if (!isInteger(size) || size < 0) { + throw new $SyntaxError('Assertion failed: Unknown TypedArray type `' + type + '`'); + } + + return size; +}; diff --git a/node_modules/es-abstract/2022/TypedArrayElementType.js b/node_modules/es-abstract/2022/TypedArrayElementType.js new file mode 100644 index 0000000000000000000000000000000000000000..0e9abe6a1d3807172b157a934f20fb4e8a4dca81 --- /dev/null +++ b/node_modules/es-abstract/2022/TypedArrayElementType.js @@ -0,0 +1,23 @@ +'use strict'; + +var $SyntaxError = require('es-errors/syntax'); +var $TypeError = require('es-errors/type'); + +var whichTypedArray = require('which-typed-array'); + +// https://262.ecma-international.org/13.0/#sec-typedarrayelementtype + +var tableTAO = require('./tables/typed-array-objects'); + +module.exports = function TypedArrayElementType(O) { + var type = whichTypedArray(O); + if (!type) { + throw new $TypeError('Assertion failed: `O` must be a TypedArray'); + } + var result = tableTAO.name['$' + type]; + if (typeof result !== 'string') { + throw new $SyntaxError('Assertion failed: Unknown TypedArray type `' + type + '`'); + } + + return result; +}; diff --git a/node_modules/es-abstract/2022/TypedArraySpeciesCreate.js b/node_modules/es-abstract/2022/TypedArraySpeciesCreate.js new file mode 100644 index 0000000000000000000000000000000000000000..6c71498a052bbfc121b4887e2aa3fff5572510b2 --- /dev/null +++ b/node_modules/es-abstract/2022/TypedArraySpeciesCreate.js @@ -0,0 +1,37 @@ +'use strict'; + +var $SyntaxError = require('es-errors/syntax'); +var $TypeError = require('es-errors/type'); + +var whichTypedArray = require('which-typed-array'); +var availableTypedArrays = require('available-typed-arrays')(); + +var IsArray = require('./IsArray'); +var SpeciesConstructor = require('./SpeciesConstructor'); +var TypedArrayCreate = require('./TypedArrayCreate'); + +var getConstructor = require('../helpers/typedArrayConstructors'); + +// https://262.ecma-international.org/7.0/#typedarray-species-create + +module.exports = function TypedArraySpeciesCreate(exemplar, argumentList) { + if (availableTypedArrays.length === 0) { + throw new $SyntaxError('Assertion failed: Typed Arrays are not supported in this environment'); + } + + var kind = whichTypedArray(exemplar); + if (!kind) { + throw new $TypeError('Assertion failed: exemplar must be a TypedArray'); // step 1 + } + if (!IsArray(argumentList)) { + throw new $TypeError('Assertion failed: `argumentList` must be a List'); // step 1 + } + + var defaultConstructor = getConstructor(kind); // step 2 + if (typeof defaultConstructor !== 'function') { + throw new $SyntaxError('Assertion failed: `constructor` of `exemplar` (' + kind + ') must exist. Please report this!'); + } + var constructor = SpeciesConstructor(exemplar, defaultConstructor); // step 3 + + return TypedArrayCreate(constructor, argumentList); // step 4 +}; diff --git a/node_modules/es-abstract/2022/UTF16EncodeCodePoint.js b/node_modules/es-abstract/2022/UTF16EncodeCodePoint.js new file mode 100644 index 0000000000000000000000000000000000000000..a35458039fc824e81d2832ac91d1fdb2e67bb621 --- /dev/null +++ b/node_modules/es-abstract/2022/UTF16EncodeCodePoint.js @@ -0,0 +1,25 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = require('es-errors/type'); +var $fromCharCode = GetIntrinsic('%String.fromCharCode%'); + +var floor = require('./floor'); +var modulo = require('./modulo'); + +var isCodePoint = require('../helpers/isCodePoint'); + +// https://262.ecma-international.org/12.0/#sec-utf16encoding + +module.exports = function UTF16EncodeCodePoint(cp) { + if (!isCodePoint(cp)) { + throw new $TypeError('Assertion failed: `cp` must be >= 0 and <= 0x10FFFF'); + } + if (cp <= 65535) { + return $fromCharCode(cp); + } + var cu1 = $fromCharCode(floor((cp - 65536) / 1024) + 0xD800); + var cu2 = $fromCharCode(modulo(cp - 65536, 1024) + 0xDC00); + return cu1 + cu2; +}; diff --git a/node_modules/es-abstract/2022/UTF16SurrogatePairToCodePoint.js b/node_modules/es-abstract/2022/UTF16SurrogatePairToCodePoint.js new file mode 100644 index 0000000000000000000000000000000000000000..d08f7be46a27b03ae34ddb71ef37571ea8f72531 --- /dev/null +++ b/node_modules/es-abstract/2022/UTF16SurrogatePairToCodePoint.js @@ -0,0 +1,19 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = require('es-errors/type'); +var $fromCharCode = GetIntrinsic('%String.fromCharCode%'); + +var isLeadingSurrogate = require('../helpers/isLeadingSurrogate'); +var isTrailingSurrogate = require('../helpers/isTrailingSurrogate'); + +// https://262.ecma-international.org/12.0/#sec-utf16decodesurrogatepair + +module.exports = function UTF16SurrogatePairToCodePoint(lead, trail) { + if (!isLeadingSurrogate(lead) || !isTrailingSurrogate(trail)) { + throw new $TypeError('Assertion failed: `lead` must be a leading surrogate char code, and `trail` must be a trailing surrogate char code'); + } + // var cp = (lead - 0xD800) * 0x400 + (trail - 0xDC00) + 0x10000; + return $fromCharCode(lead) + $fromCharCode(trail); +}; diff --git a/node_modules/es-abstract/2022/UnicodeEscape.js b/node_modules/es-abstract/2022/UnicodeEscape.js new file mode 100644 index 0000000000000000000000000000000000000000..739602cc8352d251c3d89180f3042bb397dabb76 --- /dev/null +++ b/node_modules/es-abstract/2022/UnicodeEscape.js @@ -0,0 +1,25 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var callBound = require('call-bound'); + +var $charCodeAt = callBound('String.prototype.charCodeAt'); +var $numberToString = callBound('Number.prototype.toString'); +var $toLowerCase = callBound('String.prototype.toLowerCase'); + +var StringPad = require('./StringPad'); + +// https://262.ecma-international.org/11.0/#sec-unicodeescape + +module.exports = function UnicodeEscape(C) { + if (typeof C !== 'string' || C.length !== 1) { + throw new $TypeError('Assertion failed: `C` must be a single code unit'); + } + var n = $charCodeAt(C, 0); + if (n > 0xFFFF) { + throw new $TypeError('`Assertion failed: numeric value of `C` must be <= 0xFFFF'); + } + + return '\\u' + StringPad($toLowerCase($numberToString(n, 16)), 4, '0', 'start'); +}; diff --git a/node_modules/es-abstract/2022/ValidateAndApplyPropertyDescriptor.js b/node_modules/es-abstract/2022/ValidateAndApplyPropertyDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..6aed0594a2548a610be2a9a812760645bd13c4e2 --- /dev/null +++ b/node_modules/es-abstract/2022/ValidateAndApplyPropertyDescriptor.js @@ -0,0 +1,171 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var DefineOwnProperty = require('../helpers/DefineOwnProperty'); +var isFullyPopulatedPropertyDescriptor = require('../helpers/isFullyPopulatedPropertyDescriptor'); +var isPropertyDescriptor = require('../helpers/records/property-descriptor'); + +var FromPropertyDescriptor = require('./FromPropertyDescriptor'); +var IsAccessorDescriptor = require('./IsAccessorDescriptor'); +var IsDataDescriptor = require('./IsDataDescriptor'); +var IsGenericDescriptor = require('./IsGenericDescriptor'); +var isPropertyKey = require('../helpers/isPropertyKey'); +var SameValue = require('./SameValue'); + +// https://262.ecma-international.org/13.0/#sec-validateandapplypropertydescriptor + +// see https://github.com/tc39/ecma262/pull/2468 for ES2022 changes + +// eslint-disable-next-line max-lines-per-function, max-statements +module.exports = function ValidateAndApplyPropertyDescriptor(O, P, extensible, Desc, current) { + if (typeof O !== 'undefined' && !isObject(O)) { + throw new $TypeError('Assertion failed: O must be undefined or an Object'); + } + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: P must be a Property Key'); + } + if (typeof extensible !== 'boolean') { + throw new $TypeError('Assertion failed: extensible must be a Boolean'); + } + if (!isPropertyDescriptor(Desc)) { + throw new $TypeError('Assertion failed: Desc must be a Property Descriptor'); + } + if (typeof current !== 'undefined' && !isPropertyDescriptor(current)) { + throw new $TypeError('Assertion failed: current must be a Property Descriptor, or undefined'); + } + + if (typeof current === 'undefined') { // step 2 + if (!extensible) { + return false; // step 2.a + } + if (typeof O === 'undefined') { + return true; // step 2.b + } + if (IsAccessorDescriptor(Desc)) { // step 2.c + return DefineOwnProperty( + IsDataDescriptor, + SameValue, + FromPropertyDescriptor, + O, + P, + Desc + ); + } + // step 2.d + return DefineOwnProperty( + IsDataDescriptor, + SameValue, + FromPropertyDescriptor, + O, + P, + { + '[[Configurable]]': !!Desc['[[Configurable]]'], + '[[Enumerable]]': !!Desc['[[Enumerable]]'], + '[[Value]]': Desc['[[Value]]'], + '[[Writable]]': !!Desc['[[Writable]]'] + } + ); + } + + // 3. Assert: current is a fully populated Property Descriptor. + if ( + !isFullyPopulatedPropertyDescriptor( + { + IsAccessorDescriptor: IsAccessorDescriptor, + IsDataDescriptor: IsDataDescriptor + }, + current + ) + ) { + throw new $TypeError('`current`, when present, must be a fully populated and valid Property Descriptor'); + } + + // 4. If every field in Desc is absent, return true. + // this can't really match the assertion that it's a Property Descriptor in our JS implementation + + // 5. If current.[[Configurable]] is false, then + if (!current['[[Configurable]]']) { + if ('[[Configurable]]' in Desc && Desc['[[Configurable]]']) { + // step 5.a + return false; + } + if ('[[Enumerable]]' in Desc && !SameValue(Desc['[[Enumerable]]'], current['[[Enumerable]]'])) { + // step 5.b + return false; + } + if (!IsGenericDescriptor(Desc) && !SameValue(IsAccessorDescriptor(Desc), IsAccessorDescriptor(current))) { + // step 5.c + return false; + } + if (IsAccessorDescriptor(current)) { // step 5.d + if ('[[Get]]' in Desc && !SameValue(Desc['[[Get]]'], current['[[Get]]'])) { + return false; + } + if ('[[Set]]' in Desc && !SameValue(Desc['[[Set]]'], current['[[Set]]'])) { + return false; + } + } else if (!current['[[Writable]]']) { // step 5.e + if ('[[Writable]]' in Desc && Desc['[[Writable]]']) { + return false; + } + if ('[[Value]]' in Desc && !SameValue(Desc['[[Value]]'], current['[[Value]]'])) { + return false; + } + } + } + + // 6. If O is not undefined, then + if (typeof O !== 'undefined') { + var configurable; + var enumerable; + if (IsDataDescriptor(current) && IsAccessorDescriptor(Desc)) { // step 6.a + configurable = ('[[Configurable]]' in Desc ? Desc : current)['[[Configurable]]']; + enumerable = ('[[Enumerable]]' in Desc ? Desc : current)['[[Enumerable]]']; + // Replace the property named P of object O with an accessor property having [[Configurable]] and [[Enumerable]] attributes as described by current and each other attribute set to its default value. + return DefineOwnProperty( + IsDataDescriptor, + SameValue, + FromPropertyDescriptor, + O, + P, + { + '[[Configurable]]': !!configurable, + '[[Enumerable]]': !!enumerable, + '[[Get]]': ('[[Get]]' in Desc ? Desc : current)['[[Get]]'], + '[[Set]]': ('[[Set]]' in Desc ? Desc : current)['[[Set]]'] + } + ); + } else if (IsAccessorDescriptor(current) && IsDataDescriptor(Desc)) { + configurable = ('[[Configurable]]' in Desc ? Desc : current)['[[Configurable]]']; + enumerable = ('[[Enumerable]]' in Desc ? Desc : current)['[[Enumerable]]']; + // i. Replace the property named P of object O with a data property having [[Configurable]] and [[Enumerable]] attributes as described by current and each other attribute set to its default value. + return DefineOwnProperty( + IsDataDescriptor, + SameValue, + FromPropertyDescriptor, + O, + P, + { + '[[Configurable]]': !!configurable, + '[[Enumerable]]': !!enumerable, + '[[Value]]': ('[[Value]]' in Desc ? Desc : current)['[[Value]]'], + '[[Writable]]': !!('[[Writable]]' in Desc ? Desc : current)['[[Writable]]'] + } + ); + } + + // For each field of Desc that is present, set the corresponding attribute of the property named P of object O to the value of the field. + return DefineOwnProperty( + IsDataDescriptor, + SameValue, + FromPropertyDescriptor, + O, + P, + Desc + ); + } + + return true; // step 7 +}; diff --git a/node_modules/es-abstract/2022/ValidateAtomicAccess.js b/node_modules/es-abstract/2022/ValidateAtomicAccess.js new file mode 100644 index 0000000000000000000000000000000000000000..d1e83a93701d36ff326ba6e0d865ecb61f433119 --- /dev/null +++ b/node_modules/es-abstract/2022/ValidateAtomicAccess.js @@ -0,0 +1,40 @@ +'use strict'; + +var $RangeError = require('es-errors/range'); +var $TypeError = require('es-errors/type'); + +var ToIndex = require('./ToIndex'); +var TypedArrayElementSize = require('./TypedArrayElementSize'); + +var isTypedArray = require('is-typed-array'); +var typedArrayByteOffset = require('typed-array-byte-offset'); +var typedArrayLength = require('typed-array-length'); + +// https://262.ecma-international.org/13.0/#sec-validateatomicaccess + +module.exports = function ValidateAtomicAccess(typedArray, requestIndex) { + if (!isTypedArray(typedArray)) { + throw new $TypeError('Assertion failed: `typedArray` must be a TypedArray'); + } + + var length = typedArrayLength(typedArray); // step 1 + + var accessIndex = ToIndex(requestIndex); // step 2 + + /* + // this assertion can never be reached + if (!(accessIndex >= 0)) { + throw new $TypeError('Assertion failed: accessIndex >= 0'); // step 4 + } + */ + + if (accessIndex >= length) { + throw new $RangeError('index out of range'); // step 4 + } + + var elementSize = TypedArrayElementSize(typedArray); // step 5 + + var offset = typedArrayByteOffset(typedArray); // step 6 + + return (accessIndex * elementSize) + offset; // step 7 +}; diff --git a/node_modules/es-abstract/2022/ValidateIntegerTypedArray.js b/node_modules/es-abstract/2022/ValidateIntegerTypedArray.js new file mode 100644 index 0000000000000000000000000000000000000000..fcce2b27c152423b62f57bf7f977ddc616878acc --- /dev/null +++ b/node_modules/es-abstract/2022/ValidateIntegerTypedArray.js @@ -0,0 +1,38 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var IsBigIntElementType = require('./IsBigIntElementType'); +var IsUnclampedIntegerElementType = require('./IsUnclampedIntegerElementType'); +var TypedArrayElementType = require('./TypedArrayElementType'); +var ValidateTypedArray = require('./ValidateTypedArray'); + +var whichTypedArray = require('which-typed-array'); +var typedArrayBuffer = require('typed-array-buffer'); + +// https://262.ecma-international.org/13.0/#sec-validateintegertypedarray + +module.exports = function ValidateIntegerTypedArray(typedArray) { + var waitable = arguments.length > 1 ? arguments[1] : false; // step 1 + + if (typeof waitable !== 'boolean') { + throw new $TypeError('Assertion failed: `waitable` must be a Boolean'); + } + + ValidateTypedArray(typedArray); // step 2 + var buffer = typedArrayBuffer(typedArray); // step 3 + + if (waitable) { // step 5 + var typeName = whichTypedArray(typedArray); + if (typeName !== 'Int32Array' && typeName !== 'BigInt64Array') { + throw new $TypeError('Assertion failed: `typedArray` must be an Int32Array or BigInt64Array when `waitable` is true'); // step 5.a + } + } else { + var type = TypedArrayElementType(typedArray); // step 5.a + if (!IsUnclampedIntegerElementType(type) && !IsBigIntElementType(type)) { + throw new $TypeError('Assertion failed: `typedArray` must be an integer TypedArray'); // step 5.b + } + } + + return buffer; // step 6 +}; diff --git a/node_modules/es-abstract/2022/ValidateTypedArray.js b/node_modules/es-abstract/2022/ValidateTypedArray.js new file mode 100644 index 0000000000000000000000000000000000000000..3a1efd7b33feeb82598a49e1e15ea7e6639c394c --- /dev/null +++ b/node_modules/es-abstract/2022/ValidateTypedArray.js @@ -0,0 +1,26 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var IsDetachedBuffer = require('./IsDetachedBuffer'); + +var isTypedArray = require('is-typed-array'); +var typedArrayBuffer = require('typed-array-buffer'); + +// https://262.ecma-international.org/13.0/#sec-validatetypedarray + +module.exports = function ValidateTypedArray(O) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: `O` must be an Object'); // step 1 + } + if (!isTypedArray(O)) { + throw new $TypeError('Assertion failed: `O` must be a Typed Array'); // steps 1 - 2 + } + + var buffer = typedArrayBuffer(O); // step 3 + + if (IsDetachedBuffer(buffer)) { + throw new $TypeError('`O` must be backed by a non-detached buffer'); // step 4 + } +}; diff --git a/node_modules/es-abstract/2022/WeakRefDeref.js b/node_modules/es-abstract/2022/WeakRefDeref.js new file mode 100644 index 0000000000000000000000000000000000000000..195b654b653be3eb14c01787a9c185e4cea2e5ac --- /dev/null +++ b/node_modules/es-abstract/2022/WeakRefDeref.js @@ -0,0 +1,23 @@ +'use strict'; + +var callBound = require('call-bound'); + +var $TypeError = require('es-errors/type'); +var $deref = callBound('WeakRef.prototype.deref', true); + +var isWeakRef = require('is-weakref'); + +var AddToKeptObjects = require('./AddToKeptObjects'); + +// https://262.ecma-international.org/12.0/#sec-weakrefderef + +module.exports = function WeakRefDeref(weakRef) { + if (!isWeakRef(weakRef)) { + throw new $TypeError('Assertion failed: `weakRef` must be a WeakRef'); + } + var target = $deref(weakRef); + if (target) { + AddToKeptObjects(target); + } + return target; +}; diff --git a/node_modules/es-abstract/2022/WeekDay.js b/node_modules/es-abstract/2022/WeekDay.js new file mode 100644 index 0000000000000000000000000000000000000000..17cf94ca34ce0aae649c1e0236cd18f248d54e3d --- /dev/null +++ b/node_modules/es-abstract/2022/WeekDay.js @@ -0,0 +1,10 @@ +'use strict'; + +var Day = require('./Day'); +var modulo = require('./modulo'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.6 + +module.exports = function WeekDay(t) { + return modulo(Day(t) + 4, 7); +}; diff --git a/node_modules/es-abstract/2022/WordCharacters.js b/node_modules/es-abstract/2022/WordCharacters.js new file mode 100644 index 0000000000000000000000000000000000000000..36532afc9087057ccdf6fb52434e7fe523714f4d --- /dev/null +++ b/node_modules/es-abstract/2022/WordCharacters.js @@ -0,0 +1,46 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var callBound = require('call-bound'); +var $indexOf = callBound('String.prototype.indexOf'); + +var Canonicalize = require('./Canonicalize'); + +var caseFolding = require('../helpers/caseFolding.json'); +var forEach = require('../helpers/forEach'); +var OwnPropertyKeys = require('own-keys'); + +var A = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_'; // step 1 + +// https://262.ecma-international.org/8.0/#sec-runtime-semantics-wordcharacters-abstract-operation + +module.exports = function WordCharacters(IgnoreCase, Unicode) { + if (typeof IgnoreCase !== 'boolean' || typeof Unicode !== 'boolean') { + throw new $TypeError('Assertion failed: `IgnoreCase` and `Unicode` must be booleans'); + } + + var U = ''; + forEach(OwnPropertyKeys(caseFolding.C), function (c) { + if ( + $indexOf(A, c) === -1 // c not in A + && $indexOf(A, Canonicalize(c, IgnoreCase, Unicode)) > -1 // canonicalized c IS in A + ) { + U += caseFolding.C[c]; // step 3 + } + }); + forEach(OwnPropertyKeys(caseFolding.S), function (c) { + if ( + $indexOf(A, c) === -1 // c not in A + && $indexOf(A, Canonicalize(c, IgnoreCase, Unicode)) > -1 // canonicalized c IS in A + ) { + U += caseFolding.S[c]; // step 3 + } + }); + + if ((!Unicode || !IgnoreCase) && U.length > 0) { + throw new $TypeError('Assertion failed: `U` must be empty when `IgnoreCase` and `Unicode` are not both true'); // step 4 + } + + return A + U; // step 5, 6 +}; diff --git a/node_modules/es-abstract/2022/YearFromTime.js b/node_modules/es-abstract/2022/YearFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..18958182021b0ecc71645057fe8ed826ef786586 --- /dev/null +++ b/node_modules/es-abstract/2022/YearFromTime.js @@ -0,0 +1,16 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $Date = GetIntrinsic('%Date%'); + +var callBound = require('call-bound'); + +var $getUTCFullYear = callBound('Date.prototype.getUTCFullYear'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.3 + +module.exports = function YearFromTime(t) { + // largest y such that this.TimeFromYear(y) <= t + return $getUTCFullYear(new $Date(t)); +}; diff --git a/node_modules/es-abstract/2022/abs.js b/node_modules/es-abstract/2022/abs.js new file mode 100644 index 0000000000000000000000000000000000000000..457f2a4a3d48f83c061c763cd26724fd8d4297f3 --- /dev/null +++ b/node_modules/es-abstract/2022/abs.js @@ -0,0 +1,9 @@ +'use strict'; + +var $abs = require('math-intrinsics/abs'); + +// https://262.ecma-international.org/11.0/#eqn-abs + +module.exports = function abs(x) { + return typeof x === 'bigint' ? BigInt($abs(Number(x))) : $abs(x); +}; diff --git a/node_modules/es-abstract/2022/clamp.js b/node_modules/es-abstract/2022/clamp.js new file mode 100644 index 0000000000000000000000000000000000000000..3fda648424302a451ffa63433b7f7933dcc6d13e --- /dev/null +++ b/node_modules/es-abstract/2022/clamp.js @@ -0,0 +1,14 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var max = require('math-intrinsics/max'); +var min = require('math-intrinsics/min'); + +// https://262.ecma-international.org/12.0/#clamping + +module.exports = function clamp(x, lower, upper) { + if (typeof x !== 'number' || typeof lower !== 'number' || typeof upper !== 'number' || !(lower <= upper)) { + throw new $TypeError('Assertion failed: all three arguments must be MVs, and `lower` must be `<= upper`'); + } + return min(max(lower, x), upper); +}; diff --git a/node_modules/es-abstract/2022/floor.js b/node_modules/es-abstract/2022/floor.js new file mode 100644 index 0000000000000000000000000000000000000000..eece19b5cbf2bd71a7655ea6d2f329cc8cd1a11d --- /dev/null +++ b/node_modules/es-abstract/2022/floor.js @@ -0,0 +1,14 @@ +'use strict'; + +// var modulo = require('./modulo'); +var $floor = require('math-intrinsics/floor'); + +// http://262.ecma-international.org/11.0/#eqn-floor + +module.exports = function floor(x) { + // return x - modulo(x, 1); + if (typeof x === 'bigint') { + return x; + } + return $floor(x); +}; diff --git a/node_modules/es-abstract/2022/max.js b/node_modules/es-abstract/2022/max.js new file mode 100644 index 0000000000000000000000000000000000000000..f83b038a221fed3a500c72b41f5fdc31e1100827 --- /dev/null +++ b/node_modules/es-abstract/2022/max.js @@ -0,0 +1,5 @@ +'use strict'; + +// https://262.ecma-international.org/6.0/#sec-algorithm-conventions + +module.exports = require('math-intrinsics/max'); diff --git a/node_modules/es-abstract/2022/min.js b/node_modules/es-abstract/2022/min.js new file mode 100644 index 0000000000000000000000000000000000000000..3a8f50539f0a6519251299edf4169f98a6db0bd9 --- /dev/null +++ b/node_modules/es-abstract/2022/min.js @@ -0,0 +1,5 @@ +'use strict'; + +// https://262.ecma-international.org/6.0/#sec-algorithm-conventions + +module.exports = require('math-intrinsics/min'); diff --git a/node_modules/es-abstract/2022/modulo.js b/node_modules/es-abstract/2022/modulo.js new file mode 100644 index 0000000000000000000000000000000000000000..b94bb52bb3c62e45629a4b1e8f0ebba219d5e41e --- /dev/null +++ b/node_modules/es-abstract/2022/modulo.js @@ -0,0 +1,9 @@ +'use strict'; + +var mod = require('../helpers/mod'); + +// https://262.ecma-international.org/5.1/#sec-5.2 + +module.exports = function modulo(x, y) { + return mod(x, y); +}; diff --git a/node_modules/es-abstract/2022/msFromTime.js b/node_modules/es-abstract/2022/msFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..a6bae767aed31c8a467b8ea1fb2128e64860a972 --- /dev/null +++ b/node_modules/es-abstract/2022/msFromTime.js @@ -0,0 +1,11 @@ +'use strict'; + +var modulo = require('./modulo'); + +var msPerSecond = require('../helpers/timeConstants').msPerSecond; + +// https://262.ecma-international.org/5.1/#sec-15.9.1.10 + +module.exports = function msFromTime(t) { + return modulo(t, msPerSecond); +}; diff --git a/node_modules/es-abstract/2022/substring.js b/node_modules/es-abstract/2022/substring.js new file mode 100644 index 0000000000000000000000000000000000000000..75fbf10e9c5e754041b8b0b509cc61f56b289fe3 --- /dev/null +++ b/node_modules/es-abstract/2022/substring.js @@ -0,0 +1,15 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isInteger = require('math-intrinsics/isInteger'); +var callBound = require('call-bound'); + +var $slice = callBound('String.prototype.slice'); + +// https://262.ecma-international.org/12.0/#substring +module.exports = function substring(S, inclusiveStart, exclusiveEnd) { + if (typeof S !== 'string' || !isInteger(inclusiveStart) || (arguments.length > 2 && !isInteger(exclusiveEnd))) { + throw new $TypeError('`S` must be a String, and `inclusiveStart` and `exclusiveEnd` must be integers'); + } + return $slice(S, inclusiveStart, arguments.length > 2 ? exclusiveEnd : S.length); +}; diff --git a/node_modules/es-abstract/2022/tables/typed-array-objects.js b/node_modules/es-abstract/2022/tables/typed-array-objects.js new file mode 100644 index 0000000000000000000000000000000000000000..8d6c70aba3046702ccb796ad62eb46fc99e038ef --- /dev/null +++ b/node_modules/es-abstract/2022/tables/typed-array-objects.js @@ -0,0 +1,36 @@ +'use strict'; + +// https://262.ecma-international.org/11.0/#table-the-typedarray-constructors + +module.exports = { + __proto__: null, + name: { + __proto__: null, + $Int8Array: 'Int8', + $Uint8Array: 'Uint8', + $Uint8ClampedArray: 'Uint8C', + $Int16Array: 'Int16', + $Uint16Array: 'Uint16', + $Int32Array: 'Int32', + $Uint32Array: 'Uint32', + $BigInt64Array: 'BigInt64', + $BigUint64Array: 'BigUint64', + $Float32Array: 'Float32', + $Float64Array: 'Float64' + }, + size: { + __proto__: null, + $Int8: 1, + $Uint8: 1, + $Uint8C: 1, + $Int16: 2, + $Uint16: 2, + $Int32: 4, + $Uint32: 4, + $BigInt64: 8, + $BigUint64: 8, + $Float32: 4, + $Float64: 8 + }, + choices: '"Int8", "Uint8", "Uint8C", "Int16", "Uint16", "Int32", "Uint32", "BigInt64", "BigUint64", "Float32", or "Float64"' +}; diff --git a/node_modules/es-abstract/2022/thisBigIntValue.js b/node_modules/es-abstract/2022/thisBigIntValue.js new file mode 100644 index 0000000000000000000000000000000000000000..ad281d3d0115e46f8e8accfeac1864be7dfdd459 --- /dev/null +++ b/node_modules/es-abstract/2022/thisBigIntValue.js @@ -0,0 +1,18 @@ +'use strict'; + +var callBound = require('call-bound'); + +var $SyntaxError = require('es-errors/syntax'); +var $bigIntValueOf = callBound('BigInt.prototype.valueOf', true); + +// https://262.ecma-international.org/11.0/#sec-thisbigintvalue + +module.exports = function thisBigIntValue(value) { + if (typeof value === 'bigint') { + return value; + } + if (!$bigIntValueOf) { + throw new $SyntaxError('BigInt is not supported'); + } + return $bigIntValueOf(value); +}; diff --git a/node_modules/es-abstract/2022/thisBooleanValue.js b/node_modules/es-abstract/2022/thisBooleanValue.js new file mode 100644 index 0000000000000000000000000000000000000000..265fff335bed60f2a636b2fa3bf2ac113b896ff7 --- /dev/null +++ b/node_modules/es-abstract/2022/thisBooleanValue.js @@ -0,0 +1,13 @@ +'use strict'; + +var $BooleanValueOf = require('call-bound')('Boolean.prototype.valueOf'); + +// https://262.ecma-international.org/6.0/#sec-properties-of-the-boolean-prototype-object + +module.exports = function thisBooleanValue(value) { + if (typeof value === 'boolean') { + return value; + } + + return $BooleanValueOf(value); +}; diff --git a/node_modules/es-abstract/2022/thisNumberValue.js b/node_modules/es-abstract/2022/thisNumberValue.js new file mode 100644 index 0000000000000000000000000000000000000000..e2457fb3f076d4f8c500d7f5ce7b19ff4846cf2d --- /dev/null +++ b/node_modules/es-abstract/2022/thisNumberValue.js @@ -0,0 +1,16 @@ +'use strict'; + +var callBound = require('call-bound'); + +var $NumberValueOf = callBound('Number.prototype.valueOf'); + +// https://262.ecma-international.org/6.0/#sec-properties-of-the-number-prototype-object + +module.exports = function thisNumberValue(value) { + if (typeof value === 'number') { + return value; + } + + return $NumberValueOf(value); +}; + diff --git a/node_modules/es-abstract/2022/thisStringValue.js b/node_modules/es-abstract/2022/thisStringValue.js new file mode 100644 index 0000000000000000000000000000000000000000..a5c70534670cd719ca425055d597ac6b5f5994c2 --- /dev/null +++ b/node_modules/es-abstract/2022/thisStringValue.js @@ -0,0 +1,13 @@ +'use strict'; + +var $StringValueOf = require('call-bound')('String.prototype.valueOf'); + +// https://262.ecma-international.org/6.0/#sec-properties-of-the-string-prototype-object + +module.exports = function thisStringValue(value) { + if (typeof value === 'string') { + return value; + } + + return $StringValueOf(value); +}; diff --git a/node_modules/es-abstract/2022/thisSymbolValue.js b/node_modules/es-abstract/2022/thisSymbolValue.js new file mode 100644 index 0000000000000000000000000000000000000000..77342ad16a77128cddbb7c79e9eb576bbe6b126c --- /dev/null +++ b/node_modules/es-abstract/2022/thisSymbolValue.js @@ -0,0 +1,20 @@ +'use strict'; + +var $SyntaxError = require('es-errors/syntax'); +var callBound = require('call-bound'); + +var $SymbolValueOf = callBound('Symbol.prototype.valueOf', true); + +// https://262.ecma-international.org/9.0/#sec-thissymbolvalue + +module.exports = function thisSymbolValue(value) { + if (typeof value === 'symbol') { + return value; + } + + if (!$SymbolValueOf) { + throw new $SyntaxError('Symbols are not supported; thisSymbolValue requires that `value` be a Symbol or a Symbol object'); + } + + return $SymbolValueOf(value); +}; diff --git a/node_modules/es-abstract/2022/thisTimeValue.js b/node_modules/es-abstract/2022/thisTimeValue.js new file mode 100644 index 0000000000000000000000000000000000000000..f64be83fcaed6a3766a1397c1c373981c0543b1a --- /dev/null +++ b/node_modules/es-abstract/2022/thisTimeValue.js @@ -0,0 +1,9 @@ +'use strict'; + +var timeValue = require('../helpers/timeValue'); + +// https://262.ecma-international.org/6.0/#sec-properties-of-the-date-prototype-object + +module.exports = function thisTimeValue(value) { + return timeValue(value); +}; diff --git a/node_modules/es-abstract/2023/AddEntriesFromIterable.js b/node_modules/es-abstract/2023/AddEntriesFromIterable.js new file mode 100644 index 0000000000000000000000000000000000000000..a784745aef55efca4daff187a3df11485b6c954e --- /dev/null +++ b/node_modules/es-abstract/2023/AddEntriesFromIterable.js @@ -0,0 +1,44 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); +var inspect = require('object-inspect'); + +var Call = require('./Call'); +var Get = require('./Get'); +var GetIterator = require('./GetIterator'); +var IsCallable = require('./IsCallable'); +var IteratorClose = require('./IteratorClose'); +var IteratorStep = require('./IteratorStep'); +var IteratorValue = require('./IteratorValue'); +var ThrowCompletion = require('./ThrowCompletion'); + +// https://262.ecma-international.org/14.0/#sec-add-entries-from-iterable + +module.exports = function AddEntriesFromIterable(target, iterable, adder) { + if (!IsCallable(adder)) { + throw new $TypeError('Assertion failed: `adder` is not callable'); + } + if (iterable == null) { + throw new $TypeError('Assertion failed: `iterable` is present, and not nullish'); + } + var iteratorRecord = GetIterator(iterable, 'sync'); + while (true) { + var next = IteratorStep(iteratorRecord); + if (!next) { + return target; + } + var nextItem = IteratorValue(next); + if (!isObject(nextItem)) { + var error = ThrowCompletion(new $TypeError('iterator next must return an Object, got ' + inspect(nextItem))); + return IteratorClose(iteratorRecord, error); + } + try { + var k = Get(nextItem, '0'); + var v = Get(nextItem, '1'); + Call(adder, target, [k, v]); + } catch (e) { + return IteratorClose(iteratorRecord, ThrowCompletion(e)); + } + } +}; diff --git a/node_modules/es-abstract/2023/AddToKeptObjects.js b/node_modules/es-abstract/2023/AddToKeptObjects.js new file mode 100644 index 0000000000000000000000000000000000000000..cce51955a6db7899e1be22e5077fb91d4f658600 --- /dev/null +++ b/node_modules/es-abstract/2023/AddToKeptObjects.js @@ -0,0 +1,18 @@ +'use strict'; + +var SLOT = require('internal-slot'); + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var ClearKeptObjects = require('./ClearKeptObjects'); + +// https://262.ecma-international.org/12.0/#sec-addtokeptobjects + +module.exports = function AddToKeptObjects(object) { + if (!isObject(object)) { + throw new $TypeError('Assertion failed: `object` must be an Object'); + } + var arr = SLOT.get(ClearKeptObjects, '[[es-abstract internal: KeptAlive]]'); + arr[arr.length] = object; +}; diff --git a/node_modules/es-abstract/2023/AdvanceStringIndex.js b/node_modules/es-abstract/2023/AdvanceStringIndex.js new file mode 100644 index 0000000000000000000000000000000000000000..370917df9dfff158449f930ef7d03643ee38982d --- /dev/null +++ b/node_modules/es-abstract/2023/AdvanceStringIndex.js @@ -0,0 +1,30 @@ +'use strict'; + +var CodePointAt = require('./CodePointAt'); + +var $TypeError = require('es-errors/type'); +var isInteger = require('math-intrinsics/isInteger'); +var MAX_SAFE_INTEGER = require('math-intrinsics/constants/maxSafeInteger'); + +// https://262.ecma-international.org/12.0/#sec-advancestringindex + +module.exports = function AdvanceStringIndex(S, index, unicode) { + if (typeof S !== 'string') { + throw new $TypeError('Assertion failed: `S` must be a String'); + } + if (!isInteger(index) || index < 0 || index > MAX_SAFE_INTEGER) { + throw new $TypeError('Assertion failed: `length` must be an integer >= 0 and <= 2**53'); + } + if (typeof unicode !== 'boolean') { + throw new $TypeError('Assertion failed: `unicode` must be a Boolean'); + } + if (!unicode) { + return index + 1; + } + var length = S.length; + if ((index + 1) >= length) { + return index + 1; + } + var cp = CodePointAt(S, index); + return index + cp['[[CodeUnitCount]]']; +}; diff --git a/node_modules/es-abstract/2023/ApplyStringOrNumericBinaryOperator.js b/node_modules/es-abstract/2023/ApplyStringOrNumericBinaryOperator.js new file mode 100644 index 0000000000000000000000000000000000000000..e65b6b2e79c756dcf2e533624ec8152e8dbfc161 --- /dev/null +++ b/node_modules/es-abstract/2023/ApplyStringOrNumericBinaryOperator.js @@ -0,0 +1,77 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var HasOwnProperty = require('./HasOwnProperty'); +var ToNumeric = require('./ToNumeric'); +var ToPrimitive = require('./ToPrimitive'); +var ToString = require('./ToString'); +var Type = require('./Type'); + +var NumberAdd = require('./Number/add'); +var NumberBitwiseAND = require('./Number/bitwiseAND'); +var NumberBitwiseOR = require('./Number/bitwiseOR'); +var NumberBitwiseXOR = require('./Number/bitwiseXOR'); +var NumberDivide = require('./Number/divide'); +var NumberExponentiate = require('./Number/exponentiate'); +var NumberLeftShift = require('./Number/leftShift'); +var NumberMultiply = require('./Number/multiply'); +var NumberRemainder = require('./Number/remainder'); +var NumberSignedRightShift = require('./Number/signedRightShift'); +var NumberSubtract = require('./Number/subtract'); +var NumberUnsignedRightShift = require('./Number/unsignedRightShift'); +var BigIntAdd = require('./BigInt/add'); +var BigIntBitwiseAND = require('./BigInt/bitwiseAND'); +var BigIntBitwiseOR = require('./BigInt/bitwiseOR'); +var BigIntBitwiseXOR = require('./BigInt/bitwiseXOR'); +var BigIntDivide = require('./BigInt/divide'); +var BigIntExponentiate = require('./BigInt/exponentiate'); +var BigIntLeftShift = require('./BigInt/leftShift'); +var BigIntMultiply = require('./BigInt/multiply'); +var BigIntRemainder = require('./BigInt/remainder'); +var BigIntSignedRightShift = require('./BigInt/signedRightShift'); +var BigIntSubtract = require('./BigInt/subtract'); +var BigIntUnsignedRightShift = require('./BigInt/unsignedRightShift'); + +// https://262.ecma-international.org/12.0/#sec-applystringornumericbinaryoperator + +// https://262.ecma-international.org/12.0/#step-applystringornumericbinaryoperator-operations-table +var table = { + '**': [NumberExponentiate, BigIntExponentiate], + '*': [NumberMultiply, BigIntMultiply], + '/': [NumberDivide, BigIntDivide], + '%': [NumberRemainder, BigIntRemainder], + '+': [NumberAdd, BigIntAdd], + '-': [NumberSubtract, BigIntSubtract], + '<<': [NumberLeftShift, BigIntLeftShift], + '>>': [NumberSignedRightShift, BigIntSignedRightShift], + '>>>': [NumberUnsignedRightShift, BigIntUnsignedRightShift], + '&': [NumberBitwiseAND, BigIntBitwiseAND], + '^': [NumberBitwiseXOR, BigIntBitwiseXOR], + '|': [NumberBitwiseOR, BigIntBitwiseOR] +}; + +module.exports = function ApplyStringOrNumericBinaryOperator(lval, opText, rval) { + if (typeof opText !== 'string' || !HasOwnProperty(table, opText)) { + throw new $TypeError('Assertion failed: `opText` must be a valid operation string'); + } + if (opText === '+') { + var lprim = ToPrimitive(lval); + var rprim = ToPrimitive(rval); + if (typeof lprim === 'string' || typeof rprim === 'string') { + var lstr = ToString(lprim); + var rstr = ToString(rprim); + return lstr + rstr; + } + /* eslint no-param-reassign: 1 */ + lval = lprim; + rval = rprim; + } + var lnum = ToNumeric(lval); + var rnum = ToNumeric(rval); + if (Type(lnum) !== Type(rnum)) { + throw new $TypeError('types of ' + lnum + ' and ' + rnum + ' differ'); + } + var Operation = table[opText][typeof lnum === 'bigint' ? 1 : 0]; + return Operation(lnum, rnum); +}; diff --git a/node_modules/es-abstract/2023/ArrayCreate.js b/node_modules/es-abstract/2023/ArrayCreate.js new file mode 100644 index 0000000000000000000000000000000000000000..568632b8a6d2ef76124399192dee465859e0ed1b --- /dev/null +++ b/node_modules/es-abstract/2023/ArrayCreate.js @@ -0,0 +1,42 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $ArrayPrototype = GetIntrinsic('%Array.prototype%'); +var $RangeError = require('es-errors/range'); +var $SyntaxError = require('es-errors/syntax'); +var $TypeError = require('es-errors/type'); +var isInteger = require('math-intrinsics/isInteger'); +var MAX_ARRAY_LENGTH = require('math-intrinsics/constants/maxArrayLength'); +var $setProto = require('set-proto'); + +// https://262.ecma-international.org/12.0/#sec-arraycreate + +module.exports = function ArrayCreate(length) { + if (!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 3, 5 + if (proto !== $ArrayPrototype) { // step 4 + 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 6 + A.length = length; + } + /* step 6, the above as a shortcut for the below + OrdinaryDefineOwnProperty(A, 'length', { + '[[Configurable]]': false, + '[[Enumerable]]': false, + '[[Value]]': length, + '[[Writable]]': true + }); + */ + return A; +}; diff --git a/node_modules/es-abstract/2023/ArraySetLength.js b/node_modules/es-abstract/2023/ArraySetLength.js new file mode 100644 index 0000000000000000000000000000000000000000..7f7a4339c2af5c8656165189f47c4212732ee1bd --- /dev/null +++ b/node_modules/es-abstract/2023/ArraySetLength.js @@ -0,0 +1,77 @@ +'use strict'; + +var $RangeError = require('es-errors/range'); +var $TypeError = require('es-errors/type'); + +var assign = require('object.assign'); + +var isPropertyDescriptor = require('../helpers/records/property-descriptor'); + +var IsArray = require('./IsArray'); +var IsDataDescriptor = require('./IsDataDescriptor'); +var OrdinaryDefineOwnProperty = require('./OrdinaryDefineOwnProperty'); +var OrdinaryGetOwnProperty = require('./OrdinaryGetOwnProperty'); +var ToNumber = require('./ToNumber'); +var ToString = require('./ToString'); +var ToUint32 = require('./ToUint32'); + +// https://262.ecma-international.org/6.0/#sec-arraysetlength + +// eslint-disable-next-line max-statements, max-lines-per-function +module.exports = function ArraySetLength(A, Desc) { + if (!IsArray(A)) { + throw new $TypeError('Assertion failed: A must be an Array'); + } + if (!isPropertyDescriptor(Desc)) { + throw new $TypeError('Assertion failed: Desc must be a Property Descriptor'); + } + if (!('[[Value]]' in Desc)) { + return OrdinaryDefineOwnProperty(A, 'length', Desc); + } + var newLenDesc = assign({}, Desc); + var newLen = ToUint32(Desc['[[Value]]']); + var numberLen = ToNumber(Desc['[[Value]]']); + if (newLen !== numberLen) { + throw new $RangeError('Invalid array length'); + } + newLenDesc['[[Value]]'] = newLen; + var oldLenDesc = OrdinaryGetOwnProperty(A, 'length'); + if (!IsDataDescriptor(oldLenDesc)) { + throw new $TypeError('Assertion failed: an array had a non-data descriptor on `length`'); + } + var oldLen = oldLenDesc['[[Value]]']; + if (newLen >= oldLen) { + return 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 = OrdinaryDefineOwnProperty(A, 'length', newLenDesc); + if (!succeeded) { + return false; + } + while (newLen < oldLen) { + oldLen -= 1; + // eslint-disable-next-line no-param-reassign + var deleteSucceeded = delete A[ToString(oldLen)]; + if (!deleteSucceeded) { + newLenDesc['[[Value]]'] = oldLen + 1; + if (!newWritable) { + newLenDesc['[[Writable]]'] = false; + OrdinaryDefineOwnProperty(A, 'length', newLenDesc); + return false; + } + } + } + if (!newWritable) { + return OrdinaryDefineOwnProperty(A, 'length', { '[[Writable]]': false }); + } + return true; +}; diff --git a/node_modules/es-abstract/2023/ArraySpeciesCreate.js b/node_modules/es-abstract/2023/ArraySpeciesCreate.js new file mode 100644 index 0000000000000000000000000000000000000000..2589c90787151d6dd4534c32499a6906b982c505 --- /dev/null +++ b/node_modules/es-abstract/2023/ArraySpeciesCreate.js @@ -0,0 +1,48 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $species = GetIntrinsic('%Symbol.species%', true); +var $TypeError = require('es-errors/type'); +var isInteger = require('math-intrinsics/isInteger'); +var isObject = require('es-object-atoms/isObject'); + +var ArrayCreate = require('./ArrayCreate'); +var Get = require('./Get'); +var IsArray = require('./IsArray'); +var IsConstructor = require('./IsConstructor'); + +// https://262.ecma-international.org/12.0/#sec-arrayspeciescreate + +module.exports = function ArraySpeciesCreate(originalArray, length) { + if (!isInteger(length) || length < 0) { + throw new $TypeError('Assertion failed: length must be an integer >= 0'); + } + + var isArray = IsArray(originalArray); + if (!isArray) { + return ArrayCreate(length); + } + + var C = Get(originalArray, 'constructor'); + // TODO: figure out how to make a cross-realm normal Array, a same-realm Array + // if (IsConstructor(C)) { + // if C is another realm's Array, C = undefined + // Object.getPrototypeOf(Object.getPrototypeOf(Object.getPrototypeOf(Array))) === null ? + // } + if ($species && isObject(C)) { + C = Get(C, $species); + if (C === null) { + C = void 0; + } + } + + if (typeof C === 'undefined') { + return ArrayCreate(length); + } + if (!IsConstructor(C)) { + throw new $TypeError('C must be a constructor'); + } + return new C(length); // Construct(C, length); +}; + diff --git a/node_modules/es-abstract/2023/AsyncFromSyncIteratorContinuation.js b/node_modules/es-abstract/2023/AsyncFromSyncIteratorContinuation.js new file mode 100644 index 0000000000000000000000000000000000000000..d545b6bfc70974e44350f20e4ec28812d9cbf9e2 --- /dev/null +++ b/node_modules/es-abstract/2023/AsyncFromSyncIteratorContinuation.js @@ -0,0 +1,45 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $SyntaxError = require('es-errors/syntax'); +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); +var $Promise = GetIntrinsic('%Promise%', true); + +var callBound = require('call-bound'); + +var CreateIterResultObject = require('./CreateIterResultObject'); +var IteratorComplete = require('./IteratorComplete'); +var IteratorValue = require('./IteratorValue'); +var PromiseResolve = require('./PromiseResolve'); + +var $then = callBound('Promise.prototype.then', true); + +// https://262.ecma-international.org/10.0/#sec-asyncfromsynciteratorcontinuation + +module.exports = function AsyncFromSyncIteratorContinuation(result) { + if (!isObject(result)) { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + if (arguments.length > 1) { + throw new $SyntaxError('although AsyncFromSyncIteratorContinuation should take a second argument, it is not used in this implementation'); + } + + if (!$Promise) { + throw new $SyntaxError('This environment does not support Promises.'); + } + + return new $Promise(function (resolve) { + var done = IteratorComplete(result); // step 2 + var value = IteratorValue(result); // step 4 + var valueWrapper = PromiseResolve($Promise, value); // step 6 + + // eslint-disable-next-line no-shadow + var onFulfilled = function (value) { // steps 8-9 + return CreateIterResultObject(value, done); // step 8.a + }; + resolve($then(valueWrapper, onFulfilled)); // step 11 + }); // step 12 +}; diff --git a/node_modules/es-abstract/2023/AsyncIteratorClose.js b/node_modules/es-abstract/2023/AsyncIteratorClose.js new file mode 100644 index 0000000000000000000000000000000000000000..d1cda2a301d35c13bee2a0e343b365fc48023edc --- /dev/null +++ b/node_modules/es-abstract/2023/AsyncIteratorClose.js @@ -0,0 +1,70 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $SyntaxError = require('es-errors/syntax'); +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); +var $Promise = GetIntrinsic('%Promise%', true); + +var Call = require('./Call'); +var CompletionRecord = require('./CompletionRecord'); +var GetMethod = require('./GetMethod'); + +var isIteratorRecord = require('../helpers/records/iterator-record-2023'); + +var callBound = require('call-bound'); + +var $then = callBound('Promise.prototype.then', true); + +// https://262.ecma-international.org/12.0/#sec-asynciteratorclose + +module.exports = function AsyncIteratorClose(iteratorRecord, completion) { + if (!isIteratorRecord(iteratorRecord)) { + throw new $TypeError('Assertion failed: `iteratorRecord` must be an Iterator Record'); // step 1 + } + + if (!(completion instanceof CompletionRecord)) { + throw new $TypeError('Assertion failed: completion is not a Completion Record instance'); // step 2 + } + + if (!$then) { + throw new $SyntaxError('This environment does not support Promises.'); + } + + var iterator = iteratorRecord['[[Iterator]]']; // step 3 + + return $then( + $then( + $then( + new $Promise(function (resolve) { + resolve(GetMethod(iterator, 'return')); // step 4 + // resolve(Call(ret, iterator, [])); // step 6 + }), + function (returnV) { // step 5.a + if (typeof returnV === 'undefined') { + return completion; // step 5.b + } + return Call(returnV, iterator); // step 5.c, 5.d. + } + ), + null, + function (e) { + if (completion.type() === 'throw') { + completion['?'](); // step 6 + } else { + throw e; // step 7 + } + } + ), + function (innerResult) { // step 8 + if (completion.type() === 'throw') { + completion['?'](); // step 6 + } + if (!isObject(innerResult)) { + throw new $TypeError('`innerResult` must be an Object'); // step 10 + } + return completion; + } + ); +}; diff --git a/node_modules/es-abstract/2023/BigInt/add.js b/node_modules/es-abstract/2023/BigInt/add.js new file mode 100644 index 0000000000000000000000000000000000000000..25cc9fa60f58e2433eb392a4cc0e00a0569474ba --- /dev/null +++ b/node_modules/es-abstract/2023/BigInt/add.js @@ -0,0 +1,14 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-add + +module.exports = function BigIntAdd(x, y) { + if (typeof x !== 'bigint' || typeof y !== 'bigint') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + + // shortcut for the actual spec mechanics + return x + y; +}; diff --git a/node_modules/es-abstract/2023/BigInt/bitwiseAND.js b/node_modules/es-abstract/2023/BigInt/bitwiseAND.js new file mode 100644 index 0000000000000000000000000000000000000000..106f4a273945d92cdb34715249ae5a72c1af93d8 --- /dev/null +++ b/node_modules/es-abstract/2023/BigInt/bitwiseAND.js @@ -0,0 +1,14 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var BigIntBitwiseOp = require('../BigIntBitwiseOp'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-bitwiseAND + +module.exports = function BigIntBitwiseAND(x, y) { + if (typeof x !== 'bigint' || typeof y !== 'bigint') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + return BigIntBitwiseOp('&', x, y); +}; diff --git a/node_modules/es-abstract/2023/BigInt/bitwiseNOT.js b/node_modules/es-abstract/2023/BigInt/bitwiseNOT.js new file mode 100644 index 0000000000000000000000000000000000000000..9fe67405f674c3501fe410d55c63c59874841d87 --- /dev/null +++ b/node_modules/es-abstract/2023/BigInt/bitwiseNOT.js @@ -0,0 +1,15 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $BigInt = GetIntrinsic('%BigInt%', true); +var $TypeError = require('es-errors/type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-bitwiseNOT + +module.exports = function BigIntBitwiseNOT(x) { + if (typeof x !== 'bigint') { + throw new $TypeError('Assertion failed: `x` argument must be a BigInt'); + } + return -x - $BigInt(1); +}; diff --git a/node_modules/es-abstract/2023/BigInt/bitwiseOR.js b/node_modules/es-abstract/2023/BigInt/bitwiseOR.js new file mode 100644 index 0000000000000000000000000000000000000000..b0ba812a8a321e0f92a9d446b4e5439ec898fd47 --- /dev/null +++ b/node_modules/es-abstract/2023/BigInt/bitwiseOR.js @@ -0,0 +1,14 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var BigIntBitwiseOp = require('../BigIntBitwiseOp'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-bitwiseOR + +module.exports = function BigIntBitwiseOR(x, y) { + if (typeof x !== 'bigint' || typeof y !== 'bigint') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + return BigIntBitwiseOp('|', x, y); +}; diff --git a/node_modules/es-abstract/2023/BigInt/bitwiseXOR.js b/node_modules/es-abstract/2023/BigInt/bitwiseXOR.js new file mode 100644 index 0000000000000000000000000000000000000000..79ac4a1f4568d559d69b64ba88061aabb1460c57 --- /dev/null +++ b/node_modules/es-abstract/2023/BigInt/bitwiseXOR.js @@ -0,0 +1,14 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var BigIntBitwiseOp = require('../BigIntBitwiseOp'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-bitwiseXOR + +module.exports = function BigIntBitwiseXOR(x, y) { + if (typeof x !== 'bigint' || typeof y !== 'bigint') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + return BigIntBitwiseOp('^', x, y); +}; diff --git a/node_modules/es-abstract/2023/BigInt/divide.js b/node_modules/es-abstract/2023/BigInt/divide.js new file mode 100644 index 0000000000000000000000000000000000000000..a194302eb682514dc75061f391f75fdad1f0da4e --- /dev/null +++ b/node_modules/es-abstract/2023/BigInt/divide.js @@ -0,0 +1,20 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $BigInt = GetIntrinsic('%BigInt%', true); +var $RangeError = require('es-errors/range'); +var $TypeError = require('es-errors/type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-divide + +module.exports = function BigIntDivide(x, y) { + if (typeof x !== 'bigint' || typeof y !== 'bigint') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + if (y === $BigInt(0)) { + throw new $RangeError('Division by zero'); + } + // shortcut for the actual spec mechanics + return x / y; +}; diff --git a/node_modules/es-abstract/2023/BigInt/equal.js b/node_modules/es-abstract/2023/BigInt/equal.js new file mode 100644 index 0000000000000000000000000000000000000000..d6b36a2551cb08160a812a8bab4dc3a63e751a8b --- /dev/null +++ b/node_modules/es-abstract/2023/BigInt/equal.js @@ -0,0 +1,13 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-equal + +module.exports = function BigIntEqual(x, y) { + if (typeof x !== 'bigint' || typeof y !== 'bigint') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + // shortcut for the actual spec mechanics + return x === y; +}; diff --git a/node_modules/es-abstract/2023/BigInt/exponentiate.js b/node_modules/es-abstract/2023/BigInt/exponentiate.js new file mode 100644 index 0000000000000000000000000000000000000000..f5bcdc148af1bc7658596120cbf5d72f7036c599 --- /dev/null +++ b/node_modules/es-abstract/2023/BigInt/exponentiate.js @@ -0,0 +1,29 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $BigInt = GetIntrinsic('%BigInt%', true); +var $RangeError = require('es-errors/range'); +var $TypeError = require('es-errors/type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-exponentiate + +module.exports = function BigIntExponentiate(base, exponent) { + if (typeof base !== 'bigint' || typeof exponent !== 'bigint') { + throw new $TypeError('Assertion failed: `base` and `exponent` arguments must be BigInts'); + } + if (exponent < $BigInt(0)) { + throw new $RangeError('Exponent must be positive'); + } + if (/* base === $BigInt(0) && */ exponent === $BigInt(0)) { + return $BigInt(1); + } + + var square = base; + var remaining = exponent; + while (remaining > $BigInt(0)) { + square += exponent; + --remaining; // eslint-disable-line no-plusplus + } + return square; +}; diff --git a/node_modules/es-abstract/2023/BigInt/index.js b/node_modules/es-abstract/2023/BigInt/index.js new file mode 100644 index 0000000000000000000000000000000000000000..6ba755ff52a6f144423c3662e0d496c0a09dad31 --- /dev/null +++ b/node_modules/es-abstract/2023/BigInt/index.js @@ -0,0 +1,39 @@ +'use strict'; + +var add = require('./add'); +var bitwiseAND = require('./bitwiseAND'); +var bitwiseNOT = require('./bitwiseNOT'); +var bitwiseOR = require('./bitwiseOR'); +var bitwiseXOR = require('./bitwiseXOR'); +var divide = require('./divide'); +var equal = require('./equal'); +var exponentiate = require('./exponentiate'); +var leftShift = require('./leftShift'); +var lessThan = require('./lessThan'); +var multiply = require('./multiply'); +var remainder = require('./remainder'); +var signedRightShift = require('./signedRightShift'); +var subtract = require('./subtract'); +var toString = require('./toString'); +var unaryMinus = require('./unaryMinus'); +var unsignedRightShift = require('./unsignedRightShift'); + +module.exports = { + add: add, + bitwiseAND: bitwiseAND, + bitwiseNOT: bitwiseNOT, + bitwiseOR: bitwiseOR, + bitwiseXOR: bitwiseXOR, + divide: divide, + equal: equal, + exponentiate: exponentiate, + leftShift: leftShift, + lessThan: lessThan, + multiply: multiply, + remainder: remainder, + signedRightShift: signedRightShift, + subtract: subtract, + toString: toString, + unaryMinus: unaryMinus, + unsignedRightShift: unsignedRightShift +}; diff --git a/node_modules/es-abstract/2023/BigInt/leftShift.js b/node_modules/es-abstract/2023/BigInt/leftShift.js new file mode 100644 index 0000000000000000000000000000000000000000..327592ea62472441e0750d4a6e5bccc81a7a5c71 --- /dev/null +++ b/node_modules/es-abstract/2023/BigInt/leftShift.js @@ -0,0 +1,14 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-leftShift + +module.exports = function BigIntLeftShift(x, y) { + if (typeof x !== 'bigint' || typeof y !== 'bigint') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + + // shortcut for the actual spec mechanics + return x << y; +}; diff --git a/node_modules/es-abstract/2023/BigInt/lessThan.js b/node_modules/es-abstract/2023/BigInt/lessThan.js new file mode 100644 index 0000000000000000000000000000000000000000..612f2dbbc4ea4aa7e5b27781f68071baa10f8727 --- /dev/null +++ b/node_modules/es-abstract/2023/BigInt/lessThan.js @@ -0,0 +1,14 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-lessThan + +module.exports = function BigIntLessThan(x, y) { + if (typeof x !== 'bigint' || typeof y !== 'bigint') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + + // shortcut for the actual spec mechanics + return x < y; +}; diff --git a/node_modules/es-abstract/2023/BigInt/multiply.js b/node_modules/es-abstract/2023/BigInt/multiply.js new file mode 100644 index 0000000000000000000000000000000000000000..a9bfbd5936a77ce9ddaec1e442a36fc2c4eb96de --- /dev/null +++ b/node_modules/es-abstract/2023/BigInt/multiply.js @@ -0,0 +1,14 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-multiply + +module.exports = function BigIntMultiply(x, y) { + if (typeof x !== 'bigint' || typeof y !== 'bigint') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + + // shortcut for the actual spec mechanics + return x * y; +}; diff --git a/node_modules/es-abstract/2023/BigInt/remainder.js b/node_modules/es-abstract/2023/BigInt/remainder.js new file mode 100644 index 0000000000000000000000000000000000000000..60346ecdeec72fc2f63f823c80fea5a45208abab --- /dev/null +++ b/node_modules/es-abstract/2023/BigInt/remainder.js @@ -0,0 +1,28 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $BigInt = GetIntrinsic('%BigInt%', true); +var $RangeError = require('es-errors/range'); +var $TypeError = require('es-errors/type'); + +var zero = $BigInt && $BigInt(0); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-remainder + +module.exports = function BigIntRemainder(n, d) { + if (typeof n !== 'bigint' || typeof d !== 'bigint') { + throw new $TypeError('Assertion failed: `n` and `d` arguments must be BigInts'); + } + + if (d === zero) { + throw new $RangeError('Division by zero'); + } + + if (n === zero) { + return zero; + } + + // shortcut for the actual spec mechanics + return n % d; +}; diff --git a/node_modules/es-abstract/2023/BigInt/signedRightShift.js b/node_modules/es-abstract/2023/BigInt/signedRightShift.js new file mode 100644 index 0000000000000000000000000000000000000000..90967d66e622397fc8e7cd54ee6e1f7c5426b786 --- /dev/null +++ b/node_modules/es-abstract/2023/BigInt/signedRightShift.js @@ -0,0 +1,15 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var BigIntLeftShift = require('./leftShift'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-signedRightShift + +module.exports = function BigIntSignedRightShift(x, y) { + if (typeof x !== 'bigint' || typeof y !== 'bigint') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + + return BigIntLeftShift(x, -y); +}; diff --git a/node_modules/es-abstract/2023/BigInt/subtract.js b/node_modules/es-abstract/2023/BigInt/subtract.js new file mode 100644 index 0000000000000000000000000000000000000000..32de730a3cbea3a14df35755a24c54dcb9e5de9f --- /dev/null +++ b/node_modules/es-abstract/2023/BigInt/subtract.js @@ -0,0 +1,14 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-subtract + +module.exports = function BigIntSubtract(x, y) { + if (typeof x !== 'bigint' || typeof y !== 'bigint') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + + // shortcut for the actual spec mechanics + return x - y; +}; diff --git a/node_modules/es-abstract/2023/BigInt/toString.js b/node_modules/es-abstract/2023/BigInt/toString.js new file mode 100644 index 0000000000000000000000000000000000000000..a5d5700465bb6ad7dde0bbf8c03023859623dad9 --- /dev/null +++ b/node_modules/es-abstract/2023/BigInt/toString.js @@ -0,0 +1,26 @@ +'use strict'; + +var $SyntaxError = require('es-errors/syntax'); +var $TypeError = require('es-errors/type'); +var callBound = require('call-bound'); +var isInteger = require('math-intrinsics/isInteger'); + +var $BigIntToString = callBound('BigInt.prototype.toString', true); + +// https://262.ecma-international.org/14.0/#sec-numeric-types-bigint-tostring + +module.exports = function BigIntToString(x, radix) { + if (typeof x !== 'bigint') { + throw new $TypeError('Assertion failed: `x` must be a BigInt'); + } + + if (!isInteger(radix) || radix < 2 || radix > 36) { + throw new $TypeError('Assertion failed: `radix` must be an integer >= 2 and <= 36'); + } + + if (!$BigIntToString) { + throw new $SyntaxError('BigInt is not supported'); + } + + return $BigIntToString(x, radix); // steps 1 - 12 +}; diff --git a/node_modules/es-abstract/2023/BigInt/unaryMinus.js b/node_modules/es-abstract/2023/BigInt/unaryMinus.js new file mode 100644 index 0000000000000000000000000000000000000000..161f02fbdba7eca7078ee2a2404f646e03b4d0be --- /dev/null +++ b/node_modules/es-abstract/2023/BigInt/unaryMinus.js @@ -0,0 +1,22 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $BigInt = GetIntrinsic('%BigInt%', true); +var $TypeError = require('es-errors/type'); + +var zero = $BigInt && $BigInt(0); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-unaryMinus + +module.exports = function BigIntUnaryMinus(x) { + if (typeof x !== 'bigint') { + throw new $TypeError('Assertion failed: `x` argument must be a BigInt'); + } + + if (x === zero) { + return zero; + } + + return -x; +}; diff --git a/node_modules/es-abstract/2023/BigInt/unsignedRightShift.js b/node_modules/es-abstract/2023/BigInt/unsignedRightShift.js new file mode 100644 index 0000000000000000000000000000000000000000..d695cb43beb3716c8015d4b83f93d6fc7307da73 --- /dev/null +++ b/node_modules/es-abstract/2023/BigInt/unsignedRightShift.js @@ -0,0 +1,13 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-unsignedRightShift + +module.exports = function BigIntUnsignedRightShift(x, y) { + if (typeof x !== 'bigint' || typeof y !== 'bigint') { + throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts'); + } + + throw new $TypeError('BigInts have no unsigned right shift, use >> instead'); +}; diff --git a/node_modules/es-abstract/2023/BigIntBitwiseOp.js b/node_modules/es-abstract/2023/BigIntBitwiseOp.js new file mode 100644 index 0000000000000000000000000000000000000000..40e1a13185c4a1b7273f3e53a48f04f9ec5161b6 --- /dev/null +++ b/node_modules/es-abstract/2023/BigIntBitwiseOp.js @@ -0,0 +1,63 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +// var $BigInt = GetIntrinsic('%BigInt%', true); +// var $pow = require('math-intrinsics/pow'); + +// var BinaryAnd = require('./BinaryAnd'); +// var BinaryOr = require('./BinaryOr'); +// var BinaryXor = require('./BinaryXor'); +// var modulo = require('./modulo'); + +// var zero = $BigInt && $BigInt(0); +// var negOne = $BigInt && $BigInt(-1); +// var two = $BigInt && $BigInt(2); + +// https://262.ecma-international.org/11.0/#sec-bigintbitwiseop + +module.exports = function BigIntBitwiseOp(op, x, y) { + if (op !== '&' && op !== '|' && op !== '^') { + throw new $TypeError('Assertion failed: `op` must be `&`, `|`, or `^`'); + } + if (typeof x !== 'bigint' || typeof y !== 'bigint') { + throw new $TypeError('`x` and `y` must be BigInts'); + } + + if (op === '&') { + return x & y; + } + if (op === '|') { + return x | y; + } + return x ^ y; + /* + var result = zero; + var shift = 0; + while (x !== zero && x !== negOne && y !== zero && y !== negOne) { + var xDigit = modulo(x, two); + var yDigit = modulo(y, two); + if (op === '&') { + result += $pow(2, shift) * BinaryAnd(xDigit, yDigit); + } else if (op === '|') { + result += $pow(2, shift) * BinaryOr(xDigit, yDigit); + } else if (op === '^') { + result += $pow(2, shift) * BinaryXor(xDigit, yDigit); + } + shift += 1; + x = (x - xDigit) / two; + y = (y - yDigit) / two; + } + var tmp; + if (op === '&') { + tmp = BinaryAnd(modulo(x, two), modulo(y, two)); + } else if (op === '|') { + tmp = BinaryAnd(modulo(x, two), modulo(y, two)); + } else { + tmp = BinaryXor(modulo(x, two), modulo(y, two)); + } + if (tmp !== 0) { + result -= $pow(2, shift); + } + return result; + */ +}; diff --git a/node_modules/es-abstract/2023/BinaryAnd.js b/node_modules/es-abstract/2023/BinaryAnd.js new file mode 100644 index 0000000000000000000000000000000000000000..bb361dea6141f1b0d447cb06b5ee18e96ea426ce --- /dev/null +++ b/node_modules/es-abstract/2023/BinaryAnd.js @@ -0,0 +1,12 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +// https://262.ecma-international.org/11.0/#sec-binaryand + +module.exports = function BinaryAnd(x, y) { + if ((x !== 0 && x !== 1) || (y !== 0 && y !== 1)) { + throw new $TypeError('Assertion failed: `x` and `y` must be either 0 or 1'); + } + return x & y; +}; diff --git a/node_modules/es-abstract/2023/BinaryOr.js b/node_modules/es-abstract/2023/BinaryOr.js new file mode 100644 index 0000000000000000000000000000000000000000..76200f8744087b5c72020f4826d5bc8f55bd3886 --- /dev/null +++ b/node_modules/es-abstract/2023/BinaryOr.js @@ -0,0 +1,12 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +// https://262.ecma-international.org/11.0/#sec-binaryor + +module.exports = function BinaryOr(x, y) { + if ((x !== 0 && x !== 1) || (y !== 0 && y !== 1)) { + throw new $TypeError('Assertion failed: `x` and `y` must be either 0 or 1'); + } + return x | y; +}; diff --git a/node_modules/es-abstract/2023/BinaryXor.js b/node_modules/es-abstract/2023/BinaryXor.js new file mode 100644 index 0000000000000000000000000000000000000000..c1da53b26c67c6379ceaa50349f7861827eb6e10 --- /dev/null +++ b/node_modules/es-abstract/2023/BinaryXor.js @@ -0,0 +1,12 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +// https://262.ecma-international.org/11.0/#sec-binaryxor + +module.exports = function BinaryXor(x, y) { + if ((x !== 0 && x !== 1) || (y !== 0 && y !== 1)) { + throw new $TypeError('Assertion failed: `x` and `y` must be either 0 or 1'); + } + return x ^ y; +}; diff --git a/node_modules/es-abstract/2023/ByteListBitwiseOp.js b/node_modules/es-abstract/2023/ByteListBitwiseOp.js new file mode 100644 index 0000000000000000000000000000000000000000..7aba5bc6346a74cdb51b6070e1e6a8159783fce0 --- /dev/null +++ b/node_modules/es-abstract/2023/ByteListBitwiseOp.js @@ -0,0 +1,39 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var IsArray = require('./IsArray'); + +var isByteValue = require('../helpers/isByteValue'); + +// https://262.ecma-international.org/12.0/#sec-bytelistbitwiseop + +module.exports = function ByteListBitwiseOp(op, xBytes, yBytes) { + if (op !== '&' && op !== '^' && op !== '|') { + throw new $TypeError('Assertion failed: `op` must be `&`, `^`, or `|`'); + } + if (!IsArray(xBytes) || !IsArray(yBytes) || xBytes.length !== yBytes.length) { + throw new $TypeError('Assertion failed: `xBytes` and `yBytes` must be same-length sequences of byte values (an integer 0-255, inclusive)'); + } + + var result = []; + + for (var i = 0; i < xBytes.length; i += 1) { + var xByte = xBytes[i]; + var yByte = yBytes[i]; + if (!isByteValue(xByte) || !isByteValue(yByte)) { + throw new $TypeError('Assertion failed: `xBytes` and `yBytes` must be same-length sequences of byte values (an integer 0-255, inclusive)'); + } + var resultByte; + if (op === '&') { + resultByte = xByte & yByte; + } else if (op === '^') { + resultByte = xByte ^ yByte; + } else { + resultByte = xByte | yByte; + } + result[result.length] = resultByte; + } + + return result; +}; diff --git a/node_modules/es-abstract/2023/ByteListEqual.js b/node_modules/es-abstract/2023/ByteListEqual.js new file mode 100644 index 0000000000000000000000000000000000000000..b581cbba25a97b6211880bf53391bfcde3986715 --- /dev/null +++ b/node_modules/es-abstract/2023/ByteListEqual.js @@ -0,0 +1,31 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var IsArray = require('./IsArray'); + +var isByteValue = require('../helpers/isByteValue'); + +// https://262.ecma-international.org/12.0/#sec-bytelistequal + +module.exports = function ByteListEqual(xBytes, yBytes) { + if (!IsArray(xBytes) || !IsArray(yBytes)) { + throw new $TypeError('Assertion failed: `xBytes` and `yBytes` must be sequences of byte values (an integer 0-255, inclusive)'); + } + + if (xBytes.length !== yBytes.length) { + return false; + } + + for (var i = 0; i < xBytes.length; i += 1) { + var xByte = xBytes[i]; + var yByte = yBytes[i]; + if (!isByteValue(xByte) || !isByteValue(yByte)) { + throw new $TypeError('Assertion failed: `xBytes` and `yBytes` must be sequences of byte values (an integer 0-255, inclusive)'); + } + if (xByte !== yByte) { + return false; + } + } + return true; +}; diff --git a/node_modules/es-abstract/2023/Call.js b/node_modules/es-abstract/2023/Call.js new file mode 100644 index 0000000000000000000000000000000000000000..90b3519cb954848f531c4921eaa79ec7d37d06bd --- /dev/null +++ b/node_modules/es-abstract/2023/Call.js @@ -0,0 +1,20 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); +var callBound = require('call-bound'); + +var $TypeError = require('es-errors/type'); + +var IsArray = require('./IsArray'); + +var $apply = GetIntrinsic('%Reflect.apply%', true) || callBound('Function.prototype.apply'); + +// https://262.ecma-international.org/6.0/#sec-call + +module.exports = function Call(F, V) { + var argumentsList = arguments.length > 2 ? arguments[2] : []; + if (!IsArray(argumentsList)) { + throw new $TypeError('Assertion failed: optional `argumentsList`, if provided, must be a List'); + } + return $apply(F, V, argumentsList); +}; diff --git a/node_modules/es-abstract/2023/CanBeHeldWeakly.js b/node_modules/es-abstract/2023/CanBeHeldWeakly.js new file mode 100644 index 0000000000000000000000000000000000000000..9f32ece50f652cf7c6e563e441b05c3965cc0f5f --- /dev/null +++ b/node_modules/es-abstract/2023/CanBeHeldWeakly.js @@ -0,0 +1,17 @@ +'use strict'; + +var isObject = require('es-object-atoms/isObject'); + +var KeyForSymbol = require('./KeyForSymbol'); + +// https://262.ecma-international.org/14.0/#sec-canbeheldweakly + +module.exports = function CanBeHeldWeakly(v) { + if (isObject(v)) { + return true; // step 1 + } + if (typeof v === 'symbol' && typeof KeyForSymbol(v) === 'undefined') { + return true; // step 2 + } + return false; // step 3 +}; diff --git a/node_modules/es-abstract/2023/CanonicalNumericIndexString.js b/node_modules/es-abstract/2023/CanonicalNumericIndexString.js new file mode 100644 index 0000000000000000000000000000000000000000..74ed02f050d21c13dbfc06c80c21ae20a8e530ee --- /dev/null +++ b/node_modules/es-abstract/2023/CanonicalNumericIndexString.js @@ -0,0 +1,19 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var SameValue = require('./SameValue'); +var ToNumber = require('./ToNumber'); +var ToString = require('./ToString'); + +// https://262.ecma-international.org/6.0/#sec-canonicalnumericindexstring + +module.exports = function CanonicalNumericIndexString(argument) { + if (typeof argument !== 'string') { + throw new $TypeError('Assertion failed: `argument` must be a String'); + } + if (argument === '-0') { return -0; } + var n = ToNumber(argument); + if (SameValue(ToString(n), argument)) { return n; } + return void 0; +}; diff --git a/node_modules/es-abstract/2023/Canonicalize.js b/node_modules/es-abstract/2023/Canonicalize.js new file mode 100644 index 0000000000000000000000000000000000000000..849d2138719e79487ec128f52b9e8b2b91671ef6 --- /dev/null +++ b/node_modules/es-abstract/2023/Canonicalize.js @@ -0,0 +1,52 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var callBound = require('call-bound'); +var hasOwn = require('hasown'); + +var $charCodeAt = callBound('String.prototype.charCodeAt'); +var $toUpperCase = callBound('String.prototype.toUpperCase'); + +var isRegExpRecord = require('../helpers/records/regexp-record'); +var caseFolding = require('../helpers/caseFolding.json'); + +// https://262.ecma-international.org/14.0/#sec-runtime-semantics-canonicalize-ch + +module.exports = function Canonicalize(rer, ch) { + if (!isRegExpRecord(rer)) { + throw new $TypeError('Assertion failed: `rer` must be a RegExp Record'); + } + + if (typeof ch !== 'string') { + throw new $TypeError('Assertion failed: `ch` must be a character'); + } + + if (rer['[[Unicode]]'] && rer['[[IgnoreCase]]']) { // step 1 + if (hasOwn(caseFolding.C, ch)) { + return caseFolding.C[ch]; + } + if (hasOwn(caseFolding.S, ch)) { + return caseFolding.S[ch]; + } + return ch; // step 1.b + } + + if (!rer['[[IgnoreCase]]']) { + return ch; // step 2 + } + + var u = $toUpperCase(ch); // step 5 + + if (u.length !== 1) { + return ch; // step 7 + } + + var cu = u; // step 8 + + if ($charCodeAt(ch, 0) >= 128 && $charCodeAt(cu, 0) < 128) { + return ch; // step 9 + } + + return cu; // step 10 +}; diff --git a/node_modules/es-abstract/2023/CharacterRange.js b/node_modules/es-abstract/2023/CharacterRange.js new file mode 100644 index 0000000000000000000000000000000000000000..e41cb7870a7411344a21dfe7fbfc7cd6888b7c9e --- /dev/null +++ b/node_modules/es-abstract/2023/CharacterRange.js @@ -0,0 +1,53 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); +var callBound = require('call-bound'); + +var $fromCharCode = GetIntrinsic('%String.fromCharCode%'); +var $TypeError = require('es-errors/type'); +var $charCodeAt = callBound('String.prototype.charCodeAt'); + +var CharSet = require('../helpers/CharSet').CharSet; + +module.exports = function CharacterRange(A, B) { + var a; + var b; + + if (A instanceof CharSet || B instanceof CharSet) { + if (!(A instanceof CharSet) || !(B instanceof CharSet)) { + throw new $TypeError('Assertion failed: CharSets A and B are not both CharSets'); + } + + A.yield(function (c) { + if (typeof a !== 'undefined') { + throw new $TypeError('Assertion failed: CharSet A has more than one character'); + } + a = c; + }); + B.yield(function (c) { + if (typeof b !== 'undefined') { + throw new $TypeError('Assertion failed: CharSet B has more than one character'); + } + b = c; + }); + } else { + if (A.length !== 1 || B.length !== 1) { + throw new $TypeError('Assertion failed: CharSets A and B contain exactly one character'); + } + a = A[0]; + b = B[0]; + } + + var i = $charCodeAt(a, 0); + var j = $charCodeAt(b, 0); + + if (!(i <= j)) { + throw new $TypeError('Assertion failed: i is not <= j'); + } + + var arr = []; + for (var k = i; k <= j; k += 1) { + arr[arr.length] = $fromCharCode(k); + } + return arr; +}; diff --git a/node_modules/es-abstract/2023/ClearKeptObjects.js b/node_modules/es-abstract/2023/ClearKeptObjects.js new file mode 100644 index 0000000000000000000000000000000000000000..50bd4a5da4199b973650ca675584246ef492edac --- /dev/null +++ b/node_modules/es-abstract/2023/ClearKeptObjects.js @@ -0,0 +1,12 @@ +'use strict'; + +var SLOT = require('internal-slot'); +var keptObjects = []; + +// https://262.ecma-international.org/12.0/#sec-clear-kept-objects + +module.exports = function ClearKeptObjects() { + keptObjects.length = 0; +}; + +SLOT.set(module.exports, '[[es-abstract internal: KeptAlive]]', keptObjects); diff --git a/node_modules/es-abstract/2023/CloneArrayBuffer.js b/node_modules/es-abstract/2023/CloneArrayBuffer.js new file mode 100644 index 0000000000000000000000000000000000000000..27c8ba96184211b7d06388f9f7302f8f4e293638 --- /dev/null +++ b/node_modules/es-abstract/2023/CloneArrayBuffer.js @@ -0,0 +1,46 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var GetPrototypeFromConstructor = require('./GetPrototypeFromConstructor'); +var IsConstructor = require('./IsConstructor'); +var IsDetachedBuffer = require('./IsDetachedBuffer'); +var OrdinarySetPrototypeOf = require('./OrdinarySetPrototypeOf'); + +var isInteger = require('math-intrinsics/isInteger'); +var isArrayBuffer = require('is-array-buffer'); +var arrayBufferSlice = require('arraybuffer.prototype.slice'); + +// https://262.ecma-international.org/12.0/#sec-clonearraybuffer + +module.exports = function CloneArrayBuffer(srcBuffer, srcByteOffset, srcLength, cloneConstructor) { + if (!isArrayBuffer(srcBuffer)) { + throw new $TypeError('Assertion failed: `srcBuffer` must be an ArrayBuffer instance'); + } + if (!isInteger(srcByteOffset) || srcByteOffset < 0) { + throw new $TypeError('Assertion failed: `srcByteOffset` must be a non-negative integer'); + } + if (!isInteger(srcLength) || srcLength < 0) { + throw new $TypeError('Assertion failed: `srcLength` must be a non-negative integer'); + } + if (!IsConstructor(cloneConstructor)) { + throw new $TypeError('Assertion failed: `cloneConstructor` must be a constructor'); + } + + // 3. Let targetBuffer be ? AllocateArrayBuffer(cloneConstructor, srcLength). + var proto = GetPrototypeFromConstructor(cloneConstructor, '%ArrayBufferPrototype%'); // step 3, kinda + + if (IsDetachedBuffer(srcBuffer)) { + throw new $TypeError('`srcBuffer` must not be a detached ArrayBuffer'); // step 4 + } + + /* + 5. Let srcBlock be srcBuffer.[[ArrayBufferData]]. + 6. Let targetBlock be targetBuffer.[[ArrayBufferData]]. + 7. Perform CopyDataBlockBytes(targetBlock, 0, srcBlock, srcByteOffset, srcLength). + */ + var targetBuffer = arrayBufferSlice(srcBuffer, srcByteOffset, srcByteOffset + srcLength); // steps 5-7 + OrdinarySetPrototypeOf(targetBuffer, proto); // step 3 + + return targetBuffer; // step 8 +}; diff --git a/node_modules/es-abstract/2023/CodePointAt.js b/node_modules/es-abstract/2023/CodePointAt.js new file mode 100644 index 0000000000000000000000000000000000000000..466d11cb64df54d4dd73c331b83903069323e526 --- /dev/null +++ b/node_modules/es-abstract/2023/CodePointAt.js @@ -0,0 +1,55 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var callBound = require('call-bound'); +var isLeadingSurrogate = require('../helpers/isLeadingSurrogate'); +var isTrailingSurrogate = require('../helpers/isTrailingSurrogate'); + +var UTF16SurrogatePairToCodePoint = require('./UTF16SurrogatePairToCodePoint'); + +var $charAt = callBound('String.prototype.charAt'); +var $charCodeAt = callBound('String.prototype.charCodeAt'); + +// https://262.ecma-international.org/12.0/#sec-codepointat + +module.exports = function CodePointAt(string, position) { + if (typeof string !== 'string') { + throw new $TypeError('Assertion failed: `string` must be a String'); + } + var size = string.length; + if (position < 0 || position >= size) { + throw new $TypeError('Assertion failed: `position` must be >= 0, and < the length of `string`'); + } + var first = $charCodeAt(string, position); + var cp = $charAt(string, position); + var firstIsLeading = isLeadingSurrogate(first); + var firstIsTrailing = isTrailingSurrogate(first); + if (!firstIsLeading && !firstIsTrailing) { + return { + '[[CodePoint]]': cp, + '[[CodeUnitCount]]': 1, + '[[IsUnpairedSurrogate]]': false + }; + } + if (firstIsTrailing || (position + 1 === size)) { + return { + '[[CodePoint]]': cp, + '[[CodeUnitCount]]': 1, + '[[IsUnpairedSurrogate]]': true + }; + } + var second = $charCodeAt(string, position + 1); + if (!isTrailingSurrogate(second)) { + return { + '[[CodePoint]]': cp, + '[[CodeUnitCount]]': 1, + '[[IsUnpairedSurrogate]]': true + }; + } + + return { + '[[CodePoint]]': UTF16SurrogatePairToCodePoint(first, second), + '[[CodeUnitCount]]': 2, + '[[IsUnpairedSurrogate]]': false + }; +}; diff --git a/node_modules/es-abstract/2023/CodePointsToString.js b/node_modules/es-abstract/2023/CodePointsToString.js new file mode 100644 index 0000000000000000000000000000000000000000..c15bcb4c93be5996162f356749622a1d104de7af --- /dev/null +++ b/node_modules/es-abstract/2023/CodePointsToString.js @@ -0,0 +1,25 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var UTF16EncodeCodePoint = require('./UTF16EncodeCodePoint'); +var IsArray = require('./IsArray'); + +var forEach = require('../helpers/forEach'); +var isCodePoint = require('../helpers/isCodePoint'); + +// https://262.ecma-international.org/12.0/#sec-codepointstostring + +module.exports = function CodePointsToString(text) { + if (!IsArray(text)) { + throw new $TypeError('Assertion failed: `text` must be a sequence of Unicode Code Points'); + } + var result = ''; + forEach(text, function (cp) { + if (!isCodePoint(cp)) { + throw new $TypeError('Assertion failed: `text` must be a sequence of Unicode Code Points'); + } + result += UTF16EncodeCodePoint(cp); + }); + return result; +}; diff --git a/node_modules/es-abstract/2023/CompareArrayElements.js b/node_modules/es-abstract/2023/CompareArrayElements.js new file mode 100644 index 0000000000000000000000000000000000000000..12dddc3c08a8d70e2249cf43594a493f384bb242 --- /dev/null +++ b/node_modules/es-abstract/2023/CompareArrayElements.js @@ -0,0 +1,50 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var Call = require('./Call'); +var IsLessThan = require('./IsLessThan'); +var ToNumber = require('./ToNumber'); +var ToString = require('./ToString'); + +var isNaN = require('math-intrinsics/isNaN'); + +// https://262.ecma-international.org/14.0/#sec-comparearrayelements + +module.exports = function CompareArrayElements(x, y, compareFn) { + if (typeof compareFn !== 'function' && typeof compareFn !== 'undefined') { + throw new $TypeError('Assertion failed: `compareFn` must be a function or undefined'); + } + + if (typeof x === 'undefined' && typeof y === 'undefined') { + return 0; // step 1 + } + + if (typeof x === 'undefined') { + return 1; // step 2 + } + + if (typeof y === 'undefined') { + return -1; // step 3 + } + + if (typeof compareFn !== 'undefined') { // step 4 + var v = ToNumber(Call(compareFn, void undefined, [x, y])); // step 4.a + if (isNaN(v)) { + return 0; // step 4.b + } + return v; // step 4.c + } + + var xString = ToString(x); // step 5 + var yString = ToString(y); // step 6 + var xSmaller = IsLessThan(xString, yString, true); // step 7 + if (xSmaller) { + return -1; // step 8 + } + var ySmaller = IsLessThan(yString, xString, true); // step 9 + if (ySmaller) { + return 1; // step 10 + } + return 0; // step 11 +}; diff --git a/node_modules/es-abstract/2023/CompareTypedArrayElements.js b/node_modules/es-abstract/2023/CompareTypedArrayElements.js new file mode 100644 index 0000000000000000000000000000000000000000..5c68925f5afdf5f6d0ff417f077d1ec24b297ef0 --- /dev/null +++ b/node_modules/es-abstract/2023/CompareTypedArrayElements.js @@ -0,0 +1,60 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var Call = require('./Call'); +var SameValue = require('./SameValue'); +var ToNumber = require('./ToNumber'); + +var isNaN = require('math-intrinsics/isNaN'); + +// https://262.ecma-international.org/14.0/#sec-comparetypedarrayelements + +module.exports = function CompareTypedArrayElements(x, y, compareFn) { + if ((typeof x !== 'number' && typeof x !== 'bigint') || typeof x !== typeof y) { + throw new $TypeError('Assertion failed: `x` and `y` must be either a BigInt or a Number, and both must be the same type'); + } + if (typeof compareFn !== 'function' && typeof compareFn !== 'undefined') { + throw new $TypeError('Assertion failed: `compareFn` must be a function or undefined'); + } + + if (typeof compareFn !== 'undefined') { // step 2 + var v = ToNumber(Call(compareFn, void undefined, [x, y])); // step 2.a + if (isNaN(v)) { + return 0; // step 2.b + } + return v; // step 2.c + } + + var xNaN = isNaN(x); + var yNaN = isNaN(y); + if (xNaN && yNaN) { + return 0; // step 3 + } + + if (xNaN) { + return 1; // step 4 + } + + if (yNaN) { + return -1; // step 5 + } + + if (x < y) { + return -1; // step 6 + } + + if (x > y) { + return 1; // step 7 + } + + if (SameValue(x, -0) && SameValue(y, 0)) { + return -1; // step 8 + } + + if (SameValue(x, 0) && SameValue(y, -0)) { + return 1; // step 9 + } + + return 0; // step 10 +}; diff --git a/node_modules/es-abstract/2023/CompletePropertyDescriptor.js b/node_modules/es-abstract/2023/CompletePropertyDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..8c9e3f441111638a3b3c9fd69857d3da22c779ee --- /dev/null +++ b/node_modules/es-abstract/2023/CompletePropertyDescriptor.js @@ -0,0 +1,43 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var hasOwn = require('hasown'); + +var IsDataDescriptor = require('./IsDataDescriptor'); +var IsGenericDescriptor = require('./IsGenericDescriptor'); + +var isPropertyDescriptor = require('../helpers/records/property-descriptor'); + +// https://262.ecma-international.org/6.0/#sec-completepropertydescriptor + +module.exports = function CompletePropertyDescriptor(Desc) { + if (!isPropertyDescriptor(Desc)) { + throw new $TypeError('Assertion failed: `Desc` must be a Property Descriptor'); + } + + /* eslint no-param-reassign: 0 */ + + if (IsGenericDescriptor(Desc) || IsDataDescriptor(Desc)) { + if (!hasOwn(Desc, '[[Value]]')) { + Desc['[[Value]]'] = void 0; + } + if (!hasOwn(Desc, '[[Writable]]')) { + Desc['[[Writable]]'] = false; + } + } else { + if (!hasOwn(Desc, '[[Get]]')) { + Desc['[[Get]]'] = void 0; + } + if (!hasOwn(Desc, '[[Set]]')) { + Desc['[[Set]]'] = void 0; + } + } + if (!hasOwn(Desc, '[[Enumerable]]')) { + Desc['[[Enumerable]]'] = false; + } + if (!hasOwn(Desc, '[[Configurable]]')) { + Desc['[[Configurable]]'] = false; + } + return Desc; +}; diff --git a/node_modules/es-abstract/2023/CompletionRecord.js b/node_modules/es-abstract/2023/CompletionRecord.js new file mode 100644 index 0000000000000000000000000000000000000000..0a7a6817c87e69578cfbc5546901b1c4dba112a9 --- /dev/null +++ b/node_modules/es-abstract/2023/CompletionRecord.js @@ -0,0 +1,48 @@ +'use strict'; + +var $SyntaxError = require('es-errors/syntax'); + +var SLOT = require('internal-slot'); + +// https://262.ecma-international.org/7.0/#sec-completion-record-specification-type + +var CompletionRecord = function CompletionRecord(type, value) { + if (!(this instanceof CompletionRecord)) { + return new CompletionRecord(type, value); + } + if (type !== 'normal' && type !== 'break' && type !== 'continue' && type !== 'return' && type !== 'throw') { + throw new $SyntaxError('Assertion failed: `type` must be one of "normal", "break", "continue", "return", or "throw"'); + } + SLOT.set(this, '[[Type]]', type); + SLOT.set(this, '[[Value]]', value); + // [[Target]] slot? +}; + +CompletionRecord.prototype.type = function Type() { + return SLOT.get(this, '[[Type]]'); +}; + +CompletionRecord.prototype.value = function Value() { + return SLOT.get(this, '[[Value]]'); +}; + +CompletionRecord.prototype['?'] = function ReturnIfAbrupt() { + var type = SLOT.get(this, '[[Type]]'); + var value = SLOT.get(this, '[[Value]]'); + + if (type === 'throw') { + throw value; + } + return value; +}; + +CompletionRecord.prototype['!'] = function assert() { + var type = SLOT.get(this, '[[Type]]'); + + if (type !== 'normal') { + throw new $SyntaxError('Assertion failed: Completion Record is not of type "normal"'); + } + return SLOT.get(this, '[[Value]]'); +}; + +module.exports = CompletionRecord; diff --git a/node_modules/es-abstract/2023/CopyDataProperties.js b/node_modules/es-abstract/2023/CopyDataProperties.js new file mode 100644 index 0000000000000000000000000000000000000000..182720710e8b97fc0ed0f09cb7743aeb4baae938 --- /dev/null +++ b/node_modules/es-abstract/2023/CopyDataProperties.js @@ -0,0 +1,69 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); +var callBound = require('call-bound'); +var OwnPropertyKeys = require('own-keys'); + +var forEach = require('../helpers/forEach'); +var every = require('../helpers/every'); +var some = require('../helpers/some'); + +var $isEnumerable = callBound('Object.prototype.propertyIsEnumerable'); + +var CreateDataPropertyOrThrow = require('./CreateDataPropertyOrThrow'); +var Get = require('./Get'); +var IsArray = require('./IsArray'); +var isPropertyKey = require('../helpers/isPropertyKey'); +var SameValue = require('./SameValue'); +var ToNumber = require('./ToNumber'); +var ToObject = require('./ToObject'); + +var isInteger = require('math-intrinsics/isInteger'); + +// https://262.ecma-international.org/12.0/#sec-copydataproperties + +module.exports = function CopyDataProperties(target, source, excludedItems) { + if (!isObject(target)) { + throw new $TypeError('Assertion failed: "target" must be an Object'); + } + + if (!IsArray(excludedItems) || !every(excludedItems, isPropertyKey)) { + throw new $TypeError('Assertion failed: "excludedItems" must be a List of Property Keys'); + } + + if (typeof source === 'undefined' || source === null) { + return target; + } + + var from = ToObject(source); + + var keys = OwnPropertyKeys(from); + forEach(keys, function (nextKey) { + var excluded = some(excludedItems, function (e) { + return SameValue(e, nextKey) === true; + }); + /* + var excluded = false; + + forEach(excludedItems, function (e) { + if (SameValue(e, nextKey) === true) { + excluded = true; + } + }); + */ + + var enumerable = $isEnumerable(from, nextKey) || ( + // this is to handle string keys being non-enumerable in older engines + typeof source === 'string' + && nextKey >= 0 + && isInteger(ToNumber(nextKey)) + ); + if (excluded === false && enumerable) { + var propValue = Get(from, nextKey); + CreateDataPropertyOrThrow(target, nextKey, propValue); + } + }); + + return target; +}; diff --git a/node_modules/es-abstract/2023/CreateAsyncFromSyncIterator.js b/node_modules/es-abstract/2023/CreateAsyncFromSyncIterator.js new file mode 100644 index 0000000000000000000000000000000000000000..e1895a145020bea60fd81627f61cedd20a7ba7a2 --- /dev/null +++ b/node_modules/es-abstract/2023/CreateAsyncFromSyncIterator.js @@ -0,0 +1,137 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $SyntaxError = require('es-errors/syntax'); +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); +var $Promise = GetIntrinsic('%Promise%', true); + +var AsyncFromSyncIteratorContinuation = require('./AsyncFromSyncIteratorContinuation'); +var Call = require('./Call'); +var CreateIterResultObject = require('./CreateIterResultObject'); +var Get = require('./Get'); +var GetMethod = require('./GetMethod'); +var IteratorNext = require('./IteratorNext'); +var OrdinaryObjectCreate = require('./OrdinaryObjectCreate'); + +var isIteratorRecord = require('../helpers/records/iterator-record-2023'); + +var SLOT = require('internal-slot'); + +var $AsyncFromSyncIteratorPrototype = GetIntrinsic('%AsyncFromSyncIteratorPrototype%', true) || { + next: function next(value) { + if (!$Promise) { + throw new $SyntaxError('This environment does not support Promises.'); + } + + var O = this; // step 1 + + SLOT.assert(O, '[[SyncIteratorRecord]]'); // step 2 + + var argsLength = arguments.length; + + return new $Promise(function (resolve) { // step 3 + var syncIteratorRecord = SLOT.get(O, '[[SyncIteratorRecord]]'); // step 4 + var result; + if (argsLength > 0) { + result = IteratorNext(syncIteratorRecord, value); // step 5.a + } else { // step 6 + result = IteratorNext(syncIteratorRecord);// step 6.a + } + resolve(AsyncFromSyncIteratorContinuation(result)); // step 8 + }); + }, + 'return': function () { + if (!$Promise) { + throw new $SyntaxError('This environment does not support Promises.'); + } + + var O = this; // step 1 + + SLOT.assert(O, '[[SyncIteratorRecord]]'); // step 2 + + var valueIsPresent = arguments.length > 0; + var value = valueIsPresent ? arguments[0] : void undefined; + + return new $Promise(function (resolve, reject) { // step 3 + var syncIterator = SLOT.get(O, '[[SyncIteratorRecord]]')['[[Iterator]]']; // step 4 + var iteratorReturn = GetMethod(syncIterator, 'return'); // step 5 + + if (typeof iteratorReturn === 'undefined') { // step 7 + var iterResult = CreateIterResultObject(value, true); // step 7.a + Call(resolve, undefined, [iterResult]); // step 7.b + return; + } + var result; + if (valueIsPresent) { // step 8 + result = Call(iteratorReturn, syncIterator, [value]); // step 8.a + } else { // step 9 + result = Call(iteratorReturn, syncIterator); // step 9.a + } + if (!isObject(result)) { // step 11 + Call(reject, undefined, [new $TypeError('Iterator `return` method returned a non-object value.')]); // step 11.a + return; + } + + resolve(AsyncFromSyncIteratorContinuation(result)); // step 12 + }); + }, + 'throw': function () { + if (!$Promise) { + throw new $SyntaxError('This environment does not support Promises.'); + } + + var O = this; // step 1 + + SLOT.assert(O, '[[SyncIteratorRecord]]'); // step 2 + + var valueIsPresent = arguments.length > 0; + var value = valueIsPresent ? arguments[0] : void undefined; + + return new $Promise(function (resolve, reject) { // step 3 + var syncIterator = SLOT.get(O, '[[SyncIteratorRecord]]')['[[Iterator]]']; // step 4 + + var throwMethod = GetMethod(syncIterator, 'throw'); // step 5 + + if (typeof throwMethod === 'undefined') { // step 7 + Call(reject, undefined, [value]); // step 7.a + return; + } + + var result; + if (valueIsPresent) { // step 8 + result = Call(throwMethod, syncIterator, [value]); // step 8.a + } else { // step 9 + result = Call(throwMethod, syncIterator); // step 9.a + } + if (!isObject(result)) { // step 11 + Call(reject, undefined, [new $TypeError('Iterator `throw` method returned a non-object value.')]); // step 11.a + return; + } + + resolve(AsyncFromSyncIteratorContinuation(result/* , promiseCapability */)); // step 12 + }); + } +}; + +// https://262.ecma-international.org/14.0/#sec-createasyncfromsynciterator + +module.exports = function CreateAsyncFromSyncIterator(syncIteratorRecord) { + if (!isIteratorRecord(syncIteratorRecord)) { + throw new $TypeError('Assertion failed: `syncIteratorRecord` must be an Iterator Record'); + } + + // var asyncIterator = OrdinaryObjectCreate(%AsyncFromSyncIteratorPrototype%, « [[SyncIteratorRecord]] »); // step 1 + var asyncIterator = OrdinaryObjectCreate($AsyncFromSyncIteratorPrototype); + + SLOT.set(asyncIterator, '[[SyncIteratorRecord]]', syncIteratorRecord); // step 2 + + var nextMethod = Get(asyncIterator, 'next'); // step 3 + + return { // steps 3-4 + '[[Iterator]]': asyncIterator, + '[[NextMethod]]': nextMethod, + '[[Done]]': false + }; +}; diff --git a/node_modules/es-abstract/2023/CreateDataProperty.js b/node_modules/es-abstract/2023/CreateDataProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..897617c0ca1e0365cb55a83855b0983550e3e298 --- /dev/null +++ b/node_modules/es-abstract/2023/CreateDataProperty.js @@ -0,0 +1,25 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var isPropertyKey = require('../helpers/isPropertyKey'); +var OrdinaryDefineOwnProperty = require('./OrdinaryDefineOwnProperty'); + +// https://262.ecma-international.org/6.0/#sec-createdataproperty + +module.exports = function CreateDataProperty(O, P, V) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: P is not a Property Key'); + } + var newDesc = { + '[[Configurable]]': true, + '[[Enumerable]]': true, + '[[Value]]': V, + '[[Writable]]': true + }; + return OrdinaryDefineOwnProperty(O, P, newDesc); +}; diff --git a/node_modules/es-abstract/2023/CreateDataPropertyOrThrow.js b/node_modules/es-abstract/2023/CreateDataPropertyOrThrow.js new file mode 100644 index 0000000000000000000000000000000000000000..bca5b077405e87db24ab5d01f62ac88244db79ff --- /dev/null +++ b/node_modules/es-abstract/2023/CreateDataPropertyOrThrow.js @@ -0,0 +1,23 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var CreateDataProperty = require('./CreateDataProperty'); + +var isPropertyKey = require('../helpers/isPropertyKey'); + +// // https://262.ecma-international.org/14.0/#sec-createdatapropertyorthrow + +module.exports = function CreateDataPropertyOrThrow(O, P, V) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: P is not a Property Key'); + } + var success = CreateDataProperty(O, P, V); + if (!success) { + throw new $TypeError('unable to create data property'); + } +}; diff --git a/node_modules/es-abstract/2023/CreateHTML.js b/node_modules/es-abstract/2023/CreateHTML.js new file mode 100644 index 0000000000000000000000000000000000000000..25630f43085954792b398e93a870ac78b46e3fc4 --- /dev/null +++ b/node_modules/es-abstract/2023/CreateHTML.js @@ -0,0 +1,27 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var callBound = require('call-bound'); + +var $replace = callBound('String.prototype.replace'); + +var RequireObjectCoercible = require('./RequireObjectCoercible'); +var ToString = require('./ToString'); + +// https://262.ecma-international.org/6.0/#sec-createhtml + +module.exports = function CreateHTML(string, tag, attribute, value) { + if (typeof tag !== 'string' || typeof attribute !== 'string') { + throw new $TypeError('Assertion failed: `tag` and `attribute` must be strings'); + } + var str = RequireObjectCoercible(string); + var S = ToString(str); + var p1 = '<' + tag; + if (attribute !== '') { + var V = ToString(value); + var escapedV = $replace(V, /\x22/g, '"'); + p1 += '\x20' + attribute + '\x3D\x22' + escapedV + '\x22'; + } + return p1 + '>' + S + ''; +}; diff --git a/node_modules/es-abstract/2023/CreateIterResultObject.js b/node_modules/es-abstract/2023/CreateIterResultObject.js new file mode 100644 index 0000000000000000000000000000000000000000..679bdf00ea851b40cce0dc9e6d55526aa9d5c5d7 --- /dev/null +++ b/node_modules/es-abstract/2023/CreateIterResultObject.js @@ -0,0 +1,15 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +// https://262.ecma-international.org/6.0/#sec-createiterresultobject + +module.exports = function CreateIterResultObject(value, done) { + if (typeof done !== 'boolean') { + throw new $TypeError('Assertion failed: Type(done) is not Boolean'); + } + return { + value: value, + done: done + }; +}; diff --git a/node_modules/es-abstract/2023/CreateListFromArrayLike.js b/node_modules/es-abstract/2023/CreateListFromArrayLike.js new file mode 100644 index 0000000000000000000000000000000000000000..3cd2d5c27a0867bd7a1fef684d6915a516544e32 --- /dev/null +++ b/node_modules/es-abstract/2023/CreateListFromArrayLike.js @@ -0,0 +1,44 @@ +'use strict'; + +var callBound = require('call-bound'); + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); +var $indexOf = callBound('Array.prototype.indexOf', true) || callBound('String.prototype.indexOf'); + +var Get = require('./Get'); +var IsArray = require('./IsArray'); +var LengthOfArrayLike = require('./LengthOfArrayLike'); +var ToString = require('./ToString'); +var Type = require('./Type'); + +var defaultElementTypes = ['Undefined', 'Null', 'Boolean', 'String', 'Symbol', 'Number', 'BigInt', 'Object']; + +// https://262.ecma-international.org/11.0/#sec-createlistfromarraylike + +module.exports = function CreateListFromArrayLike(obj) { + var elementTypes = arguments.length > 1 + ? arguments[1] + : defaultElementTypes; + + if (!isObject(obj)) { + throw new $TypeError('Assertion failed: `obj` must be an Object'); + } + if (!IsArray(elementTypes)) { + throw new $TypeError('Assertion failed: `elementTypes`, if provided, must be an array'); + } + var len = LengthOfArrayLike(obj); + var list = []; + var index = 0; + while (index < len) { + var indexName = ToString(index); + var next = Get(obj, indexName); + var nextType = Type(next); + if ($indexOf(elementTypes, nextType) < 0) { + throw new $TypeError('item type ' + nextType + ' is not a valid elementType'); + } + list[list.length] = next; + index += 1; + } + return list; +}; diff --git a/node_modules/es-abstract/2023/CreateMethodProperty.js b/node_modules/es-abstract/2023/CreateMethodProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..4c53a40986ad2c0f6678b161465bca1ba569dd21 --- /dev/null +++ b/node_modules/es-abstract/2023/CreateMethodProperty.js @@ -0,0 +1,38 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var DefineOwnProperty = require('../helpers/DefineOwnProperty'); + +var FromPropertyDescriptor = require('./FromPropertyDescriptor'); +var IsDataDescriptor = require('./IsDataDescriptor'); +var isPropertyKey = require('../helpers/isPropertyKey'); +var SameValue = require('./SameValue'); + +// https://262.ecma-international.org/6.0/#sec-createmethodproperty + +module.exports = function CreateMethodProperty(O, P, V) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: P is not a Property Key'); + } + + var newDesc = { + '[[Configurable]]': true, + '[[Enumerable]]': false, + '[[Value]]': V, + '[[Writable]]': true + }; + return DefineOwnProperty( + IsDataDescriptor, + SameValue, + FromPropertyDescriptor, + O, + P, + newDesc + ); +}; diff --git a/node_modules/es-abstract/2023/CreateNonEnumerableDataPropertyOrThrow.js b/node_modules/es-abstract/2023/CreateNonEnumerableDataPropertyOrThrow.js new file mode 100644 index 0000000000000000000000000000000000000000..5fc18ac2e0e9e296821337593b2568e4884b605d --- /dev/null +++ b/node_modules/es-abstract/2023/CreateNonEnumerableDataPropertyOrThrow.js @@ -0,0 +1,28 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var DefinePropertyOrThrow = require('./DefinePropertyOrThrow'); + +var isPropertyKey = require('../helpers/isPropertyKey'); + +// https://262.ecma-international.org/13.0/#sec-createnonenumerabledatapropertyorthrow + +module.exports = function CreateNonEnumerableDataPropertyOrThrow(O, P, V) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: P is not a Property Key'); + } + + var newDesc = { + '[[Configurable]]': true, + '[[Enumerable]]': false, + '[[Value]]': V, + '[[Writable]]': true + }; + return DefinePropertyOrThrow(O, P, newDesc); +}; diff --git a/node_modules/es-abstract/2023/CreateRegExpStringIterator.js b/node_modules/es-abstract/2023/CreateRegExpStringIterator.js new file mode 100644 index 0000000000000000000000000000000000000000..d7cc09963e2b8c33147bd8285d986e86d80201ea --- /dev/null +++ b/node_modules/es-abstract/2023/CreateRegExpStringIterator.js @@ -0,0 +1,100 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); +var hasSymbols = require('has-symbols')(); + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); +var IteratorPrototype = GetIntrinsic('%IteratorPrototype%', true); + +var AdvanceStringIndex = require('./AdvanceStringIndex'); +var CreateIterResultObject = require('./CreateIterResultObject'); +var CreateMethodProperty = require('./CreateMethodProperty'); +var Get = require('./Get'); +var OrdinaryObjectCreate = require('./OrdinaryObjectCreate'); +var RegExpExec = require('./RegExpExec'); +var Set = require('./Set'); +var ToLength = require('./ToLength'); +var ToString = require('./ToString'); + +var SLOT = require('internal-slot'); +var setToStringTag = require('es-set-tostringtag'); + +var RegExpStringIterator = function RegExpStringIterator(R, S, global, fullUnicode) { + if (typeof S !== 'string') { + throw new $TypeError('`S` must be a string'); + } + if (typeof global !== 'boolean') { + throw new $TypeError('`global` must be a boolean'); + } + if (typeof fullUnicode !== 'boolean') { + throw new $TypeError('`fullUnicode` must be a boolean'); + } + SLOT.set(this, '[[IteratingRegExp]]', R); + SLOT.set(this, '[[IteratedString]]', S); + SLOT.set(this, '[[Global]]', global); + SLOT.set(this, '[[Unicode]]', fullUnicode); + SLOT.set(this, '[[Done]]', false); +}; + +if (IteratorPrototype) { + RegExpStringIterator.prototype = OrdinaryObjectCreate(IteratorPrototype); +} + +var RegExpStringIteratorNext = function next() { + var O = this; + if (!isObject(O)) { + throw new $TypeError('receiver must be an object'); + } + if ( + !(O instanceof RegExpStringIterator) + || !SLOT.has(O, '[[IteratingRegExp]]') + || !SLOT.has(O, '[[IteratedString]]') + || !SLOT.has(O, '[[Global]]') + || !SLOT.has(O, '[[Unicode]]') + || !SLOT.has(O, '[[Done]]') + ) { + throw new $TypeError('"this" value must be a RegExpStringIterator instance'); + } + if (SLOT.get(O, '[[Done]]')) { + return CreateIterResultObject(undefined, true); + } + var R = SLOT.get(O, '[[IteratingRegExp]]'); + var S = SLOT.get(O, '[[IteratedString]]'); + var global = SLOT.get(O, '[[Global]]'); + var fullUnicode = SLOT.get(O, '[[Unicode]]'); + var match = RegExpExec(R, S); + if (match === null) { + SLOT.set(O, '[[Done]]', true); + return CreateIterResultObject(undefined, true); + } + if (global) { + var matchStr = ToString(Get(match, '0')); + if (matchStr === '') { + var thisIndex = ToLength(Get(R, 'lastIndex')); + var nextIndex = AdvanceStringIndex(S, thisIndex, fullUnicode); + Set(R, 'lastIndex', nextIndex, true); + } + return CreateIterResultObject(match, false); + } + SLOT.set(O, '[[Done]]', true); + return CreateIterResultObject(match, false); +}; +CreateMethodProperty(RegExpStringIterator.prototype, 'next', RegExpStringIteratorNext); + +if (hasSymbols) { + setToStringTag(RegExpStringIterator.prototype, 'RegExp String Iterator'); + + if (Symbol.iterator && typeof RegExpStringIterator.prototype[Symbol.iterator] !== 'function') { + var iteratorFn = function SymbolIterator() { + return this; + }; + CreateMethodProperty(RegExpStringIterator.prototype, Symbol.iterator, iteratorFn); + } +} + +// https://262.ecma-international.org/11.0/#sec-createregexpstringiterator +module.exports = function CreateRegExpStringIterator(R, S, global, fullUnicode) { + // assert R.global === global && R.unicode === fullUnicode? + return new RegExpStringIterator(R, S, global, fullUnicode); +}; diff --git a/node_modules/es-abstract/2023/DateFromTime.js b/node_modules/es-abstract/2023/DateFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..ec7edcd295f8bdd79eb60e44d8a17bb0b90fd80d --- /dev/null +++ b/node_modules/es-abstract/2023/DateFromTime.js @@ -0,0 +1,52 @@ +'use strict'; + +var $EvalError = require('es-errors/eval'); + +var DayWithinYear = require('./DayWithinYear'); +var InLeapYear = require('./InLeapYear'); +var MonthFromTime = require('./MonthFromTime'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.5 + +module.exports = function DateFromTime(t) { + var m = MonthFromTime(t); + var d = DayWithinYear(t); + if (m === 0) { + return d + 1; + } + if (m === 1) { + return d - 30; + } + var leap = InLeapYear(t); + if (m === 2) { + return d - 58 - leap; + } + if (m === 3) { + return d - 89 - leap; + } + if (m === 4) { + return d - 119 - leap; + } + if (m === 5) { + return d - 150 - leap; + } + if (m === 6) { + return d - 180 - leap; + } + if (m === 7) { + return d - 211 - leap; + } + if (m === 8) { + return d - 242 - leap; + } + if (m === 9) { + return d - 272 - leap; + } + if (m === 10) { + return d - 303 - leap; + } + if (m === 11) { + return d - 333 - leap; + } + throw new $EvalError('Assertion failed: MonthFromTime returned an impossible value: ' + m); +}; diff --git a/node_modules/es-abstract/2023/DateString.js b/node_modules/es-abstract/2023/DateString.js new file mode 100644 index 0000000000000000000000000000000000000000..8106127a7d9e7708279035a2488e66cd49bbd5cb --- /dev/null +++ b/node_modules/es-abstract/2023/DateString.js @@ -0,0 +1,27 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var weekdays = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']; +var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; + +var $isNaN = require('math-intrinsics/isNaN'); +var padTimeComponent = require('../helpers/padTimeComponent'); + +var DateFromTime = require('./DateFromTime'); +var MonthFromTime = require('./MonthFromTime'); +var WeekDay = require('./WeekDay'); +var YearFromTime = require('./YearFromTime'); + +// https://262.ecma-international.org/9.0/#sec-datestring + +module.exports = function DateString(tv) { + if (typeof tv !== 'number' || $isNaN(tv)) { + throw new $TypeError('Assertion failed: `tv` must be a non-NaN Number'); + } + var weekday = weekdays[WeekDay(tv)]; + var month = months[MonthFromTime(tv)]; + var day = padTimeComponent(DateFromTime(tv)); + var year = padTimeComponent(YearFromTime(tv), 4); + return weekday + '\x20' + month + '\x20' + day + '\x20' + year; +}; diff --git a/node_modules/es-abstract/2023/Day.js b/node_modules/es-abstract/2023/Day.js new file mode 100644 index 0000000000000000000000000000000000000000..51d01033c81cbd356ff4da8010c166137364237d --- /dev/null +++ b/node_modules/es-abstract/2023/Day.js @@ -0,0 +1,11 @@ +'use strict'; + +var floor = require('./floor'); + +var msPerDay = require('../helpers/timeConstants').msPerDay; + +// https://262.ecma-international.org/5.1/#sec-15.9.1.2 + +module.exports = function Day(t) { + return floor(t / msPerDay); +}; diff --git a/node_modules/es-abstract/2023/DayFromYear.js b/node_modules/es-abstract/2023/DayFromYear.js new file mode 100644 index 0000000000000000000000000000000000000000..341bf22a6c19352ec6225944fb49adeed22983e8 --- /dev/null +++ b/node_modules/es-abstract/2023/DayFromYear.js @@ -0,0 +1,10 @@ +'use strict'; + +var floor = require('./floor'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.3 + +module.exports = function DayFromYear(y) { + return (365 * (y - 1970)) + floor((y - 1969) / 4) - floor((y - 1901) / 100) + floor((y - 1601) / 400); +}; + diff --git a/node_modules/es-abstract/2023/DayWithinYear.js b/node_modules/es-abstract/2023/DayWithinYear.js new file mode 100644 index 0000000000000000000000000000000000000000..4c580940a58c58dcc3f7c2f96c5bca8e8237ebfc --- /dev/null +++ b/node_modules/es-abstract/2023/DayWithinYear.js @@ -0,0 +1,11 @@ +'use strict'; + +var Day = require('./Day'); +var DayFromYear = require('./DayFromYear'); +var YearFromTime = require('./YearFromTime'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.4 + +module.exports = function DayWithinYear(t) { + return Day(t) - DayFromYear(YearFromTime(t)); +}; diff --git a/node_modules/es-abstract/2023/DaysInYear.js b/node_modules/es-abstract/2023/DaysInYear.js new file mode 100644 index 0000000000000000000000000000000000000000..7116c69027022323e41130f384db7cc3d35709f9 --- /dev/null +++ b/node_modules/es-abstract/2023/DaysInYear.js @@ -0,0 +1,18 @@ +'use strict'; + +var modulo = require('./modulo'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.3 + +module.exports = function DaysInYear(y) { + if (modulo(y, 4) !== 0) { + return 365; + } + if (modulo(y, 100) !== 0) { + return 366; + } + if (modulo(y, 400) !== 0) { + return 365; + } + return 366; +}; diff --git a/node_modules/es-abstract/2023/DefaultTimeZone.js b/node_modules/es-abstract/2023/DefaultTimeZone.js new file mode 100644 index 0000000000000000000000000000000000000000..16ae745b25e3b4627ca13511a8f5b63c5ab4b197 --- /dev/null +++ b/node_modules/es-abstract/2023/DefaultTimeZone.js @@ -0,0 +1,18 @@ +'use strict'; + +var callBind = require('call-bind'); + +var I402 = typeof Intl === 'undefined' ? null : Intl; +var DateTimeFormat = !!I402 && I402.DateTimeFormat; +var resolvedOptions = !!DateTimeFormat && callBind(DateTimeFormat.prototype.resolvedOptions); + +// https://262.ecma-international.org/14.0/#sec-defaulttimezone +// https://tc39.es/ecma402/2023/#sup-defaulttimezone + +module.exports = function DefaultTimeZone() { + if (DateTimeFormat && resolvedOptions) { + return resolvedOptions(new DateTimeFormat()).timeZone; + + } + return 'UTC'; +}; diff --git a/node_modules/es-abstract/2023/DefineMethodProperty.js b/node_modules/es-abstract/2023/DefineMethodProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..f6eb168d4edebc7af367a994242bdd56f5f240e9 --- /dev/null +++ b/node_modules/es-abstract/2023/DefineMethodProperty.js @@ -0,0 +1,42 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var DefinePropertyOrThrow = require('./DefinePropertyOrThrow'); +var IsExtensible = require('./IsExtensible'); + +var isPropertyKey = require('../helpers/isPropertyKey'); + +// https://262.ecma-international.org/13.0/#sec-definemethodproperty + +module.exports = function DefineMethodProperty(homeObject, key, closure, enumerable) { + if (!isObject(homeObject)) { + throw new $TypeError('Assertion failed: `homeObject` is not an Object'); + } + if (!isPropertyKey(key)) { + throw new $TypeError('Assertion failed: `key` is not a Property Key or a Private Name'); + } + if (typeof closure !== 'function') { + throw new $TypeError('Assertion failed: `closure` is not a function'); + } + if (typeof enumerable !== 'boolean') { + throw new $TypeError('Assertion failed: `enumerable` is not a Boolean'); + } + + // 1. Assert: homeObject is an ordinary, extensible object with no non-configurable properties. + if (!IsExtensible(homeObject)) { + throw new $TypeError('Assertion failed: `homeObject` is not an ordinary, extensible object, with no non-configurable properties'); + } + + // 2. If key is a Private Name, then + // a. Return PrivateElement { [[Key]]: key, [[Kind]]: method, [[Value]]: closure }. + // 3. Else, + var desc = { // step 3.a + '[[Value]]': closure, + '[[Writable]]': true, + '[[Enumerable]]': enumerable, + '[[Configurable]]': true + }; + DefinePropertyOrThrow(homeObject, key, desc); // step 3.b +}; diff --git a/node_modules/es-abstract/2023/DefinePropertyOrThrow.js b/node_modules/es-abstract/2023/DefinePropertyOrThrow.js new file mode 100644 index 0000000000000000000000000000000000000000..ff6683c3dc954ec27c072032bfcc0cfd70936587 --- /dev/null +++ b/node_modules/es-abstract/2023/DefinePropertyOrThrow.js @@ -0,0 +1,39 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var isPropertyDescriptor = require('../helpers/records/property-descriptor'); +var DefineOwnProperty = require('../helpers/DefineOwnProperty'); + +var FromPropertyDescriptor = require('./FromPropertyDescriptor'); +var IsDataDescriptor = require('./IsDataDescriptor'); +var isPropertyKey = require('../helpers/isPropertyKey'); +var SameValue = require('./SameValue'); +var ToPropertyDescriptor = require('./ToPropertyDescriptor'); + +// https://262.ecma-international.org/6.0/#sec-definepropertyorthrow + +module.exports = function DefinePropertyOrThrow(O, P, desc) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: P is not a Property Key'); + } + + var Desc = isPropertyDescriptor(desc) ? desc : ToPropertyDescriptor(desc); + if (!isPropertyDescriptor(Desc)) { + throw new $TypeError('Assertion failed: Desc is not a valid Property Descriptor'); + } + + return DefineOwnProperty( + IsDataDescriptor, + SameValue, + FromPropertyDescriptor, + O, + P, + Desc + ); +}; diff --git a/node_modules/es-abstract/2023/DeletePropertyOrThrow.js b/node_modules/es-abstract/2023/DeletePropertyOrThrow.js new file mode 100644 index 0000000000000000000000000000000000000000..8841fda81f7663673367bdfc1af99794fb0ef747 --- /dev/null +++ b/node_modules/es-abstract/2023/DeletePropertyOrThrow.js @@ -0,0 +1,25 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var isPropertyKey = require('../helpers/isPropertyKey'); + +// https://262.ecma-international.org/6.0/#sec-deletepropertyorthrow + +module.exports = function DeletePropertyOrThrow(O, P) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: P is not a Property Key'); + } + + // eslint-disable-next-line no-param-reassign + var success = delete O[P]; + if (!success) { + throw new $TypeError('Attempt to delete property failed.'); + } + return success; +}; diff --git a/node_modules/es-abstract/2023/DetachArrayBuffer.js b/node_modules/es-abstract/2023/DetachArrayBuffer.js new file mode 100644 index 0000000000000000000000000000000000000000..6ded9de5652c4483ba14060ba82380eb3e63d92a --- /dev/null +++ b/node_modules/es-abstract/2023/DetachArrayBuffer.js @@ -0,0 +1,46 @@ +'use strict'; + +var $SyntaxError = require('es-errors/syntax'); +var $TypeError = require('es-errors/type'); + +var IsDetachedBuffer = require('./IsDetachedBuffer'); + +var isArrayBuffer = require('is-array-buffer'); +var isSharedArrayBuffer = require('is-shared-array-buffer'); + +var MessageChannel; +try { + // eslint-disable-next-line global-require + MessageChannel = require('worker_threads').MessageChannel; +} catch (e) { /**/ } + +// https://262.ecma-international.org/9.0/#sec-detacharraybuffer + +/* globals postMessage */ + +module.exports = function DetachArrayBuffer(arrayBuffer) { + if (!isArrayBuffer(arrayBuffer) || isSharedArrayBuffer(arrayBuffer)) { + throw new $TypeError('Assertion failed: `arrayBuffer` must be an Object with an [[ArrayBufferData]] internal slot, and not a Shared Array Buffer'); + } + + // commented out since there's no way to set or access this key + // var key = arguments.length > 1 ? arguments[1] : void undefined; + + // if (!SameValue(arrayBuffer[[ArrayBufferDetachKey]], key)) { + // throw new $TypeError('Assertion failed: `key` must be the value of the [[ArrayBufferDetachKey]] internal slot of `arrayBuffer`'); + // } + + if (!IsDetachedBuffer(arrayBuffer)) { // node v21.0.0+ throws when you structuredClone a detached buffer + if (typeof structuredClone === 'function') { + structuredClone(arrayBuffer, { transfer: [arrayBuffer] }); + } else if (typeof postMessage === 'function') { + postMessage('', '/', [arrayBuffer]); // TODO: see if this might trigger listeners + } else if (MessageChannel) { + (new MessageChannel()).port1.postMessage(null, [arrayBuffer]); + } else { + throw new $SyntaxError('DetachArrayBuffer is not supported in this environment'); + } + } + + return null; +}; diff --git a/node_modules/es-abstract/2023/EnumerableOwnProperties.js b/node_modules/es-abstract/2023/EnumerableOwnProperties.js new file mode 100644 index 0000000000000000000000000000000000000000..cd606db53067db473c794b383a59a2d967897fd9 --- /dev/null +++ b/node_modules/es-abstract/2023/EnumerableOwnProperties.js @@ -0,0 +1,36 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); +var objectKeys = require('object-keys'); +var safePushApply = require('safe-push-apply'); +var callBound = require('call-bound'); + +var $isEnumerable = callBound('Object.prototype.propertyIsEnumerable'); + +var forEach = require('../helpers/forEach'); + +// https://262.ecma-international.org/14.0/#sec-enumerableownproperties + +module.exports = function EnumerableOwnProperties(O, kind) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + var keys = objectKeys(O); + if (kind === 'key') { + return keys; + } + if (kind === 'value' || kind === 'key+value') { + var results = []; + forEach(keys, function (key) { + if ($isEnumerable(O, key)) { + safePushApply(results, [ + kind === 'value' ? O[key] : [key, O[key]] + ]); + } + }); + return results; + } + throw new $TypeError('Assertion failed: "kind" is not "key", "value", or "key+value": ' + kind); +}; diff --git a/node_modules/es-abstract/2023/FindViaPredicate.js b/node_modules/es-abstract/2023/FindViaPredicate.js new file mode 100644 index 0000000000000000000000000000000000000000..bd42b45ec99256de4f4cd42cfa4d89ff2c2f0156 --- /dev/null +++ b/node_modules/es-abstract/2023/FindViaPredicate.js @@ -0,0 +1,43 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isInteger = require('math-intrinsics/isInteger'); +var isObject = require('es-object-atoms/isObject'); + +var Call = require('./Call'); +var Get = require('./Get'); +var ToBoolean = require('./ToBoolean'); +var IsCallable = require('./IsCallable'); +var ToString = require('./ToString'); + +// https://262.ecma-international.org/14.0/#sec-findviapredicate + +module.exports = function FindViaPredicate(O, len, direction, predicate, thisArg) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + if (!isInteger(len) || len < 0) { + throw new $TypeError('Assertion failed: len must be a non-negative integer'); + } + if (direction !== 'ascending' && direction !== 'descending') { + throw new $TypeError('Assertion failed: direction must be "ascending" or "descending"'); + } + + if (!IsCallable(predicate)) { + throw new $TypeError('predicate must be callable'); // step 1 + } + + for ( // steps 2-4 + var k = direction === 'ascending' ? 0 : len - 1; + direction === 'ascending' ? k < len : k >= 0; + k += 1 + ) { + var Pk = ToString(k); // step 4.a + var kValue = Get(O, Pk); // step 4.c + var testResult = Call(predicate, thisArg, [kValue, k, O]); // step 4.d + if (ToBoolean(testResult)) { + return { '[[Index]]': k, '[[Value]]': kValue }; // step 4.e + } + } + return { '[[Index]]': -1, '[[Value]]': void undefined }; // step 5 +}; diff --git a/node_modules/es-abstract/2023/FlattenIntoArray.js b/node_modules/es-abstract/2023/FlattenIntoArray.js new file mode 100644 index 0000000000000000000000000000000000000000..78dc57c8cc90f0c0a60adb32fc7f41c230c4a591 --- /dev/null +++ b/node_modules/es-abstract/2023/FlattenIntoArray.js @@ -0,0 +1,55 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var MAX_SAFE_INTEGER = require('math-intrinsics/constants/maxSafeInteger'); + +var Call = require('./Call'); +var CreateDataPropertyOrThrow = require('./CreateDataPropertyOrThrow'); +var Get = require('./Get'); +var HasProperty = require('./HasProperty'); +var IsArray = require('./IsArray'); +var LengthOfArrayLike = require('./LengthOfArrayLike'); +var ToString = require('./ToString'); + +// https://262.ecma-international.org/11.0/#sec-flattenintoarray + +module.exports = function FlattenIntoArray(target, source, sourceLen, start, depth) { + var mapperFunction; + if (arguments.length > 5) { + mapperFunction = arguments[5]; + } + + var targetIndex = start; + var sourceIndex = 0; + while (sourceIndex < sourceLen) { + var P = ToString(sourceIndex); + var exists = HasProperty(source, P); + if (exists === true) { + var element = Get(source, P); + if (typeof mapperFunction !== 'undefined') { + if (arguments.length <= 6) { + throw new $TypeError('Assertion failed: thisArg is required when mapperFunction is provided'); + } + element = Call(mapperFunction, arguments[6], [element, sourceIndex, source]); + } + var shouldFlatten = false; + if (depth > 0) { + shouldFlatten = IsArray(element); + } + if (shouldFlatten) { + var elementLen = LengthOfArrayLike(element); + targetIndex = FlattenIntoArray(target, element, elementLen, targetIndex, depth - 1); + } else { + if (targetIndex >= MAX_SAFE_INTEGER) { + throw new $TypeError('index too large'); + } + CreateDataPropertyOrThrow(target, ToString(targetIndex), element); + targetIndex += 1; + } + } + sourceIndex += 1; + } + + return targetIndex; +}; diff --git a/node_modules/es-abstract/2023/FromPropertyDescriptor.js b/node_modules/es-abstract/2023/FromPropertyDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..45b6379f1214c415e1e43b855db01f18b3566cba --- /dev/null +++ b/node_modules/es-abstract/2023/FromPropertyDescriptor.js @@ -0,0 +1,16 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var isPropertyDescriptor = require('../helpers/records/property-descriptor'); +var fromPropertyDescriptor = require('../helpers/fromPropertyDescriptor'); + +// https://262.ecma-international.org/6.0/#sec-frompropertydescriptor + +module.exports = function FromPropertyDescriptor(Desc) { + if (typeof Desc !== 'undefined' && !isPropertyDescriptor(Desc)) { + throw new $TypeError('Assertion failed: `Desc` must be a Property Descriptor'); + } + + return fromPropertyDescriptor(Desc); +}; diff --git a/node_modules/es-abstract/2023/Get.js b/node_modules/es-abstract/2023/Get.js new file mode 100644 index 0000000000000000000000000000000000000000..42f7a14d853e05735d4166708590df2743cfa74c --- /dev/null +++ b/node_modules/es-abstract/2023/Get.js @@ -0,0 +1,24 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var inspect = require('object-inspect'); + +var isPropertyKey = require('../helpers/isPropertyKey'); + +var isObject = require('es-object-atoms/isObject'); + +// https://262.ecma-international.org/6.0/#sec-get-o-p + +module.exports = function Get(O, P) { + // 7.3.1.1 + if (!isObject(O)) { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + // 7.3.1.2 + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: P is not a Property Key, got ' + inspect(P)); + } + // 7.3.1.3 + return O[P]; +}; diff --git a/node_modules/es-abstract/2023/GetGlobalObject.js b/node_modules/es-abstract/2023/GetGlobalObject.js new file mode 100644 index 0000000000000000000000000000000000000000..0541ede0c48889fefe9a137e0e37a2e13573c091 --- /dev/null +++ b/node_modules/es-abstract/2023/GetGlobalObject.js @@ -0,0 +1,9 @@ +'use strict'; + +var getGlobal = require('globalthis/polyfill'); + +// https://262.ecma-international.org/6.0/#sec-getglobalobject + +module.exports = function GetGlobalObject() { + return getGlobal(); +}; diff --git a/node_modules/es-abstract/2023/GetIterator.js b/node_modules/es-abstract/2023/GetIterator.js new file mode 100644 index 0000000000000000000000000000000000000000..5e7207f2af56710d49c40f6e49e51583a0c193ee --- /dev/null +++ b/node_modules/es-abstract/2023/GetIterator.js @@ -0,0 +1,53 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = require('es-errors/type'); +var $asyncIterator = GetIntrinsic('%Symbol.asyncIterator%', true); + +var inspect = require('object-inspect'); +var hasSymbols = require('has-symbols')(); + +var AdvanceStringIndex = require('./AdvanceStringIndex'); +var CreateAsyncFromSyncIterator = require('./CreateAsyncFromSyncIterator'); +var GetIteratorFromMethod = require('./GetIteratorFromMethod'); +var GetMethod = require('./GetMethod'); + +var getIteratorMethod = require('../helpers/getIteratorMethod'); + +var ES = { + AdvanceStringIndex: AdvanceStringIndex, + GetMethod: GetMethod +}; + +// https://262.ecma-international.org/14.0/#sec-getiterator + +module.exports = function GetIterator(obj, kind) { + if (kind !== 'sync' && kind !== 'async') { + throw new $TypeError("Assertion failed: `kind` must be one of 'sync' or 'async', got " + inspect(kind)); + } + + var method; + if (kind === 'async') { // step 1 + if (hasSymbols && $asyncIterator) { + method = GetMethod(obj, $asyncIterator); // step 1.a + } + } + if (typeof method === 'undefined') { // step 1.b + // var syncMethod = GetMethod(obj, $iterator); // step 1.b.i + var syncMethod = getIteratorMethod(ES, obj); + if (kind === 'async') { + if (typeof syncMethod === 'undefined') { + throw new $TypeError('iterator method is `undefined`'); // step 1.b.ii + } + var syncIteratorRecord = GetIteratorFromMethod(obj, syncMethod); // step 1.b.iii + return CreateAsyncFromSyncIterator(syncIteratorRecord); // step 1.b.iv + } + method = syncMethod; // step 2, kind of + } + + if (typeof method === 'undefined') { + throw new $TypeError('iterator method is `undefined`'); // step 3 + } + return GetIteratorFromMethod(obj, method); // step 4 +}; diff --git a/node_modules/es-abstract/2023/GetIteratorFromMethod.js b/node_modules/es-abstract/2023/GetIteratorFromMethod.js new file mode 100644 index 0000000000000000000000000000000000000000..695c2c6299d9ee943949e504ba31ca2c359bfa5d --- /dev/null +++ b/node_modules/es-abstract/2023/GetIteratorFromMethod.js @@ -0,0 +1,28 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var Call = require('./Call'); +var GetV = require('./GetV'); +var IsCallable = require('./IsCallable'); + +// https://262.ecma-international.org/14.0/#sec-getiteratorfrommethod + +module.exports = function GetIteratorFromMethod(obj, method) { + if (!IsCallable(method)) { + throw new $TypeError('method must be a function'); + } + + var iterator = Call(method, obj); // step 1 + if (!isObject(iterator)) { + throw new $TypeError('iterator must return an object'); // step 2 + } + + var nextMethod = GetV(iterator, 'next'); // step 3 + return { // steps 4-5 + '[[Iterator]]': iterator, + '[[NextMethod]]': nextMethod, + '[[Done]]': false + }; +}; diff --git a/node_modules/es-abstract/2023/GetMatchIndexPair.js b/node_modules/es-abstract/2023/GetMatchIndexPair.js new file mode 100644 index 0000000000000000000000000000000000000000..76cda5d841f9ac233954d221eee40c7a06bacc3a --- /dev/null +++ b/node_modules/es-abstract/2023/GetMatchIndexPair.js @@ -0,0 +1,24 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var isMatchRecord = require('../helpers/records/match-record'); + +// https://262.ecma-international.org/13.0/#sec-getmatchindexpair + +module.exports = function GetMatchIndexPair(S, match) { + if (typeof S !== 'string') { + throw new $TypeError('Assertion failed: `S` must be a String'); + } + if (!isMatchRecord(match)) { + throw new $TypeError('Assertion failed: `match` must be a Match Record'); + } + + if (!(match['[[StartIndex]]'] <= S.length)) { + throw new $TypeError('`match` [[StartIndex]] must be a non-negative integer <= the length of S'); + } + if (!(match['[[EndIndex]]'] <= S.length)) { + throw new $TypeError('`match` [[EndIndex]] must be an integer between [[StartIndex]] and the length of S, inclusive'); + } + return [match['[[StartIndex]]'], match['[[EndIndex]]']]; +}; diff --git a/node_modules/es-abstract/2023/GetMatchString.js b/node_modules/es-abstract/2023/GetMatchString.js new file mode 100644 index 0000000000000000000000000000000000000000..7fddd4ea202f7482baaa85b582a8fcbe069caa12 --- /dev/null +++ b/node_modules/es-abstract/2023/GetMatchString.js @@ -0,0 +1,26 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var substring = require('./substring'); + +var isMatchRecord = require('../helpers/records/match-record'); + +// https://262.ecma-international.org/13.0/#sec-getmatchstring + +module.exports = function GetMatchString(S, match) { + if (typeof S !== 'string') { + throw new $TypeError('Assertion failed: `S` must be a String'); + } + if (!isMatchRecord(match)) { + throw new $TypeError('Assertion failed: `match` must be a Match Record'); + } + + if (!(match['[[StartIndex]]'] <= S.length)) { + throw new $TypeError('`match` [[StartIndex]] must be a non-negative integer <= the length of S'); + } + if (!(match['[[EndIndex]]'] <= S.length)) { + throw new $TypeError('`match` [[EndIndex]] must be an integer between [[StartIndex]] and the length of S, inclusive'); + } + return substring(S, match['[[StartIndex]]'], match['[[EndIndex]]']); +}; diff --git a/node_modules/es-abstract/2023/GetMethod.js b/node_modules/es-abstract/2023/GetMethod.js new file mode 100644 index 0000000000000000000000000000000000000000..e28bb1501fc8e4d4a67250c5110cba73bbcba385 --- /dev/null +++ b/node_modules/es-abstract/2023/GetMethod.js @@ -0,0 +1,34 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var GetV = require('./GetV'); +var IsCallable = require('./IsCallable'); +var isPropertyKey = require('../helpers/isPropertyKey'); + +var inspect = require('object-inspect'); + +// https://262.ecma-international.org/6.0/#sec-getmethod + +module.exports = function GetMethod(O, P) { + // 7.3.9.1 + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: P is not a Property Key'); + } + + // 7.3.9.2 + var func = GetV(O, P); + + // 7.3.9.4 + if (func == null) { + return void 0; + } + + // 7.3.9.5 + if (!IsCallable(func)) { + throw new $TypeError(inspect(P) + ' is not a function: ' + inspect(func)); + } + + // 7.3.9.6 + return func; +}; diff --git a/node_modules/es-abstract/2023/GetNamedTimeZoneEpochNanoseconds.js b/node_modules/es-abstract/2023/GetNamedTimeZoneEpochNanoseconds.js new file mode 100644 index 0000000000000000000000000000000000000000..6577062583d1a8073c49a5716d7f02916c2a373a --- /dev/null +++ b/node_modules/es-abstract/2023/GetNamedTimeZoneEpochNanoseconds.js @@ -0,0 +1,72 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var GetUTCEpochNanoseconds = require('./GetUTCEpochNanoseconds'); + +var isInteger = require('math-intrinsics/isInteger'); + +// https://262.ecma-international.org/14.0/#sec-getnamedtimezoneepochnanoseconds + +// eslint-disable-next-line max-params +module.exports = function GetNamedTimeZoneEpochNanoseconds( + timeZoneIdentifier, + year, + month, + day, + hour, + minute, + second, + millisecond, + microsecond, + nanosecond +) { + if (typeof timeZoneIdentifier !== 'string') { + throw new $TypeError('Assertion failed: `timeZoneIdentifier` must be a string'); + } + if (!isInteger(year)) { + throw new $TypeError('Assertion failed: `year` must be an integral number'); + } + if (!isInteger(month) || month < 1 || month > 12) { + throw new $TypeError('Assertion failed: `month` must be an integral number between 1 and 12, inclusive'); + } + if (!isInteger(day) || day < 1 || day > 31) { + throw new $TypeError('Assertion failed: `day` must be an integral number between 1 and 31, inclusive'); + } + if (!isInteger(hour) || hour < 0 || hour > 23) { + throw new $TypeError('Assertion failed: `hour` must be an integral number between 0 and 23, inclusive'); + } + if (!isInteger(minute) || minute < 0 || minute > 59) { + throw new $TypeError('Assertion failed: `minute` must be an integral number between 0 and 59, inclusive'); + } + if (!isInteger(second) || second < 0 || second > 999) { + throw new $TypeError('Assertion failed: `second` must be an integral number between 0 and 999, inclusive'); + } + if (!isInteger(millisecond) || millisecond < 0 || millisecond > 999) { + throw new $TypeError('Assertion failed: `millisecond` must be an integral number between 0 and 999, inclusive'); + } + if (!isInteger(microsecond) || microsecond < 0 || microsecond > 999) { + throw new $TypeError('Assertion failed: `microsecond` must be an integral number between 0 and 999, inclusive'); + } + if (!isInteger(nanosecond) || nanosecond < 0 || nanosecond > 999) { + throw new $TypeError('Assertion failed: `nanosecond` must be an integral number between 0 and 999, inclusive'); + } + + if (timeZoneIdentifier !== 'UTC') { + throw new $TypeError('Assertion failed: only UTC time zone is supported'); // step 1 + } + + var epochNanoseconds = GetUTCEpochNanoseconds( + year, + month, + day, + hour, + minute, + second, + millisecond, + microsecond, + nanosecond + ); // step 2 + + return [epochNanoseconds]; // step 3 +}; diff --git a/node_modules/es-abstract/2023/GetOwnPropertyKeys.js b/node_modules/es-abstract/2023/GetOwnPropertyKeys.js new file mode 100644 index 0000000000000000000000000000000000000000..e9b50d744a5fdf42221ad18e6674e777fa3b0a47 --- /dev/null +++ b/node_modules/es-abstract/2023/GetOwnPropertyKeys.js @@ -0,0 +1,30 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var hasSymbols = require('has-symbols')(); + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var $gOPN = GetIntrinsic('%Object.getOwnPropertyNames%', true); +var $gOPS = hasSymbols && GetIntrinsic('%Object.getOwnPropertySymbols%', true); +var keys = require('object-keys'); + +// https://262.ecma-international.org/6.0/#sec-getownpropertykeys + +module.exports = function GetOwnPropertyKeys(O, Type) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + if (Type === 'Symbol') { + return $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"`'); +}; diff --git a/node_modules/es-abstract/2023/GetPromiseResolve.js b/node_modules/es-abstract/2023/GetPromiseResolve.js new file mode 100644 index 0000000000000000000000000000000000000000..7c9d9a945a0c268fa7558eec169a2cee0e903b86 --- /dev/null +++ b/node_modules/es-abstract/2023/GetPromiseResolve.js @@ -0,0 +1,20 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var Get = require('./Get'); +var IsCallable = require('./IsCallable'); +var IsConstructor = require('./IsConstructor'); + +// https://262.ecma-international.org/12.0/#sec-getpromiseresolve + +module.exports = function GetPromiseResolve(promiseConstructor) { + if (!IsConstructor(promiseConstructor)) { + throw new $TypeError('Assertion failed: `promiseConstructor` must be a constructor'); + } + var promiseResolve = Get(promiseConstructor, 'resolve'); + if (IsCallable(promiseResolve) === false) { + throw new $TypeError('`resolve` method is not callable'); + } + return promiseResolve; +}; diff --git a/node_modules/es-abstract/2023/GetPrototypeFromConstructor.js b/node_modules/es-abstract/2023/GetPrototypeFromConstructor.js new file mode 100644 index 0000000000000000000000000000000000000000..687f6ef200fb11a3dc97a27533d15430c305fb3b --- /dev/null +++ b/node_modules/es-abstract/2023/GetPrototypeFromConstructor.js @@ -0,0 +1,33 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $Function = GetIntrinsic('%Function%'); +var $TypeError = require('es-errors/type'); +var $SyntaxError = require('es-errors/syntax'); + +var Get = require('./Get'); +var IsConstructor = require('./IsConstructor'); + +var isObject = require('es-object-atoms/isObject'); + +// https://262.ecma-international.org/6.0/#sec-getprototypefromconstructor + +module.exports = function GetPrototypeFromConstructor(constructor, intrinsicDefaultProto) { + var intrinsic = GetIntrinsic(intrinsicDefaultProto); // throws if not a valid intrinsic + if (!isObject(intrinsic)) { + throw new $TypeError('intrinsicDefaultProto must be an object'); + } + if (!IsConstructor(constructor)) { + throw new $TypeError('Assertion failed: `constructor` must be a constructor'); + } + var proto = Get(constructor, 'prototype'); + if (!isObject(proto)) { + if (!(constructor instanceof $Function)) { + // ignore other realms, for now + throw new $SyntaxError('cross-realm constructors not currently supported'); + } + proto = intrinsic; + } + return proto; +}; diff --git a/node_modules/es-abstract/2023/GetStringIndex.js b/node_modules/es-abstract/2023/GetStringIndex.js new file mode 100644 index 0000000000000000000000000000000000000000..101198ff01a6d832dbc8f84c0ff574944e67a8b6 --- /dev/null +++ b/node_modules/es-abstract/2023/GetStringIndex.js @@ -0,0 +1,27 @@ +'use strict'; + +var callBound = require('call-bound'); +var $TypeError = require('es-errors/type'); +var isInteger = require('math-intrinsics/isInteger'); + +var StringToCodePoints = require('./StringToCodePoints'); + +var $indexOf = callBound('String.prototype.indexOf'); + +// https://262.ecma-international.org/13.0/#sec-getstringindex + +module.exports = function GetStringIndex(S, e) { + if (typeof S !== 'string') { + throw new $TypeError('Assertion failed: `S` must be a String'); + } + if (!isInteger(e) || e < 0) { + throw new $TypeError('Assertion failed: `e` must be a non-negative integer'); + } + + if (S === '') { + return 0; + } + var codepoints = StringToCodePoints(S); + var eUTF = e >= codepoints.length ? S.length : $indexOf(S, codepoints[e]); + return eUTF; +}; diff --git a/node_modules/es-abstract/2023/GetSubstitution.js b/node_modules/es-abstract/2023/GetSubstitution.js new file mode 100644 index 0000000000000000000000000000000000000000..419dd0b2758bc022520139d2a1b9d6fa82af9f60 --- /dev/null +++ b/node_modules/es-abstract/2023/GetSubstitution.js @@ -0,0 +1,138 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); +var inspect = require('object-inspect'); +var isInteger = require('math-intrinsics/isInteger'); +var regexTester = require('safe-regex-test'); + +var Get = require('./Get'); +var IsArray = require('./IsArray'); +var min = require('./min'); +var StringIndexOf = require('./StringIndexOf'); +var StringToNumber = require('./StringToNumber'); +var substring = require('./substring'); +var ToString = require('./ToString'); + +var every = require('../helpers/every'); +var isPrefixOf = require('../helpers/isPrefixOf'); +var isStringOrUndefined = require('../helpers/isStringOrUndefined'); + +var startsWithDollarDigit = regexTester(/^\$[0-9]/); +var startsWithDollarTwoDigit = regexTester(/^\$[0-9][0-9]/); + +// http://www.ecma-international.org/ecma-262/14.0/#sec-getsubstitution + +// eslint-disable-next-line max-statements, max-params, max-lines-per-function +module.exports = function GetSubstitution(matched, str, position, captures, namedCaptures, replacementTemplate) { + if (typeof matched !== 'string') { + throw new $TypeError('Assertion failed: `matched` must be a String'); + } + + if (typeof str !== 'string') { + throw new $TypeError('Assertion failed: `str` must be a String'); + } + + if (!isInteger(position) || position < 0) { + throw new $TypeError('Assertion failed: `position` must be a nonnegative integer, got ' + inspect(position)); + } + + if (!IsArray(captures) || !every(captures, isStringOrUndefined)) { + throw new $TypeError('Assertion failed: `captures` must be a possibly-empty List of Strings or `undefined`, got ' + inspect(captures)); + } + + if (typeof namedCaptures !== 'undefined' && !isObject(namedCaptures)) { + throw new $TypeError('Assertion failed: `namedCaptures` must be `undefined` or an Object'); + } + + if (typeof replacementTemplate !== 'string') { + throw new $TypeError('Assertion failed: `replacementTemplate` must be a String'); + } + + var stringLength = str.length; // step 1 + + if (position > stringLength) { + throw new $TypeError('Assertion failed: position > stringLength, got ' + inspect(position)); // step 2 + } + + var templateRemainder = replacementTemplate; // step 3 + + var result = ''; // step 4 + + while (templateRemainder !== '') { // step 5 + // 5.a NOTE: The following steps isolate ref (a prefix of templateRemainder), determine refReplacement (its replacement), and then append that replacement to result. + + var ref, refReplacement, capture; + if (isPrefixOf('$$', templateRemainder)) { // step 5.b + ref = '$$'; // step 5.b.i + refReplacement = '$'; // step 5.b.ii + } else if (isPrefixOf('$`', templateRemainder)) { // step 5.c + ref = '$`'; // step 5.c.i + refReplacement = substring(str, 0, position); // step 5.c.ii + } else if (isPrefixOf('$&', templateRemainder)) { // step 5.d + ref = '$&'; // step 5.d.i + refReplacement = matched; // step 5.d.ii + } else if (isPrefixOf('$\'', templateRemainder)) { // step 5.e + ref = '$\''; // step 5.e.i + var matchLength = matched.length; // step 5.e.ii + var tailPos = position + matchLength; // step 5.e.iii + refReplacement = substring(str, min(tailPos, stringLength)); // step 5.e.iv + // 5.e.v NOTE: tailPos can exceed stringLength only if this abstract operation was invoked by a call to the intrinsic @@replace method of %RegExp.prototype% on an object whose "exec" property is not the intrinsic %RegExp.prototype.exec%. + } else if (startsWithDollarDigit(templateRemainder)) { // step 5.f + var digitCount = startsWithDollarTwoDigit(templateRemainder) ? 2 : 1; // step 5.f.i + + ref = substring(templateRemainder, 0, 1 + digitCount); // step 5.f.ii + + var digits = substring(templateRemainder, 1, 1 + digitCount); // step 5.f.iii + + var index = StringToNumber(digits); // step 5.f.iv + + if (index < 0 || index > 99) { + throw new $TypeError('Assertion failed: `index` must be >= 0 and <= 99'); // step 5.f.v + } + + var captureLen = captures.length; // step 5.f.vi + + if (1 <= index && index <= captureLen) { // step 5.f.vii + capture = captures[index - 1]; // step 5.f.vii.1 + + if (typeof capture === 'undefined') { // step 5.f.vii.2 + refReplacement = ''; // step 5.f.vii.2.a + } else { // step 5.f.vii.3 + refReplacement = capture; // step 5.f.vii.3.a + } + } else { // step 5.f.viii + refReplacement = ref; // step 5.f.viii.1 + } + } else if (isPrefixOf('$<', templateRemainder)) { // step 5.g + var gtPos = StringIndexOf(templateRemainder, '>', 0); // step 5.g.i + if (gtPos === -1 || typeof namedCaptures === 'undefined') { // step 5.g.ii + ref = '$<'; // step 5.g.ii.1 + refReplacement = ref; // step 5.g.ii.2 + } else { // step 5.g.iii + ref = substring(templateRemainder, 0, gtPos + 1); // step 5.g.iii.1 + var groupName = substring(templateRemainder, 2, gtPos); // step 5.g.iii.2 + if (!isObject(namedCaptures)) { + throw new $TypeError('Assertion failed: Type(namedCaptures) is not Object'); // step 5.g.iii.3 + } + capture = Get(namedCaptures, groupName); // step 5.g.iii.4 + if (typeof capture === 'undefined') { // step 5.g.iii.5 + refReplacement = ''; // step 5.g.iii.5.a + } else { // step 5.g.iii.6 + refReplacement = ToString(capture); // step 5.g.iii.6.a + } + } + } else { // step 5.h + ref = substring(templateRemainder, 0, 1); // step 5.h.i + refReplacement = ref; // step 5.h.ii + } + + var refLength = ref.length; // step 5.i + + templateRemainder = substring(templateRemainder, refLength); // step 5.j + + result += refReplacement; // step 5.k + } + + return result; // step 6 +}; diff --git a/node_modules/es-abstract/2023/GetUTCEpochNanoseconds.js b/node_modules/es-abstract/2023/GetUTCEpochNanoseconds.js new file mode 100644 index 0000000000000000000000000000000000000000..bf645b1d0462515d71dd22c5685e0d34d9488636 --- /dev/null +++ b/node_modules/es-abstract/2023/GetUTCEpochNanoseconds.js @@ -0,0 +1,68 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var MakeDay = require('./MakeDay'); +var MakeTime = require('./MakeTime'); +var MakeDate = require('./MakeDate'); + +var isInteger = require('math-intrinsics/isInteger'); + +var $BigInt = GetIntrinsic('%BigInt%', true); +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +// https://tc39.es/ecma262/#sec-getutcepochnanoseconds + +// eslint-disable-next-line max-params +module.exports = function GetUTCEpochNanoseconds( + year, + month, + day, + hour, + minute, + second, + millisecond, + microsecond, + nanosecond +) { + if (!isInteger(year)) { + throw new $TypeError('Assertion failed: `year` must be an integral Number'); + } + if (!isInteger(month) || month < 1 || month > 12) { + throw new $TypeError('Assertion failed: `month` must be an integral Number between 1 and 12, inclusive'); + } + if (!isInteger(day) || day < 1 || day > 31) { + throw new $TypeError('Assertion failed: `day` must be an integral Number between 1 and 31, inclusive'); + } + if (!isInteger(hour) || hour < 0 || hour > 23) { + throw new $TypeError('Assertion failed: `hour` must be an integral Number between 0 and 23, inclusive'); + } + if (!isInteger(minute) || minute < 0 || minute > 59) { + throw new $TypeError('Assertion failed: `minute` must be an integral Number between 0 and 59, inclusive'); + } + if (!isInteger(second) || second < 0 || second > 59) { + throw new $TypeError('Assertion failed: `second` must be an integral Number between 0 and 59, inclusive'); + } + if (!isInteger(millisecond) || millisecond < 0 || millisecond > 999) { + throw new $TypeError('Assertion failed: `millisecond` must be an integral Number between 0 and 999, inclusive'); + } + if (!isInteger(microsecond) || microsecond < 0 || microsecond > 999) { + throw new $TypeError('Assertion failed: `microsecond` must be an integral Number between 0 and 999, inclusive'); + } + if (!isInteger(nanosecond) || nanosecond < 0 || nanosecond > 999) { + throw new $TypeError('Assertion failed: `nanosecond` must be an integral Number between 0 and 999, inclusive'); + } + + var date = MakeDay(year, month - 1, day); // step 1 + var time = MakeTime(hour, minute, second, millisecond); // step 2 + var ms = MakeDate(date, time); // step 3 + if (!isInteger(ms)) { + throw new $TypeError('Assertion failed: `ms` from MakeDate is not an integral Number'); // step 4 + } + + if (!$BigInt) { + throw new $SyntaxError('BigInts are not supported in this environment'); + } + return $BigInt((ms * 1e6) + (microsecond * 1e3) + nanosecond); // step 5 +}; diff --git a/node_modules/es-abstract/2023/GetV.js b/node_modules/es-abstract/2023/GetV.js new file mode 100644 index 0000000000000000000000000000000000000000..920dec3c4a4eac8aa63678c2afa5683e79e3337f --- /dev/null +++ b/node_modules/es-abstract/2023/GetV.js @@ -0,0 +1,23 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var inspect = require('object-inspect'); + +var isPropertyKey = require('../helpers/isPropertyKey'); +// var ToObject = require('./ToObject'); + +// https://262.ecma-international.org/6.0/#sec-getv + +module.exports = function GetV(V, P) { + // 7.3.2.1 + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: P is not a Property Key, got ' + inspect(P)); + } + + // 7.3.2.2-3 + // var O = ToObject(V); + + // 7.3.2.4 + return V[P]; +}; diff --git a/node_modules/es-abstract/2023/GetValueFromBuffer.js b/node_modules/es-abstract/2023/GetValueFromBuffer.js new file mode 100644 index 0000000000000000000000000000000000000000..0519a10e9aacb656f66b4a875b0ce98b8695c474 --- /dev/null +++ b/node_modules/es-abstract/2023/GetValueFromBuffer.js @@ -0,0 +1,96 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $SyntaxError = require('es-errors/syntax'); +var $TypeError = require('es-errors/type'); +var $Uint8Array = GetIntrinsic('%Uint8Array%', true); +var isInteger = require('math-intrinsics/isInteger'); + +var callBound = require('call-bound'); + +var $slice = callBound('Array.prototype.slice'); + +var IsDetachedBuffer = require('./IsDetachedBuffer'); +var RawBytesToNumeric = require('./RawBytesToNumeric'); + +var isArrayBuffer = require('is-array-buffer'); +var isSharedArrayBuffer = require('is-shared-array-buffer'); +var safeConcat = require('safe-array-concat'); + +var tableTAO = require('./tables/typed-array-objects'); + +var defaultEndianness = require('../helpers/defaultEndianness'); + +// https://262.ecma-international.org/11.0/#sec-getvaluefrombuffer + +module.exports = function GetValueFromBuffer(arrayBuffer, byteIndex, type, isTypedArray, order) { + var isSAB = isSharedArrayBuffer(arrayBuffer); + if (!isArrayBuffer(arrayBuffer) && !isSAB) { + throw new $TypeError('Assertion failed: `arrayBuffer` must be an ArrayBuffer or a SharedArrayBuffer'); + } + + if (!isInteger(byteIndex)) { + throw new $TypeError('Assertion failed: `byteIndex` must be an integer'); + } + + if (typeof type !== 'string' || typeof tableTAO.size['$' + type] !== 'number') { + throw new $TypeError('Assertion failed: `type` must be one of ' + tableTAO.choices); + } + + if (typeof isTypedArray !== 'boolean') { + throw new $TypeError('Assertion failed: `isTypedArray` must be a boolean'); + } + + if (order !== 'SeqCst' && order !== 'Unordered') { + throw new $TypeError('Assertion failed: `order` must be either `SeqCst` or `Unordered`'); + } + + if (arguments.length > 5 && typeof arguments[5] !== 'boolean') { + throw new $TypeError('Assertion failed: `isLittleEndian` must be a boolean, if present'); + } + + if (IsDetachedBuffer(arrayBuffer)) { + throw new $TypeError('Assertion failed: `arrayBuffer` is detached'); // step 1 + } + + // 2. Assert: There are sufficient bytes in arrayBuffer starting at byteIndex to represent a value of type. + + if (byteIndex < 0) { + throw new $TypeError('Assertion failed: `byteIndex` must be non-negative'); // step 3 + } + + // 4. Let block be arrayBuffer.[[ArrayBufferData]]. + + var elementSize = tableTAO.size['$' + type]; // step 5 + if (!elementSize) { + throw new $TypeError('Assertion failed: `type` must be one of ' + tableTAO.choices); + } + + var rawValue; + if (isSAB) { // step 6 + /* + a. Let execution be the [[CandidateExecution]] field of the surrounding agent's Agent Record. + b. Let eventList be the [[EventList]] field of the element in execution.[[EventLists]] whose [[AgentSignifier]] is AgentSignifier(). + c. If isTypedArray is true and type is "Int8", "Uint8", "Int16", "Uint16", "Int32", or "Uint32", let noTear be true; otherwise let noTear be false. + d. Let rawValue be a List of length elementSize of nondeterministically chosen byte values. + e. NOTE: In implementations, rawValue is the result of a non-atomic or atomic read instruction on the underlying hardware. The nondeterminism is a semantic prescription of the memory model to describe observable behaviour of hardware with weak consistency. + f. Let readEvent be ReadSharedMemory{ [[Order]]: order, [[NoTear]]: noTear, [[Block]]: block, [[ByteIndex]]: byteIndex, [[ElementSize]]: elementSize }. + g. Append readEvent to eventList. + h. Append Chosen Value Record { [[Event]]: readEvent, [[ChosenValue]]: rawValue } to execution.[[ChosenValues]]. + */ + throw new $SyntaxError('SharedArrayBuffer is not supported by this implementation'); + } else { + // 7. Let rawValue be a List of elementSize containing, in order, the elementSize sequence of bytes starting with block[byteIndex]. + rawValue = $slice(new $Uint8Array(arrayBuffer, byteIndex), 0, elementSize); // step 6 + } + + // 8. If isLittleEndian is not present, set isLittleEndian to either true or false. The choice is implementation dependent and should be the alternative that is most efficient for the implementation. An implementation must use the same value each time this step is executed and the same value must be used for the corresponding step in the SetValueInBuffer abstract operation. + var isLittleEndian = arguments.length > 5 ? arguments[5] : defaultEndianness === 'little'; // step 8 + + var bytes = isLittleEndian + ? $slice(safeConcat([0, 0, 0, 0, 0, 0, 0, 0], rawValue), -elementSize) + : $slice(safeConcat(rawValue, [0, 0, 0, 0, 0, 0, 0, 0]), 0, elementSize); + + return RawBytesToNumeric(type, bytes, isLittleEndian); +}; diff --git a/node_modules/es-abstract/2023/HasOwnProperty.js b/node_modules/es-abstract/2023/HasOwnProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..617f0b856e81f2518d2c03bf72b367eea50eb6ef --- /dev/null +++ b/node_modules/es-abstract/2023/HasOwnProperty.js @@ -0,0 +1,20 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var hasOwn = require('hasown'); +var isObject = require('es-object-atoms/isObject'); + +var isPropertyKey = require('../helpers/isPropertyKey'); + +// https://262.ecma-international.org/6.0/#sec-hasownproperty + +module.exports = function HasOwnProperty(O, P) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: `O` must be an Object'); + } + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: `P` must be a Property Key'); + } + return hasOwn(O, P); +}; diff --git a/node_modules/es-abstract/2023/HasProperty.js b/node_modules/es-abstract/2023/HasProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..eb66ca9853ec09c092d87f10333fcdb19a882c83 --- /dev/null +++ b/node_modules/es-abstract/2023/HasProperty.js @@ -0,0 +1,18 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var isPropertyKey = require('../helpers/isPropertyKey'); + +// https://262.ecma-international.org/6.0/#sec-hasproperty + +module.exports = function HasProperty(O, P) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: `O` must be an Object'); + } + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: `P` must be a Property Key'); + } + return P in O; +}; diff --git a/node_modules/es-abstract/2023/HourFromTime.js b/node_modules/es-abstract/2023/HourFromTime.js new file mode 100644 index 0000000000000000000000000000000000000000..f963bfb68540ba21f46be00b623cb89db98d63f5 --- /dev/null +++ b/node_modules/es-abstract/2023/HourFromTime.js @@ -0,0 +1,14 @@ +'use strict'; + +var floor = require('./floor'); +var modulo = require('./modulo'); + +var timeConstants = require('../helpers/timeConstants'); +var msPerHour = timeConstants.msPerHour; +var HoursPerDay = timeConstants.HoursPerDay; + +// https://262.ecma-international.org/5.1/#sec-15.9.1.10 + +module.exports = function HourFromTime(t) { + return modulo(floor(t / msPerHour), HoursPerDay); +}; diff --git a/node_modules/es-abstract/2023/InLeapYear.js b/node_modules/es-abstract/2023/InLeapYear.js new file mode 100644 index 0000000000000000000000000000000000000000..4a283a4b6097f4b2c4e872b0cc775024ff517b77 --- /dev/null +++ b/node_modules/es-abstract/2023/InLeapYear.js @@ -0,0 +1,19 @@ +'use strict'; + +var $EvalError = require('es-errors/eval'); + +var DaysInYear = require('./DaysInYear'); +var YearFromTime = require('./YearFromTime'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.3 + +module.exports = function InLeapYear(t) { + var days = DaysInYear(YearFromTime(t)); + if (days === 365) { + return 0; + } + if (days === 366) { + return 1; + } + throw new $EvalError('Assertion failed: there are not 365 or 366 days in a year, got: ' + days); +}; diff --git a/node_modules/es-abstract/2023/InstallErrorCause.js b/node_modules/es-abstract/2023/InstallErrorCause.js new file mode 100644 index 0000000000000000000000000000000000000000..c740a5d6c22e58e2c9d630595c0e25ff92f9356e --- /dev/null +++ b/node_modules/es-abstract/2023/InstallErrorCause.js @@ -0,0 +1,21 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var CreateNonEnumerableDataPropertyOrThrow = require('./CreateNonEnumerableDataPropertyOrThrow'); +var Get = require('./Get'); +var HasProperty = require('./HasProperty'); + +// https://262.ecma-international.org/13.0/#sec-installerrorcause + +module.exports = function InstallErrorCause(O, options) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + if (isObject(options) && HasProperty(options, 'cause')) { + var cause = Get(options, 'cause'); + CreateNonEnumerableDataPropertyOrThrow(O, 'cause', cause); + } +}; diff --git a/node_modules/es-abstract/2023/InstanceofOperator.js b/node_modules/es-abstract/2023/InstanceofOperator.js new file mode 100644 index 0000000000000000000000000000000000000000..5dd7d04a4c16b423b1613070585b864e22b2dc9e --- /dev/null +++ b/node_modules/es-abstract/2023/InstanceofOperator.js @@ -0,0 +1,30 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var $hasInstance = GetIntrinsic('%Symbol.hasInstance%', true); + +var Call = require('./Call'); +var GetMethod = require('./GetMethod'); +var IsCallable = require('./IsCallable'); +var OrdinaryHasInstance = require('./OrdinaryHasInstance'); +var ToBoolean = require('./ToBoolean'); + +// https://262.ecma-international.org/6.0/#sec-instanceofoperator + +module.exports = function InstanceofOperator(O, C) { + if (!isObject(O)) { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + var instOfHandler = $hasInstance ? GetMethod(C, $hasInstance) : void 0; + if (typeof instOfHandler !== 'undefined') { + return ToBoolean(Call(instOfHandler, C, [O])); + } + if (!IsCallable(C)) { + throw new $TypeError('`C` is not Callable'); + } + return OrdinaryHasInstance(C, O); +}; diff --git a/node_modules/es-abstract/2023/IntegerIndexedElementGet.js b/node_modules/es-abstract/2023/IntegerIndexedElementGet.js new file mode 100644 index 0000000000000000000000000000000000000000..cf8ff308d3f15c601c1e3dc92e7737cab110eb74 --- /dev/null +++ b/node_modules/es-abstract/2023/IntegerIndexedElementGet.js @@ -0,0 +1,38 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var GetValueFromBuffer = require('./GetValueFromBuffer'); +var IsValidIntegerIndex = require('./IsValidIntegerIndex'); +var TypedArrayElementSize = require('./TypedArrayElementSize'); +var TypedArrayElementType = require('./TypedArrayElementType'); + +var isTypedArray = require('is-typed-array'); +var typedArrayBuffer = require('typed-array-buffer'); +var typedArrayByteOffset = require('typed-array-byte-offset'); + +// https://262.ecma-international.org/13.0/#sec-integerindexedelementget + +module.exports = function IntegerIndexedElementGet(O, index) { + if (!isTypedArray(O)) { + throw new $TypeError('Assertion failed: `O` must be a TypedArray'); + } + + if (typeof index !== 'number') { + throw new $TypeError('Assertion failed: `index` must be a Number'); + } + + if (!IsValidIntegerIndex(O, index)) { + return void undefined; // step 1 + } + + var offset = typedArrayByteOffset(O); // step 2 + + var elementSize = TypedArrayElementSize(O); // step 3 + + var indexedPosition = (index * elementSize) + offset; // step 4 + + var elementType = TypedArrayElementType(O); // step 5 + + return GetValueFromBuffer(typedArrayBuffer(O), indexedPosition, elementType, true, 'Unordered'); // step 11 +}; diff --git a/node_modules/es-abstract/2023/IntegerIndexedElementSet.js b/node_modules/es-abstract/2023/IntegerIndexedElementSet.js new file mode 100644 index 0000000000000000000000000000000000000000..4edac7d7552c6cbfd2132f6e5a121f57a8ab3367 --- /dev/null +++ b/node_modules/es-abstract/2023/IntegerIndexedElementSet.js @@ -0,0 +1,42 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var IsValidIntegerIndex = require('./IsValidIntegerIndex'); +var SetValueInBuffer = require('./SetValueInBuffer'); +var ToBigInt = require('./ToBigInt'); +var ToNumber = require('./ToNumber'); +var TypedArrayElementSize = require('./TypedArrayElementSize'); +var TypedArrayElementType = require('./TypedArrayElementType'); + +var typedArrayBuffer = require('typed-array-buffer'); +var typedArrayByteOffset = require('typed-array-byte-offset'); +var whichTypedArray = require('which-typed-array'); + +// https://262.ecma-international.org/13.0/#sec-integerindexedelementset + +module.exports = function IntegerIndexedElementSet(O, index, value) { + var arrayTypeName = whichTypedArray(O); + if (!arrayTypeName) { + throw new $TypeError('Assertion failed: `O` must be a TypedArray'); + } + + if (typeof index !== 'number') { + throw new $TypeError('Assertion failed: `index` must be a Number'); + } + + var contentType = arrayTypeName === 'BigInt64Array' || arrayTypeName === 'BigUint64Array' ? 'BigInt' : 'Number'; + var numValue = contentType === 'BigInt' ? ToBigInt(value) : ToNumber(value); // steps 1 - 2 + + if (IsValidIntegerIndex(O, index)) { // step 3 + var offset = typedArrayByteOffset(O); // step 3.a + + var elementSize = TypedArrayElementSize(O); // step 3.b + + var indexedPosition = (index * elementSize) + offset; // step 3.c + + var elementType = TypedArrayElementType(O); // step 3.d + + SetValueInBuffer(typedArrayBuffer(O), indexedPosition, elementType, numValue, true, 'Unordered'); // step 3.e + } +}; diff --git a/node_modules/es-abstract/2023/InternalizeJSONProperty.js b/node_modules/es-abstract/2023/InternalizeJSONProperty.js new file mode 100644 index 0000000000000000000000000000000000000000..eabb7caab216526d29423cbfa8d8db23b7d9e593 --- /dev/null +++ b/node_modules/es-abstract/2023/InternalizeJSONProperty.js @@ -0,0 +1,68 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var Call = require('./Call'); +var CreateDataProperty = require('./CreateDataProperty'); +var EnumerableOwnProperties = require('./EnumerableOwnProperties'); +var Get = require('./Get'); +var IsArray = require('./IsArray'); +var LengthOfArrayLike = require('./LengthOfArrayLike'); +var ToString = require('./ToString'); + +var forEach = require('../helpers/forEach'); + +// https://262.ecma-international.org/14.0/#sec-internalizejsonproperty + +// note: `reviver` was implicitly closed-over until ES2020, where it becomes a third argument + +module.exports = function InternalizeJSONProperty(holder, name, reviver) { + if (!isObject(holder)) { + throw new $TypeError('Assertion failed: `holder` is not an Object'); + } + if (typeof name !== 'string') { + throw new $TypeError('Assertion failed: `name` is not a String'); + } + if (typeof reviver !== 'function') { + throw new $TypeError('Assertion failed: `reviver` is not a Function'); + } + + var val = Get(holder, name); // step 1 + + if (isObject(val)) { // step 2 + var isArray = IsArray(val); // step 2.a + if (isArray) { // step 2.b + var I = 0; // step 2.b.i + + var len = LengthOfArrayLike(val); // step 2.b.ii + + while (I < len) { // step 2.b.iii + var newElement = InternalizeJSONProperty(val, ToString(I), reviver); // step 2.b.iv.1 + + if (typeof newElement === 'undefined') { // step 2.b.iii.2 + delete val[ToString(I)]; // step 2.b.iii.2.a + } else { // step 2.b.iii.3 + CreateDataProperty(val, ToString(I), newElement); // step 2.b.iii.3.a + } + + I += 1; // step 2.b.iii.4 + } + } else { // step 2.c + var keys = EnumerableOwnProperties(val, 'key'); // step 2.c.i + + forEach(keys, function (P) { // step 2.c.ii + // eslint-disable-next-line no-shadow + var newElement = InternalizeJSONProperty(val, P, reviver); // step 2.c.ii.1 + + if (typeof newElement === 'undefined') { // step 2.c.ii.2 + delete val[P]; // step 2.c.ii.2.a + } else { // step 2.c.ii.3 + CreateDataProperty(val, P, newElement); // step 2.c.ii.3.a + } + }); + } + } + + return Call(reviver, holder, [name, val]); // step 3 +}; diff --git a/node_modules/es-abstract/2023/Invoke.js b/node_modules/es-abstract/2023/Invoke.js new file mode 100644 index 0000000000000000000000000000000000000000..57bca8ebc3dcb6172949cb3bef6f134dacabbf4b --- /dev/null +++ b/node_modules/es-abstract/2023/Invoke.js @@ -0,0 +1,22 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var Call = require('./Call'); +var IsArray = require('./IsArray'); +var GetV = require('./GetV'); +var isPropertyKey = require('../helpers/isPropertyKey'); + +// https://262.ecma-international.org/6.0/#sec-invoke + +module.exports = function Invoke(O, P) { + if (!isPropertyKey(P)) { + throw new $TypeError('Assertion failed: P must be a Property Key'); + } + var argumentsList = arguments.length > 2 ? arguments[2] : []; + if (!IsArray(argumentsList)) { + throw new $TypeError('Assertion failed: optional `argumentsList`, if provided, must be a List'); + } + var func = GetV(O, P); + return Call(func, O, argumentsList); +}; diff --git a/node_modules/es-abstract/2023/IsAccessorDescriptor.js b/node_modules/es-abstract/2023/IsAccessorDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..f7bf73afb1c1617b04596a6e2af6d1617857bf1e --- /dev/null +++ b/node_modules/es-abstract/2023/IsAccessorDescriptor.js @@ -0,0 +1,25 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var hasOwn = require('hasown'); + +var isPropertyDescriptor = require('../helpers/records/property-descriptor'); + +// https://262.ecma-international.org/5.1/#sec-8.10.1 + +module.exports = function IsAccessorDescriptor(Desc) { + if (typeof Desc === 'undefined') { + return false; + } + + if (!isPropertyDescriptor(Desc)) { + throw new $TypeError('Assertion failed: `Desc` must be a Property Descriptor'); + } + + if (!hasOwn(Desc, '[[Get]]') && !hasOwn(Desc, '[[Set]]')) { + return false; + } + + return true; +}; diff --git a/node_modules/es-abstract/2023/IsArray.js b/node_modules/es-abstract/2023/IsArray.js new file mode 100644 index 0000000000000000000000000000000000000000..c2c48c1f233c058c691d45d7587f1b58d3de5eb2 --- /dev/null +++ b/node_modules/es-abstract/2023/IsArray.js @@ -0,0 +1,4 @@ +'use strict'; + +// https://262.ecma-international.org/6.0/#sec-isarray +module.exports = require('../helpers/IsArray'); diff --git a/node_modules/es-abstract/2023/IsBigIntElementType.js b/node_modules/es-abstract/2023/IsBigIntElementType.js new file mode 100644 index 0000000000000000000000000000000000000000..e3f58a949b3cabcde8a8078afb501cd872820398 --- /dev/null +++ b/node_modules/es-abstract/2023/IsBigIntElementType.js @@ -0,0 +1,7 @@ +'use strict'; + +// https://262.ecma-international.org/11.0/#sec-isbigintelementtype + +module.exports = function IsBigIntElementType(type) { + return type === 'BigUint64' || type === 'BigInt64'; +}; diff --git a/node_modules/es-abstract/2023/IsCallable.js b/node_modules/es-abstract/2023/IsCallable.js new file mode 100644 index 0000000000000000000000000000000000000000..3a69b19267dff33491a84421b667a0d82cba21f9 --- /dev/null +++ b/node_modules/es-abstract/2023/IsCallable.js @@ -0,0 +1,5 @@ +'use strict'; + +// http://262.ecma-international.org/5.1/#sec-9.11 + +module.exports = require('is-callable'); diff --git a/node_modules/es-abstract/2023/IsCompatiblePropertyDescriptor.js b/node_modules/es-abstract/2023/IsCompatiblePropertyDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..48e719f3c1e515175311d0f2fe599b4743f43062 --- /dev/null +++ b/node_modules/es-abstract/2023/IsCompatiblePropertyDescriptor.js @@ -0,0 +1,9 @@ +'use strict'; + +var ValidateAndApplyPropertyDescriptor = require('./ValidateAndApplyPropertyDescriptor'); + +// https://262.ecma-international.org/13.0/#sec-iscompatiblepropertydescriptor + +module.exports = function IsCompatiblePropertyDescriptor(Extensible, Desc, Current) { + return ValidateAndApplyPropertyDescriptor(undefined, '', Extensible, Desc, Current); +}; diff --git a/node_modules/es-abstract/2023/IsConcatSpreadable.js b/node_modules/es-abstract/2023/IsConcatSpreadable.js new file mode 100644 index 0000000000000000000000000000000000000000..ace2695309292c91b185505f63da3cc942534bd2 --- /dev/null +++ b/node_modules/es-abstract/2023/IsConcatSpreadable.js @@ -0,0 +1,26 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $isConcatSpreadable = GetIntrinsic('%Symbol.isConcatSpreadable%', true); + +var Get = require('./Get'); +var IsArray = require('./IsArray'); +var ToBoolean = require('./ToBoolean'); + +var isObject = require('es-object-atoms/isObject'); + +// https://262.ecma-international.org/6.0/#sec-isconcatspreadable + +module.exports = function IsConcatSpreadable(O) { + if (!isObject(O)) { + return false; + } + if ($isConcatSpreadable) { + var spreadable = Get(O, $isConcatSpreadable); + if (typeof spreadable !== 'undefined') { + return ToBoolean(spreadable); + } + } + return IsArray(O); +}; diff --git a/node_modules/es-abstract/2023/IsConstructor.js b/node_modules/es-abstract/2023/IsConstructor.js new file mode 100644 index 0000000000000000000000000000000000000000..62ac47f6a3d262927a9b147ee0057dfba9664b24 --- /dev/null +++ b/node_modules/es-abstract/2023/IsConstructor.js @@ -0,0 +1,40 @@ +'use strict'; + +var GetIntrinsic = require('../GetIntrinsic.js'); + +var $construct = GetIntrinsic('%Reflect.construct%', true); + +var DefinePropertyOrThrow = require('./DefinePropertyOrThrow'); +try { + DefinePropertyOrThrow({}, '', { '[[Get]]': function () {} }); +} catch (e) { + // Accessor properties aren't supported + DefinePropertyOrThrow = null; +} + +// https://262.ecma-international.org/6.0/#sec-isconstructor + +if (DefinePropertyOrThrow && $construct) { + var isConstructorMarker = {}; + var badArrayLike = {}; + DefinePropertyOrThrow(badArrayLike, 'length', { + '[[Get]]': function () { + throw isConstructorMarker; + }, + '[[Enumerable]]': true + }); + + module.exports = function IsConstructor(argument) { + try { + // `Reflect.construct` invokes `IsConstructor(target)` before `Get(args, 'length')`: + $construct(argument, badArrayLike); + } catch (err) { + return err === isConstructorMarker; + } + }; +} else { + module.exports = function IsConstructor(argument) { + // unfortunately there's no way to truly check this without try/catch `new argument` in old environments + return typeof argument === 'function' && !!argument.prototype; + }; +} diff --git a/node_modules/es-abstract/2023/IsDataDescriptor.js b/node_modules/es-abstract/2023/IsDataDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..d56bd36d4294369f6486f6dfc5d60dada2cc410a --- /dev/null +++ b/node_modules/es-abstract/2023/IsDataDescriptor.js @@ -0,0 +1,25 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var hasOwn = require('hasown'); + +var isPropertyDescriptor = require('../helpers/records/property-descriptor'); + +// https://262.ecma-international.org/5.1/#sec-8.10.2 + +module.exports = function IsDataDescriptor(Desc) { + if (typeof Desc === 'undefined') { + return false; + } + + if (!isPropertyDescriptor(Desc)) { + throw new $TypeError('Assertion failed: `Desc` must be a Property Descriptor'); + } + + if (!hasOwn(Desc, '[[Value]]') && !hasOwn(Desc, '[[Writable]]')) { + return false; + } + + return true; +}; diff --git a/node_modules/es-abstract/2023/IsDetachedBuffer.js b/node_modules/es-abstract/2023/IsDetachedBuffer.js new file mode 100644 index 0000000000000000000000000000000000000000..71c4f6be8d20b02a92a6721c7ae2833adf21150e --- /dev/null +++ b/node_modules/es-abstract/2023/IsDetachedBuffer.js @@ -0,0 +1,28 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var $byteLength = require('array-buffer-byte-length'); +var availableTypedArrays = require('available-typed-arrays')(); +var callBound = require('call-bound'); +var isArrayBuffer = require('is-array-buffer'); +var isSharedArrayBuffer = require('is-shared-array-buffer'); + +var $sabByteLength = callBound('SharedArrayBuffer.prototype.byteLength', true); + +// https://262.ecma-international.org/8.0/#sec-isdetachedbuffer + +module.exports = function IsDetachedBuffer(arrayBuffer) { + var isSAB = isSharedArrayBuffer(arrayBuffer); + if (!isArrayBuffer(arrayBuffer) && !isSAB) { + throw new $TypeError('Assertion failed: `arrayBuffer` must be an Object with an [[ArrayBufferData]] internal slot'); + } + if ((isSAB ? $sabByteLength : $byteLength)(arrayBuffer) === 0) { + try { + new global[availableTypedArrays[0]](arrayBuffer); // eslint-disable-line no-new + } catch (error) { + return !!error && error.name === 'TypeError'; + } + } + return false; +}; diff --git a/node_modules/es-abstract/2023/IsExtensible.js b/node_modules/es-abstract/2023/IsExtensible.js new file mode 100644 index 0000000000000000000000000000000000000000..aa19b914c2d3dc31c1215e2b203dc3ffbb78746c --- /dev/null +++ b/node_modules/es-abstract/2023/IsExtensible.js @@ -0,0 +1,18 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $preventExtensions = GetIntrinsic('%Object.preventExtensions%', true); +var $isExtensible = GetIntrinsic('%Object.isExtensible%', true); + +var isPrimitive = require('../helpers/isPrimitive'); + +// https://262.ecma-international.org/6.0/#sec-isextensible-o + +module.exports = $preventExtensions + ? function IsExtensible(obj) { + return !isPrimitive(obj) && $isExtensible(obj); + } + : function IsExtensible(obj) { + return !isPrimitive(obj); + }; diff --git a/node_modules/es-abstract/2023/IsGenericDescriptor.js b/node_modules/es-abstract/2023/IsGenericDescriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..9f6ef045ee44e9eaea4506a234f0e41e0bd1bac9 --- /dev/null +++ b/node_modules/es-abstract/2023/IsGenericDescriptor.js @@ -0,0 +1,26 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var IsAccessorDescriptor = require('./IsAccessorDescriptor'); +var IsDataDescriptor = require('./IsDataDescriptor'); + +var isPropertyDescriptor = require('../helpers/records/property-descriptor'); + +// https://262.ecma-international.org/6.0/#sec-isgenericdescriptor + +module.exports = function IsGenericDescriptor(Desc) { + if (typeof Desc === 'undefined') { + return false; + } + + if (!isPropertyDescriptor(Desc)) { + throw new $TypeError('Assertion failed: `Desc` must be a Property Descriptor'); + } + + if (!IsAccessorDescriptor(Desc) && !IsDataDescriptor(Desc)) { + return true; + } + + return false; +}; diff --git a/node_modules/es-abstract/2023/IsIntegralNumber.js b/node_modules/es-abstract/2023/IsIntegralNumber.js new file mode 100644 index 0000000000000000000000000000000000000000..62e497b40ff7f907d7da1f245c760572712ab4f5 --- /dev/null +++ b/node_modules/es-abstract/2023/IsIntegralNumber.js @@ -0,0 +1,14 @@ +'use strict'; + +var truncate = require('./truncate'); + +var $isFinite = require('math-intrinsics/isFinite'); + +// https://262.ecma-international.org/14.0/#sec-isintegralnumber + +module.exports = function IsIntegralNumber(argument) { + if (typeof argument !== 'number' || !$isFinite(argument)) { + return false; + } + return truncate(argument) === argument; +}; diff --git a/node_modules/es-abstract/2023/IsLessThan.js b/node_modules/es-abstract/2023/IsLessThan.js new file mode 100644 index 0000000000000000000000000000000000000000..73f6cff9a254af6a6585ae68821c504048d2c192 --- /dev/null +++ b/node_modules/es-abstract/2023/IsLessThan.js @@ -0,0 +1,97 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $Number = GetIntrinsic('%Number%'); +var $TypeError = require('es-errors/type'); +var min = require('math-intrinsics/min'); +var $isNaN = require('math-intrinsics/isNaN'); + +var $charCodeAt = require('call-bound')('String.prototype.charCodeAt'); + +var StringToBigInt = require('./StringToBigInt'); +var ToNumeric = require('./ToNumeric'); +var ToPrimitive = require('./ToPrimitive'); + +var BigIntLessThan = require('./BigInt/lessThan'); +var NumberLessThan = require('./Number/lessThan'); + +// https://262.ecma-international.org/14.0/#sec-islessthan + +// eslint-disable-next-line max-statements, max-lines-per-function +module.exports = function IsLessThan(x, y, LeftFirst) { + if (typeof LeftFirst !== 'boolean') { + throw new $TypeError('Assertion failed: LeftFirst argument must be a Boolean'); + } + var px; + var py; + if (LeftFirst) { + px = ToPrimitive(x, $Number); + py = ToPrimitive(y, $Number); + } else { + py = ToPrimitive(y, $Number); + px = ToPrimitive(x, $Number); + } + + if (typeof px === 'string' && typeof py === 'string') { // step 3 + // a. Let lx be the length of px. + // b. Let ly be the length of py. + // c. For each integer i starting with 0 such that i < min(lx, ly), in ascending order, do + // i. Let cx be the integer that is the numeric value of the code unit at index i within px. + // ii. Let cy be the integer that is the numeric value of the code unit at index i within py. + // iii. If cx < cy, return true. + // iv. If cx > cy, return false. + // d. If lx < ly, return true. Otherwise, return false. + + var lx = px.length; // step 3.a + var ly = py.length; // step 3.b + for (var i = 0; i < min(lx, ly); i++) { // step 3.c + var cx = $charCodeAt(px, i); // step 3.c.i + var cy = $charCodeAt(py, i); // step 3.c.ii + if (cx < cy) { + return true; // step 3.c.iii + } + if (cx > cy) { + return false; // step 3.c.iv + } + } + return lx < ly; // step 3.d + } + + var nx; + var ny; + if (typeof px === 'bigint' && typeof py === 'string') { + ny = StringToBigInt(py); + if (typeof ny === 'undefined') { + return void undefined; + } + return BigIntLessThan(px, ny); + } + if (typeof px === 'string' && typeof py === 'bigint') { + nx = StringToBigInt(px); + if (typeof nx === 'undefined') { + return void undefined; + } + return BigIntLessThan(nx, py); + } + + nx = ToNumeric(px); + ny = ToNumeric(py); + + if (typeof nx === typeof ny) { + return typeof nx === 'number' ? NumberLessThan(nx, ny) : BigIntLessThan(nx, ny); + } + + if ($isNaN(nx) || $isNaN(ny)) { + return void undefined; + } + + if (nx === -Infinity || ny === Infinity) { + return true; + } + if (nx === Infinity || ny === -Infinity) { + return false; + } + + return nx < ny; // by now, these are both finite, and the same type +}; diff --git a/node_modules/es-abstract/2023/IsLooselyEqual.js b/node_modules/es-abstract/2023/IsLooselyEqual.js new file mode 100644 index 0000000000000000000000000000000000000000..c7bb047f55d337b5ca46405cc07a284d5843d71a --- /dev/null +++ b/node_modules/es-abstract/2023/IsLooselyEqual.js @@ -0,0 +1,58 @@ +'use strict'; + +var isFinite = require('math-intrinsics/isFinite'); +var isObject = require('es-object-atoms/isObject'); + +var IsStrictlyEqual = require('./IsStrictlyEqual'); +var StringToBigInt = require('./StringToBigInt'); +var ToNumber = require('./ToNumber'); +var ToPrimitive = require('./ToPrimitive'); + +var isSameType = require('../helpers/isSameType'); + +// https://262.ecma-international.org/13.0/#sec-islooselyequal + +module.exports = function IsLooselyEqual(x, y) { + if (isSameType(x, y)) { + return IsStrictlyEqual(x, y); + } + if (x == null && y == null) { + return true; + } + if (typeof x === 'number' && typeof y === 'string') { + return IsLooselyEqual(x, ToNumber(y)); + } + if (typeof x === 'string' && typeof y === 'number') { + return IsLooselyEqual(ToNumber(x), y); + } + if (typeof x === 'bigint' && typeof y === 'string') { + var n = StringToBigInt(y); + if (typeof n === 'undefined') { + return false; + } + return IsLooselyEqual(x, n); + } + if (typeof x === 'string' && typeof y === 'bigint') { + return IsLooselyEqual(y, x); + } + if (typeof x === 'boolean') { + return IsLooselyEqual(ToNumber(x), y); + } + if (typeof y === 'boolean') { + return IsLooselyEqual(x, ToNumber(y)); + } + if ((typeof x === 'string' || typeof x === 'number' || typeof x === 'symbol' || typeof x === 'bigint') && isObject(y)) { + return IsLooselyEqual(x, ToPrimitive(y)); + } + if (isObject(x) && (typeof y === 'string' || typeof y === 'number' || typeof y === 'symbol' || typeof y === 'bigint')) { + return IsLooselyEqual(ToPrimitive(x), y); + } + if ((typeof x === 'bigint' && typeof y === 'number') || (typeof x === 'number' && typeof y === 'bigint')) { + if (!isFinite(x) || !isFinite(y)) { + return false; + } + // eslint-disable-next-line eqeqeq + return x == y; // shortcut for step 13.b. + } + return false; +}; diff --git a/node_modules/es-abstract/2023/IsNoTearConfiguration.js b/node_modules/es-abstract/2023/IsNoTearConfiguration.js new file mode 100644 index 0000000000000000000000000000000000000000..f0d2808737ac6c853571ca68c94f57f7ee4cb59b --- /dev/null +++ b/node_modules/es-abstract/2023/IsNoTearConfiguration.js @@ -0,0 +1,16 @@ +'use strict'; + +var IsUnclampedIntegerElementType = require('./IsUnclampedIntegerElementType'); +var IsBigIntElementType = require('./IsBigIntElementType'); + +// https://262.ecma-international.org/11.0/#sec-isnotearconfiguration + +module.exports = function IsNoTearConfiguration(type, order) { + if (IsUnclampedIntegerElementType(type)) { + return true; + } + if (IsBigIntElementType(type) && order !== 'Init' && order !== 'Unordered') { + return true; + } + return false; +}; diff --git a/node_modules/es-abstract/2023/IsPromise.js b/node_modules/es-abstract/2023/IsPromise.js new file mode 100644 index 0000000000000000000000000000000000000000..f3d67b1c7045d7657ec74a6d084dc088aadb5ff4 --- /dev/null +++ b/node_modules/es-abstract/2023/IsPromise.js @@ -0,0 +1,24 @@ +'use strict'; + +var callBound = require('call-bound'); + +var $PromiseThen = callBound('Promise.prototype.then', true); + +var isObject = require('es-object-atoms/isObject'); + +// https://262.ecma-international.org/6.0/#sec-ispromise + +module.exports = function IsPromise(x) { + if (!isObject(x)) { + return false; + } + if (!$PromiseThen) { // Promises are not supported + return false; + } + try { + $PromiseThen(x); // throws if not a promise + } catch (e) { + return false; + } + return true; +}; diff --git a/node_modules/es-abstract/2023/IsPropertyKey.js b/node_modules/es-abstract/2023/IsPropertyKey.js new file mode 100644 index 0000000000000000000000000000000000000000..4b1c9c71461ca474f34b517c0bc04e5d700280f2 --- /dev/null +++ b/node_modules/es-abstract/2023/IsPropertyKey.js @@ -0,0 +1,9 @@ +'use strict'; + +var isPropertyKey = require('../helpers/isPropertyKey'); + +// https://262.ecma-international.org/6.0/#sec-ispropertykey + +module.exports = function IsPropertyKey(argument) { + return isPropertyKey(argument); +}; diff --git a/node_modules/es-abstract/2023/IsRegExp.js b/node_modules/es-abstract/2023/IsRegExp.js new file mode 100644 index 0000000000000000000000000000000000000000..8855492d58ded3c061b84be35e962fe32c8de53e --- /dev/null +++ b/node_modules/es-abstract/2023/IsRegExp.js @@ -0,0 +1,25 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $match = GetIntrinsic('%Symbol.match%', true); + +var hasRegExpMatcher = require('is-regex'); +var isObject = require('es-object-atoms/isObject'); + +var ToBoolean = require('./ToBoolean'); + +// https://262.ecma-international.org/6.0/#sec-isregexp + +module.exports = function IsRegExp(argument) { + if (!isObject(argument)) { + return false; + } + if ($match) { + var isRegExp = argument[$match]; + if (typeof isRegExp !== 'undefined') { + return ToBoolean(isRegExp); + } + } + return hasRegExpMatcher(argument); +}; diff --git a/node_modules/es-abstract/2023/IsSharedArrayBuffer.js b/node_modules/es-abstract/2023/IsSharedArrayBuffer.js new file mode 100644 index 0000000000000000000000000000000000000000..41d61b116db4b3aabf7dde87e6b46cc5aa378d99 --- /dev/null +++ b/node_modules/es-abstract/2023/IsSharedArrayBuffer.js @@ -0,0 +1,16 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var isSharedArrayBuffer = require('is-shared-array-buffer'); + +// https://262.ecma-international.org/8.0/#sec-issharedarraybuffer + +module.exports = function IsSharedArrayBuffer(obj) { + if (!isObject(obj)) { + throw new $TypeError('Assertion failed: Type(O) is not Object'); + } + + return isSharedArrayBuffer(obj); +}; diff --git a/node_modules/es-abstract/2023/IsStrictlyEqual.js b/node_modules/es-abstract/2023/IsStrictlyEqual.js new file mode 100644 index 0000000000000000000000000000000000000000..3bec0744e003db56188fdc5a486bbef3d7338091 --- /dev/null +++ b/node_modules/es-abstract/2023/IsStrictlyEqual.js @@ -0,0 +1,14 @@ +'use strict'; + +var SameValueNonNumber = require('./SameValueNonNumber'); +var Type = require('./Type'); +var NumberEqual = require('./Number/equal'); + +// https://262.ecma-international.org/14.0/#sec-isstrictlyequal + +module.exports = function IsStrictlyEqual(x, y) { + if (Type(x) !== Type(y)) { + return false; + } + return typeof x === 'number' ? NumberEqual(x, y) : SameValueNonNumber(x, y); +}; diff --git a/node_modules/es-abstract/2023/IsStringWellFormedUnicode.js b/node_modules/es-abstract/2023/IsStringWellFormedUnicode.js new file mode 100644 index 0000000000000000000000000000000000000000..d5fa48a69550d7faadb0a377af014cd530a74a87 --- /dev/null +++ b/node_modules/es-abstract/2023/IsStringWellFormedUnicode.js @@ -0,0 +1,23 @@ +'use strict'; + +var CodePointAt = require('./CodePointAt'); + +var $TypeError = require('es-errors/type'); + +// https://262.ecma-international.org/14.0/#sec-isstringwellformedunicode + +module.exports = function IsStringWellFormedUnicode(string) { + if (typeof string !== 'string') { + throw new $TypeError('Assertion failed: `string` must be a String'); + } + var len = string.length; // step 1 + var k = 0; // step 2 + while (k < len) { // step 3 + var cp = CodePointAt(string, k); // step 3.a + if (cp['[[IsUnpairedSurrogate]]']) { + return false; // step 3.b + } + k += cp['[[CodeUnitCount]]']; // step 3.c + } + return true; // step 4 +}; diff --git a/node_modules/es-abstract/2023/IsTimeZoneOffsetString.js b/node_modules/es-abstract/2023/IsTimeZoneOffsetString.js new file mode 100644 index 0000000000000000000000000000000000000000..a05ae41b4416d1c83c8a3fe5e72f19c13dfb2a33 --- /dev/null +++ b/node_modules/es-abstract/2023/IsTimeZoneOffsetString.js @@ -0,0 +1,20 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var regexTester = require('safe-regex-test'); + +// https://tc39.es/ecma262/#sec-istimezoneoffsetstring + +// implementation taken from https://github.com/tc39/proposal-temporal/blob/21ee5b13f0672990c807475ba094092d19dd6dc5/polyfill/lib/ecmascript.mjs#L2140 + +var OFFSET = /^([+\u2212-])([01][0-9]|2[0-3])(?::?([0-5][0-9])(?::?([0-5][0-9])(?:[.,](\d{1,9}))?)?)?$/; + +var testOffset = regexTester(OFFSET); + +module.exports = function IsTimeZoneOffsetString(offsetString) { + if (typeof offsetString !== 'string') { + throw new $TypeError('Assertion failed: `offsetString` must be a String'); + } + return testOffset(offsetString); +}; diff --git a/node_modules/es-abstract/2023/IsUnclampedIntegerElementType.js b/node_modules/es-abstract/2023/IsUnclampedIntegerElementType.js new file mode 100644 index 0000000000000000000000000000000000000000..4e3a38425d65f2320b3e72bc16d3bf6b38ae3f38 --- /dev/null +++ b/node_modules/es-abstract/2023/IsUnclampedIntegerElementType.js @@ -0,0 +1,12 @@ +'use strict'; + +// https://262.ecma-international.org/11.0/#sec-isunclampedintegerelementtype + +module.exports = function IsUnclampedIntegerElementType(type) { + return type === 'Int8' + || type === 'Uint8' + || type === 'Int16' + || type === 'Uint16' + || type === 'Int32' + || type === 'Uint32'; +}; diff --git a/node_modules/es-abstract/2023/IsUnsignedElementType.js b/node_modules/es-abstract/2023/IsUnsignedElementType.js new file mode 100644 index 0000000000000000000000000000000000000000..b1ff194d73916d487ce951d1c7553b7aa5ab34cf --- /dev/null +++ b/node_modules/es-abstract/2023/IsUnsignedElementType.js @@ -0,0 +1,11 @@ +'use strict'; + +// https://262.ecma-international.org/11.0/#sec-isunsignedelementtype + +module.exports = function IsUnsignedElementType(type) { + return type === 'Uint8' + || type === 'Uint8C' + || type === 'Uint16' + || type === 'Uint32' + || type === 'BigUint64'; +}; diff --git a/node_modules/es-abstract/2023/IsValidIntegerIndex.js b/node_modules/es-abstract/2023/IsValidIntegerIndex.js new file mode 100644 index 0000000000000000000000000000000000000000..d5deae7a72ff0e4bad585acc679453c2f22538e9 --- /dev/null +++ b/node_modules/es-abstract/2023/IsValidIntegerIndex.js @@ -0,0 +1,30 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isNegativeZero = require('math-intrinsics/isNegativeZero'); + +var IsDetachedBuffer = require('./IsDetachedBuffer'); + +var isInteger = require('math-intrinsics/isInteger'); +var typedArrayBuffer = require('typed-array-buffer'); + +// https://262.ecma-international.org/12.0/#sec-isvalidintegerindex + +module.exports = function IsValidIntegerIndex(O, index) { + // Assert: O is an Integer-Indexed exotic object. + var buffer = typedArrayBuffer(O); // step 1 + + if (typeof index !== 'number') { + throw new $TypeError('Assertion failed: Type(index) is not Number'); + } + + if (IsDetachedBuffer(buffer)) { return false; } // step 2 + + if (!isInteger(index)) { return false; } // step 3 + + if (isNegativeZero(index)) { return false; } // step 4 + + if (index < 0 || index >= O.length) { return false; } // step 5 + + return true; // step 6 +}; diff --git a/node_modules/es-abstract/2023/IsWordChar.js b/node_modules/es-abstract/2023/IsWordChar.js new file mode 100644 index 0000000000000000000000000000000000000000..8a440c3356d46c9a78e37007f82a208b697c75cd --- /dev/null +++ b/node_modules/es-abstract/2023/IsWordChar.js @@ -0,0 +1,42 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var callBound = require('call-bound'); +var isInteger = require('math-intrinsics/isInteger'); + +var $indexOf = callBound('String.prototype.indexOf'); + +var IsArray = require('./IsArray'); +var WordCharacters = require('./WordCharacters'); + +var every = require('../helpers/every'); +var isRegExpRecord = require('../helpers/records/regexp-record'); + +var isChar = function isChar(c) { + return typeof c === 'string'; +}; + +// https://262.ecma-international.org/14.0/#sec-runtime-semantics-iswordchar-abstract-operation + +module.exports = function IsWordChar(rer, Input, e) { + if (!isRegExpRecord(rer)) { + throw new $TypeError('Assertion failed: `rer` must be a RegExp Record'); + } + if (!IsArray(Input) || !every(Input, isChar)) { + throw new $TypeError('Assertion failed: `Input` must be a List of characters'); + } + + if (!isInteger(e)) { + throw new $TypeError('Assertion failed: `e` must be an integer'); + } + + var InputLength = Input.length; // step 1 + + if (e === -1 || e === InputLength) { + return false; // step 2 + } + + var c = Input[e]; // step 3 + + return $indexOf(WordCharacters(rer), c) > -1; // steps 4-5 +}; diff --git a/node_modules/es-abstract/2023/IteratorClose.js b/node_modules/es-abstract/2023/IteratorClose.js new file mode 100644 index 0000000000000000000000000000000000000000..42d46f834c5f03b6da4d1899e3ab164ec8f8ccb3 --- /dev/null +++ b/node_modules/es-abstract/2023/IteratorClose.js @@ -0,0 +1,65 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var Call = require('./Call'); +var CompletionRecord = require('./CompletionRecord'); +var GetMethod = require('./GetMethod'); +var IsCallable = require('./IsCallable'); + +var isIteratorRecord = require('../helpers/records/iterator-record-2023'); + +// https://262.ecma-international.org/14.0/#sec-iteratorclose + +module.exports = function IteratorClose(iteratorRecord, completion) { + if (!isIteratorRecord(iteratorRecord)) { + throw new $TypeError('Assertion failed: `iteratorRecord` must be an Iterator Record'); // step 1 + } + if (!isObject(iteratorRecord['[[Iterator]]'])) { + throw new $TypeError('Assertion failed: iteratorRecord.[[Iterator]] must be an Object'); // step 1 + } + + if (!IsCallable(completion) && !(completion instanceof CompletionRecord)) { // step 2 + throw new $TypeError('Assertion failed: completion is not a thunk representing a Completion Record, nor a Completion Record instance'); + } + var completionThunk = completion instanceof CompletionRecord ? function () { return completion['?'](); } : completion; + + var iterator = iteratorRecord['[[Iterator]]']; // step 3 + + var iteratorReturn; + try { + iteratorReturn = GetMethod(iterator, 'return'); // step 4 + } catch (e) { + completionThunk(); // throws if `completion` is a throw completion // step 6 + // eslint-disable-next-line no-useless-assignment + completionThunk = null; // ensure it's not called twice. + throw e; // step 7 + } + if (typeof iteratorReturn === 'undefined') { + return completionThunk(); // step 5.a - 5.b + } + + var innerResult; + try { + innerResult = Call(iteratorReturn, iterator, []); + } catch (e) { + // if we hit here, then "e" is the innerResult completion that needs re-throwing + + completionThunk(); // throws if `completion` is a throw completion // step 6 + // eslint-disable-next-line no-useless-assignment + completionThunk = null; // ensure it's not called twice. + + // if not, then return the innerResult completion + throw e; // step 7 + } + var completionRecord = completionThunk(); // if innerResult worked, then throw if the completion does + // eslint-disable-next-line no-useless-assignment + completionThunk = null; // ensure it's not called twice. + + if (!isObject(innerResult)) { + throw new $TypeError('iterator .return must return an object'); + } + + return completionRecord; +}; diff --git a/node_modules/es-abstract/2023/IteratorComplete.js b/node_modules/es-abstract/2023/IteratorComplete.js new file mode 100644 index 0000000000000000000000000000000000000000..c8a0d67c244bbec3d032bb8a4cc5597b7419d97b --- /dev/null +++ b/node_modules/es-abstract/2023/IteratorComplete.js @@ -0,0 +1,16 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var Get = require('./Get'); +var ToBoolean = require('./ToBoolean'); + +// https://262.ecma-international.org/6.0/#sec-iteratorcomplete + +module.exports = function IteratorComplete(iterResult) { + if (!isObject(iterResult)) { + throw new $TypeError('Assertion failed: Type(iterResult) is not Object'); + } + return ToBoolean(Get(iterResult, 'done')); +}; diff --git a/node_modules/es-abstract/2023/IteratorNext.js b/node_modules/es-abstract/2023/IteratorNext.js new file mode 100644 index 0000000000000000000000000000000000000000..a1257f72e706b917d179e6eba1c04b8dbbf5269f --- /dev/null +++ b/node_modules/es-abstract/2023/IteratorNext.js @@ -0,0 +1,28 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var Call = require('./Call'); + +var isIteratorRecord = require('../helpers/records/iterator-record-2023'); + +// https://262.ecma-international.org/14.0/#sec-iteratornext + +module.exports = function IteratorNext(iteratorRecord) { + if (!isIteratorRecord(iteratorRecord)) { + throw new $TypeError('Assertion failed: `iteratorRecord` must be an Iterator Record'); // step 1 + } + + var result; + if (arguments.length < 2) { // step 1 + result = Call(iteratorRecord['[[NextMethod]]'], iteratorRecord['[[Iterator]]']); // step 1.a + } else { // step 2 + result = Call(iteratorRecord['[[NextMethod]]'], iteratorRecord['[[Iterator]]'], [arguments[1]]); // step 2.a + } + + if (!isObject(result)) { + throw new $TypeError('iterator next must return an object'); // step 3 + } + return result; // step 4 +}; diff --git a/node_modules/es-abstract/2023/IteratorStep.js b/node_modules/es-abstract/2023/IteratorStep.js new file mode 100644 index 0000000000000000000000000000000000000000..28a7f95aa389de77adc76e444b8c869cdf11a7b2 --- /dev/null +++ b/node_modules/es-abstract/2023/IteratorStep.js @@ -0,0 +1,21 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var IteratorComplete = require('./IteratorComplete'); +var IteratorNext = require('./IteratorNext'); + +var isIteratorRecord = require('../helpers/records/iterator-record-2023'); + +// https://262.ecma-international.org/14.0/#sec-iteratorstep + +module.exports = function IteratorStep(iteratorRecord) { + if (!isIteratorRecord(iteratorRecord)) { + throw new $TypeError('Assertion failed: `iteratorRecord` must be an Iterator Record'); // step 1 + } + + var result = IteratorNext(iteratorRecord); // step 1 + var done = IteratorComplete(result); // step 2 + return done === true ? false : result; // steps 3-4 +}; + diff --git a/node_modules/es-abstract/2023/IteratorToList.js b/node_modules/es-abstract/2023/IteratorToList.js new file mode 100644 index 0000000000000000000000000000000000000000..325cc20987204d81d301e1dea1faa81fd4745acd --- /dev/null +++ b/node_modules/es-abstract/2023/IteratorToList.js @@ -0,0 +1,27 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var IteratorStep = require('./IteratorStep'); +var IteratorValue = require('./IteratorValue'); + +var isIteratorRecord = require('../helpers/records/iterator-record-2023'); + +// https://262.ecma-international.org/14.0/#sec-iteratortolist + +module.exports = function IteratorToList(iteratorRecord) { + if (!isIteratorRecord(iteratorRecord)) { + throw new $TypeError('Assertion failed: `iteratorRecord` must be an Iterator Record'); // step 1 + } + + var values = []; // step 1 + var next = true; // step 2 + while (next) { // step 3 + next = IteratorStep(iteratorRecord); // step 3.a + if (next) { + var nextValue = IteratorValue(next); // step 3.b.i + values[values.length] = nextValue; // step 3.b.ii + } + } + return values; // step 4 +}; diff --git a/node_modules/es-abstract/2023/IteratorValue.js b/node_modules/es-abstract/2023/IteratorValue.js new file mode 100644 index 0000000000000000000000000000000000000000..016ddfbd4f01381dd13487740d6806003449d4b1 --- /dev/null +++ b/node_modules/es-abstract/2023/IteratorValue.js @@ -0,0 +1,16 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var Get = require('./Get'); + +// https://262.ecma-international.org/6.0/#sec-iteratorvalue + +module.exports = function IteratorValue(iterResult) { + if (!isObject(iterResult)) { + throw new $TypeError('Assertion failed: Type(iterResult) is not Object'); + } + return Get(iterResult, 'value'); +}; + diff --git a/node_modules/es-abstract/2023/KeyForSymbol.js b/node_modules/es-abstract/2023/KeyForSymbol.js new file mode 100644 index 0000000000000000000000000000000000000000..e0f0f1c881b24881bb47560527efcd160a776cb9 --- /dev/null +++ b/node_modules/es-abstract/2023/KeyForSymbol.js @@ -0,0 +1,16 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var callBound = require('call-bound'); + +var $keyFor = callBound('Symbol.keyFor', true); + +// https://262.ecma-international.org/14.0/#sec-keyforsymbol + +module.exports = function KeyForSymbol(sym) { + if (typeof sym !== 'symbol') { + throw new $TypeError('Assertion failed: `sym` must be a Symbol'); + } + return $keyFor(sym); +}; diff --git a/node_modules/es-abstract/2023/LengthOfArrayLike.js b/node_modules/es-abstract/2023/LengthOfArrayLike.js new file mode 100644 index 0000000000000000000000000000000000000000..437bcd86c93b2ea23f727bb18c83ae4b58fe7e2b --- /dev/null +++ b/node_modules/es-abstract/2023/LengthOfArrayLike.js @@ -0,0 +1,18 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); +var isObject = require('es-object-atoms/isObject'); + +var Get = require('./Get'); +var ToLength = require('./ToLength'); + +// https://262.ecma-international.org/11.0/#sec-lengthofarraylike + +module.exports = function LengthOfArrayLike(obj) { + if (!isObject(obj)) { + throw new $TypeError('Assertion failed: `obj` must be an Object'); + } + return ToLength(Get(obj, 'length')); +}; + +// TODO: use this all over diff --git a/node_modules/es-abstract/2023/MakeDate.js b/node_modules/es-abstract/2023/MakeDate.js new file mode 100644 index 0000000000000000000000000000000000000000..3256ae1092afd21a469f4ca086dc028a73ecaa52 --- /dev/null +++ b/node_modules/es-abstract/2023/MakeDate.js @@ -0,0 +1,14 @@ +'use strict'; + +var $isFinite = require('math-intrinsics/isFinite'); + +var msPerDay = require('../helpers/timeConstants').msPerDay; + +// https://262.ecma-international.org/5.1/#sec-15.9.1.13 + +module.exports = function MakeDate(day, time) { + if (!$isFinite(day) || !$isFinite(time)) { + return NaN; + } + return (day * msPerDay) + time; +}; diff --git a/node_modules/es-abstract/2023/MakeDay.js b/node_modules/es-abstract/2023/MakeDay.js new file mode 100644 index 0000000000000000000000000000000000000000..3e5a91e6d1696ed0b1ede1140b517182ab10c84a --- /dev/null +++ b/node_modules/es-abstract/2023/MakeDay.js @@ -0,0 +1,36 @@ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $DateUTC = GetIntrinsic('%Date.UTC%'); + +var $isFinite = require('math-intrinsics/isFinite'); + +var DateFromTime = require('./DateFromTime'); +var Day = require('./Day'); +var floor = require('./floor'); +var modulo = require('./modulo'); +var MonthFromTime = require('./MonthFromTime'); +var ToIntegerOrInfinity = require('./ToIntegerOrInfinity'); +var YearFromTime = require('./YearFromTime'); + +// https://262.ecma-international.org/5.1/#sec-15.9.1.12 + +module.exports = function MakeDay(year, month, date) { + if (!$isFinite(year) || !$isFinite(month) || !$isFinite(date)) { + return NaN; + } + var y = ToIntegerOrInfinity(year); + var m = ToIntegerOrInfinity(month); + var dt = ToIntegerOrInfinity(date); + var ym = y + floor(m / 12); + if (!$isFinite(ym)) { + return NaN; + } + var mn = modulo(m, 12); + var t = $DateUTC(ym, mn, 1); + if (YearFromTime(t) !== ym || MonthFromTime(t) !== mn || DateFromTime(t) !== 1) { + return NaN; + } + return Day(t) + dt - 1; +}; diff --git a/node_modules/es-abstract/2023/MakeMatchIndicesIndexPairArray.js b/node_modules/es-abstract/2023/MakeMatchIndicesIndexPairArray.js new file mode 100644 index 0000000000000000000000000000000000000000..eeb5b39020f0188982d6924e7d7479df06aa39c6 --- /dev/null +++ b/node_modules/es-abstract/2023/MakeMatchIndicesIndexPairArray.js @@ -0,0 +1,66 @@ +'use strict'; + +var $TypeError = require('es-errors/type'); + +var ArrayCreate = require('./ArrayCreate'); +var CreateDataPropertyOrThrow = require('./CreateDataPropertyOrThrow'); +var GetMatchIndexPair = require('./GetMatchIndexPair'); +var IsArray = require('./IsArray'); +var OrdinaryObjectCreate = require('./OrdinaryObjectCreate'); +var ToString = require('./ToString'); + +var every = require('../helpers/every'); +var isMatchRecord = require('../helpers/records/match-record'); + +var isStringOrUndefined = function isStringOrUndefined(s) { + return typeof s === 'undefined' || typeof s === 'string'; +}; + +var isMatchRecordOrUndefined = function isMatchRecordOrUndefined(m) { + return typeof m === 'undefined' || isMatchRecord(m); +}; + +var MAX_ARRAY_LENGTH = require('math-intrinsics/constants/maxArrayLength'); + +// https://262.ecma-international.org/13.0/#sec-getmatchindexpair + +module.exports = function MakeMatchIndicesIndexPairArray(S, indices, groupNames, hasGroups) { + if (typeof S !== 'string') { + throw new $TypeError('Assertion failed: `S` must be a String'); + } + if (!IsArray(indices) || !every(indices, isMatchRecordOrUndefined)) { + throw new $TypeError('Assertion failed: `indices` must be a List of either Match Records or `undefined`'); + } + if (!IsArray(groupNames) || !every(groupNames, isStringOrUndefined)) { + throw new $TypeError('Assertion failed: `groupNames` must be a List of either Strings or `undefined`'); + } + if (typeof hasGroups !== 'boolean') { + throw new $TypeError('Assertion failed: `hasGroups` must be a Boolean'); + } + + var n = indices.length; // step 1 + if (!(n < MAX_ARRAY_LENGTH)) { + throw new $TypeError('Assertion failed: `indices` length must be less than the max array size, 2**32 - 1'); + } + if (groupNames.length !== n - 1) { + throw new $TypeError('Assertion failed: `groupNames` must have exactly one fewer item than `indices`'); + } + + var A = ArrayCreate(n); // step 5 + var groups = hasGroups ? OrdinaryObjectCreate(null) : void undefined; // step 6-7 + CreateDataPropertyOrThrow(A, 'groups', groups); // step 8 + + for (var i = 0; i < n; i += 1) { // step 9 + var matchIndices = indices[i]; // step 9.a + // eslint-disable-next-line no-negated-condition + var matchIndexPair = typeof matchIndices !== 'undefined' ? GetMatchIndexPair(S, matchIndices) : void undefined; // step 9.b-9.c + CreateDataPropertyOrThrow(A, ToString(i), matchIndexPair); // step 9.d + if (i > 0 && typeof groupNames[i - 1] !== 'undefined') { // step 9.e + if (!groups) { + throw new $TypeError('if `hasGroups` is `false`, `groupNames` can only contain `undefined` values'); + } + CreateDataPropertyOrThrow(groups, groupNames[i - 1], matchIndexPair); // step 9.e.i + } + } + return A; // step 10 +}; diff --git a/node_modules/es-abstract/2023/MakeTime.js b/node_modules/es-abstract/2023/MakeTime.js new file mode 100644 index 0000000000000000000000000000000000000000..ac7d81f7aeb735f350796f6f1e12bce24c8eb114 --- /dev/null +++ b/node_modules/es-abstract/2023/MakeTime.js @@ -0,0 +1,23 @@ +'use strict'; + +var $isFinite = require('math-intrinsics/isFinite'); +var timeConstants = require('../helpers/timeConstants'); +var msPerSecond = timeConstants.msPerSecond; +var msPerMinute = timeConstants.msPerMinute; +var msPerHour = timeConstants.msPerHour; + +var ToIntegerOrInfinity = require('./ToIntegerOrInfinity'); + +// https://262.ecma-international.org/12.0/#sec-maketime + +module.exports = function MakeTime(hour, min, sec, ms) { + if (!$isFinite(hour) || !$isFinite(min) || !$isFinite(sec) || !$isFinite(ms)) { + return NaN; + } + var h = ToIntegerOrInfinity(hour); + var m = ToIntegerOrInfinity(min); + var s = ToIntegerOrInfinity(sec); + var milli = ToIntegerOrInfinity(ms); + var t = (h * msPerHour) + (m * msPerMinute) + (s * msPerSecond) + milli; + return t; +};