diff --git a/2015/InstanceofOperator.js b/2015/InstanceofOperator.js index adb8127f..d940cd6e 100644 --- a/2015/InstanceofOperator.js +++ b/2015/InstanceofOperator.js @@ -4,7 +4,7 @@ var GetIntrinsic = require('get-intrinsic'); var $TypeError = require('es-errors/type'); -var $hasInstance = GetIntrinsic('Symbol.hasInstance', true); +var $hasInstance = GetIntrinsic('%Symbol.hasInstance%', true); var Call = require('./Call'); var GetMethod = require('./GetMethod'); diff --git a/2016/InstanceofOperator.js b/2016/InstanceofOperator.js index adb8127f..d940cd6e 100644 --- a/2016/InstanceofOperator.js +++ b/2016/InstanceofOperator.js @@ -4,7 +4,7 @@ var GetIntrinsic = require('get-intrinsic'); var $TypeError = require('es-errors/type'); -var $hasInstance = GetIntrinsic('Symbol.hasInstance', true); +var $hasInstance = GetIntrinsic('%Symbol.hasInstance%', true); var Call = require('./Call'); var GetMethod = require('./GetMethod'); diff --git a/2017/InstanceofOperator.js b/2017/InstanceofOperator.js index adb8127f..d940cd6e 100644 --- a/2017/InstanceofOperator.js +++ b/2017/InstanceofOperator.js @@ -4,7 +4,7 @@ var GetIntrinsic = require('get-intrinsic'); var $TypeError = require('es-errors/type'); -var $hasInstance = GetIntrinsic('Symbol.hasInstance', true); +var $hasInstance = GetIntrinsic('%Symbol.hasInstance%', true); var Call = require('./Call'); var GetMethod = require('./GetMethod'); diff --git a/2018/InstanceofOperator.js b/2018/InstanceofOperator.js index adb8127f..d940cd6e 100644 --- a/2018/InstanceofOperator.js +++ b/2018/InstanceofOperator.js @@ -4,7 +4,7 @@ var GetIntrinsic = require('get-intrinsic'); var $TypeError = require('es-errors/type'); -var $hasInstance = GetIntrinsic('Symbol.hasInstance', true); +var $hasInstance = GetIntrinsic('%Symbol.hasInstance%', true); var Call = require('./Call'); var GetMethod = require('./GetMethod'); diff --git a/2019/InstanceofOperator.js b/2019/InstanceofOperator.js index adb8127f..d940cd6e 100644 --- a/2019/InstanceofOperator.js +++ b/2019/InstanceofOperator.js @@ -4,7 +4,7 @@ var GetIntrinsic = require('get-intrinsic'); var $TypeError = require('es-errors/type'); -var $hasInstance = GetIntrinsic('Symbol.hasInstance', true); +var $hasInstance = GetIntrinsic('%Symbol.hasInstance%', true); var Call = require('./Call'); var GetMethod = require('./GetMethod'); diff --git a/2020/InstanceofOperator.js b/2020/InstanceofOperator.js index adb8127f..d940cd6e 100644 --- a/2020/InstanceofOperator.js +++ b/2020/InstanceofOperator.js @@ -4,7 +4,7 @@ var GetIntrinsic = require('get-intrinsic'); var $TypeError = require('es-errors/type'); -var $hasInstance = GetIntrinsic('Symbol.hasInstance', true); +var $hasInstance = GetIntrinsic('%Symbol.hasInstance%', true); var Call = require('./Call'); var GetMethod = require('./GetMethod'); diff --git a/2021/InstanceofOperator.js b/2021/InstanceofOperator.js index adb8127f..d940cd6e 100644 --- a/2021/InstanceofOperator.js +++ b/2021/InstanceofOperator.js @@ -4,7 +4,7 @@ var GetIntrinsic = require('get-intrinsic'); var $TypeError = require('es-errors/type'); -var $hasInstance = GetIntrinsic('Symbol.hasInstance', true); +var $hasInstance = GetIntrinsic('%Symbol.hasInstance%', true); var Call = require('./Call'); var GetMethod = require('./GetMethod'); diff --git a/2022/InstanceofOperator.js b/2022/InstanceofOperator.js index adb8127f..d940cd6e 100644 --- a/2022/InstanceofOperator.js +++ b/2022/InstanceofOperator.js @@ -4,7 +4,7 @@ var GetIntrinsic = require('get-intrinsic'); var $TypeError = require('es-errors/type'); -var $hasInstance = GetIntrinsic('Symbol.hasInstance', true); +var $hasInstance = GetIntrinsic('%Symbol.hasInstance%', true); var Call = require('./Call'); var GetMethod = require('./GetMethod'); diff --git a/2022/TypedArrayElementSize.js b/2022/TypedArrayElementSize.js index ea4f95f2..2cc3ce39 100644 --- a/2022/TypedArrayElementSize.js +++ b/2022/TypedArrayElementSize.js @@ -13,7 +13,7 @@ var tableTAO = require('./tables/typed-array-objects'); module.exports = function TypedArrayElementSize(O) { var type = whichTypedArray(O); - if (type === false) { + if (!type) { throw new $TypeError('Assertion failed: `O` must be a TypedArray'); } var size = tableTAO.size['$' + tableTAO.name['$' + type]]; diff --git a/2022/TypedArrayElementType.js b/2022/TypedArrayElementType.js index 103976ac..0e9abe6a 100644 --- a/2022/TypedArrayElementType.js +++ b/2022/TypedArrayElementType.js @@ -11,7 +11,7 @@ var tableTAO = require('./tables/typed-array-objects'); module.exports = function TypedArrayElementType(O) { var type = whichTypedArray(O); - if (type === false) { + if (!type) { throw new $TypeError('Assertion failed: `O` must be a TypedArray'); } var result = tableTAO.name['$' + type]; diff --git a/2023/FindViaPredicate.js b/2023/FindViaPredicate.js index d72ec454..a1c46947 100644 --- a/2023/FindViaPredicate.js +++ b/2023/FindViaPredicate.js @@ -11,6 +11,8 @@ var ToString = require('./ToString'); var isInteger = require('../helpers/isInteger'); var isObject = require('../helpers/isObject'); +// https://262.ecma-international.org/14.0/#sec-findviapredicate + module.exports = function FindViaPredicate(O, len, direction, predicate, thisArg) { if (!isObject(O)) { throw new $TypeError('Assertion failed: Type(O) is not Object'); diff --git a/2023/InstanceofOperator.js b/2023/InstanceofOperator.js index adb8127f..d940cd6e 100644 --- a/2023/InstanceofOperator.js +++ b/2023/InstanceofOperator.js @@ -4,7 +4,7 @@ var GetIntrinsic = require('get-intrinsic'); var $TypeError = require('es-errors/type'); -var $hasInstance = GetIntrinsic('Symbol.hasInstance', true); +var $hasInstance = GetIntrinsic('%Symbol.hasInstance%', true); var Call = require('./Call'); var GetMethod = require('./GetMethod'); diff --git a/2023/TypedArrayElementSize.js b/2023/TypedArrayElementSize.js index ea4f95f2..2cc3ce39 100644 --- a/2023/TypedArrayElementSize.js +++ b/2023/TypedArrayElementSize.js @@ -13,7 +13,7 @@ var tableTAO = require('./tables/typed-array-objects'); module.exports = function TypedArrayElementSize(O) { var type = whichTypedArray(O); - if (type === false) { + if (!type) { throw new $TypeError('Assertion failed: `O` must be a TypedArray'); } var size = tableTAO.size['$' + tableTAO.name['$' + type]]; diff --git a/2023/TypedArrayElementType.js b/2023/TypedArrayElementType.js index 103976ac..0e9abe6a 100644 --- a/2023/TypedArrayElementType.js +++ b/2023/TypedArrayElementType.js @@ -11,7 +11,7 @@ var tableTAO = require('./tables/typed-array-objects'); module.exports = function TypedArrayElementType(O) { var type = whichTypedArray(O); - if (type === false) { + if (!type) { throw new $TypeError('Assertion failed: `O` must be a TypedArray'); } var result = tableTAO.name['$' + type]; diff --git a/2024/FindViaPredicate.js b/2024/FindViaPredicate.js index 24e3ecdd..21247221 100644 --- a/2024/FindViaPredicate.js +++ b/2024/FindViaPredicate.js @@ -11,6 +11,8 @@ var ToString = require('./ToString'); var isInteger = require('../helpers/isInteger'); var isObject = require('../helpers/isObject'); +// https://262.ecma-international.org/15.0/#sec-findviapredicate + module.exports = function FindViaPredicate(O, len, direction, predicate, thisArg) { if (!isObject(O)) { throw new $TypeError('Assertion failed: Type(O) is not Object'); diff --git a/2024/GroupBy.js b/2024/GroupBy.js index 95b03648..e91787c4 100644 --- a/2024/GroupBy.js +++ b/2024/GroupBy.js @@ -39,7 +39,8 @@ module.exports = function GroupBy(items, callbackfn, keyCoercion) { while (true) { // step 6 if (k >= maxSafeInteger) { // step 6.a var error = ThrowCompletion(new $TypeError('k must be less than 2 ** 53 - 1')); // step 6.a.i - return IteratorClose(iteratorRecord, error); // step 6.a.ii + IteratorClose(iteratorRecord, error); // step 6.a.ii + return void undefined; } var next = IteratorStep(iteratorRecord); // step 6.b if (!next) { // step 6.c @@ -52,14 +53,16 @@ module.exports = function GroupBy(items, callbackfn, keyCoercion) { try { key = Call(callbackfn, undefined, [value, k]); // step 6.e } catch (e) { - return IteratorClose(iteratorRecord, ThrowCompletion(e)); // step 6.f + IteratorClose(iteratorRecord, ThrowCompletion(e)); // step 6.f + return void undefined; } if (keyCoercion === 'PROPERTY') { // step 6.g try { key = ToPropertyKey(key); // step 6.g.i } catch (e) { - return IteratorClose(iteratorRecord, ThrowCompletion(e)); // step 6.g.ii + IteratorClose(iteratorRecord, ThrowCompletion(e)); // step 6.g.ii + return void undefined; } } else { // step 6.h if (keyCoercion !== 'ZERO') { diff --git a/2024/InstanceofOperator.js b/2024/InstanceofOperator.js index adb8127f..d940cd6e 100644 --- a/2024/InstanceofOperator.js +++ b/2024/InstanceofOperator.js @@ -4,7 +4,7 @@ var GetIntrinsic = require('get-intrinsic'); var $TypeError = require('es-errors/type'); -var $hasInstance = GetIntrinsic('Symbol.hasInstance', true); +var $hasInstance = GetIntrinsic('%Symbol.hasInstance%', true); var Call = require('./Call'); var GetMethod = require('./GetMethod'); diff --git a/2024/SetValueInBuffer.js b/2024/SetValueInBuffer.js index a706720b..44d11b29 100644 --- a/2024/SetValueInBuffer.js +++ b/2024/SetValueInBuffer.js @@ -14,7 +14,7 @@ var NumericToRawBytes = require('./NumericToRawBytes'); var isArrayBuffer = require('is-array-buffer'); var isSharedArrayBuffer = require('is-shared-array-buffer'); -var has = require('hasown'); +var hasOwn = require('hasown'); var tableTAO = require('./tables/typed-array-objects'); @@ -35,7 +35,7 @@ module.exports = function SetValueInBuffer(arrayBuffer, byteIndex, type, value, throw new $TypeError('Assertion failed: `byteIndex` must be a non-negative integer'); } - if (typeof type !== 'string' || !has(tableTAO.size, '$' + type)) { + if (typeof type !== 'string' || !hasOwn(tableTAO.size, '$' + type)) { throw new $TypeError('Assertion failed: `type` must be a Typed Array Element Type'); } diff --git a/2024/ThisBigIntValue.js b/2024/ThisBigIntValue.js index 252f9553..7b479349 100644 --- a/2024/ThisBigIntValue.js +++ b/2024/ThisBigIntValue.js @@ -9,10 +9,12 @@ var $bigIntValueOf = callBound('BigInt.prototype.valueOf', true); module.exports = function ThisBigIntValue(value) { if (typeof value === 'bigint') { - return value; // step 1 + return value; } + if (!$bigIntValueOf) { throw new $SyntaxError('BigInt is not supported'); } + return $bigIntValueOf(value); }; diff --git a/2024/TypedArrayElementSize.js b/2024/TypedArrayElementSize.js index ea4f95f2..2cc3ce39 100644 --- a/2024/TypedArrayElementSize.js +++ b/2024/TypedArrayElementSize.js @@ -13,7 +13,7 @@ var tableTAO = require('./tables/typed-array-objects'); module.exports = function TypedArrayElementSize(O) { var type = whichTypedArray(O); - if (type === false) { + if (!type) { throw new $TypeError('Assertion failed: `O` must be a TypedArray'); } var size = tableTAO.size['$' + tableTAO.name['$' + type]]; diff --git a/2024/TypedArrayElementType.js b/2024/TypedArrayElementType.js index 103976ac..0e9abe6a 100644 --- a/2024/TypedArrayElementType.js +++ b/2024/TypedArrayElementType.js @@ -11,7 +11,7 @@ var tableTAO = require('./tables/typed-array-objects'); module.exports = function TypedArrayElementType(O) { var type = whichTypedArray(O); - if (type === false) { + if (!type) { throw new $TypeError('Assertion failed: `O` must be a TypedArray'); } var result = tableTAO.name['$' + type]; diff --git a/helpers/isFullyPopulatedPropertyDescriptor.js b/helpers/isFullyPopulatedPropertyDescriptor.js index e75f33f7..227860ef 100644 --- a/helpers/isFullyPopulatedPropertyDescriptor.js +++ b/helpers/isFullyPopulatedPropertyDescriptor.js @@ -4,7 +4,6 @@ var isPropertyDescriptor = require('./records/property-descriptor'); module.exports = function isFullyPopulatedPropertyDescriptor(ES, Desc) { return isPropertyDescriptor(Desc) - && typeof Desc === 'object' && '[[Enumerable]]' in Desc && '[[Configurable]]' in Desc && (ES.IsAccessorDescriptor(Desc) || ES.IsDataDescriptor(Desc)); diff --git a/helpers/isObject.js b/helpers/isObject.js index 620243f2..10469eef 100644 --- a/helpers/isObject.js +++ b/helpers/isObject.js @@ -1,5 +1,5 @@ 'use strict'; module.exports = function isObject(x) { - return x && (typeof x === 'function' || typeof x === 'object'); + return !!x && (typeof x === 'function' || typeof x === 'object'); };