Update checked-in dependencies

This commit is contained in:
github-actions[bot] 2024-09-16 17:29:58 +00:00
parent 1afca056e3
commit 6989ba7bd2
3942 changed files with 55190 additions and 132206 deletions

View file

@ -2,9 +2,7 @@
var inspect = require('object-inspect');
var GetIntrinsic = require('get-intrinsic');
var $TypeError = GetIntrinsic('%TypeError%');
var $TypeError = require('es-errors/type');
var Call = require('./Call');
var Get = require('./Get');

View file

@ -1,10 +1,9 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var callBound = require('call-bind/callBound');
var SLOT = require('internal-slot');
var $TypeError = GetIntrinsic('%TypeError%');
var $TypeError = require('es-errors/type');
var ClearKeptObjects = require('./ClearKeptObjects');
var Type = require('./Type');

View file

@ -1,25 +1,22 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var CodePointAt = require('./CodePointAt');
var Type = require('./Type');
var isInteger = require('../helpers/isInteger');
var MAX_SAFE_INTEGER = require('../helpers/maxSafeInteger');
var $TypeError = GetIntrinsic('%TypeError%');
var $TypeError = require('es-errors/type');
// https://262.ecma-international.org/12.0/#sec-advancestringindex
module.exports = function AdvanceStringIndex(S, index, unicode) {
if (Type(S) !== 'String') {
if (typeof S !== 'string') {
throw new $TypeError('Assertion failed: `S` must be a String');
}
if (!isInteger(index) || index < 0 || index > MAX_SAFE_INTEGER) {
throw new $TypeError('Assertion failed: `length` must be an integer >= 0 and <= 2**53');
}
if (Type(unicode) !== 'Boolean') {
if (typeof unicode !== 'boolean') {
throw new $TypeError('Assertion failed: `unicode` must be a Boolean');
}
if (!unicode) {

View file

@ -1,8 +1,6 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $TypeError = GetIntrinsic('%TypeError%');
var $TypeError = require('es-errors/type');
var HasOwnProperty = require('./HasOwnProperty');
var ToNumeric = require('./ToNumeric');
@ -54,13 +52,13 @@ var table = {
};
module.exports = function ApplyStringOrNumericBinaryOperator(lval, opText, rval) {
if (Type(opText) !== 'String' || !HasOwnProperty(table, opText)) {
if (typeof opText !== 'string' || !HasOwnProperty(table, opText)) {
throw new $TypeError('Assertion failed: `opText` must be a valid operation string');
}
if (opText === '+') {
var lprim = ToPrimitive(lval);
var rprim = ToPrimitive(rval);
if (Type(lprim) === 'String' || Type(rprim) === 'String') {
if (typeof lprim === 'string' || typeof rprim === 'string') {
var lstr = ToString(lprim);
var rstr = ToString(rprim);
return lstr + rstr;

View file

@ -3,9 +3,9 @@
var GetIntrinsic = require('get-intrinsic');
var $ArrayPrototype = GetIntrinsic('%Array.prototype%');
var $RangeError = GetIntrinsic('%RangeError%');
var $SyntaxError = GetIntrinsic('%SyntaxError%');
var $TypeError = GetIntrinsic('%TypeError%');
var $RangeError = require('es-errors/range');
var $SyntaxError = require('es-errors/syntax');
var $TypeError = require('es-errors/type');
var isInteger = require('../helpers/isInteger');

View file

@ -1,23 +1,19 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $RangeError = GetIntrinsic('%RangeError%');
var $TypeError = GetIntrinsic('%TypeError%');
var $RangeError = require('es-errors/range');
var $TypeError = require('es-errors/type');
var assign = require('object.assign');
var isPropertyDescriptor = require('../helpers/isPropertyDescriptor');
var isPropertyDescriptor = require('../helpers/records/property-descriptor');
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
@ -26,11 +22,7 @@ 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)) {
if (!isPropertyDescriptor(Desc)) {
throw new $TypeError('Assertion failed: Desc must be a Property Descriptor');
}
if (!('[[Value]]' in Desc)) {

View file

@ -3,7 +3,7 @@
var GetIntrinsic = require('get-intrinsic');
var $species = GetIntrinsic('%Symbol.species%', true);
var $TypeError = GetIntrinsic('%TypeError%');
var $TypeError = require('es-errors/type');
var ArrayCreate = require('./ArrayCreate');
var Get = require('./Get');

View file

@ -2,8 +2,8 @@
var GetIntrinsic = require('get-intrinsic');
var $SyntaxError = GetIntrinsic('%SyntaxError%');
var $TypeError = GetIntrinsic('%TypeError%');
var $SyntaxError = require('es-errors/syntax');
var $TypeError = require('es-errors/type');
var $Promise = GetIntrinsic('%Promise%', true);
var callBound = require('call-bind/callBound');
@ -31,7 +31,7 @@ module.exports = function AsyncFromSyncIteratorContinuation(result) {
throw new $SyntaxError('This environment does not support Promises.');
}
return new Promise(function (resolve) {
return new $Promise(function (resolve) {
var done = IteratorComplete(result); // step 2
var value = IteratorValue(result); // step 4
var valueWrapper = PromiseResolve($Promise, value); // step 6

View file

@ -2,8 +2,8 @@
var GetIntrinsic = require('get-intrinsic');
var $SyntaxError = GetIntrinsic('%SyntaxError%');
var $TypeError = GetIntrinsic('%TypeError%');
var $SyntaxError = require('es-errors/syntax');
var $TypeError = require('es-errors/type');
var $Promise = GetIntrinsic('%Promise%', true);
var Call = require('./Call');
@ -11,7 +11,7 @@ var CompletionRecord = require('./CompletionRecord');
var GetMethod = require('./GetMethod');
var Type = require('./Type');
var assertRecord = require('../helpers/assertRecord');
var isIteratorRecord = require('../helpers/records/iterator-record');
var callBound = require('call-bind/callBound');
@ -20,7 +20,9 @@ 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 (!isIteratorRecord(iteratorRecord)) {
throw new $TypeError('Assertion failed: `iteratorRecord` must be an Iterator Record'); // step 1
}
if (!(completion instanceof CompletionRecord)) {
throw new $TypeError('Assertion failed: completion is not a Completion Record instance'); // step 2

View file

@ -1,15 +1,11 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $TypeError = GetIntrinsic('%TypeError%');
var Type = require('../Type');
var $TypeError = require('es-errors/type');
// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-add
module.exports = function BigIntAdd(x, y) {
if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') {
if (typeof x !== 'bigint' || typeof y !== 'bigint') {
throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts');
}

View file

@ -1,16 +1,13 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $TypeError = GetIntrinsic('%TypeError%');
var $TypeError = require('es-errors/type');
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') {
if (typeof x !== 'bigint' || typeof y !== 'bigint') {
throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts');
}
return BigIntBitwiseOp('&', x, y);

View file

@ -3,14 +3,12 @@
var GetIntrinsic = require('get-intrinsic');
var $BigInt = GetIntrinsic('%BigInt%', true);
var $TypeError = GetIntrinsic('%TypeError%');
var Type = require('../Type');
var $TypeError = require('es-errors/type');
// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-bitwiseNOT
module.exports = function BigIntBitwiseNOT(x) {
if (Type(x) !== 'BigInt') {
if (typeof x !== 'bigint') {
throw new $TypeError('Assertion failed: `x` argument must be a BigInt');
}
return -x - $BigInt(1);

View file

@ -1,16 +1,13 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $TypeError = GetIntrinsic('%TypeError%');
var $TypeError = require('es-errors/type');
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') {
if (typeof x !== 'bigint' || typeof y !== 'bigint') {
throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts');
}
return BigIntBitwiseOp('|', x, y);

View file

@ -1,16 +1,13 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $TypeError = GetIntrinsic('%TypeError%');
var $TypeError = require('es-errors/type');
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') {
if (typeof x !== 'bigint' || typeof y !== 'bigint') {
throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts');
}
return BigIntBitwiseOp('^', x, y);

View file

@ -3,15 +3,13 @@
var GetIntrinsic = require('get-intrinsic');
var $BigInt = GetIntrinsic('%BigInt%', true);
var $RangeError = GetIntrinsic('%RangeError%');
var $TypeError = GetIntrinsic('%TypeError%');
var Type = require('../Type');
var $RangeError = require('es-errors/range');
var $TypeError = require('es-errors/type');
// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-divide
module.exports = function BigIntDivide(x, y) {
if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') {
if (typeof x !== 'bigint' || typeof y !== 'bigint') {
throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts');
}
if (y === $BigInt(0)) {

View file

@ -1,15 +1,11 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $TypeError = GetIntrinsic('%TypeError%');
var Type = require('../Type');
var $TypeError = require('es-errors/type');
// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-equal
module.exports = function BigIntEqual(x, y) {
if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') {
if (typeof x !== 'bigint' || typeof y !== 'bigint') {
throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts');
}
// shortcut for the actual spec mechanics

View file

@ -3,15 +3,13 @@
var GetIntrinsic = require('get-intrinsic');
var $BigInt = GetIntrinsic('%BigInt%', true);
var $RangeError = GetIntrinsic('%RangeError%');
var $TypeError = GetIntrinsic('%TypeError%');
var Type = require('../Type');
var $RangeError = require('es-errors/range');
var $TypeError = require('es-errors/type');
// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-exponentiate
module.exports = function BigIntExponentiate(base, exponent) {
if (Type(base) !== 'BigInt' || Type(exponent) !== 'BigInt') {
if (typeof base !== 'bigint' || typeof exponent !== 'bigint') {
throw new $TypeError('Assertion failed: `base` and `exponent` arguments must be BigInts');
}
if (exponent < $BigInt(0)) {

View file

@ -1,15 +1,11 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $TypeError = GetIntrinsic('%TypeError%');
var Type = require('../Type');
var $TypeError = require('es-errors/type');
// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-leftShift
module.exports = function BigIntLeftShift(x, y) {
if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') {
if (typeof x !== 'bigint' || typeof y !== 'bigint') {
throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts');
}

View file

@ -1,15 +1,11 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $TypeError = GetIntrinsic('%TypeError%');
var Type = require('../Type');
var $TypeError = require('es-errors/type');
// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-lessThan
module.exports = function BigIntLessThan(x, y) {
if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') {
if (typeof x !== 'bigint' || typeof y !== 'bigint') {
throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts');
}

View file

@ -1,15 +1,11 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $TypeError = GetIntrinsic('%TypeError%');
var Type = require('../Type');
var $TypeError = require('es-errors/type');
// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-multiply
module.exports = function BigIntMultiply(x, y) {
if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') {
if (typeof x !== 'bigint' || typeof y !== 'bigint') {
throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts');
}

View file

@ -3,17 +3,15 @@
var GetIntrinsic = require('get-intrinsic');
var $BigInt = GetIntrinsic('%BigInt%', true);
var $RangeError = GetIntrinsic('%RangeError%');
var $TypeError = GetIntrinsic('%TypeError%');
var Type = require('../Type');
var $RangeError = require('es-errors/range');
var $TypeError = require('es-errors/type');
var zero = $BigInt && $BigInt(0);
// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-remainder
module.exports = function BigIntRemainder(n, d) {
if (Type(n) !== 'BigInt' || Type(d) !== 'BigInt') {
if (typeof n !== 'bigint' || typeof d !== 'bigint') {
throw new $TypeError('Assertion failed: `n` and `d` arguments must be BigInts');
}

View file

@ -1,16 +1,13 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $TypeError = require('es-errors/type');
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') {
if (typeof x !== 'bigint' || typeof y !== 'bigint') {
throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts');
}

View file

@ -1,16 +1,13 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $TypeError = require('es-errors/type');
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') {
if (typeof x !== 'bigint' || typeof y !== 'bigint') {
throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts');
}

View file

@ -1,16 +1,13 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $TypeError = require('es-errors/type');
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') {
if (typeof x !== 'bigint' || typeof y !== 'bigint') {
throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts');
}

View file

@ -1,15 +1,11 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $TypeError = GetIntrinsic('%TypeError%');
var Type = require('../Type');
var $TypeError = require('es-errors/type');
// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-subtract
module.exports = function BigIntSubtract(x, y) {
if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') {
if (typeof x !== 'bigint' || typeof y !== 'bigint') {
throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts');
}

View file

@ -3,14 +3,12 @@
var GetIntrinsic = require('get-intrinsic');
var $String = GetIntrinsic('%String%');
var $TypeError = GetIntrinsic('%TypeError%');
var Type = require('../Type');
var $TypeError = require('es-errors/type');
// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-tostring
module.exports = function BigIntToString(x) {
if (Type(x) !== 'BigInt') {
if (typeof x !== 'bigint') {
throw new $TypeError('Assertion failed: `x` must be a BigInt');
}

View file

@ -3,16 +3,14 @@
var GetIntrinsic = require('get-intrinsic');
var $BigInt = GetIntrinsic('%BigInt%', true);
var $TypeError = GetIntrinsic('%TypeError%');
var Type = require('../Type');
var $TypeError = require('es-errors/type');
var zero = $BigInt && $BigInt(0);
// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-unaryMinus
module.exports = function BigIntUnaryMinus(x) {
if (Type(x) !== 'BigInt') {
if (typeof x !== 'bigint') {
throw new $TypeError('Assertion failed: `x` argument must be a BigInt');
}

View file

@ -1,15 +1,11 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $TypeError = GetIntrinsic('%TypeError%');
var Type = require('../Type');
var $TypeError = require('es-errors/type');
// https://262.ecma-international.org/11.0/#sec-numeric-types-bigint-unsignedRightShift
module.exports = function BigIntUnsignedRightShift(x, y) {
if (Type(x) !== 'BigInt' || Type(y) !== 'BigInt') {
if (typeof x !== 'bigint' || typeof y !== 'bigint') {
throw new $TypeError('Assertion failed: `x` and `y` arguments must be BigInts');
}

View file

@ -1,15 +1,12 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $TypeError = GetIntrinsic('%TypeError%');
var $TypeError = require('es-errors/type');
// 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);
@ -22,7 +19,7 @@ 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') {
if (typeof x !== 'bigint' || typeof y !== 'bigint') {
throw new $TypeError('`x` and `y` must be BigInts');
}

View file

@ -1,8 +1,6 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $TypeError = GetIntrinsic('%TypeError%');
var $TypeError = require('es-errors/type');
// https://262.ecma-international.org/11.0/#sec-binaryand

View file

@ -1,8 +1,6 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $TypeError = GetIntrinsic('%TypeError%');
var $TypeError = require('es-errors/type');
// https://262.ecma-international.org/11.0/#sec-binaryor

View file

@ -1,8 +1,6 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $TypeError = GetIntrinsic('%TypeError%');
var $TypeError = require('es-errors/type');
// https://262.ecma-international.org/11.0/#sec-binaryxor

View file

@ -1,9 +1,8 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var callBound = require('call-bind/callBound');
var $TypeError = GetIntrinsic('%TypeError%');
var $TypeError = require('es-errors/type');
var $push = callBound('Array.prototype.push');

View file

@ -1,8 +1,6 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $TypeError = GetIntrinsic('%TypeError%');
var $TypeError = require('es-errors/type');
var IsArray = require('./IsArray');

View file

@ -3,7 +3,7 @@
var GetIntrinsic = require('get-intrinsic');
var callBound = require('call-bind/callBound');
var $TypeError = GetIntrinsic('%TypeError%');
var $TypeError = require('es-errors/type');
var IsArray = require('./IsArray');

View file

@ -1,18 +1,15 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $TypeError = GetIntrinsic('%TypeError%');
var $TypeError = require('es-errors/type');
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') {
if (typeof argument !== 'string') {
throw new $TypeError('Assertion failed: `argument` must be a String');
}
if (argument === '-0') { return -0; }

View file

@ -1,27 +1,23 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $TypeError = GetIntrinsic('%TypeError%');
var $TypeError = require('es-errors/type');
var callBound = require('call-bind/callBound');
var has = require('has');
var hasOwn = require('hasown');
var $charCodeAt = callBound('String.prototype.charCodeAt');
var $toUpperCase = callBound('String.prototype.toUpperCase');
var Type = require('./Type');
var caseFolding = require('../helpers/caseFolding');
var caseFolding = require('../helpers/caseFolding.json');
// https://262.ecma-international.org/6.0/#sec-runtime-semantics-canonicalize-ch
module.exports = function Canonicalize(ch, IgnoreCase, Unicode) {
if (Type(ch) !== 'String') {
if (typeof ch !== 'string') {
throw new $TypeError('Assertion failed: `ch` must be a character');
}
if (Type(IgnoreCase) !== 'Boolean' || Type(Unicode) !== 'Boolean') {
if (typeof IgnoreCase !== 'boolean' || typeof Unicode !== 'boolean') {
throw new $TypeError('Assertion failed: `IgnoreCase` and `Unicode` must be Booleans');
}
@ -30,10 +26,10 @@ module.exports = function Canonicalize(ch, IgnoreCase, Unicode) {
}
if (Unicode) { // step 2
if (has(caseFolding.C, ch)) {
if (hasOwn(caseFolding.C, ch)) {
return caseFolding.C[ch];
}
if (has(caseFolding.S, ch)) {
if (hasOwn(caseFolding.S, ch)) {
return caseFolding.S[ch];
}
return ch; // step 2.b

View file

@ -4,7 +4,7 @@ var GetIntrinsic = require('get-intrinsic');
var callBound = require('call-bind/callBound');
var $fromCharCode = GetIntrinsic('%String.fromCharCode%');
var $TypeError = GetIntrinsic('%TypeError%');
var $TypeError = require('es-errors/type');
var $charCodeAt = callBound('String.prototype.charCodeAt');
var $push = callBound('Array.prototype.push');

View file

@ -1,8 +1,6 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $TypeError = GetIntrinsic('%TypeError%');
var $TypeError = require('es-errors/type');
var GetPrototypeFromConstructor = require('./GetPrototypeFromConstructor');
var IsConstructor = require('./IsConstructor');

View file

@ -1,13 +1,10 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $TypeError = GetIntrinsic('%TypeError%');
var $TypeError = require('es-errors/type');
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');
@ -16,7 +13,7 @@ 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') {
if (typeof string !== 'string') {
throw new $TypeError('Assertion failed: `string` must be a String');
}
var size = string.length;

View file

@ -1,8 +1,6 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $TypeError = GetIntrinsic('%TypeError%');
var $TypeError = require('es-errors/type');
var UTF16EncodeCodePoint = require('./UTF16EncodeCodePoint');
var IsArray = require('./IsArray');

View file

@ -1,38 +1,42 @@
'use strict';
var has = require('has');
var $TypeError = require('es-errors/type');
var assertRecord = require('../helpers/assertRecord');
var hasOwn = require('hasown');
var IsDataDescriptor = require('./IsDataDescriptor');
var IsGenericDescriptor = require('./IsGenericDescriptor');
var Type = require('./Type');
var isPropertyDescriptor = require('../helpers/records/property-descriptor');
// https://262.ecma-international.org/6.0/#sec-completepropertydescriptor
module.exports = function CompletePropertyDescriptor(Desc) {
if (!isPropertyDescriptor(Desc)) {
throw new $TypeError('Assertion failed: `Desc` must be a Property Descriptor');
}
/* eslint no-param-reassign: 0 */
assertRecord(Type, 'Property Descriptor', 'Desc', Desc);
if (IsGenericDescriptor(Desc) || IsDataDescriptor(Desc)) {
if (!has(Desc, '[[Value]]')) {
if (!hasOwn(Desc, '[[Value]]')) {
Desc['[[Value]]'] = void 0;
}
if (!has(Desc, '[[Writable]]')) {
if (!hasOwn(Desc, '[[Writable]]')) {
Desc['[[Writable]]'] = false;
}
} else {
if (!has(Desc, '[[Get]]')) {
if (!hasOwn(Desc, '[[Get]]')) {
Desc['[[Get]]'] = void 0;
}
if (!has(Desc, '[[Set]]')) {
if (!hasOwn(Desc, '[[Set]]')) {
Desc['[[Set]]'] = void 0;
}
}
if (!has(Desc, '[[Enumerable]]')) {
if (!hasOwn(Desc, '[[Enumerable]]')) {
Desc['[[Enumerable]]'] = false;
}
if (!has(Desc, '[[Configurable]]')) {
if (!hasOwn(Desc, '[[Configurable]]')) {
Desc['[[Configurable]]'] = false;
}
return Desc;

View file

@ -1,8 +1,6 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $SyntaxError = GetIntrinsic('%SyntaxError%');
var $SyntaxError = require('es-errors/syntax');
var SLOT = require('internal-slot');

View file

@ -1,8 +1,6 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $TypeError = GetIntrinsic('%TypeError%');
var $TypeError = require('es-errors/type');
var callBound = require('call-bind/callBound');
var forEach = require('../helpers/forEach');

View file

@ -2,7 +2,9 @@
var GetIntrinsic = require('get-intrinsic');
var $TypeError = GetIntrinsic('%TypeError%');
var $SyntaxError = require('es-errors/syntax');
var $TypeError = require('es-errors/type');
var $Promise = GetIntrinsic('%Promise%', true);
var AsyncFromSyncIteratorContinuation = require('./AsyncFromSyncIteratorContinuation');
var Call = require('./Call');
@ -13,19 +15,23 @@ var IteratorNext = require('./IteratorNext');
var OrdinaryObjectCreate = require('./OrdinaryObjectCreate');
var Type = require('./Type');
var SLOT = require('internal-slot');
var isIteratorRecord = require('../helpers/records/iterator-record');
var assertRecord = require('../helpers/assertRecord');
var SLOT = require('internal-slot');
var $AsyncFromSyncIteratorPrototype = GetIntrinsic('%AsyncFromSyncIteratorPrototype%', true) || {
next: function next(value) {
if (!$Promise) {
throw new $SyntaxError('This environment does not support Promises.');
}
var O = this; // step 1
SLOT.assert(O, '[[SyncIteratorRecord]]'); // step 2
var argsLength = arguments.length;
return new Promise(function (resolve) { // step 3
return new $Promise(function (resolve) { // step 3
var syncIteratorRecord = SLOT.get(O, '[[SyncIteratorRecord]]'); // step 4
var result;
if (argsLength > 0) {
@ -37,6 +43,10 @@ var $AsyncFromSyncIteratorPrototype = GetIntrinsic('%AsyncFromSyncIteratorProtot
});
},
'return': function () {
if (!$Promise) {
throw new $SyntaxError('This environment does not support Promises.');
}
var O = this; // step 1
SLOT.assert(O, '[[SyncIteratorRecord]]'); // step 2
@ -44,7 +54,7 @@ var $AsyncFromSyncIteratorPrototype = GetIntrinsic('%AsyncFromSyncIteratorProtot
var valueIsPresent = arguments.length > 0;
var value = valueIsPresent ? arguments[0] : void undefined;
return new Promise(function (resolve, reject) { // step 3
return new $Promise(function (resolve, reject) { // step 3
var syncIterator = SLOT.get(O, '[[SyncIteratorRecord]]')['[[Iterator]]']; // step 4
var iteratorReturn = GetMethod(syncIterator, 'return'); // step 5
@ -68,6 +78,10 @@ var $AsyncFromSyncIteratorPrototype = GetIntrinsic('%AsyncFromSyncIteratorProtot
});
},
'throw': function () {
if (!$Promise) {
throw new $SyntaxError('This environment does not support Promises.');
}
var O = this; // step 1
SLOT.assert(O, '[[SyncIteratorRecord]]'); // step 2
@ -75,7 +89,7 @@ var $AsyncFromSyncIteratorPrototype = GetIntrinsic('%AsyncFromSyncIteratorProtot
var valueIsPresent = arguments.length > 0;
var value = valueIsPresent ? arguments[0] : void undefined;
return new Promise(function (resolve, reject) { // step 3
return new $Promise(function (resolve, reject) { // step 3
var syncIterator = SLOT.get(O, '[[SyncIteratorRecord]]')['[[Iterator]]']; // step 4
var throwMethod = GetMethod(syncIterator, 'throw'); // step 5
@ -104,7 +118,9 @@ var $AsyncFromSyncIteratorPrototype = GetIntrinsic('%AsyncFromSyncIteratorProtot
// https://262.ecma-international.org/11.0/#sec-createasyncfromsynciterator
module.exports = function CreateAsyncFromSyncIterator(syncIteratorRecord) {
assertRecord(Type, 'Iterator Record', 'syncIteratorRecord', syncIteratorRecord);
if (!isIteratorRecord(syncIteratorRecord)) {
throw new $TypeError('Assertion failed: `syncIteratorRecord` must be an Iterator Record');
}
// var asyncIterator = OrdinaryObjectCreate(%AsyncFromSyncIteratorPrototype%, « [[SyncIteratorRecord]] »); // step 1
var asyncIterator = OrdinaryObjectCreate($AsyncFromSyncIteratorPrototype);

View file

@ -1,8 +1,6 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $TypeError = GetIntrinsic('%TypeError%');
var $TypeError = require('es-errors/type');
var IsPropertyKey = require('./IsPropertyKey');
var OrdinaryDefineOwnProperty = require('./OrdinaryDefineOwnProperty');

View file

@ -1,8 +1,6 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $TypeError = GetIntrinsic('%TypeError%');
var $TypeError = require('es-errors/type');
var CreateDataProperty = require('./CreateDataProperty');
var IsPropertyKey = require('./IsPropertyKey');

View file

@ -1,8 +1,6 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $TypeError = GetIntrinsic('%TypeError%');
var $TypeError = require('es-errors/type');
var callBound = require('call-bind/callBound');
@ -10,12 +8,11 @@ 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') {
if (typeof tag !== 'string' || typeof attribute !== 'string') {
throw new $TypeError('Assertion failed: `tag` and `attribute` must be strings');
}
var str = RequireObjectCoercible(string);

View file

@ -1,15 +1,11 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $TypeError = GetIntrinsic('%TypeError%');
var Type = require('./Type');
var $TypeError = require('es-errors/type');
// https://262.ecma-international.org/6.0/#sec-createiterresultobject
module.exports = function CreateIterResultObject(value, done) {
if (Type(done) !== 'Boolean') {
if (typeof done !== 'boolean') {
throw new $TypeError('Assertion failed: Type(done) is not Boolean');
}
return {

View file

@ -1,10 +1,8 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var callBound = require('call-bind/callBound');
var $TypeError = GetIntrinsic('%TypeError%');
var $TypeError = require('es-errors/type');
var $indexOf = callBound('Array.prototype.indexOf', true) || callBound('String.prototype.indexOf');
var $push = callBound('Array.prototype.push');

View file

@ -1,8 +1,6 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $TypeError = GetIntrinsic('%TypeError%');
var $TypeError = require('es-errors/type');
var DefineOwnProperty = require('../helpers/DefineOwnProperty');

View file

@ -1,8 +1,6 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $TypeError = GetIntrinsic('%TypeError%');
var $TypeError = require('es-errors/type');
var DefinePropertyOrThrow = require('./DefinePropertyOrThrow');
var IsPropertyKey = require('./IsPropertyKey');

View file

@ -3,7 +3,7 @@
var GetIntrinsic = require('get-intrinsic');
var hasSymbols = require('has-symbols')();
var $TypeError = GetIntrinsic('%TypeError%');
var $TypeError = require('es-errors/type');
var IteratorPrototype = GetIntrinsic('%IteratorPrototype%', true);
var AdvanceStringIndex = require('./AdvanceStringIndex');
@ -21,13 +21,13 @@ var SLOT = require('internal-slot');
var setToStringTag = require('es-set-tostringtag');
var RegExpStringIterator = function RegExpStringIterator(R, S, global, fullUnicode) {
if (Type(S) !== 'String') {
if (typeof S !== 'string') {
throw new $TypeError('`S` must be a string');
}
if (Type(global) !== 'Boolean') {
if (typeof global !== 'boolean') {
throw new $TypeError('`global` must be a boolean');
}
if (Type(fullUnicode) !== 'Boolean') {
if (typeof fullUnicode !== 'boolean') {
throw new $TypeError('`fullUnicode` must be a boolean');
}
SLOT.set(this, '[[IteratingRegExp]]', R);

View file

@ -1,8 +1,6 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $EvalError = GetIntrinsic('%EvalError%');
var $EvalError = require('es-errors/eval');
var DayWithinYear = require('./DayWithinYear');
var InLeapYear = require('./InLeapYear');

View file

@ -1,8 +1,6 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $TypeError = GetIntrinsic('%TypeError%');
var $TypeError = require('es-errors/type');
var weekdays = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
@ -10,16 +8,15 @@ var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oc
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');
var MonthFromTime = require('./MonthFromTime');
var WeekDay = require('./WeekDay');
var YearFromTime = require('./YearFromTime');
// https://262.ecma-international.org/9.0/#sec-datestring
module.exports = function DateString(tv) {
if (Type(tv) !== 'Number' || $isNaN(tv)) {
if (typeof tv !== 'number' || $isNaN(tv)) {
throw new $TypeError('Assertion failed: `tv` must be a non-NaN Number');
}
var weekday = weekdays[WeekDay(tv)];

41
node_modules/es-abstract/2022/DefineMethodProperty.js generated vendored Normal file
View file

@ -0,0 +1,41 @@
'use strict';
var $TypeError = require('es-errors/type');
var DefinePropertyOrThrow = require('./DefinePropertyOrThrow');
var IsExtensible = require('./IsExtensible');
var IsPropertyKey = require('./IsPropertyKey');
var Type = require('./Type');
// https://262.ecma-international.org/13.0/#sec-definemethodproperty
module.exports = function DefineMethodProperty(homeObject, key, closure, enumerable) {
if (Type(homeObject) !== 'Object') {
throw new $TypeError('Assertion failed: `homeObject` is not an Object');
}
if (!IsPropertyKey(key)) {
throw new $TypeError('Assertion failed: `key` is not a Property Key or a Private Name');
}
if (typeof closure !== 'function') {
throw new $TypeError('Assertion failed: `closure` is not a function');
}
if (typeof enumerable !== 'boolean') {
throw new $TypeError('Assertion failed: `enumerable` is not a Boolean');
}
// 1. Assert: homeObject is an ordinary, extensible object with no non-configurable properties.
if (!IsExtensible(homeObject)) {
throw new $TypeError('Assertion failed: `homeObject` is not an ordinary, extensible object, with no non-configurable properties');
}
// 2. If key is a Private Name, then
// a. Return PrivateElement { [[Key]]: key, [[Kind]]: method, [[Value]]: closure }.
// 3. Else,
var desc = { // step 3.a
'[[Value]]': closure,
'[[Writable]]': true,
'[[Enumerable]]': enumerable,
'[[Configurable]]': true
};
DefinePropertyOrThrow(homeObject, key, desc); // step 3.b
};

View file

@ -1,14 +1,11 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $TypeError = require('es-errors/type');
var $TypeError = GetIntrinsic('%TypeError%');
var isPropertyDescriptor = require('../helpers/isPropertyDescriptor');
var isPropertyDescriptor = require('../helpers/records/property-descriptor');
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');
@ -26,16 +23,8 @@ module.exports = function DefinePropertyOrThrow(O, P, desc) {
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)) {
var Desc = isPropertyDescriptor(desc) ? desc : ToPropertyDescriptor(desc);
if (!isPropertyDescriptor(Desc)) {
throw new $TypeError('Assertion failed: Desc is not a valid Property Descriptor');
}

View file

@ -1,8 +1,6 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $TypeError = GetIntrinsic('%TypeError%');
var $TypeError = require('es-errors/type');
var IsPropertyKey = require('./IsPropertyKey');
var Type = require('./Type');

View file

@ -1,9 +1,9 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $SyntaxError = require('es-errors/syntax');
var $TypeError = require('es-errors/type');
var $SyntaxError = GetIntrinsic('%SyntaxError%');
var $TypeError = GetIntrinsic('%TypeError%');
var IsDetachedBuffer = require('./IsDetachedBuffer');
var isArrayBuffer = require('is-array-buffer');
var isSharedArrayBuffer = require('is-shared-array-buffer');
@ -30,14 +30,17 @@ module.exports = function DetachArrayBuffer(arrayBuffer) {
// 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');
if (!IsDetachedBuffer(arrayBuffer)) { // node v21.0.0+ throws when you structuredClone a detached buffer
if (typeof structuredClone === 'function') {
structuredClone(arrayBuffer, { transfer: [arrayBuffer] });
} else if (typeof postMessage === 'function') {
postMessage('', '/', [arrayBuffer]); // TODO: see if this might trigger listeners
} else if (MessageChannel) {
(new MessageChannel()).port1.postMessage(null, [arrayBuffer]);
} else {
throw new $SyntaxError('DetachArrayBuffer is not supported in this environment');
}
}
return null;
};

View file

@ -2,7 +2,7 @@
var GetIntrinsic = require('get-intrinsic');
var $TypeError = GetIntrinsic('%TypeError%');
var $TypeError = require('es-errors/type');
var objectKeys = require('object-keys');

View file

@ -1,8 +1,6 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $TypeError = GetIntrinsic('%TypeError%');
var $TypeError = require('es-errors/type');
var MAX_SAFE_INTEGER = require('../helpers/maxSafeInteger');

View file

@ -1,15 +1,15 @@
'use strict';
var assertRecord = require('../helpers/assertRecord');
var fromPropertyDescriptor = require('../helpers/fromPropertyDescriptor');
var $TypeError = require('es-errors/type');
var Type = require('./Type');
var isPropertyDescriptor = require('../helpers/records/property-descriptor');
var fromPropertyDescriptor = require('../helpers/fromPropertyDescriptor');
// https://262.ecma-international.org/6.0/#sec-frompropertydescriptor
module.exports = function FromPropertyDescriptor(Desc) {
if (typeof Desc !== 'undefined') {
assertRecord(Type, 'Property Descriptor', 'Desc', Desc);
if (typeof Desc !== 'undefined' && !isPropertyDescriptor(Desc)) {
throw new $TypeError('Assertion failed: `Desc` must be a Property Descriptor');
}
return fromPropertyDescriptor(Desc);

View file

@ -1,8 +1,6 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $TypeError = GetIntrinsic('%TypeError%');
var $TypeError = require('es-errors/type');
var inspect = require('object-inspect');

View file

@ -2,8 +2,8 @@
var GetIntrinsic = require('get-intrinsic');
var $TypeError = GetIntrinsic('%TypeError%');
var $SyntaxError = GetIntrinsic('%SyntaxError%');
var $TypeError = require('es-errors/type');
var $SyntaxError = require('es-errors/syntax');
var $asyncIterator = GetIntrinsic('%Symbol.asyncIterator%', true);
var inspect = require('object-inspect');

View file

@ -1,20 +1,18 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $TypeError = require('es-errors/type');
var $TypeError = GetIntrinsic('%TypeError%');
var Type = require('./Type');
var assertRecord = require('../helpers/assertRecord');
var isMatchRecord = require('../helpers/records/match-record');
// https://262.ecma-international.org/13.0/#sec-getmatchindexpair
module.exports = function GetMatchIndexPair(S, match) {
if (Type(S) !== 'String') {
if (typeof S !== 'string') {
throw new $TypeError('Assertion failed: `S` must be a String');
}
assertRecord(Type, 'Match Record', 'match', match);
if (!isMatchRecord(match)) {
throw new $TypeError('Assertion failed: `match` must be a Match Record');
}
if (!(match['[[StartIndex]]'] <= S.length)) {
throw new $TypeError('`match` [[StartIndex]] must be a non-negative integer <= the length of S');

View file

@ -1,21 +1,20 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $TypeError = GetIntrinsic('%TypeError%');
var $TypeError = require('es-errors/type');
var substring = require('./substring');
var Type = require('./Type');
var assertRecord = require('../helpers/assertRecord');
var isMatchRecord = require('../helpers/records/match-record');
// https://262.ecma-international.org/13.0/#sec-getmatchstring
module.exports = function GetMatchString(S, match) {
if (Type(S) !== 'String') {
if (typeof S !== 'string') {
throw new $TypeError('Assertion failed: `S` must be a String');
}
assertRecord(Type, 'Match Record', 'match', match);
if (!isMatchRecord(match)) {
throw new $TypeError('Assertion failed: `match` must be a Match Record');
}
if (!(match['[[StartIndex]]'] <= S.length)) {
throw new $TypeError('`match` [[StartIndex]] must be a non-negative integer <= the length of S');

View file

@ -1,8 +1,6 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $TypeError = GetIntrinsic('%TypeError%');
var $TypeError = require('es-errors/type');
var GetV = require('./GetV');
var IsCallable = require('./IsCallable');

View file

@ -4,7 +4,7 @@ var GetIntrinsic = require('get-intrinsic');
var hasSymbols = require('has-symbols')();
var $TypeError = GetIntrinsic('%TypeError%');
var $TypeError = require('es-errors/type');
var $gOPN = GetIntrinsic('%Object.getOwnPropertyNames%', true);
var $gOPS = hasSymbols && GetIntrinsic('%Object.getOwnPropertySymbols%', true);

View file

@ -1,8 +1,6 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $TypeError = GetIntrinsic('%TypeError%');
var $TypeError = require('es-errors/type');
var Get = require('./Get');
var IsCallable = require('./IsCallable');

View file

@ -3,8 +3,8 @@
var GetIntrinsic = require('get-intrinsic');
var $Function = GetIntrinsic('%Function%');
var $TypeError = GetIntrinsic('%TypeError%');
var $SyntaxError = GetIntrinsic('%SyntaxError%');
var $TypeError = require('es-errors/type');
var $SyntaxError = require('es-errors/syntax');
var Get = require('./Get');
var IsConstructor = require('./IsConstructor');

View file

@ -1,12 +1,10 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var callBound = require('call-bind/callBound');
var $TypeError = GetIntrinsic('%TypeError%');
var $TypeError = require('es-errors/type');
var StringToCodePoints = require('./StringToCodePoints');
var Type = require('./Type');
var isInteger = require('../helpers/isInteger');
@ -15,7 +13,7 @@ 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') {
if (typeof S !== 'string') {
throw new $TypeError('Assertion failed: `S` must be a String');
}
if (!isInteger(e) || e < 0) {

View file

@ -1,124 +1,139 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $TypeError = require('es-errors/type');
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 ToObject = require('./ToObject');
var min = require('./min');
var StringIndexOf = require('./StringIndexOf');
var StringToNumber = require('./StringToNumber');
var substring = require('./substring');
var ToString = require('./ToString');
var Type = require('./Type');
var isInteger = require('../helpers/isInteger');
var isStringOrHole = require('../helpers/isStringOrHole');
var isStringOrUndefined = require('../helpers/isStringOrUndefined');
var isPrefixOf = require('../helpers/isPrefixOf');
// http://www.ecma-international.org/ecma-262/12.0/#sec-getsubstitution
var startsWithDollarDigit = regexTester(/^\$[0-9]/);
// http://www.ecma-international.org/ecma-262/13.0/#sec-getsubstitution
// eslint-disable-next-line max-statements, max-params, max-lines-per-function
module.exports = function GetSubstitution(matched, str, position, captures, namedCaptures, replacement) {
if (Type(matched) !== 'String') {
module.exports = function GetSubstitution(matched, str, position, captures, namedCaptures, replacementTemplate) {
if (typeof matched !== 'string') {
throw new $TypeError('Assertion failed: `matched` must be a String');
}
var matchLength = matched.length;
if (Type(str) !== 'String') {
if (typeof str !== 'string') {
throw new $TypeError('Assertion failed: `str` must be a String');
}
var stringLength = str.length;
if (!isInteger(position) || position < 0 || position > stringLength) {
throw new $TypeError('Assertion failed: `position` must be a nonnegative integer, and less than or equal to the length of `string`, got ' + inspect(position));
if (!isInteger(position) || position < 0) {
throw new $TypeError('Assertion failed: `position` must be a nonnegative integer, 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 (!IsArray(captures) || !every(captures, isStringOrUndefined)) {
throw new $TypeError('Assertion failed: `captures` must be a possibly-empty List of Strings or `undefined`, got ' + inspect(captures));
}
if (Type(replacement) !== 'String') {
throw new $TypeError('Assertion failed: `replacement` must be a String');
if (typeof namedCaptures !== 'undefined' && Type(namedCaptures) !== 'Object') {
throw new $TypeError('Assertion failed: `namedCaptures` must be `undefined` or an Object');
}
var tailPos = position + matchLength;
var m = captures.length;
if (Type(namedCaptures) !== 'Undefined') {
namedCaptures = ToObject(namedCaptures); // eslint-disable-line no-param-reassign
if (typeof replacementTemplate !== 'string') {
throw new $TypeError('Assertion failed: `replacementTemplate` must be a String');
}
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;
}
var stringLength = str.length; // step 1
if (position > stringLength) {
throw new $TypeError('Assertion failed: position > stringLength, got ' + inspect(position)); // step 2
}
var templateRemainder = replacementTemplate; // step 3
var result = ''; // step 4
while (templateRemainder !== '') { // step 5
// 5.a NOTE: The following steps isolate ref (a prefix of templateRemainder), determine refReplacement (its replacement), and then append that replacement to result.
var ref, refReplacement, found, capture;
if (isPrefixOf('$$', templateRemainder)) { // step 5.b
ref = '$$'; // step 5.b.i
refReplacement = '$'; // step 5.b.ii
} else if (isPrefixOf('$`', templateRemainder)) { // step 5.c
ref = '$`'; // step 5.c.i
refReplacement = substring(str, 0, position); // step 5.c.ii
} else if (isPrefixOf('$&', templateRemainder)) { // step 5.d
ref = '$&'; // step 5.d.i
refReplacement = matched; // step 5.d.ii
} else if (isPrefixOf('$\'', templateRemainder)) { // step 5.e
ref = '$\''; // step 5.e.i
var matchLength = matched.length; // step 5.e.ii
var tailPos = position + matchLength; // step 5.e.iii
refReplacement = substring(str, min(tailPos, stringLength)); // step 5.e.iv
// 5.e.v NOTE: tailPos can exceed stringLength only if this abstract operation was invoked by a call to the intrinsic @@replace method of %RegExp.prototype% on an object whose "exec" property is not the intrinsic %RegExp.prototype.exec%.
} else if (startsWithDollarDigit(templateRemainder)) { // step 5.f
found = false; // step 5.f.i
for (var d = 2; d > 0; d -= 1) { // step 5.f.ii
// If found is false and templateRemainder starts with "$" followed by d or more decimal digits, then
if (!found) { // step 5.f.ii.1
found = true; // step 5.f.ii.1.a
ref = substring(templateRemainder, 0, 1 + d); // step 5.f.ii.1.b
var digits = substring(templateRemainder, 1, 1 + d); // step 5.f.ii.1.c
var index = StringToNumber(digits); // step 5.f.ii.1.d
if (index < 0 || index > 99) {
throw new $TypeError('Assertion failed: `index` must be >= 0 and <= 99'); // step 5.f.ii.1.e
}
if (index === 0) { // step 5.f.ii.1.f
refReplacement = ref;
} else if (index <= captures.length) { // step 5.f.ii.1.g
capture = captures[index - 1]; // step 5.f.ii.1.g.i
if (typeof capture === 'undefined') { // step 5.f.ii.1.g.ii
refReplacement = ''; // step 5.f.ii.1.g.ii.i
} else { // step 5.f.ii.1.g.iii
refReplacement = capture; // step 5.f.ii.1.g.iii.i
}
} else { // step 5.f.ii.1.h
refReplacement = ref; // step 5.f.ii.1.h.i
}
} else {
result += '$';
}
}
} else {
// the final $, or else not a $
result += $charAt(replacement, i);
} else if (isPrefixOf('$<', templateRemainder)) { // step 5.g
var gtPos = StringIndexOf(templateRemainder, '>', 0); // step 5.g.i
if (gtPos === -1 || typeof namedCaptures === 'undefined') { // step 5.g.ii
ref = '$<'; // step 5.g.ii.1
refReplacement = ref; // step 5.g.ii.2
} else { // step 5.g.iii
ref = substring(templateRemainder, 0, gtPos + 1); // step 5.g.iii.1
var groupName = substring(templateRemainder, 2, gtPos); // step 5.g.iii.2
if (Type(namedCaptures) !== 'Object') {
throw new $TypeError('Assertion failed: Type(namedCaptures) is not Object'); // step 5.g.iii.3
}
capture = Get(namedCaptures, groupName); // step 5.g.iii.4
if (typeof capture === 'undefined') { // step 5.g.iii.5
refReplacement = ''; // step 5.g.iii.5.a
} else { // step 5.g.iii.6
refReplacement = ToString(capture); // step 5.g.iii.6.a
}
}
} else { // step 5.h
ref = substring(templateRemainder, 0, 1); // step 5.h.i
refReplacement = ref; // step 5.h.ii
}
var refLength = ref.length; // step 5.i
templateRemainder = substring(templateRemainder, refLength); // step 5.j
result += refReplacement; // step 5.k
}
return result;
return result; // step 6
};

View file

@ -1,8 +1,6 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $TypeError = GetIntrinsic('%TypeError%');
var $TypeError = require('es-errors/type');
var inspect = require('object-inspect');

View file

@ -2,8 +2,8 @@
var GetIntrinsic = require('get-intrinsic');
var $SyntaxError = GetIntrinsic('%SyntaxError%');
var $TypeError = GetIntrinsic('%TypeError%');
var $SyntaxError = require('es-errors/syntax');
var $TypeError = require('es-errors/type');
var $Uint8Array = GetIntrinsic('%Uint8Array%', true);
var callBound = require('call-bind/callBound');
@ -19,20 +19,7 @@ var isArrayBuffer = require('is-array-buffer');
var isSharedArrayBuffer = require('is-shared-array-buffer');
var safeConcat = require('safe-array-concat');
var table61 = {
__proto__: null,
$Int8: 1,
$Uint8: 1,
$Uint8C: 1,
$Int16: 2,
$Uint16: 2,
$Int32: 4,
$Uint32: 4,
$BigInt64: 8,
$BigUint64: 8,
$Float32: 4,
$Float64: 8
};
var tableTAO = require('./tables/typed-array-objects');
var defaultEndianness = require('../helpers/defaultEndianness');
@ -48,7 +35,7 @@ module.exports = function GetValueFromBuffer(arrayBuffer, byteIndex, type, isTyp
throw new $TypeError('Assertion failed: `byteIndex` must be an integer');
}
if (typeof type !== 'string' || typeof table61['$' + type] !== 'number') {
if (typeof type !== 'string' || typeof tableTAO.size['$' + type] !== 'number') {
throw new $TypeError('Assertion failed: `type` must be a Typed Array element type');
}
@ -76,7 +63,7 @@ module.exports = function GetValueFromBuffer(arrayBuffer, byteIndex, type, isTyp
// 4. Let block be arrayBuffer.[[ArrayBufferData]].
var elementSize = table61['$' + type]; // step 5
var elementSize = tableTAO.size['$' + type]; // step 5
if (!elementSize) {
throw new $TypeError('Assertion failed: `type` must be one of "Int8", "Uint8", "Uint8C", "Int16", "Uint16", "Int32", "Uint32", "BigInt64", "BigUint64", "Float32", or "Float64"');
}

View file

@ -1,10 +1,8 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $TypeError = require('es-errors/type');
var $TypeError = GetIntrinsic('%TypeError%');
var has = require('has');
var hasOwn = require('hasown');
var IsPropertyKey = require('./IsPropertyKey');
var Type = require('./Type');
@ -18,5 +16,5 @@ module.exports = function HasOwnProperty(O, P) {
if (!IsPropertyKey(P)) {
throw new $TypeError('Assertion failed: `P` must be a Property Key');
}
return has(O, P);
return hasOwn(O, P);
};

View file

@ -1,8 +1,6 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $TypeError = GetIntrinsic('%TypeError%');
var $TypeError = require('es-errors/type');
var IsPropertyKey = require('./IsPropertyKey');
var Type = require('./Type');

View file

@ -1,8 +1,6 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $EvalError = GetIntrinsic('%EvalError%');
var $EvalError = require('es-errors/eval');
var DaysInYear = require('./DaysInYear');
var YearFromTime = require('./YearFromTime');

View file

@ -1,8 +1,6 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $TypeError = GetIntrinsic('%TypeError%');
var $TypeError = require('es-errors/type');
var CreateNonEnumerableDataPropertyOrThrow = require('./CreateNonEnumerableDataPropertyOrThrow');
var Get = require('./Get');

View file

@ -2,7 +2,7 @@
var GetIntrinsic = require('get-intrinsic');
var $TypeError = GetIntrinsic('%TypeError%');
var $TypeError = require('es-errors/type');
var $hasInstance = GetIntrinsic('Symbol.hasInstance', true);

View file

@ -0,0 +1,38 @@
'use strict';
var $TypeError = require('es-errors/type');
var GetValueFromBuffer = require('./GetValueFromBuffer');
var IsValidIntegerIndex = require('./IsValidIntegerIndex');
var TypedArrayElementSize = require('./TypedArrayElementSize');
var TypedArrayElementType = require('./TypedArrayElementType');
var isTypedArray = require('is-typed-array');
var typedArrayBuffer = require('typed-array-buffer');
var typedArrayByteOffset = require('typed-array-byte-offset');
// https://262.ecma-international.org/13.0/#sec-integerindexedelementget
module.exports = function IntegerIndexedElementGet(O, index) {
if (!isTypedArray(O)) {
throw new $TypeError('Assertion failed: `O` must be a TypedArray');
}
if (typeof index !== 'number') {
throw new $TypeError('Assertion failed: `index` must be a Number');
}
if (!IsValidIntegerIndex(O, index)) {
return void undefined; // step 1
}
var offset = typedArrayByteOffset(O); // step 2
var elementSize = TypedArrayElementSize(O); // step 3
var indexedPosition = (index * elementSize) + offset; // step 4
var elementType = TypedArrayElementType(O); // step 5
return GetValueFromBuffer(typedArrayBuffer(O), indexedPosition, elementType, true, 'Unordered'); // step 11
};

View file

@ -0,0 +1,42 @@
'use strict';
var $TypeError = require('es-errors/type');
var IsValidIntegerIndex = require('./IsValidIntegerIndex');
var SetValueInBuffer = require('./SetValueInBuffer');
var ToBigInt = require('./ToBigInt');
var ToNumber = require('./ToNumber');
var TypedArrayElementSize = require('./TypedArrayElementSize');
var TypedArrayElementType = require('./TypedArrayElementType');
var typedArrayBuffer = require('typed-array-buffer');
var typedArrayByteOffset = require('typed-array-byte-offset');
var whichTypedArray = require('which-typed-array');
// https://262.ecma-international.org/13.0/#sec-integerindexedelementset
module.exports = function IntegerIndexedElementSet(O, index, value) {
var arrayTypeName = whichTypedArray(O);
if (!arrayTypeName) {
throw new $TypeError('Assertion failed: `O` must be a TypedArray');
}
if (typeof index !== 'number') {
throw new $TypeError('Assertion failed: `index` must be a Number');
}
var contentType = arrayTypeName === 'BigInt64Array' || arrayTypeName === 'BigUint64Array' ? 'BigInt' : 'Number';
var numValue = contentType === 'BigInt' ? ToBigInt(value) : ToNumber(value); // steps 1 - 2
if (IsValidIntegerIndex(O, index)) { // step 3
var offset = typedArrayByteOffset(O); // step 3.a
var elementSize = TypedArrayElementSize(O); // step 3.b
var indexedPosition = (index * elementSize) + offset; // step 3.c
var elementType = TypedArrayElementType(O); // step 3.d
SetValueInBuffer(typedArrayBuffer(O), indexedPosition, elementType, numValue, true, 'Unordered'); // step 3.e
}
};

View file

@ -0,0 +1,66 @@
'use strict';
var $TypeError = require('es-errors/type');
var Call = require('./Call');
var CreateDataProperty = require('./CreateDataProperty');
var EnumerableOwnPropertyNames = require('./EnumerableOwnPropertyNames');
var Get = require('./Get');
var IsArray = require('./IsArray');
var LengthOfArrayLike = require('./LengthOfArrayLike');
var ToString = require('./ToString');
var Type = require('./Type');
var forEach = require('../helpers/forEach');
// https://262.ecma-international.org/11.0/#sec-internalizejsonproperty
module.exports = function InternalizeJSONProperty(holder, name, reviver) {
if (Type(holder) !== 'Object') {
throw new $TypeError('Assertion failed: `holder` is not an Object');
}
if (typeof name !== 'string') {
throw new $TypeError('Assertion failed: `name` is not a String');
}
if (typeof reviver !== 'function') {
throw new $TypeError('Assertion failed: `reviver` is not a Function');
}
var val = Get(holder, name); // step 1
if (Type(val) === 'Object') { // step 2
var isArray = IsArray(val); // step 2.a
if (isArray) { // step 2.b
var I = 0; // step 2.b.i
var len = LengthOfArrayLike(val, 'length'); // step 2.b.ii
while (I < len) { // step 2.b.iii
var newElement = InternalizeJSONProperty(val, ToString(I), reviver); // step 2.b.iv.1
if (typeof newElement === 'undefined') { // step 2.b.iii.2
delete val[ToString(I)]; // step 2.b.iii.2.a
} else { // step 2.b.iii.3
CreateDataProperty(val, ToString(I), newElement); // step 2.b.iii.3.a
}
I += 1; // step 2.b.iii.4
}
} else { // step 2.c
var keys = EnumerableOwnPropertyNames(val, 'key'); // step 2.c.i
forEach(keys, function (P) { // step 2.c.ii
// eslint-disable-next-line no-shadow
var newElement = InternalizeJSONProperty(val, P, reviver); // step 2.c.ii.1
if (typeof newElement === 'undefined') { // step 2.c.ii.2
delete val[P]; // step 2.c.ii.2.a
} else { // step 2.c.ii.3
CreateDataProperty(val, P, newElement); // step 2.c.ii.3.a
}
});
}
}
return Call(reviver, holder, [name, val]); // step 3
};

View file

@ -1,8 +1,6 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $TypeError = GetIntrinsic('%TypeError%');
var $TypeError = require('es-errors/type');
var Call = require('./Call');
var IsArray = require('./IsArray');

View file

@ -1,10 +1,10 @@
'use strict';
var has = require('has');
var $TypeError = require('es-errors/type');
var Type = require('./Type');
var hasOwn = require('hasown');
var assertRecord = require('../helpers/assertRecord');
var isPropertyDescriptor = require('../helpers/records/property-descriptor');
// https://262.ecma-international.org/5.1/#sec-8.10.1
@ -13,9 +13,11 @@ module.exports = function IsAccessorDescriptor(Desc) {
return false;
}
assertRecord(Type, 'Property Descriptor', 'Desc', Desc);
if (!isPropertyDescriptor(Desc)) {
throw new $TypeError('Assertion failed: `Desc` must be a Property Descriptor');
}
if (!has(Desc, '[[Get]]') && !has(Desc, '[[Set]]')) {
if (!hasOwn(Desc, '[[Get]]') && !hasOwn(Desc, '[[Set]]')) {
return false;
}

View file

@ -1,10 +1,10 @@
'use strict';
var has = require('has');
var $TypeError = require('es-errors/type');
var Type = require('./Type');
var hasOwn = require('hasown');
var assertRecord = require('../helpers/assertRecord');
var isPropertyDescriptor = require('../helpers/records/property-descriptor');
// https://262.ecma-international.org/5.1/#sec-8.10.2
@ -13,9 +13,11 @@ module.exports = function IsDataDescriptor(Desc) {
return false;
}
assertRecord(Type, 'Property Descriptor', 'Desc', Desc);
if (!isPropertyDescriptor(Desc)) {
throw new $TypeError('Assertion failed: `Desc` must be a Property Descriptor');
}
if (!has(Desc, '[[Value]]') && !has(Desc, '[[Writable]]')) {
if (!hasOwn(Desc, '[[Value]]') && !hasOwn(Desc, '[[Writable]]')) {
return false;
}

View file

@ -1,22 +1,23 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $TypeError = GetIntrinsic('%TypeError%');
var $TypeError = require('es-errors/type');
var $byteLength = require('array-buffer-byte-length');
var isArrayBuffer = require('is-array-buffer');
var availableTypedArrays = require('available-typed-arrays')();
var callBound = require('call-bind/callBound');
var isArrayBuffer = require('is-array-buffer');
var isSharedArrayBuffer = require('is-shared-array-buffer');
// https://262.ecma-international.org/6.0/#sec-isdetachedbuffer
var $sabByteLength = callBound('SharedArrayBuffer.prototype.byteLength', true);
// https://262.ecma-international.org/8.0/#sec-isdetachedbuffer
module.exports = function IsDetachedBuffer(arrayBuffer) {
if (!isArrayBuffer(arrayBuffer)) {
var isSAB = isSharedArrayBuffer(arrayBuffer);
if (!isArrayBuffer(arrayBuffer) && !isSAB) {
throw new $TypeError('Assertion failed: `arrayBuffer` must be an Object with an [[ArrayBufferData]] internal slot');
}
if ($byteLength(arrayBuffer) === 0) {
if ((isSAB ? $sabByteLength : $byteLength)(arrayBuffer) === 0) {
try {
new global[availableTypedArrays[0]](arrayBuffer); // eslint-disable-line no-new
} catch (error) {

View file

@ -1,10 +1,11 @@
'use strict';
var assertRecord = require('../helpers/assertRecord');
var $TypeError = require('es-errors/type');
var IsAccessorDescriptor = require('./IsAccessorDescriptor');
var IsDataDescriptor = require('./IsDataDescriptor');
var Type = require('./Type');
var isPropertyDescriptor = require('../helpers/records/property-descriptor');
// https://262.ecma-international.org/6.0/#sec-isgenericdescriptor
@ -13,7 +14,9 @@ module.exports = function IsGenericDescriptor(Desc) {
return false;
}
assertRecord(Type, 'Property Descriptor', 'Desc', Desc);
if (!isPropertyDescriptor(Desc)) {
throw new $TypeError('Assertion failed: `Desc` must be a Property Descriptor');
}
if (!IsAccessorDescriptor(Desc) && !IsDataDescriptor(Desc)) {
return true;

View file

@ -3,7 +3,7 @@
var GetIntrinsic = require('get-intrinsic');
var $Number = GetIntrinsic('%Number%');
var $TypeError = GetIntrinsic('%TypeError%');
var $TypeError = require('es-errors/type');
var $isNaN = require('../helpers/isNaN');
@ -11,7 +11,6 @@ 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');
@ -20,7 +19,7 @@ var NumberLessThan = require('./Number/lessThan');
// eslint-disable-next-line max-statements, max-lines-per-function
module.exports = function IsLessThan(x, y, LeftFirst) {
if (Type(LeftFirst) !== 'Boolean') {
if (typeof LeftFirst !== 'boolean') {
throw new $TypeError('Assertion failed: LeftFirst argument must be a Boolean');
}
var px;
@ -32,9 +31,8 @@ module.exports = function IsLessThan(x, y, LeftFirst) {
py = ToPrimitive(y, $Number);
px = ToPrimitive(x, $Number);
}
var pxType = Type(px);
var pyType = Type(py);
if (pxType === 'String' && pyType === 'String') {
if (typeof px === 'string' && typeof py === 'string') {
if (IsStringPrefix(py, px)) {
return false;
}
@ -52,14 +50,14 @@ module.exports = function IsLessThan(x, y, LeftFirst) {
var nx;
var ny;
if (pxType === 'BigInt' && pyType === 'String') {
if (typeof px === 'bigint' && typeof py === 'string') {
ny = StringToBigInt(py);
if (typeof ny === 'undefined') {
return void undefined;
}
return BigIntLessThan(px, ny);
}
if (pxType === 'String' && pyType === 'BigInt') {
if (typeof px === 'string' && typeof py === 'bigint') {
nx = StringToBigInt(px);
if (typeof nx === 'undefined') {
return void undefined;
@ -70,9 +68,8 @@ module.exports = function IsLessThan(x, y, LeftFirst) {
nx = ToNumeric(px);
ny = ToNumeric(py);
var nxType = Type(nx);
if (nxType === Type(ny)) {
return nxType === 'Number' ? NumberLessThan(nx, ny) : BigIntLessThan(nx, ny);
if (typeof nx === typeof ny) {
return typeof nx === 'number' ? NumberLessThan(nx, ny) : BigIntLessThan(nx, ny);
}
if ($isNaN(nx) || $isNaN(ny)) {

View file

@ -1,8 +1,6 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $TypeError = GetIntrinsic('%TypeError%');
var $TypeError = require('es-errors/type');
var Type = require('./Type');

View file

@ -1,20 +1,17 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $TypeError = GetIntrinsic('%TypeError%');
var $TypeError = require('es-errors/type');
var StringIndexOf = require('./StringIndexOf');
var Type = require('./Type');
// https://262.ecma-international.org/13.0/#sec-isstringprefix
module.exports = function IsStringPrefix(p, q) {
if (Type(p) !== 'String') {
if (typeof p !== 'string') {
throw new $TypeError('Assertion failed: "p" must be a String');
}
if (Type(q) !== 'String') {
if (typeof q !== 'string') {
throw new $TypeError('Assertion failed: "q" must be a String');
}

View file

@ -1,16 +1,13 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var CodePointAt = require('./CodePointAt');
var $TypeError = GetIntrinsic('%TypeError%');
var Type = require('./Type');
var $TypeError = require('es-errors/type');
// https://262.ecma-international.org/13.0/#sec-isstringwellformedunicode
module.exports = function IsStringWellFormedUnicode(string) {
if (Type(string) !== 'String') {
if (typeof string !== 'string') {
throw new $TypeError('Assertion failed: `string` must be a String');
}
var strLen = string.length; // step 1

View file

@ -1,8 +1,6 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $TypeError = GetIntrinsic('%TypeError%');
var $TypeError = require('es-errors/type');
var IsDetachedBuffer = require('./IsDetachedBuffer');
var IsIntegralNumber = require('./IsIntegralNumber');

View file

@ -1,8 +1,6 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $TypeError = GetIntrinsic('%TypeError%');
var $TypeError = require('es-errors/type');
var callBound = require('call-bind/callBound');
@ -10,7 +8,6 @@ var $indexOf = callBound('String.prototype.indexOf');
var IsArray = require('./IsArray');
var IsIntegralNumber = require('./IsIntegralNumber');
var Type = require('./Type');
var WordCharacters = require('./WordCharacters');
var every = require('../helpers/every');
@ -32,7 +29,7 @@ module.exports = function IsWordChar(e, InputLength, Input, IgnoreCase, Unicode)
if (!IsArray(Input) || !every(Input, isChar)) {
throw new $TypeError('Assertion failed: `Input` must be a List of characters');
}
if (Type(IgnoreCase) !== 'Boolean' || Type(Unicode) !== 'Boolean') {
if (typeof IgnoreCase !== 'boolean' || typeof Unicode !== 'boolean') {
throw new $TypeError('Assertion failed: `IgnoreCase` and `Unicode` must be booleans');
}

View file

@ -1,8 +1,6 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $TypeError = GetIntrinsic('%TypeError%');
var $TypeError = require('es-errors/type');
var Call = require('./Call');
var CompletionRecord = require('./CompletionRecord');

View file

@ -1,8 +1,6 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $TypeError = GetIntrinsic('%TypeError%');
var $TypeError = require('es-errors/type');
var Get = require('./Get');
var ToBoolean = require('./ToBoolean');

View file

@ -1,8 +1,6 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $TypeError = GetIntrinsic('%TypeError%');
var $TypeError = require('es-errors/type');
var Invoke = require('./Invoke');
var Type = require('./Type');

View file

@ -1,8 +1,6 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $TypeError = GetIntrinsic('%TypeError%');
var $TypeError = require('es-errors/type');
var Get = require('./Get');
var Type = require('./Type');

View file

@ -1,8 +1,6 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $TypeError = GetIntrinsic('%TypeError%');
var $TypeError = require('es-errors/type');
var Get = require('./Get');
var ToLength = require('./ToLength');

View file

@ -1,8 +1,6 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $TypeError = GetIntrinsic('%TypeError%');
var $TypeError = require('es-errors/type');
var ArrayCreate = require('./ArrayCreate');
var CreateDataPropertyOrThrow = require('./CreateDataPropertyOrThrow');
@ -10,10 +8,9 @@ var GetMatchIndexPair = require('./GetMatchIndexPair');
var IsArray = require('./IsArray');
var OrdinaryObjectCreate = require('./OrdinaryObjectCreate');
var ToString = require('./ToString');
var Type = require('./Type');
var every = require('../helpers/every');
var isMatchRecord = require('../helpers/isMatchRecord');
var isMatchRecord = require('../helpers/records/match-record');
var isStringOrUndefined = function isStringOrUndefined(s) {
return typeof s === 'undefined' || typeof s === 'string';
@ -28,7 +25,7 @@ var MAX_ARRAY_LENGTH = Math.pow(2, 32) - 1;
// https://262.ecma-international.org/13.0/#sec-getmatchindexpair
module.exports = function MakeMatchIndicesIndexPairArray(S, indices, groupNames, hasGroups) {
if (Type(S) !== 'String') {
if (typeof S !== 'string') {
throw new $TypeError('Assertion failed: `S` must be a String');
}
if (!IsArray(indices) || !every(indices, isMatchRecordOrUndefined)) {
@ -37,7 +34,7 @@ module.exports = function MakeMatchIndicesIndexPairArray(S, indices, groupNames,
if (!IsArray(groupNames) || !every(groupNames, isStringOrUndefined)) {
throw new $TypeError('Assertion failed: `groupNames` must be a List of either Strings or `undefined`');
}
if (Type(hasGroups) !== 'Boolean') {
if (typeof hasGroups !== 'boolean') {
throw new $TypeError('Assertion failed: `hasGroups` must be a Boolean');
}

View file

@ -1,11 +1,9 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $TypeError = require('es-errors/type');
var $TypeError = GetIntrinsic('%TypeError%');
var IsCallable = require('es-abstract/2022/IsCallable');
var IsConstructor = require('es-abstract/2022/IsConstructor');
var IsCallable = require('./IsCallable');
var IsConstructor = require('./IsConstructor');
// https://262.ecma-international.org/6.0/#sec-newpromisecapability

Some files were not shown because too many files have changed in this diff Show more