jai shree ram
This commit is contained in:
52
node_modules/es-abstract/2022/AddEntriesFromIterable.js
generated
vendored
Normal file
52
node_modules/es-abstract/2022/AddEntriesFromIterable.js
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
'use strict';
|
||||
|
||||
var inspect = require('object-inspect');
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
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 Type = require('./Type');
|
||||
|
||||
// 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) { // eslint-disable-line no-constant-condition
|
||||
var next = IteratorStep(iteratorRecord);
|
||||
if (!next) {
|
||||
return target;
|
||||
}
|
||||
var nextItem = IteratorValue(next);
|
||||
if (Type(nextItem) !== 'Object') {
|
||||
var error = new $TypeError('iterator next must return an Object, got ' + inspect(nextItem));
|
||||
return IteratorClose(
|
||||
iteratorRecord,
|
||||
function () { throw error; } // eslint-disable-line no-loop-func
|
||||
);
|
||||
}
|
||||
try {
|
||||
var k = Get(nextItem, '0');
|
||||
var v = Get(nextItem, '1');
|
||||
Call(adder, target, [k, v]);
|
||||
} catch (e) {
|
||||
return IteratorClose(
|
||||
iteratorRecord,
|
||||
function () { throw e; }
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
21
node_modules/es-abstract/2022/AddToKeptObjects.js
generated
vendored
Normal file
21
node_modules/es-abstract/2022/AddToKeptObjects.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
var callBound = require('call-bind/callBound');
|
||||
var SLOT = require('internal-slot');
|
||||
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
var ClearKeptObjects = require('./ClearKeptObjects');
|
||||
var Type = require('./Type');
|
||||
|
||||
var $push = callBound('Array.prototype.push');
|
||||
|
||||
// https://262.ecma-international.org/12.0/#sec-addtokeptobjects
|
||||
|
||||
module.exports = function AddToKeptObjects(object) {
|
||||
if (Type(object) !== 'Object') {
|
||||
throw new $TypeError('Assertion failed: `object` must be an Object');
|
||||
}
|
||||
$push(SLOT.get(ClearKeptObjects, '[[es-abstract internal: KeptAlive]]'), object);
|
||||
};
|
34
node_modules/es-abstract/2022/AdvanceStringIndex.js
generated
vendored
Normal file
34
node_modules/es-abstract/2022/AdvanceStringIndex.js
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var CodePointAt = require('./CodePointAt');
|
||||
var IsIntegralNumber = require('./IsIntegralNumber');
|
||||
var Type = require('./Type');
|
||||
|
||||
var MAX_SAFE_INTEGER = require('../helpers/maxSafeInteger');
|
||||
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
// https://262.ecma-international.org/12.0/#sec-advancestringindex
|
||||
|
||||
module.exports = function AdvanceStringIndex(S, index, unicode) {
|
||||
if (Type(S) !== 'String') {
|
||||
throw new $TypeError('Assertion failed: `S` must be a String');
|
||||
}
|
||||
if (!IsIntegralNumber(index) || index < 0 || index > MAX_SAFE_INTEGER) {
|
||||
throw new $TypeError('Assertion failed: `length` must be an integer >= 0 and <= 2**53');
|
||||
}
|
||||
if (Type(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]]'];
|
||||
};
|
80
node_modules/es-abstract/2022/ApplyStringOrNumericBinaryOperator.js
generated
vendored
Normal file
80
node_modules/es-abstract/2022/ApplyStringOrNumericBinaryOperator.js
generated
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
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 (Type(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 (Type(lprim) === 'String' || Type(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);
|
||||
var T = Type(lnum);
|
||||
if (T !== Type(rnum)) {
|
||||
throw new $TypeError('types of ' + lnum + ' and ' + rnum + ' differ');
|
||||
}
|
||||
var Operation = table[opText][T === 'BigInt' ? 1 : 0];
|
||||
return Operation(lnum, rnum);
|
||||
};
|
54
node_modules/es-abstract/2022/ArrayCreate.js
generated
vendored
Normal file
54
node_modules/es-abstract/2022/ArrayCreate.js
generated
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $ArrayPrototype = GetIntrinsic('%Array.prototype%');
|
||||
var $RangeError = GetIntrinsic('%RangeError%');
|
||||
var $SyntaxError = GetIntrinsic('%SyntaxError%');
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
var IsIntegralNumber = require('./IsIntegralNumber');
|
||||
|
||||
var MAX_ARRAY_LENGTH = Math.pow(2, 32) - 1;
|
||||
|
||||
var hasProto = require('has-proto')();
|
||||
|
||||
var $setProto = GetIntrinsic('%Object.setPrototypeOf%', true) || (
|
||||
hasProto
|
||||
? function (O, proto) {
|
||||
O.__proto__ = proto; // eslint-disable-line no-proto, no-param-reassign
|
||||
return O;
|
||||
}
|
||||
: null
|
||||
);
|
||||
|
||||
// https://262.ecma-international.org/12.0/#sec-arraycreate
|
||||
|
||||
module.exports = function ArrayCreate(length) {
|
||||
if (!IsIntegralNumber(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;
|
||||
};
|
85
node_modules/es-abstract/2022/ArraySetLength.js
generated
vendored
Normal file
85
node_modules/es-abstract/2022/ArraySetLength.js
generated
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $RangeError = GetIntrinsic('%RangeError%');
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
var assign = require('object.assign');
|
||||
|
||||
var isPropertyDescriptor = require('../helpers/isPropertyDescriptor');
|
||||
|
||||
var IsArray = require('./IsArray');
|
||||
var IsAccessorDescriptor = require('./IsAccessorDescriptor');
|
||||
var IsDataDescriptor = require('./IsDataDescriptor');
|
||||
var OrdinaryDefineOwnProperty = require('./OrdinaryDefineOwnProperty');
|
||||
var OrdinaryGetOwnProperty = require('./OrdinaryGetOwnProperty');
|
||||
var ToNumber = require('./ToNumber');
|
||||
var ToString = require('./ToString');
|
||||
var ToUint32 = require('./ToUint32');
|
||||
var Type = require('./Type');
|
||||
|
||||
// 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({
|
||||
Type: Type,
|
||||
IsDataDescriptor: IsDataDescriptor,
|
||||
IsAccessorDescriptor: IsAccessorDescriptor
|
||||
}, 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;
|
||||
};
|
48
node_modules/es-abstract/2022/ArraySpeciesCreate.js
generated
vendored
Normal file
48
node_modules/es-abstract/2022/ArraySpeciesCreate.js
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $species = GetIntrinsic('%Symbol.species%', true);
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
var ArrayCreate = require('./ArrayCreate');
|
||||
var Get = require('./Get');
|
||||
var IsArray = require('./IsArray');
|
||||
var IsConstructor = require('./IsConstructor');
|
||||
var IsIntegralNumber = require('./IsIntegralNumber');
|
||||
var Type = require('./Type');
|
||||
|
||||
// https://262.ecma-international.org/12.0/#sec-arrayspeciescreate
|
||||
|
||||
module.exports = function ArraySpeciesCreate(originalArray, length) {
|
||||
if (!IsIntegralNumber(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 && Type(C) === 'Object') {
|
||||
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);
|
||||
};
|
||||
|
45
node_modules/es-abstract/2022/AsyncFromSyncIteratorContinuation.js
generated
vendored
Normal file
45
node_modules/es-abstract/2022/AsyncFromSyncIteratorContinuation.js
generated
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $SyntaxError = GetIntrinsic('%SyntaxError%');
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
var $Promise = GetIntrinsic('%Promise%', true);
|
||||
|
||||
var callBound = require('call-bind/callBound');
|
||||
|
||||
var CreateIterResultObject = require('./CreateIterResultObject');
|
||||
var IteratorComplete = require('./IteratorComplete');
|
||||
var IteratorValue = require('./IteratorValue');
|
||||
var PromiseResolve = require('./PromiseResolve');
|
||||
var Type = require('./Type');
|
||||
|
||||
var $then = callBound('Promise.prototype.then', true);
|
||||
|
||||
// https://262.ecma-international.org/10.0/#sec-asyncfromsynciteratorcontinuation
|
||||
|
||||
module.exports = function AsyncFromSyncIteratorContinuation(result) {
|
||||
if (Type(result) !== 'Object') {
|
||||
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
|
||||
};
|
68
node_modules/es-abstract/2022/AsyncIteratorClose.js
generated
vendored
Normal file
68
node_modules/es-abstract/2022/AsyncIteratorClose.js
generated
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $SyntaxError = GetIntrinsic('%SyntaxError%');
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
var $Promise = GetIntrinsic('%Promise%', true);
|
||||
|
||||
var Call = require('./Call');
|
||||
var CompletionRecord = require('./CompletionRecord');
|
||||
var GetMethod = require('./GetMethod');
|
||||
var Type = require('./Type');
|
||||
|
||||
var assertRecord = require('../helpers/assertRecord');
|
||||
|
||||
var callBound = require('call-bind/callBound');
|
||||
|
||||
var $then = callBound('Promise.prototype.then', true);
|
||||
|
||||
// https://262.ecma-international.org/12.0/#sec-asynciteratorclose
|
||||
|
||||
module.exports = function AsyncIteratorClose(iteratorRecord, completion) {
|
||||
assertRecord(Type, 'Iterator Record', 'iteratorRecord', iteratorRecord); // 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 (Type(innerResult) !== 'Object') {
|
||||
throw new $TypeError('`innerResult` must be an Object'); // step 10
|
||||
}
|
||||
return completion;
|
||||
}
|
||||
);
|
||||
};
|
18
node_modules/es-abstract/2022/BigInt/add.js
generated
vendored
Normal file
18
node_modules/es-abstract/2022/BigInt/add.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
var Type = require('../Type');
|
||||
|
||||
// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-add
|
||||
|
||||
module.exports = function BigIntAdd(x, y) {
|
||||
if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') {
|
||||
throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts');
|
||||
}
|
||||
|
||||
// shortcut for the actual spec mechanics
|
||||
return x + y;
|
||||
};
|
17
node_modules/es-abstract/2022/BigInt/bitwiseAND.js
generated
vendored
Normal file
17
node_modules/es-abstract/2022/BigInt/bitwiseAND.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
var BigIntBitwiseOp = require('../BigIntBitwiseOp');
|
||||
var Type = require('../Type');
|
||||
|
||||
// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-bitwiseAND
|
||||
|
||||
module.exports = function BigIntBitwiseAND(x, y) {
|
||||
if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') {
|
||||
throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts');
|
||||
}
|
||||
return BigIntBitwiseOp('&', x, y);
|
||||
};
|
17
node_modules/es-abstract/2022/BigInt/bitwiseNOT.js
generated
vendored
Normal file
17
node_modules/es-abstract/2022/BigInt/bitwiseNOT.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $BigInt = GetIntrinsic('%BigInt%', true);
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
var Type = require('../Type');
|
||||
|
||||
// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-bitwiseNOT
|
||||
|
||||
module.exports = function BigIntBitwiseNOT(x) {
|
||||
if (Type(x) !== 'BigInt') {
|
||||
throw new $TypeError('Assertion failed: `x` argument must be a BigInt');
|
||||
}
|
||||
return -x - $BigInt(1);
|
||||
};
|
17
node_modules/es-abstract/2022/BigInt/bitwiseOR.js
generated
vendored
Normal file
17
node_modules/es-abstract/2022/BigInt/bitwiseOR.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
var BigIntBitwiseOp = require('../BigIntBitwiseOp');
|
||||
var Type = require('../Type');
|
||||
|
||||
// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-bitwiseOR
|
||||
|
||||
module.exports = function BigIntBitwiseOR(x, y) {
|
||||
if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') {
|
||||
throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts');
|
||||
}
|
||||
return BigIntBitwiseOp('|', x, y);
|
||||
};
|
17
node_modules/es-abstract/2022/BigInt/bitwiseXOR.js
generated
vendored
Normal file
17
node_modules/es-abstract/2022/BigInt/bitwiseXOR.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
var BigIntBitwiseOp = require('../BigIntBitwiseOp');
|
||||
var Type = require('../Type');
|
||||
|
||||
// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-bitwiseXOR
|
||||
|
||||
module.exports = function BigIntBitwiseXOR(x, y) {
|
||||
if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') {
|
||||
throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts');
|
||||
}
|
||||
return BigIntBitwiseOp('^', x, y);
|
||||
};
|
22
node_modules/es-abstract/2022/BigInt/divide.js
generated
vendored
Normal file
22
node_modules/es-abstract/2022/BigInt/divide.js
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $BigInt = GetIntrinsic('%BigInt%', true);
|
||||
var $RangeError = GetIntrinsic('%RangeError%');
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
var Type = require('../Type');
|
||||
|
||||
// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-divide
|
||||
|
||||
module.exports = function BigIntDivide(x, y) {
|
||||
if (Type(x) !== 'BigInt' || Type(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;
|
||||
};
|
17
node_modules/es-abstract/2022/BigInt/equal.js
generated
vendored
Normal file
17
node_modules/es-abstract/2022/BigInt/equal.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
var Type = require('../Type');
|
||||
|
||||
// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-equal
|
||||
|
||||
module.exports = function BigIntEqual(x, y) {
|
||||
if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') {
|
||||
throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts');
|
||||
}
|
||||
// shortcut for the actual spec mechanics
|
||||
return x === y;
|
||||
};
|
31
node_modules/es-abstract/2022/BigInt/exponentiate.js
generated
vendored
Normal file
31
node_modules/es-abstract/2022/BigInt/exponentiate.js
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $BigInt = GetIntrinsic('%BigInt%', true);
|
||||
var $RangeError = GetIntrinsic('%RangeError%');
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
var Type = require('../Type');
|
||||
|
||||
// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-exponentiate
|
||||
|
||||
module.exports = function BigIntExponentiate(base, exponent) {
|
||||
if (Type(base) !== 'BigInt' || Type(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;
|
||||
};
|
43
node_modules/es-abstract/2022/BigInt/index.js
generated
vendored
Normal file
43
node_modules/es-abstract/2022/BigInt/index.js
generated
vendored
Normal file
@@ -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
|
||||
};
|
18
node_modules/es-abstract/2022/BigInt/leftShift.js
generated
vendored
Normal file
18
node_modules/es-abstract/2022/BigInt/leftShift.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
var Type = require('../Type');
|
||||
|
||||
// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-leftShift
|
||||
|
||||
module.exports = function BigIntLeftShift(x, y) {
|
||||
if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') {
|
||||
throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts');
|
||||
}
|
||||
|
||||
// shortcut for the actual spec mechanics
|
||||
return x << y;
|
||||
};
|
18
node_modules/es-abstract/2022/BigInt/lessThan.js
generated
vendored
Normal file
18
node_modules/es-abstract/2022/BigInt/lessThan.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
var Type = require('../Type');
|
||||
|
||||
// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-lessThan
|
||||
|
||||
module.exports = function BigIntLessThan(x, y) {
|
||||
if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') {
|
||||
throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts');
|
||||
}
|
||||
|
||||
// shortcut for the actual spec mechanics
|
||||
return x < y;
|
||||
};
|
18
node_modules/es-abstract/2022/BigInt/multiply.js
generated
vendored
Normal file
18
node_modules/es-abstract/2022/BigInt/multiply.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
var Type = require('../Type');
|
||||
|
||||
// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-multiply
|
||||
|
||||
module.exports = function BigIntMultiply(x, y) {
|
||||
if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') {
|
||||
throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts');
|
||||
}
|
||||
|
||||
// shortcut for the actual spec mechanics
|
||||
return x * y;
|
||||
};
|
30
node_modules/es-abstract/2022/BigInt/remainder.js
generated
vendored
Normal file
30
node_modules/es-abstract/2022/BigInt/remainder.js
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $BigInt = GetIntrinsic('%BigInt%', true);
|
||||
var $RangeError = GetIntrinsic('%RangeError%');
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
var Type = require('../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 (Type(n) !== 'BigInt' || Type(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;
|
||||
};
|
18
node_modules/es-abstract/2022/BigInt/sameValue.js
generated
vendored
Normal file
18
node_modules/es-abstract/2022/BigInt/sameValue.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
var Type = require('../Type');
|
||||
var BigIntEqual = require('./equal');
|
||||
|
||||
// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-sameValue
|
||||
|
||||
module.exports = function BigIntSameValue(x, y) {
|
||||
if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') {
|
||||
throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts');
|
||||
}
|
||||
|
||||
return BigIntEqual(x, y);
|
||||
};
|
18
node_modules/es-abstract/2022/BigInt/sameValueZero.js
generated
vendored
Normal file
18
node_modules/es-abstract/2022/BigInt/sameValueZero.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
var Type = require('../Type');
|
||||
var BigIntEqual = require('./equal');
|
||||
|
||||
// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-sameValueZero
|
||||
|
||||
module.exports = function BigIntSameValueZero(x, y) {
|
||||
if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') {
|
||||
throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts');
|
||||
}
|
||||
|
||||
return BigIntEqual(x, y);
|
||||
};
|
18
node_modules/es-abstract/2022/BigInt/signedRightShift.js
generated
vendored
Normal file
18
node_modules/es-abstract/2022/BigInt/signedRightShift.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
var Type = require('../Type');
|
||||
var BigIntLeftShift = require('./leftShift');
|
||||
|
||||
// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-signedRightShift
|
||||
|
||||
module.exports = function BigIntSignedRightShift(x, y) {
|
||||
if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') {
|
||||
throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts');
|
||||
}
|
||||
|
||||
return BigIntLeftShift(x, -y);
|
||||
};
|
18
node_modules/es-abstract/2022/BigInt/subtract.js
generated
vendored
Normal file
18
node_modules/es-abstract/2022/BigInt/subtract.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
var Type = require('../Type');
|
||||
|
||||
// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-subtract
|
||||
|
||||
module.exports = function BigIntSubtract(x, y) {
|
||||
if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') {
|
||||
throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts');
|
||||
}
|
||||
|
||||
// shortcut for the actual spec mechanics
|
||||
return x - y;
|
||||
};
|
18
node_modules/es-abstract/2022/BigInt/toString.js
generated
vendored
Normal file
18
node_modules/es-abstract/2022/BigInt/toString.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $String = GetIntrinsic('%String%');
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
var Type = require('../Type');
|
||||
|
||||
// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-tostring
|
||||
|
||||
module.exports = function BigIntToString(x) {
|
||||
if (Type(x) !== 'BigInt') {
|
||||
throw new $TypeError('Assertion failed: `x` must be a BigInt');
|
||||
}
|
||||
|
||||
return $String(x);
|
||||
};
|
24
node_modules/es-abstract/2022/BigInt/unaryMinus.js
generated
vendored
Normal file
24
node_modules/es-abstract/2022/BigInt/unaryMinus.js
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $BigInt = GetIntrinsic('%BigInt%', true);
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
var Type = require('../Type');
|
||||
|
||||
var zero = $BigInt && $BigInt(0);
|
||||
|
||||
// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-unaryMinus
|
||||
|
||||
module.exports = function BigIntUnaryMinus(x) {
|
||||
if (Type(x) !== 'BigInt') {
|
||||
throw new $TypeError('Assertion failed: `x` argument must be a BigInt');
|
||||
}
|
||||
|
||||
if (x === zero) {
|
||||
return zero;
|
||||
}
|
||||
|
||||
return -x;
|
||||
};
|
17
node_modules/es-abstract/2022/BigInt/unsignedRightShift.js
generated
vendored
Normal file
17
node_modules/es-abstract/2022/BigInt/unsignedRightShift.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
var Type = require('../Type');
|
||||
|
||||
// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-unsignedRightShift
|
||||
|
||||
module.exports = function BigIntUnsignedRightShift(x, y) {
|
||||
if (Type(x) !== 'BigInt' || Type(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');
|
||||
};
|
66
node_modules/es-abstract/2022/BigIntBitwiseOp.js
generated
vendored
Normal file
66
node_modules/es-abstract/2022/BigIntBitwiseOp.js
generated
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
// var $BigInt = GetIntrinsic('%BigInt%', true);
|
||||
// var $pow = GetIntrinsic('%Math.pow%');
|
||||
|
||||
// var BinaryAnd = require('./BinaryAnd');
|
||||
// var BinaryOr = require('./BinaryOr');
|
||||
// var BinaryXor = require('./BinaryXor');
|
||||
var Type = require('./Type');
|
||||
// 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 (Type(x) !== 'BigInt' || Type(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;
|
||||
*/
|
||||
};
|
14
node_modules/es-abstract/2022/BinaryAnd.js
generated
vendored
Normal file
14
node_modules/es-abstract/2022/BinaryAnd.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
// 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;
|
||||
};
|
14
node_modules/es-abstract/2022/BinaryOr.js
generated
vendored
Normal file
14
node_modules/es-abstract/2022/BinaryOr.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
// 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;
|
||||
};
|
14
node_modules/es-abstract/2022/BinaryXor.js
generated
vendored
Normal file
14
node_modules/es-abstract/2022/BinaryXor.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
// 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;
|
||||
};
|
44
node_modules/es-abstract/2022/ByteListBitwiseOp.js
generated
vendored
Normal file
44
node_modules/es-abstract/2022/ByteListBitwiseOp.js
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
var callBound = require('call-bind/callBound');
|
||||
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
var $push = callBound('Array.prototype.push');
|
||||
|
||||
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;
|
||||
}
|
||||
$push(result, resultByte);
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
33
node_modules/es-abstract/2022/ByteListEqual.js
generated
vendored
Normal file
33
node_modules/es-abstract/2022/ByteListEqual.js
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
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;
|
||||
};
|
20
node_modules/es-abstract/2022/Call.js
generated
vendored
Normal file
20
node_modules/es-abstract/2022/Call.js
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
var callBound = require('call-bind/callBound');
|
||||
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
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);
|
||||
};
|
22
node_modules/es-abstract/2022/CanonicalNumericIndexString.js
generated
vendored
Normal file
22
node_modules/es-abstract/2022/CanonicalNumericIndexString.js
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
var SameValue = require('./SameValue');
|
||||
var ToNumber = require('./ToNumber');
|
||||
var ToString = require('./ToString');
|
||||
var Type = require('./Type');
|
||||
|
||||
// https://262.ecma-international.org/6.0/#sec-canonicalnumericindexstring
|
||||
|
||||
module.exports = function CanonicalNumericIndexString(argument) {
|
||||
if (Type(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;
|
||||
};
|
31
node_modules/es-abstract/2022/CharacterRange.js
generated
vendored
Normal file
31
node_modules/es-abstract/2022/CharacterRange.js
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
var callBound = require('call-bind/callBound');
|
||||
|
||||
var $fromCharCode = GetIntrinsic('%String.fromCharCode%');
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
var $charCodeAt = callBound('String.prototype.charCodeAt');
|
||||
var $push = callBound('Array.prototype.push');
|
||||
|
||||
module.exports = function CharacterRange(A, B) {
|
||||
if (A.length !== 1 || B.length !== 1) {
|
||||
throw new $TypeError('Assertion failed: CharSets A and B contain exactly one character');
|
||||
}
|
||||
|
||||
var a = A[0];
|
||||
var 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) {
|
||||
$push(arr, $fromCharCode(k));
|
||||
}
|
||||
return arr;
|
||||
};
|
12
node_modules/es-abstract/2022/ClearKeptObjects.js
generated
vendored
Normal file
12
node_modules/es-abstract/2022/ClearKeptObjects.js
generated
vendored
Normal file
@@ -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);
|
58
node_modules/es-abstract/2022/CodePointAt.js
generated
vendored
Normal file
58
node_modules/es-abstract/2022/CodePointAt.js
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
var callBound = require('call-bind/callBound');
|
||||
var isLeadingSurrogate = require('../helpers/isLeadingSurrogate');
|
||||
var isTrailingSurrogate = require('../helpers/isTrailingSurrogate');
|
||||
|
||||
var Type = require('./Type');
|
||||
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 (Type(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
|
||||
};
|
||||
};
|
27
node_modules/es-abstract/2022/CodePointsToString.js
generated
vendored
Normal file
27
node_modules/es-abstract/2022/CodePointsToString.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
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;
|
||||
};
|
39
node_modules/es-abstract/2022/CompletePropertyDescriptor.js
generated
vendored
Normal file
39
node_modules/es-abstract/2022/CompletePropertyDescriptor.js
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
'use strict';
|
||||
|
||||
var has = require('has');
|
||||
|
||||
var assertRecord = require('../helpers/assertRecord');
|
||||
|
||||
var IsDataDescriptor = require('./IsDataDescriptor');
|
||||
var IsGenericDescriptor = require('./IsGenericDescriptor');
|
||||
var Type = require('./Type');
|
||||
|
||||
// https://262.ecma-international.org/6.0/#sec-completepropertydescriptor
|
||||
|
||||
module.exports = function CompletePropertyDescriptor(Desc) {
|
||||
/* eslint no-param-reassign: 0 */
|
||||
assertRecord(Type, 'Property Descriptor', 'Desc', Desc);
|
||||
|
||||
if (IsGenericDescriptor(Desc) || IsDataDescriptor(Desc)) {
|
||||
if (!has(Desc, '[[Value]]')) {
|
||||
Desc['[[Value]]'] = void 0;
|
||||
}
|
||||
if (!has(Desc, '[[Writable]]')) {
|
||||
Desc['[[Writable]]'] = false;
|
||||
}
|
||||
} else {
|
||||
if (!has(Desc, '[[Get]]')) {
|
||||
Desc['[[Get]]'] = void 0;
|
||||
}
|
||||
if (!has(Desc, '[[Set]]')) {
|
||||
Desc['[[Set]]'] = void 0;
|
||||
}
|
||||
}
|
||||
if (!has(Desc, '[[Enumerable]]')) {
|
||||
Desc['[[Enumerable]]'] = false;
|
||||
}
|
||||
if (!has(Desc, '[[Configurable]]')) {
|
||||
Desc['[[Configurable]]'] = false;
|
||||
}
|
||||
return Desc;
|
||||
};
|
53
node_modules/es-abstract/2022/CompletionRecord.js
generated
vendored
Normal file
53
node_modules/es-abstract/2022/CompletionRecord.js
generated
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $SyntaxError = GetIntrinsic('%SyntaxError%');
|
||||
|
||||
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 === 'normal') {
|
||||
return value;
|
||||
}
|
||||
if (type === 'throw') {
|
||||
throw value;
|
||||
}
|
||||
throw new $SyntaxError('Completion Record is not of type "normal" or "throw": other types not supported');
|
||||
};
|
||||
|
||||
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;
|
70
node_modules/es-abstract/2022/CopyDataProperties.js
generated
vendored
Normal file
70
node_modules/es-abstract/2022/CopyDataProperties.js
generated
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
var callBound = require('call-bind/callBound');
|
||||
var forEach = require('../helpers/forEach');
|
||||
var every = require('../helpers/every');
|
||||
var some = require('../helpers/some');
|
||||
var OwnPropertyKeys = require('../helpers/OwnPropertyKeys');
|
||||
|
||||
var $isEnumerable = callBound('Object.prototype.propertyIsEnumerable');
|
||||
|
||||
var CreateDataPropertyOrThrow = require('./CreateDataPropertyOrThrow');
|
||||
var Get = require('./Get');
|
||||
var IsArray = require('./IsArray');
|
||||
var IsIntegralNumber = require('./IsIntegralNumber');
|
||||
var IsPropertyKey = require('./IsPropertyKey');
|
||||
var SameValue = require('./SameValue');
|
||||
var ToNumber = require('./ToNumber');
|
||||
var ToObject = require('./ToObject');
|
||||
var Type = require('./Type');
|
||||
|
||||
// https://262.ecma-international.org/12.0/#sec-copydataproperties
|
||||
|
||||
module.exports = function CopyDataProperties(target, source, excludedItems) {
|
||||
if (Type(target) !== 'Object') {
|
||||
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
|
||||
&& IsIntegralNumber(ToNumber(nextKey))
|
||||
);
|
||||
if (excluded === false && enumerable) {
|
||||
var propValue = Get(from, nextKey);
|
||||
CreateDataPropertyOrThrow(target, nextKey, propValue);
|
||||
}
|
||||
});
|
||||
|
||||
return target;
|
||||
};
|
121
node_modules/es-abstract/2022/CreateAsyncFromSyncIterator.js
generated
vendored
Normal file
121
node_modules/es-abstract/2022/CreateAsyncFromSyncIterator.js
generated
vendored
Normal file
@@ -0,0 +1,121 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
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 Type = require('./Type');
|
||||
|
||||
var SLOT = require('internal-slot');
|
||||
|
||||
var assertRecord = require('../helpers/assertRecord');
|
||||
|
||||
var $AsyncFromSyncIteratorPrototype = GetIntrinsic('%AsyncFromSyncIteratorPrototype%', true) || {
|
||||
next: function next(value) {
|
||||
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 () {
|
||||
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 (Type(result) !== 'Object') { // 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 () {
|
||||
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 (Type(result) !== 'Object') { // 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) {
|
||||
assertRecord(Type, 'Iterator Record', 'syncIteratorRecord', syncIteratorRecord);
|
||||
|
||||
// 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
|
||||
};
|
||||
};
|
27
node_modules/es-abstract/2022/CreateDataProperty.js
generated
vendored
Normal file
27
node_modules/es-abstract/2022/CreateDataProperty.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
var IsPropertyKey = require('./IsPropertyKey');
|
||||
var OrdinaryDefineOwnProperty = require('./OrdinaryDefineOwnProperty');
|
||||
var Type = require('./Type');
|
||||
|
||||
// https://262.ecma-international.org/6.0/#sec-createdataproperty
|
||||
|
||||
module.exports = function CreateDataProperty(O, P, V) {
|
||||
if (Type(O) !== 'Object') {
|
||||
throw new $TypeError('Assertion failed: Type(O) is not Object');
|
||||
}
|
||||
if (!IsPropertyKey(P)) {
|
||||
throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true');
|
||||
}
|
||||
var newDesc = {
|
||||
'[[Configurable]]': true,
|
||||
'[[Enumerable]]': true,
|
||||
'[[Value]]': V,
|
||||
'[[Writable]]': true
|
||||
};
|
||||
return OrdinaryDefineOwnProperty(O, P, newDesc);
|
||||
};
|
25
node_modules/es-abstract/2022/CreateDataPropertyOrThrow.js
generated
vendored
Normal file
25
node_modules/es-abstract/2022/CreateDataPropertyOrThrow.js
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
var CreateDataProperty = require('./CreateDataProperty');
|
||||
var IsPropertyKey = require('./IsPropertyKey');
|
||||
var Type = require('./Type');
|
||||
|
||||
// // https://262.ecma-international.org/6.0/#sec-createdatapropertyorthrow
|
||||
|
||||
module.exports = function CreateDataPropertyOrThrow(O, P, V) {
|
||||
if (Type(O) !== 'Object') {
|
||||
throw new $TypeError('Assertion failed: Type(O) is not Object');
|
||||
}
|
||||
if (!IsPropertyKey(P)) {
|
||||
throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true');
|
||||
}
|
||||
var success = CreateDataProperty(O, P, V);
|
||||
if (!success) {
|
||||
throw new $TypeError('unable to create data property');
|
||||
}
|
||||
return success;
|
||||
};
|
30
node_modules/es-abstract/2022/CreateHTML.js
generated
vendored
Normal file
30
node_modules/es-abstract/2022/CreateHTML.js
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
var callBound = require('call-bind/callBound');
|
||||
|
||||
var $replace = callBound('String.prototype.replace');
|
||||
|
||||
var RequireObjectCoercible = require('./RequireObjectCoercible');
|
||||
var ToString = require('./ToString');
|
||||
var Type = require('./Type');
|
||||
|
||||
// https://262.ecma-international.org/6.0/#sec-createhtml
|
||||
|
||||
module.exports = function CreateHTML(string, tag, attribute, value) {
|
||||
if (Type(tag) !== 'String' || Type(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 + '</' + tag + '>';
|
||||
};
|
19
node_modules/es-abstract/2022/CreateIterResultObject.js
generated
vendored
Normal file
19
node_modules/es-abstract/2022/CreateIterResultObject.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
var Type = require('./Type');
|
||||
|
||||
// https://262.ecma-international.org/6.0/#sec-createiterresultobject
|
||||
|
||||
module.exports = function CreateIterResultObject(value, done) {
|
||||
if (Type(done) !== 'Boolean') {
|
||||
throw new $TypeError('Assertion failed: Type(done) is not Boolean');
|
||||
}
|
||||
return {
|
||||
value: value,
|
||||
done: done
|
||||
};
|
||||
};
|
46
node_modules/es-abstract/2022/CreateListFromArrayLike.js
generated
vendored
Normal file
46
node_modules/es-abstract/2022/CreateListFromArrayLike.js
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var callBound = require('call-bind/callBound');
|
||||
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
var $indexOf = callBound('Array.prototype.indexOf', true) || callBound('String.prototype.indexOf');
|
||||
var $push = callBound('Array.prototype.push');
|
||||
|
||||
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 (Type(obj) !== 'Object') {
|
||||
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');
|
||||
}
|
||||
$push(list, next);
|
||||
index += 1;
|
||||
}
|
||||
return list;
|
||||
};
|
40
node_modules/es-abstract/2022/CreateMethodProperty.js
generated
vendored
Normal file
40
node_modules/es-abstract/2022/CreateMethodProperty.js
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
var DefineOwnProperty = require('../helpers/DefineOwnProperty');
|
||||
|
||||
var FromPropertyDescriptor = require('./FromPropertyDescriptor');
|
||||
var IsDataDescriptor = require('./IsDataDescriptor');
|
||||
var IsPropertyKey = require('./IsPropertyKey');
|
||||
var SameValue = require('./SameValue');
|
||||
var Type = require('./Type');
|
||||
|
||||
// https://262.ecma-international.org/6.0/#sec-createmethodproperty
|
||||
|
||||
module.exports = function CreateMethodProperty(O, P, V) {
|
||||
if (Type(O) !== 'Object') {
|
||||
throw new $TypeError('Assertion failed: Type(O) is not Object');
|
||||
}
|
||||
|
||||
if (!IsPropertyKey(P)) {
|
||||
throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true');
|
||||
}
|
||||
|
||||
var newDesc = {
|
||||
'[[Configurable]]': true,
|
||||
'[[Enumerable]]': false,
|
||||
'[[Value]]': V,
|
||||
'[[Writable]]': true
|
||||
};
|
||||
return DefineOwnProperty(
|
||||
IsDataDescriptor,
|
||||
SameValue,
|
||||
FromPropertyDescriptor,
|
||||
O,
|
||||
P,
|
||||
newDesc
|
||||
);
|
||||
};
|
29
node_modules/es-abstract/2022/CreateNonEnumerableDataPropertyOrThrow.js
generated
vendored
Normal file
29
node_modules/es-abstract/2022/CreateNonEnumerableDataPropertyOrThrow.js
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
var DefinePropertyOrThrow = require('./DefinePropertyOrThrow');
|
||||
var IsPropertyKey = require('./IsPropertyKey');
|
||||
var Type = require('./Type');
|
||||
|
||||
// https://262.ecma-international.org/13.0/#sec-createnonenumerabledatapropertyorthrow
|
||||
|
||||
module.exports = function CreateNonEnumerableDataPropertyOrThrow(O, P, V) {
|
||||
if (Type(O) !== 'Object') {
|
||||
throw new $TypeError('Assertion failed: Type(O) is not Object');
|
||||
}
|
||||
|
||||
if (!IsPropertyKey(P)) {
|
||||
throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true');
|
||||
}
|
||||
|
||||
var newDesc = {
|
||||
'[[Configurable]]': true,
|
||||
'[[Enumerable]]': false,
|
||||
'[[Value]]': V,
|
||||
'[[Writable]]': true
|
||||
};
|
||||
return DefinePropertyOrThrow(O, P, newDesc);
|
||||
};
|
100
node_modules/es-abstract/2022/CreateRegExpStringIterator.js
generated
vendored
Normal file
100
node_modules/es-abstract/2022/CreateRegExpStringIterator.js
generated
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
var hasSymbols = require('has-symbols')();
|
||||
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
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 Type = require('./Type');
|
||||
|
||||
var SLOT = require('internal-slot');
|
||||
var setToStringTag = require('es-set-tostringtag');
|
||||
|
||||
var RegExpStringIterator = function RegExpStringIterator(R, S, global, fullUnicode) {
|
||||
if (Type(S) !== 'String') {
|
||||
throw new $TypeError('`S` must be a string');
|
||||
}
|
||||
if (Type(global) !== 'Boolean') {
|
||||
throw new $TypeError('`global` must be a boolean');
|
||||
}
|
||||
if (Type(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; // eslint-disable-line no-invalid-this
|
||||
if (Type(O) !== 'Object') {
|
||||
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);
|
||||
};
|
54
node_modules/es-abstract/2022/DateFromTime.js
generated
vendored
Normal file
54
node_modules/es-abstract/2022/DateFromTime.js
generated
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $EvalError = GetIntrinsic('%EvalError%');
|
||||
|
||||
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);
|
||||
};
|
30
node_modules/es-abstract/2022/DateString.js
generated
vendored
Normal file
30
node_modules/es-abstract/2022/DateString.js
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
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('../helpers/isNaN');
|
||||
var padTimeComponent = require('../helpers/padTimeComponent');
|
||||
|
||||
var Type = require('./Type');
|
||||
var WeekDay = require('./WeekDay');
|
||||
var MonthFromTime = require('./MonthFromTime');
|
||||
var YearFromTime = require('./YearFromTime');
|
||||
var DateFromTime = require('./DateFromTime');
|
||||
|
||||
// https://262.ecma-international.org/9.0/#sec-datestring
|
||||
|
||||
module.exports = function DateString(tv) {
|
||||
if (Type(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;
|
||||
};
|
11
node_modules/es-abstract/2022/Day.js
generated
vendored
Normal file
11
node_modules/es-abstract/2022/Day.js
generated
vendored
Normal file
@@ -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);
|
||||
};
|
10
node_modules/es-abstract/2022/DayFromYear.js
generated
vendored
Normal file
10
node_modules/es-abstract/2022/DayFromYear.js
generated
vendored
Normal file
@@ -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);
|
||||
};
|
||||
|
11
node_modules/es-abstract/2022/DayWithinYear.js
generated
vendored
Normal file
11
node_modules/es-abstract/2022/DayWithinYear.js
generated
vendored
Normal file
@@ -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));
|
||||
};
|
18
node_modules/es-abstract/2022/DaysInYear.js
generated
vendored
Normal file
18
node_modules/es-abstract/2022/DaysInYear.js
generated
vendored
Normal file
@@ -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;
|
||||
};
|
50
node_modules/es-abstract/2022/DefinePropertyOrThrow.js
generated
vendored
Normal file
50
node_modules/es-abstract/2022/DefinePropertyOrThrow.js
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
var isPropertyDescriptor = require('../helpers/isPropertyDescriptor');
|
||||
var DefineOwnProperty = require('../helpers/DefineOwnProperty');
|
||||
|
||||
var FromPropertyDescriptor = require('./FromPropertyDescriptor');
|
||||
var IsAccessorDescriptor = require('./IsAccessorDescriptor');
|
||||
var IsDataDescriptor = require('./IsDataDescriptor');
|
||||
var IsPropertyKey = require('./IsPropertyKey');
|
||||
var SameValue = require('./SameValue');
|
||||
var ToPropertyDescriptor = require('./ToPropertyDescriptor');
|
||||
var Type = require('./Type');
|
||||
|
||||
// https://262.ecma-international.org/6.0/#sec-definepropertyorthrow
|
||||
|
||||
module.exports = function DefinePropertyOrThrow(O, P, desc) {
|
||||
if (Type(O) !== 'Object') {
|
||||
throw new $TypeError('Assertion failed: Type(O) is not Object');
|
||||
}
|
||||
|
||||
if (!IsPropertyKey(P)) {
|
||||
throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true');
|
||||
}
|
||||
|
||||
var Desc = isPropertyDescriptor({
|
||||
Type: Type,
|
||||
IsDataDescriptor: IsDataDescriptor,
|
||||
IsAccessorDescriptor: IsAccessorDescriptor
|
||||
}, desc) ? desc : ToPropertyDescriptor(desc);
|
||||
if (!isPropertyDescriptor({
|
||||
Type: Type,
|
||||
IsDataDescriptor: IsDataDescriptor,
|
||||
IsAccessorDescriptor: IsAccessorDescriptor
|
||||
}, Desc)) {
|
||||
throw new $TypeError('Assertion failed: Desc is not a valid Property Descriptor');
|
||||
}
|
||||
|
||||
return DefineOwnProperty(
|
||||
IsDataDescriptor,
|
||||
SameValue,
|
||||
FromPropertyDescriptor,
|
||||
O,
|
||||
P,
|
||||
Desc
|
||||
);
|
||||
};
|
27
node_modules/es-abstract/2022/DeletePropertyOrThrow.js
generated
vendored
Normal file
27
node_modules/es-abstract/2022/DeletePropertyOrThrow.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
var IsPropertyKey = require('./IsPropertyKey');
|
||||
var Type = require('./Type');
|
||||
|
||||
// https://262.ecma-international.org/6.0/#sec-deletepropertyorthrow
|
||||
|
||||
module.exports = function DeletePropertyOrThrow(O, P) {
|
||||
if (Type(O) !== 'Object') {
|
||||
throw new $TypeError('Assertion failed: Type(O) is not Object');
|
||||
}
|
||||
|
||||
if (!IsPropertyKey(P)) {
|
||||
throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true');
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
var success = delete O[P];
|
||||
if (!success) {
|
||||
throw new $TypeError('Attempt to delete property failed.');
|
||||
}
|
||||
return success;
|
||||
};
|
43
node_modules/es-abstract/2022/DetachArrayBuffer.js
generated
vendored
Normal file
43
node_modules/es-abstract/2022/DetachArrayBuffer.js
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $SyntaxError = GetIntrinsic('%SyntaxError%');
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
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 (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;
|
||||
};
|
43
node_modules/es-abstract/2022/EnumerableOwnPropertyNames.js
generated
vendored
Normal file
43
node_modules/es-abstract/2022/EnumerableOwnPropertyNames.js
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
var objectKeys = require('object-keys');
|
||||
|
||||
var callBound = require('call-bind/callBound');
|
||||
|
||||
var callBind = require('call-bind');
|
||||
|
||||
var $isEnumerable = callBound('Object.prototype.propertyIsEnumerable');
|
||||
var $pushApply = callBind.apply(GetIntrinsic('%Array.prototype.push%'));
|
||||
|
||||
var forEach = require('../helpers/forEach');
|
||||
|
||||
var Type = require('./Type');
|
||||
|
||||
// https://262.ecma-international.org/8.0/#sec-enumerableownproperties
|
||||
|
||||
module.exports = function EnumerableOwnPropertyNames(O, kind) {
|
||||
if (Type(O) !== 'Object') {
|
||||
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)) {
|
||||
$pushApply(results, [
|
||||
kind === 'value' ? O[key] : [key, O[key]]
|
||||
]);
|
||||
}
|
||||
});
|
||||
return results;
|
||||
}
|
||||
throw new $TypeError('Assertion failed: "kind" is not "key", "value", or "key+value": ' + kind);
|
||||
};
|
58
node_modules/es-abstract/2022/FlattenIntoArray.js
generated
vendored
Normal file
58
node_modules/es-abstract/2022/FlattenIntoArray.js
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
var MAX_SAFE_INTEGER = require('../helpers/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
|
||||
|
||||
// eslint-disable-next-line max-params
|
||||
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;
|
||||
};
|
16
node_modules/es-abstract/2022/FromPropertyDescriptor.js
generated
vendored
Normal file
16
node_modules/es-abstract/2022/FromPropertyDescriptor.js
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
'use strict';
|
||||
|
||||
var assertRecord = require('../helpers/assertRecord');
|
||||
var fromPropertyDescriptor = require('../helpers/fromPropertyDescriptor');
|
||||
|
||||
var Type = require('./Type');
|
||||
|
||||
// https://262.ecma-international.org/6.0/#sec-frompropertydescriptor
|
||||
|
||||
module.exports = function FromPropertyDescriptor(Desc) {
|
||||
if (typeof Desc !== 'undefined') {
|
||||
assertRecord(Type, 'Property Descriptor', 'Desc', Desc);
|
||||
}
|
||||
|
||||
return fromPropertyDescriptor(Desc);
|
||||
};
|
25
node_modules/es-abstract/2022/Get.js
generated
vendored
Normal file
25
node_modules/es-abstract/2022/Get.js
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
var inspect = require('object-inspect');
|
||||
|
||||
var IsPropertyKey = require('./IsPropertyKey');
|
||||
var Type = require('./Type');
|
||||
|
||||
// https://262.ecma-international.org/6.0/#sec-get-o-p
|
||||
|
||||
module.exports = function Get(O, P) {
|
||||
// 7.3.1.1
|
||||
if (Type(O) !== 'Object') {
|
||||
throw new $TypeError('Assertion failed: Type(O) is not Object');
|
||||
}
|
||||
// 7.3.1.2
|
||||
if (!IsPropertyKey(P)) {
|
||||
throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true, got ' + inspect(P));
|
||||
}
|
||||
// 7.3.1.3
|
||||
return O[P];
|
||||
};
|
9
node_modules/es-abstract/2022/GetGlobalObject.js
generated
vendored
Normal file
9
node_modules/es-abstract/2022/GetGlobalObject.js
generated
vendored
Normal file
@@ -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();
|
||||
};
|
66
node_modules/es-abstract/2022/GetIterator.js
generated
vendored
Normal file
66
node_modules/es-abstract/2022/GetIterator.js
generated
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
var $SyntaxError = GetIntrinsic('%SyntaxError%');
|
||||
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 IsArray = require('./IsArray');
|
||||
var Type = require('./Type');
|
||||
|
||||
// https://262.ecma-international.org/11.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(
|
||||
{
|
||||
AdvanceStringIndex: AdvanceStringIndex,
|
||||
GetMethod: GetMethod,
|
||||
IsArray: IsArray
|
||||
},
|
||||
obj
|
||||
);
|
||||
}
|
||||
}
|
||||
var iterator = Call(actualMethod, obj);
|
||||
if (Type(iterator) !== 'Object') {
|
||||
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
|
||||
};
|
||||
*/
|
||||
};
|
26
node_modules/es-abstract/2022/GetMatchIndexPair.js
generated
vendored
Normal file
26
node_modules/es-abstract/2022/GetMatchIndexPair.js
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
var Type = require('./Type');
|
||||
|
||||
var assertRecord = require('../helpers/assertRecord');
|
||||
|
||||
// https://262.ecma-international.org/13.0/#sec-getmatchindexpair
|
||||
|
||||
module.exports = function GetMatchIndexPair(S, match) {
|
||||
if (Type(S) !== 'String') {
|
||||
throw new $TypeError('Assertion failed: `S` must be a String');
|
||||
}
|
||||
assertRecord(Type, 'Match Record', 'match', match);
|
||||
|
||||
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]]']];
|
||||
};
|
27
node_modules/es-abstract/2022/GetMatchString.js
generated
vendored
Normal file
27
node_modules/es-abstract/2022/GetMatchString.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
var substring = require('./substring');
|
||||
var Type = require('./Type');
|
||||
|
||||
var assertRecord = require('../helpers/assertRecord');
|
||||
|
||||
// https://262.ecma-international.org/13.0/#sec-getmatchstring
|
||||
|
||||
module.exports = function GetMatchString(S, match) {
|
||||
if (Type(S) !== 'String') {
|
||||
throw new $TypeError('Assertion failed: `S` must be a String');
|
||||
}
|
||||
assertRecord(Type, 'Match Record', 'match', match);
|
||||
|
||||
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]]']);
|
||||
};
|
36
node_modules/es-abstract/2022/GetMethod.js
generated
vendored
Normal file
36
node_modules/es-abstract/2022/GetMethod.js
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
var GetV = require('./GetV');
|
||||
var IsCallable = require('./IsCallable');
|
||||
var IsPropertyKey = require('./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: IsPropertyKey(P) is not true');
|
||||
}
|
||||
|
||||
// 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;
|
||||
};
|
31
node_modules/es-abstract/2022/GetOwnPropertyKeys.js
generated
vendored
Normal file
31
node_modules/es-abstract/2022/GetOwnPropertyKeys.js
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var hasSymbols = require('has-symbols')();
|
||||
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
var $gOPN = GetIntrinsic('%Object.getOwnPropertyNames%', true);
|
||||
var $gOPS = hasSymbols && GetIntrinsic('%Object.getOwnPropertySymbols%', true);
|
||||
var keys = require('object-keys');
|
||||
|
||||
var esType = require('./Type');
|
||||
|
||||
// https://262.ecma-international.org/6.0/#sec-getownpropertykeys
|
||||
|
||||
module.exports = function GetOwnPropertyKeys(O, Type) {
|
||||
if (esType(O) !== 'Object') {
|
||||
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"`');
|
||||
};
|
22
node_modules/es-abstract/2022/GetPromiseResolve.js
generated
vendored
Normal file
22
node_modules/es-abstract/2022/GetPromiseResolve.js
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
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;
|
||||
};
|
32
node_modules/es-abstract/2022/GetPrototypeFromConstructor.js
generated
vendored
Normal file
32
node_modules/es-abstract/2022/GetPrototypeFromConstructor.js
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $Function = GetIntrinsic('%Function%');
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
var $SyntaxError = GetIntrinsic('%SyntaxError%');
|
||||
|
||||
var Get = require('./Get');
|
||||
var IsConstructor = require('./IsConstructor');
|
||||
var Type = require('./Type');
|
||||
|
||||
// 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 (Type(intrinsic) !== 'Object') {
|
||||
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 (Type(proto) !== 'Object') {
|
||||
if (!(constructor instanceof $Function)) {
|
||||
// ignore other realms, for now
|
||||
throw new $SyntaxError('cross-realm constructors not currently supported');
|
||||
}
|
||||
proto = intrinsic;
|
||||
}
|
||||
return proto;
|
||||
};
|
30
node_modules/es-abstract/2022/GetStringIndex.js
generated
vendored
Normal file
30
node_modules/es-abstract/2022/GetStringIndex.js
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
var callBound = require('call-bind/callBound');
|
||||
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
var IsIntegralNumber = require('./IsIntegralNumber');
|
||||
var StringToCodePoints = require('./StringToCodePoints');
|
||||
var Type = require('./Type');
|
||||
|
||||
var $indexOf = callBound('String.prototype.indexOf');
|
||||
|
||||
// https://262.ecma-international.org/13.0/#sec-getstringindex
|
||||
|
||||
module.exports = function GetStringIndex(S, e) {
|
||||
if (Type(S) !== 'String') {
|
||||
throw new $TypeError('Assertion failed: `S` must be a String');
|
||||
}
|
||||
if (!IsIntegralNumber(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;
|
||||
};
|
128
node_modules/es-abstract/2022/GetSubstitution.js
generated
vendored
Normal file
128
node_modules/es-abstract/2022/GetSubstitution.js
generated
vendored
Normal file
@@ -0,0 +1,128 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
var callBound = require('call-bind/callBound');
|
||||
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 Get = require('./Get');
|
||||
var IsArray = require('./IsArray');
|
||||
var IsIntegralNumber = require('./IsIntegralNumber');
|
||||
var ToObject = require('./ToObject');
|
||||
var ToString = require('./ToString');
|
||||
var Type = require('./Type');
|
||||
|
||||
var canDistinguishSparseFromUndefined = 0 in [undefined]; // IE 6 - 8 have a bug where this returns false
|
||||
|
||||
var isStringOrHole = function (capture, index, arr) {
|
||||
return Type(capture) === 'String' || (canDistinguishSparseFromUndefined ? !(index in arr) : Type(capture) === 'Undefined');
|
||||
};
|
||||
|
||||
// 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 (Type(matched) !== 'String') {
|
||||
throw new $TypeError('Assertion failed: `matched` must be a String');
|
||||
}
|
||||
var matchLength = matched.length;
|
||||
|
||||
if (Type(str) !== 'String') {
|
||||
throw new $TypeError('Assertion failed: `str` must be a String');
|
||||
}
|
||||
var stringLength = str.length;
|
||||
|
||||
if (!IsIntegralNumber(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, isStringOrHole)) {
|
||||
throw new $TypeError('Assertion failed: `captures` must be a possibly-empty List of Strings, got ' + inspect(captures));
|
||||
}
|
||||
|
||||
if (Type(replacement) !== 'String') {
|
||||
throw new $TypeError('Assertion failed: `replacement` must be a String');
|
||||
}
|
||||
|
||||
var tailPos = position + matchLength;
|
||||
var m = captures.length;
|
||||
if (Type(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 && Type(captures[n - 1]) === 'Undefined' ? '' : captures[n - 1];
|
||||
i += 1;
|
||||
} else if (isDigit(next) && (nextIsLast || isDigit(nextNext))) {
|
||||
// $00 through $99
|
||||
var nn = next + nextNext;
|
||||
var nnI = $parseInt(nn, 10) - 1;
|
||||
// if nn === '00' or nn > m, impl-defined
|
||||
result += nn <= m && Type(captures[nnI]) === 'Undefined' ? '' : captures[nnI];
|
||||
i += 2;
|
||||
} else if (next === '<') {
|
||||
// eslint-disable-next-line max-depth
|
||||
if (Type(namedCaptures) === 'Undefined') {
|
||||
result += '$<';
|
||||
i += 2;
|
||||
} else {
|
||||
var endIndex = $indexOf(replacement, '>', i);
|
||||
// eslint-disable-next-line max-depth
|
||||
if (endIndex > -1) {
|
||||
var groupName = $strSlice(replacement, i + '$<'.length, endIndex);
|
||||
var capture = Get(namedCaptures, groupName);
|
||||
// eslint-disable-next-line max-depth
|
||||
if (Type(capture) !== 'Undefined') {
|
||||
result += ToString(capture);
|
||||
}
|
||||
i += ('<' + groupName + '>').length;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
result += '$';
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// the final $, or else not a $
|
||||
result += $charAt(replacement, i);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
};
|
23
node_modules/es-abstract/2022/GetV.js
generated
vendored
Normal file
23
node_modules/es-abstract/2022/GetV.js
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
var IsPropertyKey = require('./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: IsPropertyKey(P) is not true');
|
||||
}
|
||||
|
||||
// 7.3.2.2-3
|
||||
var O = ToObject(V);
|
||||
|
||||
// 7.3.2.4
|
||||
return O[P];
|
||||
};
|
22
node_modules/es-abstract/2022/HasOwnProperty.js
generated
vendored
Normal file
22
node_modules/es-abstract/2022/HasOwnProperty.js
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
var has = require('has');
|
||||
|
||||
var IsPropertyKey = require('./IsPropertyKey');
|
||||
var Type = require('./Type');
|
||||
|
||||
// https://262.ecma-international.org/6.0/#sec-hasownproperty
|
||||
|
||||
module.exports = function HasOwnProperty(O, P) {
|
||||
if (Type(O) !== 'Object') {
|
||||
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 has(O, P);
|
||||
};
|
20
node_modules/es-abstract/2022/HasProperty.js
generated
vendored
Normal file
20
node_modules/es-abstract/2022/HasProperty.js
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
var IsPropertyKey = require('./IsPropertyKey');
|
||||
var Type = require('./Type');
|
||||
|
||||
// https://262.ecma-international.org/6.0/#sec-hasproperty
|
||||
|
||||
module.exports = function HasProperty(O, P) {
|
||||
if (Type(O) !== 'Object') {
|
||||
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;
|
||||
};
|
14
node_modules/es-abstract/2022/HourFromTime.js
generated
vendored
Normal file
14
node_modules/es-abstract/2022/HourFromTime.js
generated
vendored
Normal file
@@ -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);
|
||||
};
|
21
node_modules/es-abstract/2022/InLeapYear.js
generated
vendored
Normal file
21
node_modules/es-abstract/2022/InLeapYear.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $EvalError = GetIntrinsic('%EvalError%');
|
||||
|
||||
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);
|
||||
};
|
23
node_modules/es-abstract/2022/InstallErrorCause.js
generated
vendored
Normal file
23
node_modules/es-abstract/2022/InstallErrorCause.js
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
var CreateNonEnumerableDataPropertyOrThrow = require('./CreateNonEnumerableDataPropertyOrThrow');
|
||||
var Get = require('./Get');
|
||||
var HasProperty = require('./HasProperty');
|
||||
var Type = require('./Type');
|
||||
|
||||
// https://262.ecma-international.org/13.0/#sec-installerrorcause
|
||||
|
||||
module.exports = function InstallErrorCause(O, options) {
|
||||
if (Type(O) !== 'Object') {
|
||||
throw new $TypeError('Assertion failed: Type(O) is not Object');
|
||||
}
|
||||
|
||||
if (Type(options) === 'Object' && HasProperty(options, 'cause')) {
|
||||
var cause = Get(options, 'cause');
|
||||
CreateNonEnumerableDataPropertyOrThrow(O, 'cause', cause);
|
||||
}
|
||||
};
|
30
node_modules/es-abstract/2022/InstanceofOperator.js
generated
vendored
Normal file
30
node_modules/es-abstract/2022/InstanceofOperator.js
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
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');
|
||||
var Type = require('./Type');
|
||||
|
||||
// https://262.ecma-international.org/6.0/#sec-instanceofoperator
|
||||
|
||||
module.exports = function InstanceofOperator(O, C) {
|
||||
if (Type(O) !== 'Object') {
|
||||
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);
|
||||
};
|
24
node_modules/es-abstract/2022/Invoke.js
generated
vendored
Normal file
24
node_modules/es-abstract/2022/Invoke.js
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
var Call = require('./Call');
|
||||
var IsArray = require('./IsArray');
|
||||
var GetV = require('./GetV');
|
||||
var IsPropertyKey = require('./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);
|
||||
};
|
23
node_modules/es-abstract/2022/IsAccessorDescriptor.js
generated
vendored
Normal file
23
node_modules/es-abstract/2022/IsAccessorDescriptor.js
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
'use strict';
|
||||
|
||||
var has = require('has');
|
||||
|
||||
var Type = require('./Type');
|
||||
|
||||
var assertRecord = require('../helpers/assertRecord');
|
||||
|
||||
// https://262.ecma-international.org/5.1/#sec-8.10.1
|
||||
|
||||
module.exports = function IsAccessorDescriptor(Desc) {
|
||||
if (typeof Desc === 'undefined') {
|
||||
return false;
|
||||
}
|
||||
|
||||
assertRecord(Type, 'Property Descriptor', 'Desc', Desc);
|
||||
|
||||
if (!has(Desc, '[[Get]]') && !has(Desc, '[[Set]]')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
4
node_modules/es-abstract/2022/IsArray.js
generated
vendored
Normal file
4
node_modules/es-abstract/2022/IsArray.js
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
'use strict';
|
||||
|
||||
// https://262.ecma-international.org/6.0/#sec-isarray
|
||||
module.exports = require('../helpers/IsArray');
|
7
node_modules/es-abstract/2022/IsBigIntElementType.js
generated
vendored
Normal file
7
node_modules/es-abstract/2022/IsBigIntElementType.js
generated
vendored
Normal file
@@ -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';
|
||||
};
|
5
node_modules/es-abstract/2022/IsCallable.js
generated
vendored
Normal file
5
node_modules/es-abstract/2022/IsCallable.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
// http://262.ecma-international.org/5.1/#sec-9.11
|
||||
|
||||
module.exports = require('is-callable');
|
9
node_modules/es-abstract/2022/IsCompatiblePropertyDescriptor.js
generated
vendored
Normal file
9
node_modules/es-abstract/2022/IsCompatiblePropertyDescriptor.js
generated
vendored
Normal file
@@ -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);
|
||||
};
|
25
node_modules/es-abstract/2022/IsConcatSpreadable.js
generated
vendored
Normal file
25
node_modules/es-abstract/2022/IsConcatSpreadable.js
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
'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 Type = require('./Type');
|
||||
|
||||
// https://262.ecma-international.org/6.0/#sec-isconcatspreadable
|
||||
|
||||
module.exports = function IsConcatSpreadable(O) {
|
||||
if (Type(O) !== 'Object') {
|
||||
return false;
|
||||
}
|
||||
if ($isConcatSpreadable) {
|
||||
var spreadable = Get(O, $isConcatSpreadable);
|
||||
if (typeof spreadable !== 'undefined') {
|
||||
return ToBoolean(spreadable);
|
||||
}
|
||||
}
|
||||
return IsArray(O);
|
||||
};
|
40
node_modules/es-abstract/2022/IsConstructor.js
generated
vendored
Normal file
40
node_modules/es-abstract/2022/IsConstructor.js
generated
vendored
Normal file
@@ -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;
|
||||
};
|
||||
}
|
23
node_modules/es-abstract/2022/IsDataDescriptor.js
generated
vendored
Normal file
23
node_modules/es-abstract/2022/IsDataDescriptor.js
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
'use strict';
|
||||
|
||||
var has = require('has');
|
||||
|
||||
var Type = require('./Type');
|
||||
|
||||
var assertRecord = require('../helpers/assertRecord');
|
||||
|
||||
// https://262.ecma-international.org/5.1/#sec-8.10.2
|
||||
|
||||
module.exports = function IsDataDescriptor(Desc) {
|
||||
if (typeof Desc === 'undefined') {
|
||||
return false;
|
||||
}
|
||||
|
||||
assertRecord(Type, 'Property Descriptor', 'Desc', Desc);
|
||||
|
||||
if (!has(Desc, '[[Value]]') && !has(Desc, '[[Writable]]')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
27
node_modules/es-abstract/2022/IsDetachedBuffer.js
generated
vendored
Normal file
27
node_modules/es-abstract/2022/IsDetachedBuffer.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
var $byteLength = require('array-buffer-byte-length');
|
||||
|
||||
var isArrayBuffer = require('is-array-buffer');
|
||||
|
||||
var availableTypedArrays = require('available-typed-arrays')();
|
||||
|
||||
// https://262.ecma-international.org/6.0/#sec-isdetachedbuffer
|
||||
|
||||
module.exports = function IsDetachedBuffer(arrayBuffer) {
|
||||
if (!isArrayBuffer(arrayBuffer)) {
|
||||
throw new $TypeError('Assertion failed: `arrayBuffer` must be an Object with an [[ArrayBufferData]] internal slot');
|
||||
}
|
||||
if ($byteLength(arrayBuffer) === 0) {
|
||||
try {
|
||||
new global[availableTypedArrays[0]](arrayBuffer); // eslint-disable-line no-new
|
||||
} catch (error) {
|
||||
return !!error && error.name === 'TypeError';
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
18
node_modules/es-abstract/2022/IsExtensible.js
generated
vendored
Normal file
18
node_modules/es-abstract/2022/IsExtensible.js
generated
vendored
Normal file
@@ -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);
|
||||
};
|
23
node_modules/es-abstract/2022/IsGenericDescriptor.js
generated
vendored
Normal file
23
node_modules/es-abstract/2022/IsGenericDescriptor.js
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
'use strict';
|
||||
|
||||
var assertRecord = require('../helpers/assertRecord');
|
||||
|
||||
var IsAccessorDescriptor = require('./IsAccessorDescriptor');
|
||||
var IsDataDescriptor = require('./IsDataDescriptor');
|
||||
var Type = require('./Type');
|
||||
|
||||
// https://262.ecma-international.org/6.0/#sec-isgenericdescriptor
|
||||
|
||||
module.exports = function IsGenericDescriptor(Desc) {
|
||||
if (typeof Desc === 'undefined') {
|
||||
return false;
|
||||
}
|
||||
|
||||
assertRecord(Type, 'Property Descriptor', 'Desc', Desc);
|
||||
|
||||
if (!IsAccessorDescriptor(Desc) && !IsDataDescriptor(Desc)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
18
node_modules/es-abstract/2022/IsIntegralNumber.js
generated
vendored
Normal file
18
node_modules/es-abstract/2022/IsIntegralNumber.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
'use strict';
|
||||
|
||||
var abs = require('./abs');
|
||||
var floor = require('./floor');
|
||||
var Type = require('./Type');
|
||||
|
||||
var $isNaN = require('../helpers/isNaN');
|
||||
var $isFinite = require('../helpers/isFinite');
|
||||
|
||||
// https://tc39.es/ecma262/#sec-isintegralnumber
|
||||
|
||||
module.exports = function IsIntegralNumber(argument) {
|
||||
if (Type(argument) !== 'Number' || $isNaN(argument) || !$isFinite(argument)) {
|
||||
return false;
|
||||
}
|
||||
var absValue = abs(argument);
|
||||
return floor(absValue) === absValue;
|
||||
};
|
90
node_modules/es-abstract/2022/IsLessThan.js
generated
vendored
Normal file
90
node_modules/es-abstract/2022/IsLessThan.js
generated
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $Number = GetIntrinsic('%Number%');
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
var $isNaN = require('../helpers/isNaN');
|
||||
|
||||
var IsStringPrefix = require('./IsStringPrefix');
|
||||
var StringToBigInt = require('./StringToBigInt');
|
||||
var ToNumeric = require('./ToNumeric');
|
||||
var ToPrimitive = require('./ToPrimitive');
|
||||
var Type = require('./Type');
|
||||
|
||||
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 (Type(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);
|
||||
}
|
||||
var pxType = Type(px);
|
||||
var pyType = Type(py);
|
||||
if (pxType === 'String' && pyType === '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 (pxType === 'BigInt' && pyType === 'String') {
|
||||
ny = StringToBigInt(py);
|
||||
if (typeof ny === 'undefined') {
|
||||
return void undefined;
|
||||
}
|
||||
return BigIntLessThan(px, ny);
|
||||
}
|
||||
if (pxType === 'String' && pyType === 'BigInt') {
|
||||
nx = StringToBigInt(px);
|
||||
if (typeof nx === 'undefined') {
|
||||
return void undefined;
|
||||
}
|
||||
return BigIntLessThan(nx, py);
|
||||
}
|
||||
|
||||
nx = ToNumeric(px);
|
||||
ny = ToNumeric(py);
|
||||
|
||||
var nxType = Type(nx);
|
||||
if (nxType === Type(ny)) {
|
||||
return nxType === '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
|
||||
};
|
58
node_modules/es-abstract/2022/IsLooselyEqual.js
generated
vendored
Normal file
58
node_modules/es-abstract/2022/IsLooselyEqual.js
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
'use strict';
|
||||
|
||||
var isFinite = require('../helpers/isFinite');
|
||||
|
||||
var IsStrictlyEqual = require('./IsStrictlyEqual');
|
||||
var StringToBigInt = require('./StringToBigInt');
|
||||
var ToNumber = require('./ToNumber');
|
||||
var ToPrimitive = require('./ToPrimitive');
|
||||
var Type = require('./Type');
|
||||
|
||||
// https://262.ecma-international.org/13.0/#sec-islooselyequal
|
||||
|
||||
module.exports = function IsLooselyEqual(x, y) {
|
||||
var xType = Type(x);
|
||||
var yType = Type(y);
|
||||
if (xType === yType) {
|
||||
return IsStrictlyEqual(x, y);
|
||||
}
|
||||
if (x == null && y == null) {
|
||||
return true;
|
||||
}
|
||||
if (xType === 'Number' && yType === 'String') {
|
||||
return IsLooselyEqual(x, ToNumber(y));
|
||||
}
|
||||
if (xType === 'String' && yType === 'Number') {
|
||||
return IsLooselyEqual(ToNumber(x), y);
|
||||
}
|
||||
if (xType === 'BigInt' && yType === 'String') {
|
||||
var n = StringToBigInt(y);
|
||||
if (typeof n === 'undefined') {
|
||||
return false;
|
||||
}
|
||||
return IsLooselyEqual(x, n);
|
||||
}
|
||||
if (xType === 'String' && yType === 'BigInt') {
|
||||
return IsLooselyEqual(y, x);
|
||||
}
|
||||
if (xType === 'Boolean') {
|
||||
return IsLooselyEqual(ToNumber(x), y);
|
||||
}
|
||||
if (yType === 'Boolean') {
|
||||
return IsLooselyEqual(x, ToNumber(y));
|
||||
}
|
||||
if ((xType === 'String' || xType === 'Number' || xType === 'Symbol' || xType === 'BigInt') && yType === 'Object') {
|
||||
return IsLooselyEqual(x, ToPrimitive(y));
|
||||
}
|
||||
if (xType === 'Object' && (yType === 'String' || yType === 'Number' || yType === 'Symbol' || yType === 'BigInt')) {
|
||||
return IsLooselyEqual(ToPrimitive(x), y);
|
||||
}
|
||||
if ((xType === 'BigInt' && yType === 'Number') || (xType === 'Number' && yType === 'BigInt')) {
|
||||
if (!isFinite(x) || !isFinite(y)) {
|
||||
return false;
|
||||
}
|
||||
// eslint-disable-next-line eqeqeq
|
||||
return x == y; // shortcut for step 13.b.
|
||||
}
|
||||
return false;
|
||||
};
|
16
node_modules/es-abstract/2022/IsNoTearConfiguration.js
generated
vendored
Normal file
16
node_modules/es-abstract/2022/IsNoTearConfiguration.js
generated
vendored
Normal file
@@ -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;
|
||||
};
|
24
node_modules/es-abstract/2022/IsPromise.js
generated
vendored
Normal file
24
node_modules/es-abstract/2022/IsPromise.js
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
'use strict';
|
||||
|
||||
var callBound = require('call-bind/callBound');
|
||||
|
||||
var $PromiseThen = callBound('Promise.prototype.then', true);
|
||||
|
||||
var Type = require('./Type');
|
||||
|
||||
// https://262.ecma-international.org/6.0/#sec-ispromise
|
||||
|
||||
module.exports = function IsPromise(x) {
|
||||
if (Type(x) !== 'Object') {
|
||||
return false;
|
||||
}
|
||||
if (!$PromiseThen) { // Promises are not supported
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
$PromiseThen(x); // throws if not a promise
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user