From c9d9049fbdbc12e547ab84bfadaf27492481c987 Mon Sep 17 00:00:00 2001 From: Denis Pushkarev Date: Fri, 15 Sep 2023 04:18:58 +0700 Subject: [PATCH] some stylistic changes --- packages/core-js/internals/is-constructor.js | 2 +- packages/core-js/internals/regexp-unsupported-dot-all.js | 2 +- tests/helpers/constants.js | 2 +- tests/unit-global/es.typed.conversions.int16.js | 6 +++--- tests/unit-global/es.typed.conversions.int8.js | 6 +++--- tests/unit-global/es.typed.conversions.uint16.js | 6 +++--- tests/unit-global/es.typed.conversions.uint8.js | 6 +++--- tests/unit-global/web.structured-clone.js | 4 ++-- tests/unit-pure/web.structured-clone.js | 4 ++-- 9 files changed, 19 insertions(+), 19 deletions(-) diff --git a/packages/core-js/internals/is-constructor.js b/packages/core-js/internals/is-constructor.js index db5a020e5a7f..4db2d72a4b46 100644 --- a/packages/core-js/internals/is-constructor.js +++ b/packages/core-js/internals/is-constructor.js @@ -11,7 +11,7 @@ var empty = []; var construct = getBuiltIn('Reflect', 'construct'); var constructorRegExp = /^\s*(?:class|function)\b/; var exec = uncurryThis(constructorRegExp.exec); -var INCORRECT_TO_STRING = !constructorRegExp.exec(noop); +var INCORRECT_TO_STRING = !constructorRegExp.test(noop); var isConstructorModern = function isConstructor(argument) { if (!isCallable(argument)) return false; diff --git a/packages/core-js/internals/regexp-unsupported-dot-all.js b/packages/core-js/internals/regexp-unsupported-dot-all.js index 266ae1b15b56..cec5db5d856c 100644 --- a/packages/core-js/internals/regexp-unsupported-dot-all.js +++ b/packages/core-js/internals/regexp-unsupported-dot-all.js @@ -7,5 +7,5 @@ var $RegExp = global.RegExp; module.exports = fails(function () { var re = $RegExp('.', 's'); - return !(re.dotAll && re.exec('\n') && re.flags === 's'); + return !(re.dotAll && re.test('\n') && re.flags === 's'); }); diff --git a/tests/helpers/constants.js b/tests/helpers/constants.js index 5b0404707930..17167c5b41cb 100644 --- a/tests/helpers/constants.js +++ b/tests/helpers/constants.js @@ -37,7 +37,7 @@ for (const name in $TYPED_ARRAYS) TYPED_ARRAYS.push({ $: Number, }); -export const TYPED_ARRAYS_WITH_BIG_INT = TYPED_ARRAYS.slice(); +export const TYPED_ARRAYS_WITH_BIG_INT = [...TYPED_ARRAYS]; for (const name of ['BigInt64Array', 'BigUint64Array']) if (GLOBAL[name]) TYPED_ARRAYS_WITH_BIG_INT.push({ name, diff --git a/tests/unit-global/es.typed.conversions.int16.js b/tests/unit-global/es.typed.conversions.int16.js index d8ec00831df9..4bea7496b107 100644 --- a/tests/unit-global/es.typed.conversions.int16.js +++ b/tests/unit-global/es.typed.conversions.int16.js @@ -12,7 +12,7 @@ if (DESCRIPTORS) QUnit.test('Int16 conversions', assert => { return it === 0 && 1 / it === -Infinity ? '-0' : it; } - let data = [ + const data = [ [0, 0, [0, 0]], [-0, 0, [0, 0]], [1, 1, [1, 0]], @@ -56,7 +56,7 @@ if (DESCRIPTORS) QUnit.test('Int16 conversions', assert => { ]; // Android 4.3- bug if (NATIVE || !/Android [2-4]/.test(GLOBAL.navigator && navigator.userAgent)) { - data = data.concat([ + data.push( [2147483649, 1, [1, 0]], [-2147483649, -1, [255, 255]], [4294967295, -1, [255, 255]], @@ -65,7 +65,7 @@ if (DESCRIPTORS) QUnit.test('Int16 conversions', assert => { [-9007199254740991, 1, [1, 0]], [9007199254740994, 2, [2, 0]], [-9007199254740994, -2, [254, 255]], - ]); + ); } for (const [value, conversion, little] of data) { const big = little.slice().reverse(); diff --git a/tests/unit-global/es.typed.conversions.int8.js b/tests/unit-global/es.typed.conversions.int8.js index b485485fefe2..cff056eca071 100644 --- a/tests/unit-global/es.typed.conversions.int8.js +++ b/tests/unit-global/es.typed.conversions.int8.js @@ -12,7 +12,7 @@ if (DESCRIPTORS) QUnit.test('Int8 conversions', assert => { return it === 0 && 1 / it === -Infinity ? '-0' : it; } - let data = [ + const data = [ [0, 0, [0]], [-0, 0, [0]], [1, 1, [1]], @@ -56,7 +56,7 @@ if (DESCRIPTORS) QUnit.test('Int8 conversions', assert => { ]; // Android 4.3- bug if (NATIVE || !/Android [2-4]/.test(GLOBAL.navigator && navigator.userAgent)) { - data = data.concat([ + data.push( [2147483649, 1, [1]], [-2147483649, -1, [255]], [4294967295, -1, [255]], @@ -65,7 +65,7 @@ if (DESCRIPTORS) QUnit.test('Int8 conversions', assert => { [-9007199254740991, 1, [1]], [9007199254740994, 2, [2]], [-9007199254740994, -2, [254]], - ]); + ); } for (const [value, conversion, little] of data) { const big = little.slice().reverse(); diff --git a/tests/unit-global/es.typed.conversions.uint16.js b/tests/unit-global/es.typed.conversions.uint16.js index 9fe174e5a5a8..fb2a63106140 100644 --- a/tests/unit-global/es.typed.conversions.uint16.js +++ b/tests/unit-global/es.typed.conversions.uint16.js @@ -12,7 +12,7 @@ if (DESCRIPTORS) QUnit.test('Uint16 conversions', assert => { return it === 0 && 1 / it === -Infinity ? '-0' : it; } - let data = [ + const data = [ [0, 0, [0, 0]], [-0, 0, [0, 0]], [1, 1, [1, 0]], @@ -56,7 +56,7 @@ if (DESCRIPTORS) QUnit.test('Uint16 conversions', assert => { ]; // Android 4.3- bug if (NATIVE || !/Android [2-4]/.test(GLOBAL.navigator && navigator.userAgent)) { - data = data.concat([ + data.push( [2147483649, 1, [1, 0]], [-2147483649, 65535, [255, 255]], [4294967295, 65535, [255, 255]], @@ -65,7 +65,7 @@ if (DESCRIPTORS) QUnit.test('Uint16 conversions', assert => { [-9007199254740991, 1, [1, 0]], [9007199254740994, 2, [2, 0]], [-9007199254740994, 65534, [254, 255]], - ]); + ); } for (const [value, conversion, little] of data) { const big = little.slice().reverse(); diff --git a/tests/unit-global/es.typed.conversions.uint8.js b/tests/unit-global/es.typed.conversions.uint8.js index d015e7c42d4c..adb2fd10a9ec 100644 --- a/tests/unit-global/es.typed.conversions.uint8.js +++ b/tests/unit-global/es.typed.conversions.uint8.js @@ -11,7 +11,7 @@ if (DESCRIPTORS) QUnit.test('Uint8 conversions', assert => { return it === 0 && 1 / it === -Infinity ? '-0' : it; } - let data = [ + const data = [ [0, 0, [0]], [-0, 0, [0]], [1, 1, [1]], @@ -54,7 +54,7 @@ if (DESCRIPTORS) QUnit.test('Uint8 conversions', assert => { ]; // Android 4.3- bug if (NATIVE || !/Android [2-4]/.test(GLOBAL.navigator && navigator.userAgent)) { - data = data.concat([ + data.push( [2147483649, 1, [1]], [-2147483649, 255, [255]], [4294967295, 255, [255]], @@ -63,7 +63,7 @@ if (DESCRIPTORS) QUnit.test('Uint8 conversions', assert => { [-9007199254740991, 1, [1]], [9007199254740994, 2, [2]], [-9007199254740994, 254, [254]], - ]); + ); } for (const [value, conversion, little] of data) { uint8array[0] = value; diff --git a/tests/unit-global/web.structured-clone.js b/tests/unit-global/web.structured-clone.js index d31066d025d0..11d7a392fc3f 100644 --- a/tests/unit-global/web.structured-clone.js +++ b/tests/unit-global/web.structured-clone.js @@ -71,7 +71,7 @@ QUnit.module('structuredClone', () => { ]; QUnit.test('primitives', assert => { - const primitives = [undefined, null].concat(booleans, numbers, bigints, strings); + const primitives = [undefined, null, ...booleans, ...numbers, ...bigints, ...strings]; for (const value of primitives) cloneTest(value, (orig, clone) => { assert.same(orig, clone, 'primitives should be same after cloned'); @@ -80,7 +80,7 @@ QUnit.module('structuredClone', () => { // "Primitive" Objects (Boolean, Number, BigInt, String) QUnit.test('primitive objects', assert => { - const primitives = [].concat(booleans, numbers, bigints, strings); + const primitives = [...booleans, ...numbers, ...bigints, ...strings]; for (const value of primitives) cloneObjectTest(assert, Object(value), (orig, clone) => { assert.same(orig.valueOf(), clone.valueOf(), 'primitive wrappers should have same value'); diff --git a/tests/unit-pure/web.structured-clone.js b/tests/unit-pure/web.structured-clone.js index 44477a263fdc..a125b7adcf13 100644 --- a/tests/unit-pure/web.structured-clone.js +++ b/tests/unit-pure/web.structured-clone.js @@ -79,7 +79,7 @@ QUnit.module('structuredClone', () => { ]; QUnit.test('primitives', assert => { - const primitives = [undefined, null].concat(booleans, numbers, bigints, strings); + const primitives = [undefined, null, ...booleans, ...numbers, ...bigints, ...strings]; for (const value of primitives) cloneTest(value, (orig, clone) => { assert.same(orig, clone, 'primitives should be same after cloned'); @@ -88,7 +88,7 @@ QUnit.module('structuredClone', () => { // "Primitive" Objects (Boolean, Number, BigInt, String) QUnit.test('primitive objects', assert => { - const primitives = [].concat(booleans, numbers, bigints, strings); + const primitives = [...booleans, ...numbers, ...bigints, ...strings]; for (const value of primitives) cloneObjectTest(assert, Object(value), (orig, clone) => { assert.same(orig.valueOf(), clone.valueOf(), 'primitive wrappers should have same value');