es-abstract
Advanced tools
Comparing version 1.21.3 to 1.22.0
@@ -5,8 +5,8 @@ 'use strict'; | ||
var IsInteger = require('./IsInteger'); | ||
var Type = require('./Type'); | ||
var MAX_SAFE_INTEGER = require('../helpers/maxSafeInteger'); | ||
var isInteger = require('../helpers/isInteger'); | ||
var isLeadingSurrogate = require('../helpers/isLeadingSurrogate'); | ||
var isTrailingSurrogate = require('../helpers/isTrailingSurrogate'); | ||
var MAX_SAFE_INTEGER = require('../helpers/maxSafeInteger'); | ||
@@ -23,3 +23,3 @@ var $TypeError = GetIntrinsic('%TypeError%'); | ||
} | ||
if (!IsInteger(index) || index < 0 || index > MAX_SAFE_INTEGER) { | ||
if (!isInteger(index) || index < 0 || index > MAX_SAFE_INTEGER) { | ||
throw new $TypeError('Assertion failed: `length` must be an integer >= 0 and <= 2**53'); | ||
@@ -26,0 +26,0 @@ } |
@@ -10,3 +10,3 @@ 'use strict'; | ||
var IsInteger = require('./IsInteger'); | ||
var isInteger = require('../helpers/isInteger'); | ||
@@ -29,3 +29,3 @@ var hasProto = require('has-proto')(); | ||
module.exports = function ArrayCreate(length) { | ||
if (!IsInteger(length) || length < 0) { | ||
if (!isInteger(length) || length < 0) { | ||
throw new $TypeError('Assertion failed: `length` must be an integer Number >= 0'); | ||
@@ -32,0 +32,0 @@ } |
@@ -12,9 +12,10 @@ 'use strict'; | ||
var IsConstructor = require('./IsConstructor'); | ||
var IsInteger = require('./IsInteger'); | ||
var Type = require('./Type'); | ||
var isInteger = require('../helpers/isInteger'); | ||
// https://262.ecma-international.org/6.0/#sec-arrayspeciescreate | ||
module.exports = function ArraySpeciesCreate(originalArray, length) { | ||
if (!IsInteger(length) || length < 0) { | ||
if (!isInteger(length) || length < 0) { | ||
throw new $TypeError('Assertion failed: length must be an integer >= 0'); | ||
@@ -21,0 +22,0 @@ } |
@@ -21,14 +21,10 @@ | ||
var IsArray = require('./IsArray'); | ||
var IsInteger = require('./IsInteger'); | ||
var Type = require('./Type'); | ||
var canDistinguishSparseFromUndefined = 0 in [undefined]; // IE 6 - 8 have a bug where this returns false | ||
var isInteger = require('../helpers/isInteger'); | ||
var isStringOrHole = require('../helpers/isStringOrHole'); | ||
var isStringOrHole = function (capture, index, arr) { | ||
return Type(capture) === 'String' || (canDistinguishSparseFromUndefined ? !(index in arr) : Type(capture) === 'Undefined'); | ||
}; | ||
// https://262.ecma-international.org/6.0/#sec-getsubstitution | ||
// eslint-disable-next-line max-statements, max-params, max-lines-per-function | ||
// eslint-disable-next-line max-statements, max-lines-per-function | ||
module.exports = function GetSubstitution(matched, str, position, captures, replacement) { | ||
@@ -45,3 +41,3 @@ if (Type(matched) !== 'String') { | ||
if (!IsInteger(position) || position < 0 || position > stringLength) { | ||
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)); | ||
@@ -48,0 +44,0 @@ } |
'use strict'; | ||
var abs = require('./abs'); | ||
var floor = require('./floor'); | ||
var isInteger = require('../helpers/isInteger'); | ||
var $isNaN = require('../helpers/isNaN'); | ||
var $isFinite = require('../helpers/isFinite'); | ||
// https://262.ecma-international.org/6.0/#sec-isinteger | ||
module.exports = function IsInteger(argument) { | ||
if (typeof argument !== 'number' || $isNaN(argument) || !$isFinite(argument)) { | ||
return false; | ||
} | ||
var absValue = abs(argument); | ||
return floor(absValue) === absValue; | ||
return isInteger(argument); | ||
}; |
@@ -8,5 +8,6 @@ 'use strict'; | ||
var IsInteger = require('./IsInteger'); | ||
var Type = require('./Type'); | ||
var isInteger = require('../helpers/isInteger'); | ||
var $charAt = callBound('String.prototype.charAt'); | ||
@@ -20,3 +21,3 @@ | ||
} | ||
if (!IsInteger(q)) { | ||
if (!isInteger(q)) { | ||
throw new $TypeError('Assertion failed: `q` must be an integer'); | ||
@@ -23,0 +24,0 @@ } |
@@ -22,3 +22,3 @@ 'use strict'; | ||
// eslint-disable-next-line max-lines-per-function, max-statements, max-params | ||
// eslint-disable-next-line max-lines-per-function, max-statements | ||
module.exports = function ValidateAndApplyPropertyDescriptor(O, P, extensible, Desc, current) { | ||
@@ -25,0 +25,0 @@ // this uses the ES2017+ logic, since it fixes a number of bugs in the ES2015 logic. |
@@ -5,8 +5,8 @@ 'use strict'; | ||
var IsInteger = require('./IsInteger'); | ||
var Type = require('./Type'); | ||
var MAX_SAFE_INTEGER = require('../helpers/maxSafeInteger'); | ||
var isInteger = require('../helpers/isInteger'); | ||
var isLeadingSurrogate = require('../helpers/isLeadingSurrogate'); | ||
var isTrailingSurrogate = require('../helpers/isTrailingSurrogate'); | ||
var MAX_SAFE_INTEGER = require('../helpers/maxSafeInteger'); | ||
@@ -23,3 +23,3 @@ var $TypeError = GetIntrinsic('%TypeError%'); | ||
} | ||
if (!IsInteger(index) || index < 0 || index > MAX_SAFE_INTEGER) { | ||
if (!isInteger(index) || index < 0 || index > MAX_SAFE_INTEGER) { | ||
throw new $TypeError('Assertion failed: `length` must be an integer >= 0 and <= 2**53'); | ||
@@ -26,0 +26,0 @@ } |
@@ -10,3 +10,3 @@ 'use strict'; | ||
var IsInteger = require('./IsInteger'); | ||
var isInteger = require('../helpers/isInteger'); | ||
@@ -29,3 +29,3 @@ var hasProto = require('has-proto')(); | ||
module.exports = function ArrayCreate(length) { | ||
if (!IsInteger(length) || length < 0) { | ||
if (!isInteger(length) || length < 0) { | ||
throw new $TypeError('Assertion failed: `length` must be an integer Number >= 0'); | ||
@@ -32,0 +32,0 @@ } |
@@ -12,9 +12,10 @@ 'use strict'; | ||
var IsConstructor = require('./IsConstructor'); | ||
var IsInteger = require('./IsInteger'); | ||
var Type = require('./Type'); | ||
var isInteger = require('../helpers/isInteger'); | ||
// https://262.ecma-international.org/6.0/#sec-arrayspeciescreate | ||
module.exports = function ArraySpeciesCreate(originalArray, length) { | ||
if (!IsInteger(length) || length < 0) { | ||
if (!isInteger(length) || length < 0) { | ||
throw new $TypeError('Assertion failed: length must be an integer >= 0'); | ||
@@ -21,0 +22,0 @@ } |
@@ -21,14 +21,10 @@ | ||
var IsArray = require('./IsArray'); | ||
var IsInteger = require('./IsInteger'); | ||
var Type = require('./Type'); | ||
var canDistinguishSparseFromUndefined = 0 in [undefined]; // IE 6 - 8 have a bug where this returns false | ||
var isInteger = require('../helpers/isInteger'); | ||
var isStringOrHole = require('../helpers/isStringOrHole'); | ||
var isStringOrHole = function (capture, index, arr) { | ||
return Type(capture) === 'String' || (canDistinguishSparseFromUndefined ? !(index in arr) : Type(capture) === 'Undefined'); | ||
}; | ||
// https://262.ecma-international.org/6.0/#sec-getsubstitution | ||
// eslint-disable-next-line max-statements, max-params, max-lines-per-function | ||
// eslint-disable-next-line max-statements, max-lines-per-function | ||
module.exports = function GetSubstitution(matched, str, position, captures, replacement) { | ||
@@ -45,3 +41,3 @@ if (Type(matched) !== 'String') { | ||
if (!IsInteger(position) || position < 0 || position > stringLength) { | ||
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)); | ||
@@ -48,0 +44,0 @@ } |
'use strict'; | ||
var abs = require('./abs'); | ||
var floor = require('./floor'); | ||
var isInteger = require('../helpers/isInteger'); | ||
var $isNaN = require('../helpers/isNaN'); | ||
var $isFinite = require('../helpers/isFinite'); | ||
// https://262.ecma-international.org/6.0/#sec-isinteger | ||
module.exports = function IsInteger(argument) { | ||
if (typeof argument !== 'number' || $isNaN(argument) || !$isFinite(argument)) { | ||
return false; | ||
} | ||
var absValue = abs(argument); | ||
return floor(absValue) === absValue; | ||
return isInteger(argument); | ||
}; |
@@ -8,5 +8,6 @@ 'use strict'; | ||
var IsInteger = require('./IsInteger'); | ||
var Type = require('./Type'); | ||
var isInteger = require('../helpers/isInteger'); | ||
var $charAt = callBound('String.prototype.charAt'); | ||
@@ -20,3 +21,3 @@ | ||
} | ||
if (!IsInteger(q)) { | ||
if (!isInteger(q)) { | ||
throw new $TypeError('Assertion failed: `q` must be an integer'); | ||
@@ -23,0 +24,0 @@ } |
@@ -22,3 +22,3 @@ 'use strict'; | ||
// eslint-disable-next-line max-lines-per-function, max-statements, max-params | ||
// eslint-disable-next-line max-lines-per-function, max-statements | ||
module.exports = function ValidateAndApplyPropertyDescriptor(O, P, extensible, Desc, current) { | ||
@@ -25,0 +25,0 @@ // this uses the ES2017+ logic, since it fixes a number of bugs in the ES2015 logic. |
@@ -5,8 +5,8 @@ 'use strict'; | ||
var IsInteger = require('./IsInteger'); | ||
var Type = require('./Type'); | ||
var MAX_SAFE_INTEGER = require('../helpers/maxSafeInteger'); | ||
var isInteger = require('../helpers/isInteger'); | ||
var isLeadingSurrogate = require('../helpers/isLeadingSurrogate'); | ||
var isTrailingSurrogate = require('../helpers/isTrailingSurrogate'); | ||
var MAX_SAFE_INTEGER = require('../helpers/maxSafeInteger'); | ||
@@ -23,3 +23,3 @@ var $TypeError = GetIntrinsic('%TypeError%'); | ||
} | ||
if (!IsInteger(index) || index < 0 || index > MAX_SAFE_INTEGER) { | ||
if (!isInteger(index) || index < 0 || index > MAX_SAFE_INTEGER) { | ||
throw new $TypeError('Assertion failed: `length` must be an integer >= 0 and <= 2**53'); | ||
@@ -26,0 +26,0 @@ } |
@@ -10,3 +10,3 @@ 'use strict'; | ||
var IsInteger = require('./IsInteger'); | ||
var isInteger = require('../helpers/isInteger'); | ||
@@ -29,3 +29,3 @@ var hasProto = require('has-proto')(); | ||
module.exports = function ArrayCreate(length) { | ||
if (!IsInteger(length) || length < 0) { | ||
if (!isInteger(length) || length < 0) { | ||
throw new $TypeError('Assertion failed: `length` must be an integer Number >= 0'); | ||
@@ -32,0 +32,0 @@ } |
@@ -12,9 +12,10 @@ 'use strict'; | ||
var IsConstructor = require('./IsConstructor'); | ||
var IsInteger = require('./IsInteger'); | ||
var Type = require('./Type'); | ||
var isInteger = require('../helpers/isInteger'); | ||
// https://262.ecma-international.org/6.0/#sec-arrayspeciescreate | ||
module.exports = function ArraySpeciesCreate(originalArray, length) { | ||
if (!IsInteger(length) || length < 0) { | ||
if (!isInteger(length) || length < 0) { | ||
throw new $TypeError('Assertion failed: length must be an integer >= 0'); | ||
@@ -21,0 +22,0 @@ } |
@@ -21,14 +21,10 @@ | ||
var IsArray = require('./IsArray'); | ||
var IsInteger = require('./IsInteger'); | ||
var Type = require('./Type'); | ||
var canDistinguishSparseFromUndefined = 0 in [undefined]; // IE 6 - 8 have a bug where this returns false | ||
var isInteger = require('../helpers/isInteger'); | ||
var isStringOrHole = require('../helpers/isStringOrHole'); | ||
var isStringOrHole = function (capture, index, arr) { | ||
return Type(capture) === 'String' || (canDistinguishSparseFromUndefined ? !(index in arr) : Type(capture) === 'Undefined'); | ||
}; | ||
// https://262.ecma-international.org/6.0/#sec-getsubstitution | ||
// eslint-disable-next-line max-statements, max-params, max-lines-per-function | ||
// eslint-disable-next-line max-statements, max-lines-per-function | ||
module.exports = function GetSubstitution(matched, str, position, captures, replacement) { | ||
@@ -45,3 +41,3 @@ if (Type(matched) !== 'String') { | ||
if (!IsInteger(position) || position < 0 || position > stringLength) { | ||
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)); | ||
@@ -48,0 +44,0 @@ } |
'use strict'; | ||
var abs = require('./abs'); | ||
var floor = require('./floor'); | ||
var isInteger = require('../helpers/isInteger'); | ||
var $isNaN = require('../helpers/isNaN'); | ||
var $isFinite = require('../helpers/isFinite'); | ||
// https://262.ecma-international.org/6.0/#sec-isinteger | ||
module.exports = function IsInteger(argument) { | ||
if (typeof argument !== 'number' || $isNaN(argument) || !$isFinite(argument)) { | ||
return false; | ||
} | ||
var absValue = abs(argument); | ||
return floor(absValue) === absValue; | ||
return isInteger(argument); | ||
}; |
@@ -5,21 +5,5 @@ 'use strict'; | ||
var $floor = GetIntrinsic('%Math.floor%'); | ||
var $log = GetIntrinsic('%Math.log%'); | ||
var $log2E = GetIntrinsic('%Math.LOG2E%'); | ||
var $log2 = GetIntrinsic('%Math.log2%', true) || function log2(x) { | ||
return $log(x) * $log2E; | ||
}; | ||
var $parseInt = GetIntrinsic('%parseInt%'); | ||
var $pow = GetIntrinsic('%Math.pow%'); | ||
var $TypeError = GetIntrinsic('%TypeError%'); | ||
var callBound = require('call-bind/callBound'); | ||
var $reverse = callBound('Array.prototype.reverse'); | ||
var $numberToString = callBound('Number.prototype.toString'); | ||
var $strSlice = callBound('String.prototype.slice'); | ||
var abs = require('./abs'); | ||
var hasOwnProperty = require('./HasOwnProperty'); | ||
var SameValue = require('./SameValue'); | ||
var ToInt16 = require('./ToInt16'); | ||
@@ -34,4 +18,5 @@ var ToInt32 = require('./ToInt32'); | ||
var isNaN = require('../helpers/isNaN'); | ||
var isFinite = require('../helpers/isFinite'); | ||
var valueToFloat32Bytes = require('../helpers/valueToFloat32Bytes'); | ||
var valueToFloat64Bytes = require('../helpers/valueToFloat64Bytes'); | ||
var integerToNBytes = require('../helpers/integerToNBytes'); | ||
@@ -78,101 +63,6 @@ var keys = require('object-keys'); | ||
var rawBytes = []; | ||
var exponent; | ||
if (type === 'Float32') { // step 1 | ||
if (isNaN(value)) { | ||
return isLittleEndian ? [0, 0, 192, 127] : [127, 192, 0, 0]; // hardcoded | ||
} | ||
var leastSig; | ||
if (value === 0) { | ||
leastSig = SameValue(value, -0) ? 0x80 : 0; | ||
return isLittleEndian ? [0, 0, 0, leastSig] : [leastSig, 0, 0, 0]; | ||
} | ||
if (!isFinite(value)) { | ||
leastSig = value < 0 ? 255 : 127; | ||
return isLittleEndian ? [0, 0, 128, leastSig] : [leastSig, 128, 0, 0]; | ||
} | ||
var sign = value < 0 ? 1 : 0; | ||
value = abs(value); // eslint-disable-line no-param-reassign | ||
exponent = 0; | ||
while (value >= 2) { | ||
exponent += 1; | ||
value /= 2; // eslint-disable-line no-param-reassign | ||
} | ||
while (value < 1) { | ||
exponent -= 1; | ||
value *= 2; // eslint-disable-line no-param-reassign | ||
} | ||
var mantissa = value - 1; | ||
mantissa *= $pow(2, 23); | ||
mantissa = $floor(mantissa); | ||
exponent += 127; | ||
exponent = exponent << 23; | ||
var result = sign << 31; | ||
result |= exponent; | ||
result |= mantissa; | ||
var byte0 = result & 255; | ||
result = result >> 8; | ||
var byte1 = result & 255; | ||
result = result >> 8; | ||
var byte2 = result & 255; | ||
result = result >> 8; | ||
var byte3 = result & 255; | ||
if (isLittleEndian) { | ||
return [byte0, byte1, byte2, byte3]; | ||
} | ||
return [byte3, byte2, byte1, byte0]; | ||
return valueToFloat32Bytes(value, isLittleEndian); | ||
} else if (type === 'Float64') { // step 2 | ||
if (value === 0) { | ||
leastSig = Object.is(value, -0) ? 0x80 : 0; | ||
return isLittleEndian ? [0, 0, 0, 0, 0, 0, 0, leastSig] : [leastSig, 0, 0, 0, 0, 0, 0, 0]; | ||
} | ||
if (isNaN(value)) { | ||
return isLittleEndian ? [0, 0, 0, 0, 0, 0, 248, 127] : [127, 248, 0, 0, 0, 0, 0, 0]; | ||
} | ||
if (!isFinite(value)) { | ||
var infBytes = value < 0 ? [0, 0, 0, 0, 0, 0, 240, 255] : [0, 0, 0, 0, 0, 0, 240, 127]; | ||
return isLittleEndian ? infBytes : $reverse(infBytes); | ||
} | ||
var isNegative = value < 0; | ||
if (isNegative) { value = -value; } // eslint-disable-line no-param-reassign | ||
exponent = $floor($log2(value)); | ||
var significand = (value / $pow(2, exponent)) - 1; | ||
var bitString = ''; | ||
for (var i = 0; i < 52; i++) { | ||
significand *= 2; | ||
if (significand >= 1) { | ||
bitString += '1'; | ||
significand -= 1; | ||
} else { | ||
bitString += '0'; | ||
} | ||
} | ||
exponent += 1023; | ||
var exponentBits = $numberToString(exponent, 2); | ||
while (exponentBits.length < 11) { exponentBits = '0' + exponentBits; } | ||
var fullBitString = (isNegative ? '1' : '0') + exponentBits + bitString; | ||
while (fullBitString.length < 64) { fullBitString = '0' + fullBitString; } | ||
for (i = 0; i < 8; i++) { | ||
rawBytes[i] = $parseInt($strSlice(fullBitString, i * 8, (i + 1) * 8), 2); | ||
} | ||
return isLittleEndian ? $reverse(rawBytes) : rawBytes; | ||
return valueToFloat64Bytes(value, isLittleEndian); | ||
} // step 3 | ||
@@ -186,18 +76,3 @@ | ||
/* | ||
if (intValue >= 0) { // step 3.d | ||
// Let rawBytes be a List containing the n-byte binary encoding of intValue. If isLittleEndian is false, the bytes are ordered in big endian order. Otherwise, the bytes are ordered in little endian order. | ||
} else { // step 3.e | ||
// Let rawBytes be a List containing the n-byte binary 2's complement encoding of intValue. If isLittleEndian is false, the bytes are ordered in big endian order. Otherwise, the bytes are ordered in little endian order. | ||
} | ||
*/ | ||
if (intValue < 0) { | ||
intValue = intValue >>> 0; | ||
} | ||
for (i = 0; i < n; i++) { | ||
rawBytes[isLittleEndian ? i : n - 1 - i] = intValue & 0xff; | ||
intValue = intValue >> 8; | ||
} | ||
return rawBytes; // step 4 | ||
return integerToNBytes(intValue, n, isLittleEndian); // step 3.d, 3.e, 4 | ||
}; |
@@ -6,3 +6,2 @@ 'use strict'; | ||
var $pow = GetIntrinsic('%Math.pow%'); | ||
var $RangeError = GetIntrinsic('%RangeError%'); | ||
@@ -19,2 +18,5 @@ var $TypeError = GetIntrinsic('%TypeError%'); | ||
var bytesAsFloat32 = require('../helpers/bytesAsFloat32'); | ||
var bytesAsFloat64 = require('../helpers/bytesAsFloat64'); | ||
var bytesAsInteger = require('../helpers/bytesAsInteger'); | ||
var every = require('../helpers/every'); | ||
@@ -66,91 +68,10 @@ var isByteValue = require('../helpers/isByteValue'); | ||
if (type === 'Float32') { // step 3 | ||
// return new Float32Array(new Uint8Array(rawBytes).buffer)[0]; | ||
/* | ||
Let value be the byte elements of rawBytes concatenated and interpreted as a little-endian bit string encoding of an IEEE 754-2008 binary32 value. | ||
If value is an IEEE 754-2008 binary32 NaN value, return the NaN Number value. | ||
Return the Number value that corresponds to value. | ||
*/ | ||
var sign = rawBytes[3] & 0x80 ? -1 : 1; // Check the sign bit | ||
var exponent = ((rawBytes[3] & 0x7F) << 1) | ||
| (rawBytes[2] >> 7); // Combine bits for exponent | ||
var mantissa = ((rawBytes[2] & 0x7F) << 16) | ||
| (rawBytes[1] << 8) | ||
| rawBytes[0]; // Combine bits for mantissa | ||
if (exponent === 0 && mantissa === 0) { | ||
return sign === 1 ? 0 : -0; | ||
} | ||
if (exponent === 0xFF && mantissa === 0) { | ||
return sign === 1 ? Infinity : -Infinity; | ||
} | ||
if (exponent === 0xFF && mantissa !== 0) { | ||
return NaN; | ||
} | ||
exponent -= 127; // subtract the bias | ||
if (exponent === -127) { | ||
return sign * mantissa * $pow(2, -126 - 23); | ||
} | ||
return sign * (1 + (mantissa * $pow(2, -23))) * $pow(2, exponent); | ||
return bytesAsFloat32(rawBytes); | ||
} | ||
if (type === 'Float64') { // step 4 | ||
// return new Float64Array(new Uint8Array(rawBytes).buffer)[0]; | ||
/* | ||
Let value be the byte elements of rawBytes concatenated and interpreted as a little-endian bit string encoding of an IEEE 754-2008 binary64 value. | ||
If value is an IEEE 754-2008 binary64 NaN value, return the NaN Number value. | ||
Return the Number value that corresponds to value. | ||
*/ | ||
var sign = rawBytes[7] & 0x80 ? -1 : 1; // first bit | ||
var exponent = ((rawBytes[7] & 0x7F) << 4) // 7 bits from index 7 | ||
| ((rawBytes[6] & 0xF0) >> 4); // 4 bits from index 6 | ||
var mantissa = ((rawBytes[6] & 0x0F) * 0x1000000000000) // 4 bits from index 6 | ||
+ (rawBytes[5] * 0x10000000000) // 8 bits from index 5 | ||
+ (rawBytes[4] * 0x100000000) // 8 bits from index 4 | ||
+ (rawBytes[3] * 0x1000000) // 8 bits from index 3 | ||
+ (rawBytes[2] * 0x10000) // 8 bits from index 2 | ||
+ (rawBytes[1] * 0x100) // 8 bits from index 1 | ||
+ rawBytes[0]; // 8 bits from index 0 | ||
if (exponent === 0 && mantissa === 0) { | ||
return sign * 0; | ||
} | ||
if (exponent === 0x7FF && mantissa !== 0) { | ||
return NaN; | ||
} | ||
if (exponent === 0x7FF && mantissa === 0) { | ||
return sign * Infinity; | ||
} | ||
exponent -= 1023; // subtract the bias | ||
// Handle subnormal numbers | ||
if (exponent === -1023) { | ||
return sign * mantissa * 5e-324; // $pow(2, -1022 - 52) | ||
} | ||
return sign * (1 + (mantissa / 0x10000000000000)) * $pow(2, exponent); | ||
return bytesAsFloat64(rawBytes); | ||
} | ||
// this is common to both branches | ||
var intValue = 0; | ||
for (var i = 0; i < rawBytes.length; i++) { | ||
intValue += rawBytes[i] * $pow(2, 8 * i); | ||
} | ||
/* | ||
Let intValue be the byte elements of rawBytes concatenated and interpreted as a bit string encoding of an unsigned little-endian binary number. | ||
*/ | ||
if ($charAt(type, 0) !== 'U') { // steps 5-6 | ||
// Let intValue be the byte elements of rawBytes concatenated and interpreted as a bit string encoding of a binary little-endian 2's complement number of bit length elementSize × 8. | ||
var bitLength = elementSize * 8; | ||
if (rawBytes[elementSize - 1] & 0x80) { | ||
intValue -= $pow(2, bitLength); | ||
} | ||
} | ||
return intValue; // step 7 | ||
return bytesAsInteger(rawBytes, elementSize, $charAt(type, 0) === 'U', false); | ||
}; |
@@ -8,5 +8,6 @@ 'use strict'; | ||
var IsInteger = require('./IsInteger'); | ||
var Type = require('./Type'); | ||
var isInteger = require('../helpers/isInteger'); | ||
var $charAt = callBound('String.prototype.charAt'); | ||
@@ -20,3 +21,3 @@ | ||
} | ||
if (!IsInteger(q)) { | ||
if (!isInteger(q)) { | ||
throw new $TypeError('Assertion failed: `q` must be an integer'); | ||
@@ -23,0 +24,0 @@ } |
@@ -22,3 +22,3 @@ 'use strict'; | ||
// eslint-disable-next-line max-lines-per-function, max-statements, max-params | ||
// eslint-disable-next-line max-lines-per-function, max-statements | ||
module.exports = function ValidateAndApplyPropertyDescriptor(O, P, extensible, Desc, current) { | ||
@@ -25,0 +25,0 @@ // this uses the ES2017+ logic, since it fixes a number of bugs in the ES2015 logic. |
@@ -5,8 +5,8 @@ 'use strict'; | ||
var IsInteger = require('./IsInteger'); | ||
var Type = require('./Type'); | ||
var MAX_SAFE_INTEGER = require('../helpers/maxSafeInteger'); | ||
var isInteger = require('../helpers/isInteger'); | ||
var isLeadingSurrogate = require('../helpers/isLeadingSurrogate'); | ||
var isTrailingSurrogate = require('../helpers/isTrailingSurrogate'); | ||
var MAX_SAFE_INTEGER = require('../helpers/maxSafeInteger'); | ||
@@ -23,3 +23,3 @@ var $TypeError = GetIntrinsic('%TypeError%'); | ||
} | ||
if (!IsInteger(index) || index < 0 || index > MAX_SAFE_INTEGER) { | ||
if (!isInteger(index) || index < 0 || index > MAX_SAFE_INTEGER) { | ||
throw new $TypeError('Assertion failed: `length` must be an integer >= 0 and <= 2**53'); | ||
@@ -26,0 +26,0 @@ } |
@@ -10,3 +10,3 @@ 'use strict'; | ||
var IsInteger = require('./IsInteger'); | ||
var isInteger = require('../helpers/isInteger'); | ||
@@ -29,3 +29,3 @@ var hasProto = require('has-proto')(); | ||
module.exports = function ArrayCreate(length) { | ||
if (!IsInteger(length) || length < 0) { | ||
if (!isInteger(length) || length < 0) { | ||
throw new $TypeError('Assertion failed: `length` must be an integer Number >= 0'); | ||
@@ -32,0 +32,0 @@ } |
@@ -12,9 +12,10 @@ 'use strict'; | ||
var IsConstructor = require('./IsConstructor'); | ||
var IsInteger = require('./IsInteger'); | ||
var Type = require('./Type'); | ||
var isInteger = require('../helpers/isInteger'); | ||
// https://262.ecma-international.org/6.0/#sec-arrayspeciescreate | ||
module.exports = function ArraySpeciesCreate(originalArray, length) { | ||
if (!IsInteger(length) || length < 0) { | ||
if (!isInteger(length) || length < 0) { | ||
throw new $TypeError('Assertion failed: length must be an integer >= 0'); | ||
@@ -21,0 +22,0 @@ } |
@@ -22,3 +22,2 @@ 'use strict'; | ||
var IsArray = require('./IsArray'); | ||
var IsInteger = require('./IsInteger'); | ||
var ToObject = require('./ToObject'); | ||
@@ -28,8 +27,5 @@ var ToString = require('./ToString'); | ||
var canDistinguishSparseFromUndefined = 0 in [undefined]; // IE 6 - 8 have a bug where this returns false | ||
var isInteger = require('../helpers/isInteger'); | ||
var isStringOrHole = require('../helpers/isStringOrHole'); | ||
var isStringOrHole = function (capture, index, arr) { | ||
return Type(capture) === 'String' || (canDistinguishSparseFromUndefined ? !(index in arr) : Type(capture) === 'Undefined'); | ||
}; | ||
// http://262.ecma-international.org/9.0/#sec-getsubstitution | ||
@@ -49,3 +45,3 @@ | ||
if (!IsInteger(position) || position < 0 || position > stringLength) { | ||
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)); | ||
@@ -52,0 +48,0 @@ } |
'use strict'; | ||
var abs = require('./abs'); | ||
var floor = require('./floor'); | ||
var isInteger = require('../helpers/isInteger'); | ||
var $isNaN = require('../helpers/isNaN'); | ||
var $isFinite = require('../helpers/isFinite'); | ||
// https://262.ecma-international.org/6.0/#sec-isinteger | ||
module.exports = function IsInteger(argument) { | ||
if (typeof argument !== 'number' || $isNaN(argument) || !$isFinite(argument)) { | ||
return false; | ||
} | ||
var absValue = abs(argument); | ||
return floor(absValue) === absValue; | ||
return isInteger(argument); | ||
}; |
@@ -5,21 +5,5 @@ 'use strict'; | ||
var $floor = GetIntrinsic('%Math.floor%'); | ||
var $log = GetIntrinsic('%Math.log%'); | ||
var $log2E = GetIntrinsic('%Math.LOG2E%'); | ||
var $log2 = GetIntrinsic('%Math.log2%', true) || function log2(x) { | ||
return $log(x) * $log2E; | ||
}; | ||
var $parseInt = GetIntrinsic('%parseInt%'); | ||
var $pow = GetIntrinsic('%Math.pow%'); | ||
var $TypeError = GetIntrinsic('%TypeError%'); | ||
var callBound = require('call-bind/callBound'); | ||
var $reverse = callBound('Array.prototype.reverse'); | ||
var $numberToString = callBound('Number.prototype.toString'); | ||
var $strSlice = callBound('String.prototype.slice'); | ||
var abs = require('./abs'); | ||
var hasOwnProperty = require('./HasOwnProperty'); | ||
var SameValue = require('./SameValue'); | ||
var ToInt16 = require('./ToInt16'); | ||
@@ -34,4 +18,5 @@ var ToInt32 = require('./ToInt32'); | ||
var isNaN = require('../helpers/isNaN'); | ||
var isFinite = require('../helpers/isFinite'); | ||
var valueToFloat32Bytes = require('../helpers/valueToFloat32Bytes'); | ||
var valueToFloat64Bytes = require('../helpers/valueToFloat64Bytes'); | ||
var integerToNBytes = require('../helpers/integerToNBytes'); | ||
@@ -78,101 +63,6 @@ var keys = require('object-keys'); | ||
var rawBytes = []; | ||
var exponent; | ||
if (type === 'Float32') { // step 1 | ||
if (isNaN(value)) { | ||
return isLittleEndian ? [0, 0, 192, 127] : [127, 192, 0, 0]; // hardcoded | ||
} | ||
var leastSig; | ||
if (value === 0) { | ||
leastSig = SameValue(value, -0) ? 0x80 : 0; | ||
return isLittleEndian ? [0, 0, 0, leastSig] : [leastSig, 0, 0, 0]; | ||
} | ||
if (!isFinite(value)) { | ||
leastSig = value < 0 ? 255 : 127; | ||
return isLittleEndian ? [0, 0, 128, leastSig] : [leastSig, 128, 0, 0]; | ||
} | ||
var sign = value < 0 ? 1 : 0; | ||
value = abs(value); // eslint-disable-line no-param-reassign | ||
exponent = 0; | ||
while (value >= 2) { | ||
exponent += 1; | ||
value /= 2; // eslint-disable-line no-param-reassign | ||
} | ||
while (value < 1) { | ||
exponent -= 1; | ||
value *= 2; // eslint-disable-line no-param-reassign | ||
} | ||
var mantissa = value - 1; | ||
mantissa *= $pow(2, 23); | ||
mantissa = $floor(mantissa); | ||
exponent += 127; | ||
exponent = exponent << 23; | ||
var result = sign << 31; | ||
result |= exponent; | ||
result |= mantissa; | ||
var byte0 = result & 255; | ||
result = result >> 8; | ||
var byte1 = result & 255; | ||
result = result >> 8; | ||
var byte2 = result & 255; | ||
result = result >> 8; | ||
var byte3 = result & 255; | ||
if (isLittleEndian) { | ||
return [byte0, byte1, byte2, byte3]; | ||
} | ||
return [byte3, byte2, byte1, byte0]; | ||
return valueToFloat32Bytes(value, isLittleEndian); | ||
} else if (type === 'Float64') { // step 2 | ||
if (value === 0) { | ||
leastSig = Object.is(value, -0) ? 0x80 : 0; | ||
return isLittleEndian ? [0, 0, 0, 0, 0, 0, 0, leastSig] : [leastSig, 0, 0, 0, 0, 0, 0, 0]; | ||
} | ||
if (isNaN(value)) { | ||
return isLittleEndian ? [0, 0, 0, 0, 0, 0, 248, 127] : [127, 248, 0, 0, 0, 0, 0, 0]; | ||
} | ||
if (!isFinite(value)) { | ||
var infBytes = value < 0 ? [0, 0, 0, 0, 0, 0, 240, 255] : [0, 0, 0, 0, 0, 0, 240, 127]; | ||
return isLittleEndian ? infBytes : $reverse(infBytes); | ||
} | ||
var isNegative = value < 0; | ||
if (isNegative) { value = -value; } // eslint-disable-line no-param-reassign | ||
exponent = $floor($log2(value)); | ||
var significand = (value / $pow(2, exponent)) - 1; | ||
var bitString = ''; | ||
for (var i = 0; i < 52; i++) { | ||
significand *= 2; | ||
if (significand >= 1) { | ||
bitString += '1'; | ||
significand -= 1; | ||
} else { | ||
bitString += '0'; | ||
} | ||
} | ||
exponent += 1023; | ||
var exponentBits = $numberToString(exponent, 2); | ||
while (exponentBits.length < 11) { exponentBits = '0' + exponentBits; } | ||
var fullBitString = (isNegative ? '1' : '0') + exponentBits + bitString; | ||
while (fullBitString.length < 64) { fullBitString = '0' + fullBitString; } | ||
for (i = 0; i < 8; i++) { | ||
rawBytes[i] = $parseInt($strSlice(fullBitString, i * 8, (i + 1) * 8), 2); | ||
} | ||
return isLittleEndian ? $reverse(rawBytes) : rawBytes; | ||
return valueToFloat64Bytes(value, isLittleEndian); | ||
} // step 3 | ||
@@ -186,18 +76,3 @@ | ||
/* | ||
if (intValue >= 0) { // step 3.d | ||
// Let rawBytes be a List containing the n-byte binary encoding of intValue. If isLittleEndian is false, the bytes are ordered in big endian order. Otherwise, the bytes are ordered in little endian order. | ||
} else { // step 3.e | ||
// Let rawBytes be a List containing the n-byte binary 2's complement encoding of intValue. If isLittleEndian is false, the bytes are ordered in big endian order. Otherwise, the bytes are ordered in little endian order. | ||
} | ||
*/ | ||
if (intValue < 0) { | ||
intValue = intValue >>> 0; | ||
} | ||
for (i = 0; i < n; i++) { | ||
rawBytes[isLittleEndian ? i : n - 1 - i] = intValue & 0xff; | ||
intValue = intValue >> 8; | ||
} | ||
return rawBytes; // step 4 | ||
return integerToNBytes(intValue, n, isLittleEndian); // step 3.d, 3.e, 4 | ||
}; |
@@ -6,3 +6,2 @@ 'use strict'; | ||
var $pow = GetIntrinsic('%Math.pow%'); | ||
var $RangeError = GetIntrinsic('%RangeError%'); | ||
@@ -19,2 +18,5 @@ var $TypeError = GetIntrinsic('%TypeError%'); | ||
var bytesAsFloat32 = require('../helpers/bytesAsFloat32'); | ||
var bytesAsFloat64 = require('../helpers/bytesAsFloat64'); | ||
var bytesAsInteger = require('../helpers/bytesAsInteger'); | ||
var every = require('../helpers/every'); | ||
@@ -66,91 +68,10 @@ var isByteValue = require('../helpers/isByteValue'); | ||
if (type === 'Float32') { // step 3 | ||
// return new Float32Array(new Uint8Array(rawBytes).buffer)[0]; | ||
/* | ||
Let value be the byte elements of rawBytes concatenated and interpreted as a little-endian bit string encoding of an IEEE 754-2008 binary32 value. | ||
If value is an IEEE 754-2008 binary32 NaN value, return the NaN Number value. | ||
Return the Number value that corresponds to value. | ||
*/ | ||
var sign = rawBytes[3] & 0x80 ? -1 : 1; // Check the sign bit | ||
var exponent = ((rawBytes[3] & 0x7F) << 1) | ||
| (rawBytes[2] >> 7); // Combine bits for exponent | ||
var mantissa = ((rawBytes[2] & 0x7F) << 16) | ||
| (rawBytes[1] << 8) | ||
| rawBytes[0]; // Combine bits for mantissa | ||
if (exponent === 0 && mantissa === 0) { | ||
return sign === 1 ? 0 : -0; | ||
} | ||
if (exponent === 0xFF && mantissa === 0) { | ||
return sign === 1 ? Infinity : -Infinity; | ||
} | ||
if (exponent === 0xFF && mantissa !== 0) { | ||
return NaN; | ||
} | ||
exponent -= 127; // subtract the bias | ||
if (exponent === -127) { | ||
return sign * mantissa * $pow(2, -126 - 23); | ||
} | ||
return sign * (1 + (mantissa * $pow(2, -23))) * $pow(2, exponent); | ||
return bytesAsFloat32(rawBytes); | ||
} | ||
if (type === 'Float64') { // step 4 | ||
// return new Float64Array(new Uint8Array(rawBytes).buffer)[0]; | ||
/* | ||
Let value be the byte elements of rawBytes concatenated and interpreted as a little-endian bit string encoding of an IEEE 754-2008 binary64 value. | ||
If value is an IEEE 754-2008 binary64 NaN value, return the NaN Number value. | ||
Return the Number value that corresponds to value. | ||
*/ | ||
var sign = rawBytes[7] & 0x80 ? -1 : 1; // first bit | ||
var exponent = ((rawBytes[7] & 0x7F) << 4) // 7 bits from index 7 | ||
| ((rawBytes[6] & 0xF0) >> 4); // 4 bits from index 6 | ||
var mantissa = ((rawBytes[6] & 0x0F) * 0x1000000000000) // 4 bits from index 6 | ||
+ (rawBytes[5] * 0x10000000000) // 8 bits from index 5 | ||
+ (rawBytes[4] * 0x100000000) // 8 bits from index 4 | ||
+ (rawBytes[3] * 0x1000000) // 8 bits from index 3 | ||
+ (rawBytes[2] * 0x10000) // 8 bits from index 2 | ||
+ (rawBytes[1] * 0x100) // 8 bits from index 1 | ||
+ rawBytes[0]; // 8 bits from index 0 | ||
if (exponent === 0 && mantissa === 0) { | ||
return sign * 0; | ||
} | ||
if (exponent === 0x7FF && mantissa !== 0) { | ||
return NaN; | ||
} | ||
if (exponent === 0x7FF && mantissa === 0) { | ||
return sign * Infinity; | ||
} | ||
exponent -= 1023; // subtract the bias | ||
// Handle subnormal numbers | ||
if (exponent === -1023) { | ||
return sign * mantissa * 5e-324; // $pow(2, -1022 - 52) | ||
} | ||
return sign * (1 + (mantissa / 0x10000000000000)) * $pow(2, exponent); | ||
return bytesAsFloat64(rawBytes); | ||
} | ||
// this is common to both branches | ||
var intValue = 0; | ||
for (var i = 0; i < rawBytes.length; i++) { | ||
intValue += rawBytes[i] * $pow(2, 8 * i); | ||
} | ||
/* | ||
Let intValue be the byte elements of rawBytes concatenated and interpreted as a bit string encoding of an unsigned little-endian binary number. | ||
*/ | ||
if ($charAt(type, 0) !== 'U') { // steps 5-6 | ||
// Let intValue be the byte elements of rawBytes concatenated and interpreted as a bit string encoding of a binary little-endian 2's complement number of bit length elementSize × 8. | ||
var bitLength = elementSize * 8; | ||
if (rawBytes[elementSize - 1] & 0x80) { | ||
intValue -= $pow(2, bitLength); | ||
} | ||
} | ||
return intValue; // step 7 | ||
return bytesAsInteger(rawBytes, elementSize, $charAt(type, 0) === 'U', false); | ||
}; |
@@ -10,5 +10,6 @@ 'use strict'; | ||
var IsExtensible = require('./IsExtensible'); | ||
var IsInteger = require('./IsInteger'); | ||
var Type = require('./Type'); | ||
var isInteger = require('../helpers/isInteger'); | ||
// https://262.ecma-international.org/9.0/#sec-setfunctionlength | ||
@@ -23,3 +24,3 @@ | ||
} | ||
if (length < 0 || !IsInteger(length)) { | ||
if (length < 0 || !isInteger(length)) { | ||
throw new $TypeError('Assertion failed: `length` must be an integer >= 0'); | ||
@@ -26,0 +27,0 @@ } |
@@ -8,5 +8,6 @@ 'use strict'; | ||
var IsInteger = require('./IsInteger'); | ||
var Type = require('./Type'); | ||
var isInteger = require('../helpers/isInteger'); | ||
var $charAt = callBound('String.prototype.charAt'); | ||
@@ -20,3 +21,3 @@ | ||
} | ||
if (!IsInteger(q)) { | ||
if (!isInteger(q)) { | ||
throw new $TypeError('Assertion failed: `q` must be an integer'); | ||
@@ -23,0 +24,0 @@ } |
@@ -22,3 +22,3 @@ 'use strict'; | ||
// eslint-disable-next-line max-lines-per-function, max-statements, max-params | ||
// eslint-disable-next-line max-lines-per-function, max-statements | ||
module.exports = function ValidateAndApplyPropertyDescriptor(O, P, extensible, Desc, current) { | ||
@@ -25,0 +25,0 @@ // this uses the ES2017+ logic, since it fixes a number of bugs in the ES2015 logic. |
@@ -5,8 +5,8 @@ 'use strict'; | ||
var IsInteger = require('./IsInteger'); | ||
var Type = require('./Type'); | ||
var MAX_SAFE_INTEGER = require('../helpers/maxSafeInteger'); | ||
var isInteger = require('../helpers/isInteger'); | ||
var isLeadingSurrogate = require('../helpers/isLeadingSurrogate'); | ||
var isTrailingSurrogate = require('../helpers/isTrailingSurrogate'); | ||
var MAX_SAFE_INTEGER = require('../helpers/maxSafeInteger'); | ||
@@ -23,3 +23,3 @@ var $TypeError = GetIntrinsic('%TypeError%'); | ||
} | ||
if (!IsInteger(index) || index < 0 || index > MAX_SAFE_INTEGER) { | ||
if (!isInteger(index) || index < 0 || index > MAX_SAFE_INTEGER) { | ||
throw new $TypeError('Assertion failed: `length` must be an integer >= 0 and <= 2**53'); | ||
@@ -26,0 +26,0 @@ } |
@@ -10,3 +10,3 @@ 'use strict'; | ||
var IsInteger = require('./IsInteger'); | ||
var isInteger = require('../helpers/isInteger'); | ||
@@ -29,3 +29,3 @@ var hasProto = require('has-proto')(); | ||
module.exports = function ArrayCreate(length) { | ||
if (!IsInteger(length) || length < 0) { | ||
if (!isInteger(length) || length < 0) { | ||
throw new $TypeError('Assertion failed: `length` must be an integer Number >= 0'); | ||
@@ -32,0 +32,0 @@ } |
@@ -12,9 +12,10 @@ 'use strict'; | ||
var IsConstructor = require('./IsConstructor'); | ||
var IsInteger = require('./IsInteger'); | ||
var Type = require('./Type'); | ||
var isInteger = require('../helpers/isInteger'); | ||
// https://262.ecma-international.org/6.0/#sec-arrayspeciescreate | ||
module.exports = function ArraySpeciesCreate(originalArray, length) { | ||
if (!IsInteger(length) || length < 0) { | ||
if (!isInteger(length) || length < 0) { | ||
throw new $TypeError('Assertion failed: length must be an integer >= 0'); | ||
@@ -21,0 +22,0 @@ } |
@@ -19,3 +19,2 @@ 'use strict'; | ||
// eslint-disable-next-line max-params | ||
module.exports = function FlattenIntoArray(target, source, sourceLen, start, depth) { | ||
@@ -22,0 +21,0 @@ var mapperFunction; |
@@ -22,3 +22,2 @@ 'use strict'; | ||
var IsArray = require('./IsArray'); | ||
var IsInteger = require('./IsInteger'); | ||
var ToObject = require('./ToObject'); | ||
@@ -28,8 +27,5 @@ var ToString = require('./ToString'); | ||
var canDistinguishSparseFromUndefined = 0 in [undefined]; // IE 6 - 8 have a bug where this returns false | ||
var isInteger = require('../helpers/isInteger'); | ||
var isStringOrHole = require('../helpers/isStringOrHole'); | ||
var isStringOrHole = function (capture, index, arr) { | ||
return Type(capture) === 'String' || (canDistinguishSparseFromUndefined ? !(index in arr) : Type(capture) === 'Undefined'); | ||
}; | ||
// http://262.ecma-international.org/9.0/#sec-getsubstitution | ||
@@ -49,3 +45,3 @@ | ||
if (!IsInteger(position) || position < 0 || position > stringLength) { | ||
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)); | ||
@@ -52,0 +48,0 @@ } |
'use strict'; | ||
var abs = require('./abs'); | ||
var floor = require('./floor'); | ||
var isInteger = require('../helpers/isInteger'); | ||
var $isNaN = require('../helpers/isNaN'); | ||
var $isFinite = require('../helpers/isFinite'); | ||
// https://262.ecma-international.org/6.0/#sec-isinteger | ||
module.exports = function IsInteger(argument) { | ||
if (typeof argument !== 'number' || $isNaN(argument) || !$isFinite(argument)) { | ||
return false; | ||
} | ||
var absValue = abs(argument); | ||
return floor(absValue) === absValue; | ||
return isInteger(argument); | ||
}; |
@@ -5,21 +5,5 @@ 'use strict'; | ||
var $floor = GetIntrinsic('%Math.floor%'); | ||
var $log = GetIntrinsic('%Math.log%'); | ||
var $log2E = GetIntrinsic('%Math.LOG2E%'); | ||
var $log2 = GetIntrinsic('%Math.log2%', true) || function log2(x) { | ||
return $log(x) * $log2E; | ||
}; | ||
var $parseInt = GetIntrinsic('%parseInt%'); | ||
var $pow = GetIntrinsic('%Math.pow%'); | ||
var $TypeError = GetIntrinsic('%TypeError%'); | ||
var callBound = require('call-bind/callBound'); | ||
var $reverse = callBound('Array.prototype.reverse'); | ||
var $numberToString = callBound('Number.prototype.toString'); | ||
var $strSlice = callBound('String.prototype.slice'); | ||
var abs = require('./abs'); | ||
var hasOwnProperty = require('./HasOwnProperty'); | ||
var SameValue = require('./SameValue'); | ||
var ToInt16 = require('./ToInt16'); | ||
@@ -34,4 +18,5 @@ var ToInt32 = require('./ToInt32'); | ||
var isNaN = require('../helpers/isNaN'); | ||
var isFinite = require('../helpers/isFinite'); | ||
var valueToFloat32Bytes = require('../helpers/valueToFloat32Bytes'); | ||
var valueToFloat64Bytes = require('../helpers/valueToFloat64Bytes'); | ||
var integerToNBytes = require('../helpers/integerToNBytes'); | ||
@@ -78,101 +63,6 @@ var keys = require('object-keys'); | ||
var rawBytes = []; | ||
var exponent; | ||
if (type === 'Float32') { // step 1 | ||
if (isNaN(value)) { | ||
return isLittleEndian ? [0, 0, 192, 127] : [127, 192, 0, 0]; // hardcoded | ||
} | ||
var leastSig; | ||
if (value === 0) { | ||
leastSig = SameValue(value, -0) ? 0x80 : 0; | ||
return isLittleEndian ? [0, 0, 0, leastSig] : [leastSig, 0, 0, 0]; | ||
} | ||
if (!isFinite(value)) { | ||
leastSig = value < 0 ? 255 : 127; | ||
return isLittleEndian ? [0, 0, 128, leastSig] : [leastSig, 128, 0, 0]; | ||
} | ||
var sign = value < 0 ? 1 : 0; | ||
value = abs(value); // eslint-disable-line no-param-reassign | ||
exponent = 0; | ||
while (value >= 2) { | ||
exponent += 1; | ||
value /= 2; // eslint-disable-line no-param-reassign | ||
} | ||
while (value < 1) { | ||
exponent -= 1; | ||
value *= 2; // eslint-disable-line no-param-reassign | ||
} | ||
var mantissa = value - 1; | ||
mantissa *= $pow(2, 23); | ||
mantissa = $floor(mantissa); | ||
exponent += 127; | ||
exponent = exponent << 23; | ||
var result = sign << 31; | ||
result |= exponent; | ||
result |= mantissa; | ||
var byte0 = result & 255; | ||
result = result >> 8; | ||
var byte1 = result & 255; | ||
result = result >> 8; | ||
var byte2 = result & 255; | ||
result = result >> 8; | ||
var byte3 = result & 255; | ||
if (isLittleEndian) { | ||
return [byte0, byte1, byte2, byte3]; | ||
} | ||
return [byte3, byte2, byte1, byte0]; | ||
return valueToFloat32Bytes(value, isLittleEndian); | ||
} else if (type === 'Float64') { // step 2 | ||
if (value === 0) { | ||
leastSig = Object.is(value, -0) ? 0x80 : 0; | ||
return isLittleEndian ? [0, 0, 0, 0, 0, 0, 0, leastSig] : [leastSig, 0, 0, 0, 0, 0, 0, 0]; | ||
} | ||
if (isNaN(value)) { | ||
return isLittleEndian ? [0, 0, 0, 0, 0, 0, 248, 127] : [127, 248, 0, 0, 0, 0, 0, 0]; | ||
} | ||
if (!isFinite(value)) { | ||
var infBytes = value < 0 ? [0, 0, 0, 0, 0, 0, 240, 255] : [0, 0, 0, 0, 0, 0, 240, 127]; | ||
return isLittleEndian ? infBytes : $reverse(infBytes); | ||
} | ||
var isNegative = value < 0; | ||
if (isNegative) { value = -value; } // eslint-disable-line no-param-reassign | ||
exponent = $floor($log2(value)); | ||
var significand = (value / $pow(2, exponent)) - 1; | ||
var bitString = ''; | ||
for (var i = 0; i < 52; i++) { | ||
significand *= 2; | ||
if (significand >= 1) { | ||
bitString += '1'; | ||
significand -= 1; | ||
} else { | ||
bitString += '0'; | ||
} | ||
} | ||
exponent += 1023; | ||
var exponentBits = $numberToString(exponent, 2); | ||
while (exponentBits.length < 11) { exponentBits = '0' + exponentBits; } | ||
var fullBitString = (isNegative ? '1' : '0') + exponentBits + bitString; | ||
while (fullBitString.length < 64) { fullBitString = '0' + fullBitString; } | ||
for (i = 0; i < 8; i++) { | ||
rawBytes[i] = $parseInt($strSlice(fullBitString, i * 8, (i + 1) * 8), 2); | ||
} | ||
return isLittleEndian ? $reverse(rawBytes) : rawBytes; | ||
return valueToFloat64Bytes(value, isLittleEndian); | ||
} // step 3 | ||
@@ -186,18 +76,3 @@ | ||
/* | ||
if (intValue >= 0) { // step 3.d | ||
// Let rawBytes be a List containing the n-byte binary encoding of intValue. If isLittleEndian is false, the bytes are ordered in big endian order. Otherwise, the bytes are ordered in little endian order. | ||
} else { // step 3.e | ||
// Let rawBytes be a List containing the n-byte binary 2's complement encoding of intValue. If isLittleEndian is false, the bytes are ordered in big endian order. Otherwise, the bytes are ordered in little endian order. | ||
} | ||
*/ | ||
if (intValue < 0) { | ||
intValue = intValue >>> 0; | ||
} | ||
for (i = 0; i < n; i++) { | ||
rawBytes[isLittleEndian ? i : n - 1 - i] = intValue & 0xff; | ||
intValue = intValue >> 8; | ||
} | ||
return rawBytes; // step 4 | ||
return integerToNBytes(intValue, n, isLittleEndian); // step 3.d, 3.e, 4 | ||
}; |
@@ -6,3 +6,2 @@ 'use strict'; | ||
var $pow = GetIntrinsic('%Math.pow%'); | ||
var $RangeError = GetIntrinsic('%RangeError%'); | ||
@@ -19,2 +18,5 @@ var $TypeError = GetIntrinsic('%TypeError%'); | ||
var bytesAsFloat32 = require('../helpers/bytesAsFloat32'); | ||
var bytesAsFloat64 = require('../helpers/bytesAsFloat64'); | ||
var bytesAsInteger = require('../helpers/bytesAsInteger'); | ||
var every = require('../helpers/every'); | ||
@@ -66,91 +68,10 @@ var isByteValue = require('../helpers/isByteValue'); | ||
if (type === 'Float32') { // step 3 | ||
// return new Float32Array(new Uint8Array(rawBytes).buffer)[0]; | ||
/* | ||
Let value be the byte elements of rawBytes concatenated and interpreted as a little-endian bit string encoding of an IEEE 754-2008 binary32 value. | ||
If value is an IEEE 754-2008 binary32 NaN value, return the NaN Number value. | ||
Return the Number value that corresponds to value. | ||
*/ | ||
var sign = rawBytes[3] & 0x80 ? -1 : 1; // Check the sign bit | ||
var exponent = ((rawBytes[3] & 0x7F) << 1) | ||
| (rawBytes[2] >> 7); // Combine bits for exponent | ||
var mantissa = ((rawBytes[2] & 0x7F) << 16) | ||
| (rawBytes[1] << 8) | ||
| rawBytes[0]; // Combine bits for mantissa | ||
if (exponent === 0 && mantissa === 0) { | ||
return sign === 1 ? 0 : -0; | ||
} | ||
if (exponent === 0xFF && mantissa === 0) { | ||
return sign === 1 ? Infinity : -Infinity; | ||
} | ||
if (exponent === 0xFF && mantissa !== 0) { | ||
return NaN; | ||
} | ||
exponent -= 127; // subtract the bias | ||
if (exponent === -127) { | ||
return sign * mantissa * $pow(2, -126 - 23); | ||
} | ||
return sign * (1 + (mantissa * $pow(2, -23))) * $pow(2, exponent); | ||
return bytesAsFloat32(rawBytes); | ||
} | ||
if (type === 'Float64') { // step 4 | ||
// return new Float64Array(new Uint8Array(rawBytes).buffer)[0]; | ||
/* | ||
Let value be the byte elements of rawBytes concatenated and interpreted as a little-endian bit string encoding of an IEEE 754-2008 binary64 value. | ||
If value is an IEEE 754-2008 binary64 NaN value, return the NaN Number value. | ||
Return the Number value that corresponds to value. | ||
*/ | ||
var sign = rawBytes[7] & 0x80 ? -1 : 1; // first bit | ||
var exponent = ((rawBytes[7] & 0x7F) << 4) // 7 bits from index 7 | ||
| ((rawBytes[6] & 0xF0) >> 4); // 4 bits from index 6 | ||
var mantissa = ((rawBytes[6] & 0x0F) * 0x1000000000000) // 4 bits from index 6 | ||
+ (rawBytes[5] * 0x10000000000) // 8 bits from index 5 | ||
+ (rawBytes[4] * 0x100000000) // 8 bits from index 4 | ||
+ (rawBytes[3] * 0x1000000) // 8 bits from index 3 | ||
+ (rawBytes[2] * 0x10000) // 8 bits from index 2 | ||
+ (rawBytes[1] * 0x100) // 8 bits from index 1 | ||
+ rawBytes[0]; // 8 bits from index 0 | ||
if (exponent === 0 && mantissa === 0) { | ||
return sign * 0; | ||
} | ||
if (exponent === 0x7FF && mantissa !== 0) { | ||
return NaN; | ||
} | ||
if (exponent === 0x7FF && mantissa === 0) { | ||
return sign * Infinity; | ||
} | ||
exponent -= 1023; // subtract the bias | ||
// Handle subnormal numbers | ||
if (exponent === -1023) { | ||
return sign * mantissa * 5e-324; // $pow(2, -1022 - 52) | ||
} | ||
return sign * (1 + (mantissa / 0x10000000000000)) * $pow(2, exponent); | ||
return bytesAsFloat64(rawBytes); | ||
} | ||
// this is common to both branches | ||
var intValue = 0; | ||
for (var i = 0; i < rawBytes.length; i++) { | ||
intValue += rawBytes[i] * $pow(2, 8 * i); | ||
} | ||
/* | ||
Let intValue be the byte elements of rawBytes concatenated and interpreted as a bit string encoding of an unsigned little-endian binary number. | ||
*/ | ||
if ($charAt(type, 0) !== 'U') { // steps 5-6 | ||
// Let intValue be the byte elements of rawBytes concatenated and interpreted as a bit string encoding of a binary little-endian 2's complement number of bit length elementSize × 8. | ||
var bitLength = elementSize * 8; | ||
if (rawBytes[elementSize - 1] & 0x80) { | ||
intValue -= $pow(2, bitLength); | ||
} | ||
} | ||
return intValue; // step 7 | ||
return bytesAsInteger(rawBytes, elementSize, $charAt(type, 0) === 'U', false); | ||
}; |
@@ -10,5 +10,6 @@ 'use strict'; | ||
var IsExtensible = require('./IsExtensible'); | ||
var IsInteger = require('./IsInteger'); | ||
var Type = require('./Type'); | ||
var isInteger = require('../helpers/isInteger'); | ||
// https://262.ecma-international.org/9.0/#sec-setfunctionlength | ||
@@ -23,3 +24,3 @@ | ||
} | ||
if (length < 0 || !IsInteger(length)) { | ||
if (length < 0 || !isInteger(length)) { | ||
throw new $TypeError('Assertion failed: `length` must be an integer >= 0'); | ||
@@ -26,0 +27,0 @@ } |
@@ -8,5 +8,6 @@ 'use strict'; | ||
var IsInteger = require('./IsInteger'); | ||
var Type = require('./Type'); | ||
var isInteger = require('../helpers/isInteger'); | ||
var $charAt = callBound('String.prototype.charAt'); | ||
@@ -20,3 +21,3 @@ | ||
} | ||
if (!IsInteger(q)) { | ||
if (!isInteger(q)) { | ||
throw new $TypeError('Assertion failed: `q` must be an integer'); | ||
@@ -23,0 +24,0 @@ } |
@@ -22,3 +22,3 @@ 'use strict'; | ||
// eslint-disable-next-line max-lines-per-function, max-statements, max-params | ||
// eslint-disable-next-line max-lines-per-function, max-statements | ||
module.exports = function ValidateAndApplyPropertyDescriptor(O, P, extensible, Desc, current) { | ||
@@ -25,0 +25,0 @@ // this uses the ES2017+ logic, since it fixes a number of bugs in the ES2015 logic. |
@@ -6,5 +6,5 @@ 'use strict'; | ||
var CodePointAt = require('./CodePointAt'); | ||
var IsInteger = require('./IsInteger'); | ||
var Type = require('./Type'); | ||
var isInteger = require('../helpers/isInteger'); | ||
var MAX_SAFE_INTEGER = require('../helpers/maxSafeInteger'); | ||
@@ -20,3 +20,3 @@ | ||
} | ||
if (!IsInteger(index) || index < 0 || index > MAX_SAFE_INTEGER) { | ||
if (!isInteger(index) || index < 0 || index > MAX_SAFE_INTEGER) { | ||
throw new $TypeError('Assertion failed: `length` must be an integer >= 0 and <= 2**53'); | ||
@@ -23,0 +23,0 @@ } |
@@ -10,3 +10,3 @@ 'use strict'; | ||
var IsInteger = require('./IsInteger'); | ||
var isInteger = require('../helpers/isInteger'); | ||
@@ -29,3 +29,3 @@ var hasProto = require('has-proto')(); | ||
module.exports = function ArrayCreate(length) { | ||
if (!IsInteger(length) || length < 0) { | ||
if (!isInteger(length) || length < 0) { | ||
throw new $TypeError('Assertion failed: `length` must be an integer Number >= 0'); | ||
@@ -32,0 +32,0 @@ } |
@@ -12,9 +12,10 @@ 'use strict'; | ||
var IsConstructor = require('./IsConstructor'); | ||
var IsInteger = require('./IsInteger'); | ||
var Type = require('./Type'); | ||
var isInteger = require('../helpers/isInteger'); | ||
// https://262.ecma-international.org/6.0/#sec-arrayspeciescreate | ||
module.exports = function ArraySpeciesCreate(originalArray, length) { | ||
if (!IsInteger(length) || length < 0) { | ||
if (!isInteger(length) || length < 0) { | ||
throw new $TypeError('Assertion failed: length must be an integer >= 0'); | ||
@@ -21,0 +22,0 @@ } |
@@ -19,3 +19,2 @@ 'use strict'; | ||
// eslint-disable-next-line max-params | ||
module.exports = function FlattenIntoArray(target, source, sourceLen, start, depth) { | ||
@@ -22,0 +21,0 @@ var mapperFunction; |
@@ -22,3 +22,2 @@ 'use strict'; | ||
var IsArray = require('./IsArray'); | ||
var IsInteger = require('./IsInteger'); | ||
var ToObject = require('./ToObject'); | ||
@@ -28,8 +27,5 @@ var ToString = require('./ToString'); | ||
var canDistinguishSparseFromUndefined = 0 in [undefined]; // IE 6 - 8 have a bug where this returns false | ||
var isInteger = require('../helpers/isInteger'); | ||
var isStringOrHole = require('../helpers/isStringOrHole'); | ||
var isStringOrHole = function (capture, index, arr) { | ||
return Type(capture) === 'String' || (canDistinguishSparseFromUndefined ? !(index in arr) : Type(capture) === 'Undefined'); | ||
}; | ||
// http://262.ecma-international.org/9.0/#sec-getsubstitution | ||
@@ -49,3 +45,3 @@ | ||
if (!IsInteger(position) || position < 0 || position > stringLength) { | ||
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)); | ||
@@ -52,0 +48,0 @@ } |
'use strict'; | ||
var abs = require('./abs'); | ||
var floor = require('./floor'); | ||
var isInteger = require('../helpers/isInteger'); | ||
var $isNaN = require('../helpers/isNaN'); | ||
var $isFinite = require('../helpers/isFinite'); | ||
// https://262.ecma-international.org/6.0/#sec-isinteger | ||
module.exports = function IsInteger(argument) { | ||
if (typeof argument !== 'number' || $isNaN(argument) || !$isFinite(argument)) { | ||
return false; | ||
} | ||
var absValue = abs(argument); | ||
return floor(absValue) === absValue; | ||
return isInteger(argument); | ||
}; |
@@ -10,5 +10,6 @@ 'use strict'; | ||
var IsInteger = require('./IsInteger'); | ||
var Type = require('./Type'); | ||
var isInteger = require('../helpers/isInteger'); | ||
// https://262.ecma-international.org/11.0/#sec-numbertobigint | ||
@@ -20,3 +21,3 @@ | ||
} | ||
if (!IsInteger(number)) { | ||
if (!isInteger(number)) { | ||
throw new $RangeError('The number ' + number + ' cannot be converted to a BigInt because it is not an integer'); | ||
@@ -23,0 +24,0 @@ } |
@@ -5,23 +5,5 @@ 'use strict'; | ||
var $floor = GetIntrinsic('%Math.floor%'); | ||
var $log = GetIntrinsic('%Math.log%'); | ||
var $log2E = GetIntrinsic('%Math.LOG2E%'); | ||
var $log2 = GetIntrinsic('%Math.log2%', true) || function log2(x) { | ||
return $log(x) * $log2E; | ||
}; | ||
var $parseInt = GetIntrinsic('%parseInt%'); | ||
var $pow = GetIntrinsic('%Math.pow%'); | ||
var $Number = GetIntrinsic('%Number%'); | ||
var $TypeError = GetIntrinsic('%TypeError%'); | ||
var $BigInt = GetIntrinsic('%BigInt%', true); | ||
var callBound = require('call-bind/callBound'); | ||
var $reverse = callBound('Array.prototype.reverse'); | ||
var $numberToString = callBound('Number.prototype.toString'); | ||
var $strSlice = callBound('String.prototype.slice'); | ||
var abs = require('./abs'); | ||
var hasOwnProperty = require('./HasOwnProperty'); | ||
var SameValue = require('./SameValue'); | ||
var ToBigInt64 = require('./ToBigInt64'); | ||
@@ -38,4 +20,5 @@ var ToBigUint64 = require('./ToBigUint64'); | ||
var isNaN = require('../helpers/isNaN'); | ||
var isFinite = require('../helpers/isFinite'); | ||
var valueToFloat32Bytes = require('../helpers/valueToFloat32Bytes'); | ||
var valueToFloat64Bytes = require('../helpers/valueToFloat64Bytes'); | ||
var integerToNBytes = require('../helpers/integerToNBytes'); | ||
@@ -86,101 +69,6 @@ var keys = require('object-keys'); | ||
var rawBytes = []; | ||
var exponent; | ||
if (type === 'Float32') { // step 1 | ||
if (isNaN(value)) { | ||
return isLittleEndian ? [0, 0, 192, 127] : [127, 192, 0, 0]; // hardcoded | ||
} | ||
var leastSig; | ||
if (value === 0) { | ||
leastSig = SameValue(value, -0) ? 0x80 : 0; | ||
return isLittleEndian ? [0, 0, 0, leastSig] : [leastSig, 0, 0, 0]; | ||
} | ||
if (!isFinite(value)) { | ||
leastSig = value < 0 ? 255 : 127; | ||
return isLittleEndian ? [0, 0, 128, leastSig] : [leastSig, 128, 0, 0]; | ||
} | ||
var sign = value < 0 ? 1 : 0; | ||
value = abs(value); // eslint-disable-line no-param-reassign | ||
exponent = 0; | ||
while (value >= 2) { | ||
exponent += 1; | ||
value /= 2; // eslint-disable-line no-param-reassign | ||
} | ||
while (value < 1) { | ||
exponent -= 1; | ||
value *= 2; // eslint-disable-line no-param-reassign | ||
} | ||
var mantissa = value - 1; | ||
mantissa *= $pow(2, 23); | ||
mantissa = $floor(mantissa); | ||
exponent += 127; | ||
exponent = exponent << 23; | ||
var result = sign << 31; | ||
result |= exponent; | ||
result |= mantissa; | ||
var byte0 = result & 255; | ||
result = result >> 8; | ||
var byte1 = result & 255; | ||
result = result >> 8; | ||
var byte2 = result & 255; | ||
result = result >> 8; | ||
var byte3 = result & 255; | ||
if (isLittleEndian) { | ||
return [byte0, byte1, byte2, byte3]; | ||
} | ||
return [byte3, byte2, byte1, byte0]; | ||
return valueToFloat32Bytes(value, isLittleEndian); | ||
} else if (type === 'Float64') { // step 2 | ||
if (value === 0) { | ||
leastSig = Object.is(value, -0) ? 0x80 : 0; | ||
return isLittleEndian ? [0, 0, 0, 0, 0, 0, 0, leastSig] : [leastSig, 0, 0, 0, 0, 0, 0, 0]; | ||
} | ||
if (isNaN(value)) { | ||
return isLittleEndian ? [0, 0, 0, 0, 0, 0, 248, 127] : [127, 248, 0, 0, 0, 0, 0, 0]; | ||
} | ||
if (!isFinite(value)) { | ||
var infBytes = value < 0 ? [0, 0, 0, 0, 0, 0, 240, 255] : [0, 0, 0, 0, 0, 0, 240, 127]; | ||
return isLittleEndian ? infBytes : $reverse(infBytes); | ||
} | ||
var isNegative = value < 0; | ||
if (isNegative) { value = -value; } // eslint-disable-line no-param-reassign | ||
exponent = $floor($log2(value)); | ||
var significand = (value / $pow(2, exponent)) - 1; | ||
var bitString = ''; | ||
for (var i = 0; i < 52; i++) { | ||
significand *= 2; | ||
if (significand >= 1) { | ||
bitString += '1'; | ||
significand -= 1; | ||
} else { | ||
bitString += '0'; | ||
} | ||
} | ||
exponent += 1023; | ||
var exponentBits = $numberToString(exponent, 2); | ||
while (exponentBits.length < 11) { exponentBits = '0' + exponentBits; } | ||
var fullBitString = (isNegative ? '1' : '0') + exponentBits + bitString; | ||
while (fullBitString.length < 64) { fullBitString = '0' + fullBitString; } | ||
for (i = 0; i < 8; i++) { | ||
rawBytes[i] = $parseInt($strSlice(fullBitString, i * 8, (i + 1) * 8), 2); | ||
} | ||
return isLittleEndian ? $reverse(rawBytes) : rawBytes; | ||
return valueToFloat64Bytes(value, isLittleEndian); | ||
} // step 3 | ||
@@ -194,21 +82,3 @@ | ||
var isBigInt = type === 'BigInt64' || type === 'BigUint64'; | ||
/* | ||
if (intValue >= 0) { // step 3.d | ||
// Let rawBytes be a List containing the n-byte binary encoding of intValue. If isLittleEndian is false, the bytes are ordered in big endian order. Otherwise, the bytes are ordered in little endian order. | ||
} else { // step 3.e | ||
// Let rawBytes be a List containing the n-byte binary 2's complement encoding of intValue. If isLittleEndian is false, the bytes are ordered in big endian order. Otherwise, the bytes are ordered in little endian order. | ||
} | ||
*/ | ||
if (intValue < 0) { | ||
intValue = intValue >>> 0; | ||
} | ||
var OxFF = isBigInt ? $BigInt(0xFF) : 0xFF; | ||
var eight = isBigInt ? $BigInt(8) : 8; | ||
for (i = 0; i < n; i++) { | ||
rawBytes[isLittleEndian ? i : n - 1 - i] = $Number(intValue & OxFF); | ||
intValue = intValue >> eight; | ||
} | ||
return rawBytes; // step 4 | ||
return integerToNBytes(intValue, n, isLittleEndian); // step 3.d, 3.e, 4 | ||
}; |
@@ -6,7 +6,5 @@ 'use strict'; | ||
var $pow = GetIntrinsic('%Math.pow%'); | ||
var $RangeError = GetIntrinsic('%RangeError%'); | ||
var $SyntaxError = GetIntrinsic('%SyntaxError%'); | ||
var $TypeError = GetIntrinsic('%TypeError%'); | ||
var $Number = GetIntrinsic('%Number%'); | ||
var $BigInt = GetIntrinsic('%BigInt%', true); | ||
@@ -20,2 +18,5 @@ | ||
var bytesAsFloat32 = require('../helpers/bytesAsFloat32'); | ||
var bytesAsFloat64 = require('../helpers/bytesAsFloat64'); | ||
var bytesAsInteger = require('../helpers/bytesAsInteger'); | ||
var every = require('../helpers/every'); | ||
@@ -77,94 +78,10 @@ var isByteValue = require('../helpers/isByteValue'); | ||
if (type === 'Float32') { // step 3 | ||
// return new Float32Array(new Uint8Array(rawBytes).buffer)[0]; | ||
/* | ||
Let value be the byte elements of rawBytes concatenated and interpreted as a little-endian bit string encoding of an IEEE 754-2008 binary32 value. | ||
If value is an IEEE 754-2008 binary32 NaN value, return the NaN Number value. | ||
Return the Number value that corresponds to value. | ||
*/ | ||
var sign = rawBytes[3] & 0x80 ? -1 : 1; // Check the sign bit | ||
var exponent = ((rawBytes[3] & 0x7F) << 1) | ||
| (rawBytes[2] >> 7); // Combine bits for exponent | ||
var mantissa = ((rawBytes[2] & 0x7F) << 16) | ||
| (rawBytes[1] << 8) | ||
| rawBytes[0]; // Combine bits for mantissa | ||
if (exponent === 0 && mantissa === 0) { | ||
return sign === 1 ? 0 : -0; | ||
} | ||
if (exponent === 0xFF && mantissa === 0) { | ||
return sign === 1 ? Infinity : -Infinity; | ||
} | ||
if (exponent === 0xFF && mantissa !== 0) { | ||
return NaN; | ||
} | ||
exponent -= 127; // subtract the bias | ||
if (exponent === -127) { | ||
return sign * mantissa * $pow(2, -126 - 23); | ||
} | ||
return sign * (1 + (mantissa * $pow(2, -23))) * $pow(2, exponent); | ||
return bytesAsFloat32(rawBytes); | ||
} | ||
if (type === 'Float64') { // step 4 | ||
// return new Float64Array(new Uint8Array(rawBytes).buffer)[0]; | ||
/* | ||
Let value be the byte elements of rawBytes concatenated and interpreted as a little-endian bit string encoding of an IEEE 754-2008 binary64 value. | ||
If value is an IEEE 754-2008 binary64 NaN value, return the NaN Number value. | ||
Return the Number value that corresponds to value. | ||
*/ | ||
var sign = rawBytes[7] & 0x80 ? -1 : 1; // first bit | ||
var exponent = ((rawBytes[7] & 0x7F) << 4) // 7 bits from index 7 | ||
| ((rawBytes[6] & 0xF0) >> 4); // 4 bits from index 6 | ||
var mantissa = ((rawBytes[6] & 0x0F) * 0x1000000000000) // 4 bits from index 6 | ||
+ (rawBytes[5] * 0x10000000000) // 8 bits from index 5 | ||
+ (rawBytes[4] * 0x100000000) // 8 bits from index 4 | ||
+ (rawBytes[3] * 0x1000000) // 8 bits from index 3 | ||
+ (rawBytes[2] * 0x10000) // 8 bits from index 2 | ||
+ (rawBytes[1] * 0x100) // 8 bits from index 1 | ||
+ rawBytes[0]; // 8 bits from index 0 | ||
if (exponent === 0 && mantissa === 0) { | ||
return sign * 0; | ||
} | ||
if (exponent === 0x7FF && mantissa !== 0) { | ||
return NaN; | ||
} | ||
if (exponent === 0x7FF && mantissa === 0) { | ||
return sign * Infinity; | ||
} | ||
exponent -= 1023; // subtract the bias | ||
// Handle subnormal numbers | ||
if (exponent === -1023) { | ||
return sign * mantissa * 5e-324; // $pow(2, -1022 - 52) | ||
} | ||
return sign * (1 + (mantissa / 0x10000000000000)) * $pow(2, exponent); | ||
return bytesAsFloat64(rawBytes); | ||
} | ||
var Z = isBigInt ? $BigInt : $Number; | ||
// this is common to both branches | ||
var intValue = Z(0); | ||
for (var i = 0; i < rawBytes.length; i++) { | ||
intValue += Z(rawBytes[i]) * Z($pow(2, 8 * i)); | ||
} | ||
/* | ||
Let intValue be the byte elements of rawBytes concatenated and interpreted as a bit string encoding of an unsigned little-endian binary number. | ||
*/ | ||
if (!IsUnsignedElementType(type)) { // steps 5-6 | ||
// Let intValue be the byte elements of rawBytes concatenated and interpreted as a bit string encoding of a binary little-endian 2's complement number of bit length elementSize × 8. | ||
var bitLength = elementSize * 8; | ||
if (rawBytes[elementSize - 1] & 0x80) { | ||
intValue -= Z($pow(2, bitLength)); | ||
} | ||
} | ||
return intValue; // step 7 | ||
return bytesAsInteger(rawBytes, elementSize, IsUnsignedElementType(type), isBigInt); | ||
}; |
@@ -8,5 +8,6 @@ 'use strict'; | ||
var IsInteger = require('./IsInteger'); | ||
var Type = require('./Type'); | ||
var isInteger = require('../helpers/isInteger'); | ||
var $charAt = callBound('String.prototype.charAt'); | ||
@@ -20,3 +21,3 @@ | ||
} | ||
if (!IsInteger(q)) { | ||
if (!isInteger(q)) { | ||
throw new $TypeError('Assertion failed: `q` must be an integer'); | ||
@@ -23,0 +24,0 @@ } |
@@ -22,3 +22,3 @@ 'use strict'; | ||
// eslint-disable-next-line max-lines-per-function, max-statements, max-params | ||
// eslint-disable-next-line max-lines-per-function, max-statements | ||
module.exports = function ValidateAndApplyPropertyDescriptor(O, P, extensible, Desc, current) { | ||
@@ -25,0 +25,0 @@ // this uses the ES2017+ logic, since it fixes a number of bugs in the ES2015 logic. |
@@ -6,5 +6,5 @@ 'use strict'; | ||
var CodePointAt = require('./CodePointAt'); | ||
var IsIntegralNumber = require('./IsIntegralNumber'); | ||
var Type = require('./Type'); | ||
var isInteger = require('../helpers/isInteger'); | ||
var MAX_SAFE_INTEGER = require('../helpers/maxSafeInteger'); | ||
@@ -20,3 +20,3 @@ | ||
} | ||
if (!IsIntegralNumber(index) || index < 0 || index > MAX_SAFE_INTEGER) { | ||
if (!isInteger(index) || index < 0 || index > MAX_SAFE_INTEGER) { | ||
throw new $TypeError('Assertion failed: `length` must be an integer >= 0 and <= 2**53'); | ||
@@ -23,0 +23,0 @@ } |
@@ -10,3 +10,3 @@ 'use strict'; | ||
var IsIntegralNumber = require('./IsIntegralNumber'); | ||
var isInteger = require('../helpers/isInteger'); | ||
@@ -29,3 +29,3 @@ var MAX_ARRAY_LENGTH = Math.pow(2, 32) - 1; | ||
module.exports = function ArrayCreate(length) { | ||
if (!IsIntegralNumber(length) || length < 0) { | ||
if (!isInteger(length) || length < 0) { | ||
throw new $TypeError('Assertion failed: `length` must be an integer Number >= 0'); | ||
@@ -32,0 +32,0 @@ } |
@@ -12,9 +12,10 @@ 'use strict'; | ||
var IsConstructor = require('./IsConstructor'); | ||
var IsIntegralNumber = require('./IsIntegralNumber'); | ||
var Type = require('./Type'); | ||
var isInteger = require('../helpers/isInteger'); | ||
// https://262.ecma-international.org/12.0/#sec-arrayspeciescreate | ||
module.exports = function ArraySpeciesCreate(originalArray, length) { | ||
if (!IsIntegralNumber(length) || length < 0) { | ||
if (!isInteger(length) || length < 0) { | ||
throw new $TypeError('Assertion failed: length must be an integer >= 0'); | ||
@@ -21,0 +22,0 @@ } |
@@ -19,3 +19,2 @@ 'use strict'; | ||
// eslint-disable-next-line max-params | ||
module.exports = function FlattenIntoArray(target, source, sourceLen, start, depth) { | ||
@@ -22,0 +21,0 @@ var mapperFunction; |
@@ -22,3 +22,2 @@ 'use strict'; | ||
var IsArray = require('./IsArray'); | ||
var IsIntegralNumber = require('./IsIntegralNumber'); | ||
var ToObject = require('./ToObject'); | ||
@@ -28,8 +27,5 @@ var ToString = require('./ToString'); | ||
var canDistinguishSparseFromUndefined = 0 in [undefined]; // IE 6 - 8 have a bug where this returns false | ||
var isInteger = require('../helpers/isInteger'); | ||
var isStringOrHole = require('../helpers/isStringOrHole'); | ||
var isStringOrHole = function (capture, index, arr) { | ||
return Type(capture) === 'String' || (canDistinguishSparseFromUndefined ? !(index in arr) : Type(capture) === 'Undefined'); | ||
}; | ||
// http://www.ecma-international.org/ecma-262/12.0/#sec-getsubstitution | ||
@@ -49,3 +45,3 @@ | ||
if (!IsIntegralNumber(position) || position < 0 || position > stringLength) { | ||
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)); | ||
@@ -52,0 +48,0 @@ } |
'use strict'; | ||
var abs = require('./abs'); | ||
var floor = require('./floor'); | ||
var Type = require('./Type'); | ||
var isInteger = require('../helpers/isInteger'); | ||
var $isNaN = require('../helpers/isNaN'); | ||
var $isFinite = require('../helpers/isFinite'); | ||
// https://262.ecma-international.org/12.0/#sec-isinteger | ||
// https://tc39.es/ecma262/#sec-isintegralnumber | ||
module.exports = function IsIntegralNumber(argument) { | ||
if (Type(argument) !== 'Number' || $isNaN(argument) || !$isFinite(argument)) { | ||
return false; | ||
} | ||
var absValue = abs(argument); | ||
return floor(absValue) === absValue; | ||
return isInteger(argument); | ||
}; |
@@ -5,23 +5,5 @@ 'use strict'; | ||
var $floor = GetIntrinsic('%Math.floor%'); | ||
var $log = GetIntrinsic('%Math.log%'); | ||
var $log2E = GetIntrinsic('%Math.LOG2E%'); | ||
var $log2 = GetIntrinsic('%Math.log2%', true) || function log2(x) { | ||
return $log(x) * $log2E; | ||
}; | ||
var $parseInt = GetIntrinsic('%parseInt%'); | ||
var $pow = GetIntrinsic('%Math.pow%'); | ||
var $Number = GetIntrinsic('%Number%'); | ||
var $TypeError = GetIntrinsic('%TypeError%'); | ||
var $BigInt = GetIntrinsic('%BigInt%', true); | ||
var callBound = require('call-bind/callBound'); | ||
var $reverse = callBound('Array.prototype.reverse'); | ||
var $numberToString = callBound('Number.prototype.toString'); | ||
var $strSlice = callBound('String.prototype.slice'); | ||
var abs = require('./abs'); | ||
var hasOwnProperty = require('./HasOwnProperty'); | ||
var SameValue = require('./SameValue'); | ||
var ToBigInt64 = require('./ToBigInt64'); | ||
@@ -38,4 +20,5 @@ var ToBigUint64 = require('./ToBigUint64'); | ||
var isNaN = require('../helpers/isNaN'); | ||
var isFinite = require('../helpers/isFinite'); | ||
var valueToFloat32Bytes = require('../helpers/valueToFloat32Bytes'); | ||
var valueToFloat64Bytes = require('../helpers/valueToFloat64Bytes'); | ||
var integerToNBytes = require('../helpers/integerToNBytes'); | ||
@@ -86,101 +69,6 @@ var keys = require('object-keys'); | ||
var rawBytes = []; | ||
var exponent; | ||
if (type === 'Float32') { // step 1 | ||
if (isNaN(value)) { | ||
return isLittleEndian ? [0, 0, 192, 127] : [127, 192, 0, 0]; // hardcoded | ||
} | ||
var leastSig; | ||
if (value === 0) { | ||
leastSig = SameValue(value, -0) ? 0x80 : 0; | ||
return isLittleEndian ? [0, 0, 0, leastSig] : [leastSig, 0, 0, 0]; | ||
} | ||
if (!isFinite(value)) { | ||
leastSig = value < 0 ? 255 : 127; | ||
return isLittleEndian ? [0, 0, 128, leastSig] : [leastSig, 128, 0, 0]; | ||
} | ||
var sign = value < 0 ? 1 : 0; | ||
value = abs(value); // eslint-disable-line no-param-reassign | ||
exponent = 0; | ||
while (value >= 2) { | ||
exponent += 1; | ||
value /= 2; // eslint-disable-line no-param-reassign | ||
} | ||
while (value < 1) { | ||
exponent -= 1; | ||
value *= 2; // eslint-disable-line no-param-reassign | ||
} | ||
var mantissa = value - 1; | ||
mantissa *= $pow(2, 23); | ||
mantissa = $floor(mantissa); | ||
exponent += 127; | ||
exponent = exponent << 23; | ||
var result = sign << 31; | ||
result |= exponent; | ||
result |= mantissa; | ||
var byte0 = result & 255; | ||
result = result >> 8; | ||
var byte1 = result & 255; | ||
result = result >> 8; | ||
var byte2 = result & 255; | ||
result = result >> 8; | ||
var byte3 = result & 255; | ||
if (isLittleEndian) { | ||
return [byte0, byte1, byte2, byte3]; | ||
} | ||
return [byte3, byte2, byte1, byte0]; | ||
return valueToFloat32Bytes(value, isLittleEndian); | ||
} else if (type === 'Float64') { // step 2 | ||
if (value === 0) { | ||
leastSig = Object.is(value, -0) ? 0x80 : 0; | ||
return isLittleEndian ? [0, 0, 0, 0, 0, 0, 0, leastSig] : [leastSig, 0, 0, 0, 0, 0, 0, 0]; | ||
} | ||
if (isNaN(value)) { | ||
return isLittleEndian ? [0, 0, 0, 0, 0, 0, 248, 127] : [127, 248, 0, 0, 0, 0, 0, 0]; | ||
} | ||
if (!isFinite(value)) { | ||
var infBytes = value < 0 ? [0, 0, 0, 0, 0, 0, 240, 255] : [0, 0, 0, 0, 0, 0, 240, 127]; | ||
return isLittleEndian ? infBytes : $reverse(infBytes); | ||
} | ||
var isNegative = value < 0; | ||
if (isNegative) { value = -value; } // eslint-disable-line no-param-reassign | ||
exponent = $floor($log2(value)); | ||
var significand = (value / $pow(2, exponent)) - 1; | ||
var bitString = ''; | ||
for (var i = 0; i < 52; i++) { | ||
significand *= 2; | ||
if (significand >= 1) { | ||
bitString += '1'; | ||
significand -= 1; | ||
} else { | ||
bitString += '0'; | ||
} | ||
} | ||
exponent += 1023; | ||
var exponentBits = $numberToString(exponent, 2); | ||
while (exponentBits.length < 11) { exponentBits = '0' + exponentBits; } | ||
var fullBitString = (isNegative ? '1' : '0') + exponentBits + bitString; | ||
while (fullBitString.length < 64) { fullBitString = '0' + fullBitString; } | ||
for (i = 0; i < 8; i++) { | ||
rawBytes[i] = $parseInt($strSlice(fullBitString, i * 8, (i + 1) * 8), 2); | ||
} | ||
return isLittleEndian ? $reverse(rawBytes) : rawBytes; | ||
return valueToFloat64Bytes(value, isLittleEndian); | ||
} // step 3 | ||
@@ -194,21 +82,3 @@ | ||
var isBigInt = type === 'BigInt64' || type === 'BigUint64'; | ||
/* | ||
if (intValue >= 0) { // step 3.d | ||
// Let rawBytes be a List containing the n-byte binary encoding of intValue. If isLittleEndian is false, the bytes are ordered in big endian order. Otherwise, the bytes are ordered in little endian order. | ||
} else { // step 3.e | ||
// Let rawBytes be a List containing the n-byte binary 2's complement encoding of intValue. If isLittleEndian is false, the bytes are ordered in big endian order. Otherwise, the bytes are ordered in little endian order. | ||
} | ||
*/ | ||
if (intValue < 0) { | ||
intValue = intValue >>> 0; | ||
} | ||
var OxFF = isBigInt ? $BigInt(0xFF) : 0xFF; | ||
var eight = isBigInt ? $BigInt(8) : 8; | ||
for (i = 0; i < n; i++) { | ||
rawBytes[isLittleEndian ? i : n - 1 - i] = $Number(intValue & OxFF); | ||
intValue = intValue >> eight; | ||
} | ||
return rawBytes; // step 4 | ||
return integerToNBytes(intValue, n, isLittleEndian); // step 3.d, 3.e, 4 | ||
}; |
@@ -6,7 +6,5 @@ 'use strict'; | ||
var $pow = GetIntrinsic('%Math.pow%'); | ||
var $RangeError = GetIntrinsic('%RangeError%'); | ||
var $SyntaxError = GetIntrinsic('%SyntaxError%'); | ||
var $TypeError = GetIntrinsic('%TypeError%'); | ||
var $Number = GetIntrinsic('%Number%'); | ||
var $BigInt = GetIntrinsic('%BigInt%', true); | ||
@@ -20,2 +18,5 @@ | ||
var bytesAsFloat32 = require('../helpers/bytesAsFloat32'); | ||
var bytesAsFloat64 = require('../helpers/bytesAsFloat64'); | ||
var bytesAsInteger = require('../helpers/bytesAsInteger'); | ||
var every = require('../helpers/every'); | ||
@@ -77,94 +78,10 @@ var isByteValue = require('../helpers/isByteValue'); | ||
if (type === 'Float32') { // step 3 | ||
// return new Float32Array(new Uint8Array(rawBytes).buffer)[0]; | ||
/* | ||
Let value be the byte elements of rawBytes concatenated and interpreted as a little-endian bit string encoding of an IEEE 754-2008 binary32 value. | ||
If value is an IEEE 754-2008 binary32 NaN value, return the NaN Number value. | ||
Return the Number value that corresponds to value. | ||
*/ | ||
var sign = rawBytes[3] & 0x80 ? -1 : 1; // Check the sign bit | ||
var exponent = ((rawBytes[3] & 0x7F) << 1) | ||
| (rawBytes[2] >> 7); // Combine bits for exponent | ||
var mantissa = ((rawBytes[2] & 0x7F) << 16) | ||
| (rawBytes[1] << 8) | ||
| rawBytes[0]; // Combine bits for mantissa | ||
if (exponent === 0 && mantissa === 0) { | ||
return sign === 1 ? 0 : -0; | ||
} | ||
if (exponent === 0xFF && mantissa === 0) { | ||
return sign === 1 ? Infinity : -Infinity; | ||
} | ||
if (exponent === 0xFF && mantissa !== 0) { | ||
return NaN; | ||
} | ||
exponent -= 127; // subtract the bias | ||
if (exponent === -127) { | ||
return sign * mantissa * $pow(2, -126 - 23); | ||
} | ||
return sign * (1 + (mantissa * $pow(2, -23))) * $pow(2, exponent); | ||
return bytesAsFloat32(rawBytes); | ||
} | ||
if (type === 'Float64') { // step 4 | ||
// return new Float64Array(new Uint8Array(rawBytes).buffer)[0]; | ||
/* | ||
Let value be the byte elements of rawBytes concatenated and interpreted as a little-endian bit string encoding of an IEEE 754-2008 binary64 value. | ||
If value is an IEEE 754-2008 binary64 NaN value, return the NaN Number value. | ||
Return the Number value that corresponds to value. | ||
*/ | ||
var sign = rawBytes[7] & 0x80 ? -1 : 1; // first bit | ||
var exponent = ((rawBytes[7] & 0x7F) << 4) // 7 bits from index 7 | ||
| ((rawBytes[6] & 0xF0) >> 4); // 4 bits from index 6 | ||
var mantissa = ((rawBytes[6] & 0x0F) * 0x1000000000000) // 4 bits from index 6 | ||
+ (rawBytes[5] * 0x10000000000) // 8 bits from index 5 | ||
+ (rawBytes[4] * 0x100000000) // 8 bits from index 4 | ||
+ (rawBytes[3] * 0x1000000) // 8 bits from index 3 | ||
+ (rawBytes[2] * 0x10000) // 8 bits from index 2 | ||
+ (rawBytes[1] * 0x100) // 8 bits from index 1 | ||
+ rawBytes[0]; // 8 bits from index 0 | ||
if (exponent === 0 && mantissa === 0) { | ||
return sign * 0; | ||
} | ||
if (exponent === 0x7FF && mantissa !== 0) { | ||
return NaN; | ||
} | ||
if (exponent === 0x7FF && mantissa === 0) { | ||
return sign * Infinity; | ||
} | ||
exponent -= 1023; // subtract the bias | ||
// Handle subnormal numbers | ||
if (exponent === -1023) { | ||
return sign * mantissa * 5e-324; // $pow(2, -1022 - 52) | ||
} | ||
return sign * (1 + (mantissa / 0x10000000000000)) * $pow(2, exponent); | ||
return bytesAsFloat64(rawBytes); | ||
} | ||
var Z = isBigInt ? $BigInt : $Number; | ||
// this is common to both branches | ||
var intValue = Z(0); | ||
for (var i = 0; i < rawBytes.length; i++) { | ||
intValue += Z(rawBytes[i]) * Z($pow(2, 8 * i)); | ||
} | ||
/* | ||
Let intValue be the byte elements of rawBytes concatenated and interpreted as a bit string encoding of an unsigned little-endian binary number. | ||
*/ | ||
if (!IsUnsignedElementType(type)) { // steps 5-6 | ||
// Let intValue be the byte elements of rawBytes concatenated and interpreted as a bit string encoding of a binary little-endian 2's complement number of bit length elementSize × 8. | ||
var bitLength = elementSize * 8; | ||
if (rawBytes[elementSize - 1] & 0x80) { | ||
intValue -= Z($pow(2, bitLength)); | ||
} | ||
} | ||
return intValue; // step 7 | ||
return bytesAsInteger(rawBytes, elementSize, IsUnsignedElementType(type), isBigInt); | ||
}; |
@@ -10,5 +10,6 @@ 'use strict'; | ||
var IsExtensible = require('./IsExtensible'); | ||
var IsIntegralNumber = require('./IsIntegralNumber'); | ||
var Type = require('./Type'); | ||
var isInteger = require('../helpers/isInteger'); | ||
// https://262.ecma-international.org/12.0/#sec-setfunctionlength | ||
@@ -23,3 +24,3 @@ | ||
} | ||
if (length !== Infinity && (!IsIntegralNumber(length) || length < 0)) { | ||
if (length !== Infinity && (!isInteger(length) || length < 0)) { | ||
throw new $TypeError('Assertion failed: `length` must be ∞, or an integer >= 0'); | ||
@@ -26,0 +27,0 @@ } |
@@ -8,5 +8,6 @@ 'use strict'; | ||
var IsIntegralNumber = require('./IsIntegralNumber'); | ||
var Type = require('./Type'); | ||
var isInteger = require('../helpers/isInteger'); | ||
var $charAt = callBound('String.prototype.charAt'); | ||
@@ -20,3 +21,3 @@ | ||
} | ||
if (!IsIntegralNumber(q)) { | ||
if (!isInteger(q)) { | ||
throw new $TypeError('Assertion failed: `q` must be an integer'); | ||
@@ -23,0 +24,0 @@ } |
@@ -8,5 +8,6 @@ 'use strict'; | ||
var IsIntegralNumber = require('./IsIntegralNumber'); | ||
var Type = require('./Type'); | ||
var isInteger = require('../helpers/isInteger'); | ||
var $slice = callBound('String.prototype.slice'); | ||
@@ -23,3 +24,3 @@ | ||
} | ||
if (!IsIntegralNumber(fromIndex) || fromIndex < 0) { | ||
if (!isInteger(fromIndex) || fromIndex < 0) { | ||
throw new $TypeError('Assertion failed: `fromIndex` must be a non-negative integer'); | ||
@@ -26,0 +27,0 @@ } |
@@ -7,5 +7,6 @@ 'use strict'; | ||
var IsIntegralNumber = require('./IsIntegralNumber'); | ||
var Type = require('./Type'); | ||
var isInteger = require('../helpers/isInteger'); | ||
var callBound = require('call-bind/callBound'); | ||
@@ -17,3 +18,3 @@ | ||
module.exports = function substring(S, inclusiveStart, exclusiveEnd) { | ||
if (Type(S) !== 'String' || !IsIntegralNumber(inclusiveStart) || (arguments.length > 2 && !IsIntegralNumber(exclusiveEnd))) { | ||
if (Type(S) !== 'String' || !isInteger(inclusiveStart) || (arguments.length > 2 && !isInteger(exclusiveEnd))) { | ||
throw new $TypeError('`S` must be a String, and `inclusiveStart` and `exclusiveEnd` must be integers'); | ||
@@ -20,0 +21,0 @@ } |
@@ -22,3 +22,3 @@ 'use strict'; | ||
// eslint-disable-next-line max-lines-per-function, max-statements, max-params | ||
// eslint-disable-next-line max-lines-per-function, max-statements | ||
module.exports = function ValidateAndApplyPropertyDescriptor(O, P, extensible, Desc, current) { | ||
@@ -25,0 +25,0 @@ // this uses the ES2017+ logic, since it fixes a number of bugs in the ES2015 logic. |
@@ -6,5 +6,5 @@ 'use strict'; | ||
var CodePointAt = require('./CodePointAt'); | ||
var IsIntegralNumber = require('./IsIntegralNumber'); | ||
var Type = require('./Type'); | ||
var isInteger = require('../helpers/isInteger'); | ||
var MAX_SAFE_INTEGER = require('../helpers/maxSafeInteger'); | ||
@@ -20,3 +20,3 @@ | ||
} | ||
if (!IsIntegralNumber(index) || index < 0 || index > MAX_SAFE_INTEGER) { | ||
if (!isInteger(index) || index < 0 || index > MAX_SAFE_INTEGER) { | ||
throw new $TypeError('Assertion failed: `length` must be an integer >= 0 and <= 2**53'); | ||
@@ -23,0 +23,0 @@ } |
@@ -10,3 +10,3 @@ 'use strict'; | ||
var IsIntegralNumber = require('./IsIntegralNumber'); | ||
var isInteger = require('../helpers/isInteger'); | ||
@@ -29,3 +29,3 @@ var MAX_ARRAY_LENGTH = Math.pow(2, 32) - 1; | ||
module.exports = function ArrayCreate(length) { | ||
if (!IsIntegralNumber(length) || length < 0) { | ||
if (!isInteger(length) || length < 0) { | ||
throw new $TypeError('Assertion failed: `length` must be an integer Number >= 0'); | ||
@@ -32,0 +32,0 @@ } |
@@ -12,9 +12,10 @@ 'use strict'; | ||
var IsConstructor = require('./IsConstructor'); | ||
var IsIntegralNumber = require('./IsIntegralNumber'); | ||
var Type = require('./Type'); | ||
var isInteger = require('../helpers/isInteger'); | ||
// https://262.ecma-international.org/12.0/#sec-arrayspeciescreate | ||
module.exports = function ArraySpeciesCreate(originalArray, length) { | ||
if (!IsIntegralNumber(length) || length < 0) { | ||
if (!isInteger(length) || length < 0) { | ||
throw new $TypeError('Assertion failed: length must be an integer >= 0'); | ||
@@ -21,0 +22,0 @@ } |
@@ -19,3 +19,2 @@ 'use strict'; | ||
// eslint-disable-next-line max-params | ||
module.exports = function FlattenIntoArray(target, source, sourceLen, start, depth) { | ||
@@ -22,0 +21,0 @@ var mapperFunction; |
@@ -8,6 +8,7 @@ 'use strict'; | ||
var IsIntegralNumber = require('./IsIntegralNumber'); | ||
var StringToCodePoints = require('./StringToCodePoints'); | ||
var Type = require('./Type'); | ||
var isInteger = require('../helpers/isInteger'); | ||
var $indexOf = callBound('String.prototype.indexOf'); | ||
@@ -21,3 +22,3 @@ | ||
} | ||
if (!IsIntegralNumber(e) || e < 0) { | ||
if (!isInteger(e) || e < 0) { | ||
throw new $TypeError('Assertion failed: `e` must be a non-negative integer'); | ||
@@ -24,0 +25,0 @@ } |
@@ -22,3 +22,2 @@ 'use strict'; | ||
var IsArray = require('./IsArray'); | ||
var IsIntegralNumber = require('./IsIntegralNumber'); | ||
var ToObject = require('./ToObject'); | ||
@@ -28,8 +27,5 @@ var ToString = require('./ToString'); | ||
var canDistinguishSparseFromUndefined = 0 in [undefined]; // IE 6 - 8 have a bug where this returns false | ||
var isInteger = require('../helpers/isInteger'); | ||
var isStringOrHole = require('../helpers/isStringOrHole'); | ||
var isStringOrHole = function (capture, index, arr) { | ||
return Type(capture) === 'String' || (canDistinguishSparseFromUndefined ? !(index in arr) : Type(capture) === 'Undefined'); | ||
}; | ||
// http://www.ecma-international.org/ecma-262/12.0/#sec-getsubstitution | ||
@@ -49,3 +45,3 @@ | ||
if (!IsIntegralNumber(position) || position < 0 || position > stringLength) { | ||
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)); | ||
@@ -52,0 +48,0 @@ } |
'use strict'; | ||
var abs = require('./abs'); | ||
var floor = require('./floor'); | ||
var Type = require('./Type'); | ||
var isInteger = require('../helpers/isInteger'); | ||
var $isNaN = require('../helpers/isNaN'); | ||
var $isFinite = require('../helpers/isFinite'); | ||
// https://262.ecma-international.org/12.0/#sec-isinteger | ||
// https://tc39.es/ecma262/#sec-isintegralnumber | ||
module.exports = function IsIntegralNumber(argument) { | ||
if (Type(argument) !== 'Number' || $isNaN(argument) || !$isFinite(argument)) { | ||
return false; | ||
} | ||
var absValue = abs(argument); | ||
return floor(absValue) === absValue; | ||
return isInteger(argument); | ||
}; |
@@ -5,23 +5,5 @@ 'use strict'; | ||
var $floor = GetIntrinsic('%Math.floor%'); | ||
var $log = GetIntrinsic('%Math.log%'); | ||
var $log2E = GetIntrinsic('%Math.LOG2E%'); | ||
var $log2 = GetIntrinsic('%Math.log2%', true) || function log2(x) { | ||
return $log(x) * $log2E; | ||
}; | ||
var $parseInt = GetIntrinsic('%parseInt%'); | ||
var $pow = GetIntrinsic('%Math.pow%'); | ||
var $Number = GetIntrinsic('%Number%'); | ||
var $TypeError = GetIntrinsic('%TypeError%'); | ||
var $BigInt = GetIntrinsic('%BigInt%', true); | ||
var callBound = require('call-bind/callBound'); | ||
var $reverse = callBound('Array.prototype.reverse'); | ||
var $numberToString = callBound('Number.prototype.toString'); | ||
var $strSlice = callBound('String.prototype.slice'); | ||
var abs = require('./abs'); | ||
var hasOwnProperty = require('./HasOwnProperty'); | ||
var SameValue = require('./SameValue'); | ||
var ToBigInt64 = require('./ToBigInt64'); | ||
@@ -38,4 +20,5 @@ var ToBigUint64 = require('./ToBigUint64'); | ||
var isNaN = require('../helpers/isNaN'); | ||
var isFinite = require('../helpers/isFinite'); | ||
var valueToFloat32Bytes = require('../helpers/valueToFloat32Bytes'); | ||
var valueToFloat64Bytes = require('../helpers/valueToFloat64Bytes'); | ||
var integerToNBytes = require('../helpers/integerToNBytes'); | ||
@@ -86,101 +69,6 @@ var keys = require('object-keys'); | ||
var rawBytes = []; | ||
var exponent; | ||
if (type === 'Float32') { // step 1 | ||
if (isNaN(value)) { | ||
return isLittleEndian ? [0, 0, 192, 127] : [127, 192, 0, 0]; // hardcoded | ||
} | ||
var leastSig; | ||
if (value === 0) { | ||
leastSig = SameValue(value, -0) ? 0x80 : 0; | ||
return isLittleEndian ? [0, 0, 0, leastSig] : [leastSig, 0, 0, 0]; | ||
} | ||
if (!isFinite(value)) { | ||
leastSig = value < 0 ? 255 : 127; | ||
return isLittleEndian ? [0, 0, 128, leastSig] : [leastSig, 128, 0, 0]; | ||
} | ||
var sign = value < 0 ? 1 : 0; | ||
value = abs(value); // eslint-disable-line no-param-reassign | ||
exponent = 0; | ||
while (value >= 2) { | ||
exponent += 1; | ||
value /= 2; // eslint-disable-line no-param-reassign | ||
} | ||
while (value < 1) { | ||
exponent -= 1; | ||
value *= 2; // eslint-disable-line no-param-reassign | ||
} | ||
var mantissa = value - 1; | ||
mantissa *= $pow(2, 23); | ||
mantissa = $floor(mantissa); | ||
exponent += 127; | ||
exponent = exponent << 23; | ||
var result = sign << 31; | ||
result |= exponent; | ||
result |= mantissa; | ||
var byte0 = result & 255; | ||
result = result >> 8; | ||
var byte1 = result & 255; | ||
result = result >> 8; | ||
var byte2 = result & 255; | ||
result = result >> 8; | ||
var byte3 = result & 255; | ||
if (isLittleEndian) { | ||
return [byte0, byte1, byte2, byte3]; | ||
} | ||
return [byte3, byte2, byte1, byte0]; | ||
return valueToFloat32Bytes(value, isLittleEndian); | ||
} else if (type === 'Float64') { // step 2 | ||
if (value === 0) { | ||
leastSig = Object.is(value, -0) ? 0x80 : 0; | ||
return isLittleEndian ? [0, 0, 0, 0, 0, 0, 0, leastSig] : [leastSig, 0, 0, 0, 0, 0, 0, 0]; | ||
} | ||
if (isNaN(value)) { | ||
return isLittleEndian ? [0, 0, 0, 0, 0, 0, 248, 127] : [127, 248, 0, 0, 0, 0, 0, 0]; | ||
} | ||
if (!isFinite(value)) { | ||
var infBytes = value < 0 ? [0, 0, 0, 0, 0, 0, 240, 255] : [0, 0, 0, 0, 0, 0, 240, 127]; | ||
return isLittleEndian ? infBytes : $reverse(infBytes); | ||
} | ||
var isNegative = value < 0; | ||
if (isNegative) { value = -value; } // eslint-disable-line no-param-reassign | ||
exponent = $floor($log2(value)); | ||
var significand = (value / $pow(2, exponent)) - 1; | ||
var bitString = ''; | ||
for (var i = 0; i < 52; i++) { | ||
significand *= 2; | ||
if (significand >= 1) { | ||
bitString += '1'; | ||
significand -= 1; | ||
} else { | ||
bitString += '0'; | ||
} | ||
} | ||
exponent += 1023; | ||
var exponentBits = $numberToString(exponent, 2); | ||
while (exponentBits.length < 11) { exponentBits = '0' + exponentBits; } | ||
var fullBitString = (isNegative ? '1' : '0') + exponentBits + bitString; | ||
while (fullBitString.length < 64) { fullBitString = '0' + fullBitString; } | ||
for (i = 0; i < 8; i++) { | ||
rawBytes[i] = $parseInt($strSlice(fullBitString, i * 8, (i + 1) * 8), 2); | ||
} | ||
return isLittleEndian ? $reverse(rawBytes) : rawBytes; | ||
return valueToFloat64Bytes(value, isLittleEndian); | ||
} // step 3 | ||
@@ -194,21 +82,3 @@ | ||
var isBigInt = type === 'BigInt64' || type === 'BigUint64'; | ||
/* | ||
if (intValue >= 0) { // step 3.d | ||
// Let rawBytes be a List containing the n-byte binary encoding of intValue. If isLittleEndian is false, the bytes are ordered in big endian order. Otherwise, the bytes are ordered in little endian order. | ||
} else { // step 3.e | ||
// Let rawBytes be a List containing the n-byte binary 2's complement encoding of intValue. If isLittleEndian is false, the bytes are ordered in big endian order. Otherwise, the bytes are ordered in little endian order. | ||
} | ||
*/ | ||
if (intValue < 0) { | ||
intValue = intValue >>> 0; | ||
} | ||
var OxFF = isBigInt ? $BigInt(0xFF) : 0xFF; | ||
var eight = isBigInt ? $BigInt(8) : 8; | ||
for (i = 0; i < n; i++) { | ||
rawBytes[isLittleEndian ? i : n - 1 - i] = $Number(intValue & OxFF); | ||
intValue = intValue >> eight; | ||
} | ||
return rawBytes; // step 4 | ||
return integerToNBytes(intValue, n, isLittleEndian); // step 3.d, 3.e, 4 | ||
}; |
@@ -6,7 +6,5 @@ 'use strict'; | ||
var $pow = GetIntrinsic('%Math.pow%'); | ||
var $RangeError = GetIntrinsic('%RangeError%'); | ||
var $SyntaxError = GetIntrinsic('%SyntaxError%'); | ||
var $TypeError = GetIntrinsic('%TypeError%'); | ||
var $Number = GetIntrinsic('%Number%'); | ||
var $BigInt = GetIntrinsic('%BigInt%', true); | ||
@@ -20,2 +18,5 @@ | ||
var bytesAsFloat32 = require('../helpers/bytesAsFloat32'); | ||
var bytesAsFloat64 = require('../helpers/bytesAsFloat64'); | ||
var bytesAsInteger = require('../helpers/bytesAsInteger'); | ||
var every = require('../helpers/every'); | ||
@@ -77,94 +78,10 @@ var isByteValue = require('../helpers/isByteValue'); | ||
if (type === 'Float32') { // step 3 | ||
// return new Float32Array(new Uint8Array(rawBytes).buffer)[0]; | ||
/* | ||
Let value be the byte elements of rawBytes concatenated and interpreted as a little-endian bit string encoding of an IEEE 754-2008 binary32 value. | ||
If value is an IEEE 754-2008 binary32 NaN value, return the NaN Number value. | ||
Return the Number value that corresponds to value. | ||
*/ | ||
var sign = rawBytes[3] & 0x80 ? -1 : 1; // Check the sign bit | ||
var exponent = ((rawBytes[3] & 0x7F) << 1) | ||
| (rawBytes[2] >> 7); // Combine bits for exponent | ||
var mantissa = ((rawBytes[2] & 0x7F) << 16) | ||
| (rawBytes[1] << 8) | ||
| rawBytes[0]; // Combine bits for mantissa | ||
if (exponent === 0 && mantissa === 0) { | ||
return sign === 1 ? 0 : -0; | ||
} | ||
if (exponent === 0xFF && mantissa === 0) { | ||
return sign === 1 ? Infinity : -Infinity; | ||
} | ||
if (exponent === 0xFF && mantissa !== 0) { | ||
return NaN; | ||
} | ||
exponent -= 127; // subtract the bias | ||
if (exponent === -127) { | ||
return sign * mantissa * $pow(2, -126 - 23); | ||
} | ||
return sign * (1 + (mantissa * $pow(2, -23))) * $pow(2, exponent); | ||
return bytesAsFloat32(rawBytes); | ||
} | ||
if (type === 'Float64') { // step 4 | ||
// return new Float64Array(new Uint8Array(rawBytes).buffer)[0]; | ||
/* | ||
Let value be the byte elements of rawBytes concatenated and interpreted as a little-endian bit string encoding of an IEEE 754-2008 binary64 value. | ||
If value is an IEEE 754-2008 binary64 NaN value, return the NaN Number value. | ||
Return the Number value that corresponds to value. | ||
*/ | ||
var sign = rawBytes[7] & 0x80 ? -1 : 1; // first bit | ||
var exponent = ((rawBytes[7] & 0x7F) << 4) // 7 bits from index 7 | ||
| ((rawBytes[6] & 0xF0) >> 4); // 4 bits from index 6 | ||
var mantissa = ((rawBytes[6] & 0x0F) * 0x1000000000000) // 4 bits from index 6 | ||
+ (rawBytes[5] * 0x10000000000) // 8 bits from index 5 | ||
+ (rawBytes[4] * 0x100000000) // 8 bits from index 4 | ||
+ (rawBytes[3] * 0x1000000) // 8 bits from index 3 | ||
+ (rawBytes[2] * 0x10000) // 8 bits from index 2 | ||
+ (rawBytes[1] * 0x100) // 8 bits from index 1 | ||
+ rawBytes[0]; // 8 bits from index 0 | ||
if (exponent === 0 && mantissa === 0) { | ||
return sign * 0; | ||
} | ||
if (exponent === 0x7FF && mantissa !== 0) { | ||
return NaN; | ||
} | ||
if (exponent === 0x7FF && mantissa === 0) { | ||
return sign * Infinity; | ||
} | ||
exponent -= 1023; // subtract the bias | ||
// Handle subnormal numbers | ||
if (exponent === -1023) { | ||
return sign * mantissa * 5e-324; // $pow(2, -1022 - 52) | ||
} | ||
return sign * (1 + (mantissa / 0x10000000000000)) * $pow(2, exponent); | ||
return bytesAsFloat64(rawBytes); | ||
} | ||
var Z = isBigInt ? $BigInt : $Number; | ||
// this is common to both branches | ||
var intValue = Z(0); | ||
for (var i = 0; i < rawBytes.length; i++) { | ||
intValue += Z(rawBytes[i]) * Z($pow(2, 8 * i)); | ||
} | ||
/* | ||
Let intValue be the byte elements of rawBytes concatenated and interpreted as a bit string encoding of an unsigned little-endian binary number. | ||
*/ | ||
if (!IsUnsignedElementType(type)) { // steps 5-6 | ||
// Let intValue be the byte elements of rawBytes concatenated and interpreted as a bit string encoding of a binary little-endian 2's complement number of bit length elementSize × 8. | ||
var bitLength = elementSize * 8; | ||
if (rawBytes[elementSize - 1] & 0x80) { | ||
intValue -= Z($pow(2, bitLength)); | ||
} | ||
} | ||
return intValue; // step 7 | ||
return bytesAsInteger(rawBytes, elementSize, IsUnsignedElementType(type), isBigInt); | ||
}; |
@@ -10,5 +10,6 @@ 'use strict'; | ||
var IsExtensible = require('./IsExtensible'); | ||
var IsIntegralNumber = require('./IsIntegralNumber'); | ||
var Type = require('./Type'); | ||
var isInteger = require('../helpers/isInteger'); | ||
// https://262.ecma-international.org/12.0/#sec-setfunctionlength | ||
@@ -23,3 +24,3 @@ | ||
} | ||
if (length !== Infinity && (!IsIntegralNumber(length) || length < 0)) { | ||
if (length !== Infinity && (!isInteger(length) || length < 0)) { | ||
throw new $TypeError('Assertion failed: `length` must be ∞, or an integer >= 0'); | ||
@@ -26,0 +27,0 @@ } |
@@ -11,3 +11,2 @@ 'use strict'; | ||
var HasProperty = require('./HasProperty'); | ||
var IsIntegralNumber = require('./IsIntegralNumber'); | ||
var Set = require('./Set'); | ||
@@ -18,2 +17,3 @@ var ToString = require('./ToString'); | ||
var isAbstractClosure = require('../helpers/isAbstractClosure'); | ||
var isInteger = require('../helpers/isInteger'); | ||
@@ -29,3 +29,3 @@ var $push = callBound('Array.prototype.push'); | ||
} | ||
if (!IsIntegralNumber(len) || len < 0) { | ||
if (!isInteger(len) || len < 0) { | ||
throw new $TypeError('Assertion failed: `len` must be an integer >= 0'); | ||
@@ -32,0 +32,0 @@ } |
@@ -8,5 +8,6 @@ 'use strict'; | ||
var IsIntegralNumber = require('./IsIntegralNumber'); | ||
var Type = require('./Type'); | ||
var isInteger = require('../helpers/isInteger'); | ||
var $slice = callBound('String.prototype.slice'); | ||
@@ -23,3 +24,3 @@ | ||
} | ||
if (!IsIntegralNumber(fromIndex) || fromIndex < 0) { | ||
if (!isInteger(fromIndex) || fromIndex < 0) { | ||
throw new $TypeError('Assertion failed: `fromIndex` must be a non-negative integer'); | ||
@@ -26,0 +27,0 @@ } |
@@ -7,5 +7,6 @@ 'use strict'; | ||
var IsIntegralNumber = require('./IsIntegralNumber'); | ||
var Type = require('./Type'); | ||
var isInteger = require('../helpers/isInteger'); | ||
var callBound = require('call-bind/callBound'); | ||
@@ -17,3 +18,3 @@ | ||
module.exports = function substring(S, inclusiveStart, exclusiveEnd) { | ||
if (Type(S) !== 'String' || !IsIntegralNumber(inclusiveStart) || (arguments.length > 2 && !IsIntegralNumber(exclusiveEnd))) { | ||
if (Type(S) !== 'String' || !isInteger(inclusiveStart) || (arguments.length > 2 && !isInteger(exclusiveEnd))) { | ||
throw new $TypeError('`S` must be a String, and `inclusiveStart` and `exclusiveEnd` must be integers'); | ||
@@ -20,0 +21,0 @@ } |
@@ -8,9 +8,10 @@ 'use strict'; | ||
var IsIntegralNumber = require('./IsIntegralNumber'); | ||
var StringPad = require('./StringPad'); | ||
var isInteger = require('../helpers/isInteger'); | ||
// https://262.ecma-international.org/13.0/#sec-tozeropaddeddecimalstring | ||
module.exports = function ToZeroPaddedDecimalString(n, minLength) { | ||
if (!IsIntegralNumber(n) || n < 0) { | ||
if (!isInteger(n) || n < 0) { | ||
throw new $RangeError('Assertion failed: `q` must be a non-negative integer'); | ||
@@ -17,0 +18,0 @@ } |
@@ -8,3 +8,3 @@ 'use strict'; | ||
var IsIntegralNumber = require('./IsIntegralNumber'); | ||
var isInteger = require('../helpers/isInteger'); | ||
@@ -36,3 +36,3 @@ var whichTypedArray = require('which-typed-array'); | ||
var size = table71['$' + type]; | ||
if (!IsIntegralNumber(size) || size < 0) { | ||
if (!isInteger(size) || size < 0) { | ||
throw new $SyntaxError('Assertion failed: Unknown TypedArray type `' + type + '`'); | ||
@@ -39,0 +39,0 @@ } |
@@ -23,3 +23,3 @@ 'use strict'; | ||
// eslint-disable-next-line max-lines-per-function, max-statements, max-params | ||
// eslint-disable-next-line max-lines-per-function, max-statements | ||
module.exports = function ValidateAndApplyPropertyDescriptor(O, P, extensible, Desc, current) { | ||
@@ -26,0 +26,0 @@ var oType = Type(O); |
@@ -0,1 +1,22 @@ | ||
1.22.0 / 2023-07-15 | ||
================= | ||
* [New] add `ES2023` | ||
* [New] `ES2021+`: add `SetTypedArrayFromArrayLike`, `SetTypedArrayFromTypedArray` | ||
* [New] `ES2021`+: add `CloneArrayBuffer` | ||
* [New] `ES2020`+: add `IsValidIntegerIndex` | ||
* [New] `ES2015`+: add `GetValueFromBuffer`, `SetValueInBuffer` | ||
* [New] `ES2016`+: add `TypedArrayCreate`, `TypedArraySpeciesCreate` | ||
* [New] `ES2015`+: add `IsWordChar` | ||
* [New] `ES2017`+ add `WordCharacters` | ||
* [New] `ES2015`+: add `Canonicalize` | ||
* [New] `ES2015`+: add `NewPromiseCapability` | ||
* [Fix] `ES2017+`: `NumberToRawBytes`, `NumericToRawBytes`: reimplement Float64, fix integer scenarios | ||
* [Refactor] add `helpers/isLineTerminator` | ||
* [Refactor] add `isInteger` helper, and use it | ||
* [Refactor] extract `isStringOrHole` to a helper | ||
* [Refactor] `ES2017`+: `RawBytesToNumber`, `RawBytesToNumeric`: extract common code to helpers | ||
* [Refactor] make a MAX_VALUE helper | ||
* [Tests] fix RawBytesToNumeric tests in node v10.4-10.8 | ||
* [Tests] fix buffer test cases in node v10.4-v10.8 | ||
1.21.3 / 2023-07-12 | ||
@@ -2,0 +23,0 @@ ================= |
@@ -15,2 +15,3 @@ 'use strict'; | ||
Call: require('./2015/Call'), | ||
Canonicalize: require('./2015/Canonicalize'), | ||
CanonicalNumericIndexString: require('./2015/CanonicalNumericIndexString'), | ||
@@ -45,2 +46,3 @@ CharacterRange: require('./2015/CharacterRange'), | ||
GetV: require('./2015/GetV'), | ||
GetValueFromBuffer: require('./2015/GetValueFromBuffer'), | ||
HasOwnProperty: require('./2015/HasOwnProperty'), | ||
@@ -67,2 +69,3 @@ HasProperty: require('./2015/HasProperty'), | ||
IsRegExp: require('./2015/IsRegExp'), | ||
IsWordChar: require('./2015/IsWordChar'), | ||
IteratorClose: require('./2015/IteratorClose'), | ||
@@ -82,2 +85,3 @@ IteratorComplete: require('./2015/IteratorComplete'), | ||
msFromTime: require('./2015/msFromTime'), | ||
NewPromiseCapability: require('./2015/NewPromiseCapability'), | ||
NormalCompletion: require('./2015/NormalCompletion'), | ||
@@ -101,2 +105,3 @@ ObjectCreate: require('./2015/ObjectCreate'), | ||
SetIntegrityLevel: require('./2015/SetIntegrityLevel'), | ||
SetValueInBuffer: require('./2015/SetValueInBuffer'), | ||
SpeciesConstructor: require('./2015/SpeciesConstructor'), | ||
@@ -103,0 +108,0 @@ SplitMatch: require('./2015/SplitMatch'), |
@@ -15,2 +15,3 @@ 'use strict'; | ||
Call: require('./2016/Call'), | ||
Canonicalize: require('./2016/Canonicalize'), | ||
CanonicalNumericIndexString: require('./2016/CanonicalNumericIndexString'), | ||
@@ -45,2 +46,3 @@ CharacterRange: require('./2016/CharacterRange'), | ||
GetV: require('./2016/GetV'), | ||
GetValueFromBuffer: require('./2016/GetValueFromBuffer'), | ||
HasOwnProperty: require('./2016/HasOwnProperty'), | ||
@@ -67,2 +69,3 @@ HasProperty: require('./2016/HasProperty'), | ||
IsRegExp: require('./2016/IsRegExp'), | ||
IsWordChar: require('./2016/IsWordChar'), | ||
IterableToArrayLike: require('./2016/IterableToArrayLike'), | ||
@@ -83,2 +86,3 @@ IteratorClose: require('./2016/IteratorClose'), | ||
msFromTime: require('./2016/msFromTime'), | ||
NewPromiseCapability: require('./2016/NewPromiseCapability'), | ||
NormalCompletion: require('./2016/NormalCompletion'), | ||
@@ -105,2 +109,3 @@ ObjectCreate: require('./2016/ObjectCreate'), | ||
SetIntegrityLevel: require('./2016/SetIntegrityLevel'), | ||
SetValueInBuffer: require('./2016/SetValueInBuffer'), | ||
SpeciesConstructor: require('./2016/SpeciesConstructor'), | ||
@@ -136,2 +141,4 @@ SplitMatch: require('./2016/SplitMatch'), | ||
Type: require('./2016/Type'), | ||
TypedArrayCreate: require('./2016/TypedArrayCreate'), | ||
TypedArraySpeciesCreate: require('./2016/TypedArraySpeciesCreate'), | ||
UTF16Decode: require('./2016/UTF16Decode'), | ||
@@ -138,0 +145,0 @@ UTF16Encoding: require('./2016/UTF16Encoding'), |
@@ -15,2 +15,3 @@ 'use strict'; | ||
Call: require('./2017/Call'), | ||
Canonicalize: require('./2017/Canonicalize'), | ||
CanonicalNumericIndexString: require('./2017/CanonicalNumericIndexString'), | ||
@@ -45,2 +46,3 @@ CharacterRange: require('./2017/CharacterRange'), | ||
GetV: require('./2017/GetV'), | ||
GetValueFromBuffer: require('./2017/GetValueFromBuffer'), | ||
HasOwnProperty: require('./2017/HasOwnProperty'), | ||
@@ -68,2 +70,3 @@ HasProperty: require('./2017/HasProperty'), | ||
IsSharedArrayBuffer: require('./2017/IsSharedArrayBuffer'), | ||
IsWordChar: require('./2017/IsWordChar'), | ||
IterableToList: require('./2017/IterableToList'), | ||
@@ -84,2 +87,3 @@ IteratorClose: require('./2017/IteratorClose'), | ||
msFromTime: require('./2017/msFromTime'), | ||
NewPromiseCapability: require('./2017/NewPromiseCapability'), | ||
NormalCompletion: require('./2017/NormalCompletion'), | ||
@@ -109,2 +113,3 @@ NumberToRawBytes: require('./2017/NumberToRawBytes'), | ||
SetIntegrityLevel: require('./2017/SetIntegrityLevel'), | ||
SetValueInBuffer: require('./2017/SetValueInBuffer'), | ||
SpeciesConstructor: require('./2017/SpeciesConstructor'), | ||
@@ -142,2 +147,4 @@ SplitMatch: require('./2017/SplitMatch'), | ||
Type: require('./2017/Type'), | ||
TypedArrayCreate: require('./2017/TypedArrayCreate'), | ||
TypedArraySpeciesCreate: require('./2017/TypedArraySpeciesCreate'), | ||
UTF16Decode: require('./2017/UTF16Decode'), | ||
@@ -149,2 +156,3 @@ UTF16Encoding: require('./2017/UTF16Encoding'), | ||
WeekDay: require('./2017/WeekDay'), | ||
WordCharacters: require('./2017/WordCharacters'), | ||
YearFromTime: require('./2017/YearFromTime') | ||
@@ -151,0 +159,0 @@ }; |
@@ -16,2 +16,3 @@ 'use strict'; | ||
Call: require('./2018/Call'), | ||
Canonicalize: require('./2018/Canonicalize'), | ||
CanonicalNumericIndexString: require('./2018/CanonicalNumericIndexString'), | ||
@@ -49,2 +50,3 @@ CharacterRange: require('./2018/CharacterRange'), | ||
GetV: require('./2018/GetV'), | ||
GetValueFromBuffer: require('./2018/GetValueFromBuffer'), | ||
HasOwnProperty: require('./2018/HasOwnProperty'), | ||
@@ -72,2 +74,3 @@ HasProperty: require('./2018/HasProperty'), | ||
IsStringPrefix: require('./2018/IsStringPrefix'), | ||
IsWordChar: require('./2018/IsWordChar'), | ||
IterableToList: require('./2018/IterableToList'), | ||
@@ -88,2 +91,3 @@ IteratorClose: require('./2018/IteratorClose'), | ||
msFromTime: require('./2018/msFromTime'), | ||
NewPromiseCapability: require('./2018/NewPromiseCapability'), | ||
NormalCompletion: require('./2018/NormalCompletion'), | ||
@@ -116,2 +120,3 @@ NumberToRawBytes: require('./2018/NumberToRawBytes'), | ||
SetIntegrityLevel: require('./2018/SetIntegrityLevel'), | ||
SetValueInBuffer: require('./2018/SetValueInBuffer'), | ||
SpeciesConstructor: require('./2018/SpeciesConstructor'), | ||
@@ -152,2 +157,4 @@ SplitMatch: require('./2018/SplitMatch'), | ||
Type: require('./2018/Type'), | ||
TypedArrayCreate: require('./2018/TypedArrayCreate'), | ||
TypedArraySpeciesCreate: require('./2018/TypedArraySpeciesCreate'), | ||
UnicodeEscape: require('./2018/UnicodeEscape'), | ||
@@ -160,2 +167,3 @@ UTF16Decode: require('./2018/UTF16Decode'), | ||
WeekDay: require('./2018/WeekDay'), | ||
WordCharacters: require('./2018/WordCharacters'), | ||
YearFromTime: require('./2018/YearFromTime') | ||
@@ -162,0 +170,0 @@ }; |
@@ -18,2 +18,3 @@ 'use strict'; | ||
Call: require('./2019/Call'), | ||
Canonicalize: require('./2019/Canonicalize'), | ||
CanonicalNumericIndexString: require('./2019/CanonicalNumericIndexString'), | ||
@@ -52,2 +53,3 @@ CharacterRange: require('./2019/CharacterRange'), | ||
GetV: require('./2019/GetV'), | ||
GetValueFromBuffer: require('./2019/GetValueFromBuffer'), | ||
HasOwnProperty: require('./2019/HasOwnProperty'), | ||
@@ -75,2 +77,3 @@ HasProperty: require('./2019/HasProperty'), | ||
IsStringPrefix: require('./2019/IsStringPrefix'), | ||
IsWordChar: require('./2019/IsWordChar'), | ||
IterableToList: require('./2019/IterableToList'), | ||
@@ -91,2 +94,3 @@ IteratorClose: require('./2019/IteratorClose'), | ||
msFromTime: require('./2019/msFromTime'), | ||
NewPromiseCapability: require('./2019/NewPromiseCapability'), | ||
NormalCompletion: require('./2019/NormalCompletion'), | ||
@@ -119,2 +123,3 @@ NumberToRawBytes: require('./2019/NumberToRawBytes'), | ||
SetIntegrityLevel: require('./2019/SetIntegrityLevel'), | ||
SetValueInBuffer: require('./2019/SetValueInBuffer'), | ||
SpeciesConstructor: require('./2019/SpeciesConstructor'), | ||
@@ -156,2 +161,4 @@ SplitMatch: require('./2019/SplitMatch'), | ||
Type: require('./2019/Type'), | ||
TypedArrayCreate: require('./2019/TypedArrayCreate'), | ||
TypedArraySpeciesCreate: require('./2019/TypedArraySpeciesCreate'), | ||
UnicodeEscape: require('./2019/UnicodeEscape'), | ||
@@ -164,2 +171,3 @@ UTF16Decode: require('./2019/UTF16Decode'), | ||
WeekDay: require('./2019/WeekDay'), | ||
WordCharacters: require('./2019/WordCharacters'), | ||
YearFromTime: require('./2019/YearFromTime') | ||
@@ -166,0 +174,0 @@ }; |
@@ -23,2 +23,3 @@ 'use strict'; | ||
Call: require('./2020/Call'), | ||
Canonicalize: require('./2020/Canonicalize'), | ||
CanonicalNumericIndexString: require('./2020/CanonicalNumericIndexString'), | ||
@@ -59,2 +60,3 @@ CharacterRange: require('./2020/CharacterRange'), | ||
GetV: require('./2020/GetV'), | ||
GetValueFromBuffer: require('./2020/GetValueFromBuffer'), | ||
HasOwnProperty: require('./2020/HasOwnProperty'), | ||
@@ -87,2 +89,4 @@ HasProperty: require('./2020/HasProperty'), | ||
IsUnsignedElementType: require('./2020/IsUnsignedElementType'), | ||
IsValidIntegerIndex: require('./2020/IsValidIntegerIndex'), | ||
IsWordChar: require('./2020/IsWordChar'), | ||
IterableToList: require('./2020/IterableToList'), | ||
@@ -104,2 +108,3 @@ IteratorClose: require('./2020/IteratorClose'), | ||
msFromTime: require('./2020/msFromTime'), | ||
NewPromiseCapability: require('./2020/NewPromiseCapability'), | ||
NormalCompletion: require('./2020/NormalCompletion'), | ||
@@ -134,2 +139,3 @@ Number: require('./2020/Number'), | ||
SetIntegrityLevel: require('./2020/SetIntegrityLevel'), | ||
SetValueInBuffer: require('./2020/SetValueInBuffer'), | ||
SpeciesConstructor: require('./2020/SpeciesConstructor'), | ||
@@ -178,2 +184,4 @@ SplitMatch: require('./2020/SplitMatch'), | ||
Type: require('./2020/Type'), | ||
TypedArrayCreate: require('./2020/TypedArrayCreate'), | ||
TypedArraySpeciesCreate: require('./2020/TypedArraySpeciesCreate'), | ||
UnicodeEscape: require('./2020/UnicodeEscape'), | ||
@@ -187,2 +195,3 @@ UTF16DecodeString: require('./2020/UTF16DecodeString'), | ||
WeekDay: require('./2020/WeekDay'), | ||
WordCharacters: require('./2020/WordCharacters'), | ||
YearFromTime: require('./2020/YearFromTime') | ||
@@ -189,0 +198,0 @@ }; |
@@ -27,2 +27,3 @@ 'use strict'; | ||
Call: require('./2021/Call'), | ||
Canonicalize: require('./2021/Canonicalize'), | ||
CanonicalNumericIndexString: require('./2021/CanonicalNumericIndexString'), | ||
@@ -32,2 +33,3 @@ CharacterRange: require('./2021/CharacterRange'), | ||
ClearKeptObjects: require('./2021/ClearKeptObjects'), | ||
CloneArrayBuffer: require('./2021/CloneArrayBuffer'), | ||
CodePointAt: require('./2021/CodePointAt'), | ||
@@ -68,2 +70,3 @@ CodePointsToString: require('./2021/CodePointsToString'), | ||
GetV: require('./2021/GetV'), | ||
GetValueFromBuffer: require('./2021/GetValueFromBuffer'), | ||
HasOwnProperty: require('./2021/HasOwnProperty'), | ||
@@ -95,2 +98,4 @@ HasProperty: require('./2021/HasProperty'), | ||
IsUnsignedElementType: require('./2021/IsUnsignedElementType'), | ||
IsValidIntegerIndex: require('./2021/IsValidIntegerIndex'), | ||
IsWordChar: require('./2021/IsWordChar'), | ||
IterableToList: require('./2021/IterableToList'), | ||
@@ -112,2 +117,3 @@ IteratorClose: require('./2021/IteratorClose'), | ||
msFromTime: require('./2021/msFromTime'), | ||
NewPromiseCapability: require('./2021/NewPromiseCapability'), | ||
NormalCompletion: require('./2021/NormalCompletion'), | ||
@@ -142,2 +148,5 @@ Number: require('./2021/Number'), | ||
SetIntegrityLevel: require('./2021/SetIntegrityLevel'), | ||
SetTypedArrayFromArrayLike: require('./2021/SetTypedArrayFromArrayLike'), | ||
SetTypedArrayFromTypedArray: require('./2021/SetTypedArrayFromTypedArray'), | ||
SetValueInBuffer: require('./2021/SetValueInBuffer'), | ||
SpeciesConstructor: require('./2021/SpeciesConstructor'), | ||
@@ -189,2 +198,4 @@ SplitMatch: require('./2021/SplitMatch'), | ||
Type: require('./2021/Type'), | ||
TypedArrayCreate: require('./2021/TypedArrayCreate'), | ||
TypedArraySpeciesCreate: require('./2021/TypedArraySpeciesCreate'), | ||
UnicodeEscape: require('./2021/UnicodeEscape'), | ||
@@ -199,2 +210,3 @@ UTF16EncodeCodePoint: require('./2021/UTF16EncodeCodePoint'), | ||
WeekDay: require('./2021/WeekDay'), | ||
WordCharacters: require('./2021/WordCharacters'), | ||
YearFromTime: require('./2021/YearFromTime') | ||
@@ -201,0 +213,0 @@ }; |
@@ -24,2 +24,3 @@ 'use strict'; | ||
Call: require('./2022/Call'), | ||
Canonicalize: require('./2022/Canonicalize'), | ||
CanonicalNumericIndexString: require('./2022/CanonicalNumericIndexString'), | ||
@@ -29,2 +30,3 @@ CharacterRange: require('./2022/CharacterRange'), | ||
ClearKeptObjects: require('./2022/ClearKeptObjects'), | ||
CloneArrayBuffer: require('./2022/CloneArrayBuffer'), | ||
CodePointAt: require('./2022/CodePointAt'), | ||
@@ -69,2 +71,3 @@ CodePointsToString: require('./2022/CodePointsToString'), | ||
GetV: require('./2022/GetV'), | ||
GetValueFromBuffer: require('./2022/GetValueFromBuffer'), | ||
HasOwnProperty: require('./2022/HasOwnProperty'), | ||
@@ -101,2 +104,4 @@ HasProperty: require('./2022/HasProperty'), | ||
IsUnsignedElementType: require('./2022/IsUnsignedElementType'), | ||
IsValidIntegerIndex: require('./2022/IsValidIntegerIndex'), | ||
IsWordChar: require('./2022/IsWordChar'), | ||
IterableToList: require('./2022/IterableToList'), | ||
@@ -119,2 +124,3 @@ IteratorClose: require('./2022/IteratorClose'), | ||
msFromTime: require('./2022/msFromTime'), | ||
NewPromiseCapability: require('./2022/NewPromiseCapability'), | ||
NormalCompletion: require('./2022/NormalCompletion'), | ||
@@ -150,2 +156,5 @@ Number: require('./2022/Number'), | ||
SetIntegrityLevel: require('./2022/SetIntegrityLevel'), | ||
SetTypedArrayFromArrayLike: require('./2022/SetTypedArrayFromArrayLike'), | ||
SetTypedArrayFromTypedArray: require('./2022/SetTypedArrayFromTypedArray'), | ||
SetValueInBuffer: require('./2022/SetValueInBuffer'), | ||
SortIndexedProperties: require('./2022/SortIndexedProperties'), | ||
@@ -199,4 +208,6 @@ SpeciesConstructor: require('./2022/SpeciesConstructor'), | ||
Type: require('./2022/Type'), | ||
TypedArrayCreate: require('./2022/TypedArrayCreate'), | ||
TypedArrayElementSize: require('./2022/TypedArrayElementSize'), | ||
TypedArrayElementType: require('./2022/TypedArrayElementType'), | ||
TypedArraySpeciesCreate: require('./2022/TypedArraySpeciesCreate'), | ||
UnicodeEscape: require('./2022/UnicodeEscape'), | ||
@@ -211,2 +222,3 @@ UTF16EncodeCodePoint: require('./2022/UTF16EncodeCodePoint'), | ||
WeekDay: require('./2022/WeekDay'), | ||
WordCharacters: require('./2022/WordCharacters'), | ||
YearFromTime: require('./2022/YearFromTime') | ||
@@ -213,0 +225,0 @@ }; |
@@ -11,2 +11,3 @@ 'use strict'; | ||
abs: require('./5/abs'), | ||
Canonicalize: require('./5/Canonicalize'), | ||
CheckObjectCoercible: require('./5/CheckObjectCoercible'), | ||
@@ -13,0 +14,0 @@ DateFromTime: require('./5/DateFromTime'), |
@@ -9,2 +9,3 @@ 'use strict'; | ||
var has = require('has'); | ||
var isInteger = require('./isInteger'); | ||
@@ -61,2 +62,17 @@ var isMatchRecord = require('./isMatchRecord'); | ||
&& predicates['PromiseCapability Record'](value['[[Capability]]']); | ||
}, | ||
'RegExp Record': function isRegExpRecord(value) { | ||
return value | ||
&& has(value, '[[IgnoreCase]]') | ||
&& typeof value['[[IgnoreCase]]'] === 'boolean' | ||
&& has(value, '[[Multiline]]') | ||
&& typeof value['[[Multiline]]'] === 'boolean' | ||
&& has(value, '[[DotAll]]') | ||
&& typeof value['[[DotAll]]'] === 'boolean' | ||
&& has(value, '[[Unicode]]') | ||
&& typeof value['[[Unicode]]'] === 'boolean' | ||
&& has(value, '[[CapturingGroupsCount]]') | ||
&& typeof value['[[CapturingGroupsCount]]'] === 'number' | ||
&& isInteger(value['[[CapturingGroupsCount]]']) | ||
&& value['[[CapturingGroupsCount]]'] >= 0; | ||
} | ||
@@ -63,0 +79,0 @@ }; |
@@ -14,2 +14,3 @@ 'use strict'; | ||
var ES2022 = require('./es2022'); | ||
var ES2023 = require('./es2023'); | ||
@@ -27,3 +28,4 @@ var ES = { | ||
ES2021: ES2021, | ||
ES2022: ES2022 | ||
ES2022: ES2022, | ||
ES2023: ES2023 | ||
}; | ||
@@ -30,0 +32,0 @@ assign(ES, ES5); |
@@ -1273,2 +1273,5 @@ 'use strict'; | ||
}, | ||
WordCharacters: { | ||
url: 'https://262.ecma-international.org/12.0/#sec-runtime-semantics-wordcharacters-abstract-operation' | ||
}, | ||
YearFromTime: { | ||
@@ -1275,0 +1278,0 @@ url: 'https://262.ecma-international.org/12.0/#eqn-YearFromTime' |
@@ -1363,2 +1363,5 @@ 'use strict'; | ||
}, | ||
WordCharacters: { | ||
url: 'https://262.ecma-international.org/13.0/#sec-runtime-semantics-wordcharacters-abstract-operation' | ||
}, | ||
YearFromTime: { | ||
@@ -1365,0 +1368,0 @@ url: 'https://262.ecma-international.org/13.0/#eqn-YearFromTime' |
{ | ||
"name": "es-abstract", | ||
"version": "1.21.3", | ||
"version": "1.22.0", | ||
"author": { | ||
@@ -29,3 +29,3 @@ "name": "Jordan Harband", | ||
"prespackle": "git ls-files | xargs git check-attr spackled | grep -v 'unspecified$' | cut -d: -f1 | xargs rm || true", | ||
"spackle": "node operations/spackle 1", | ||
"spackle": "node operations/spackle 1 && node operations/build-unicode.mjs", | ||
"postspackle": "git ls-files | xargs git check-attr spackled | grep -v 'unspecified$' | cut -d: -f1 | xargs git add", | ||
@@ -60,2 +60,3 @@ "prepack": "npmignore --auto --commentLines=autogenerated", | ||
"array-buffer-byte-length": "^1.0.0", | ||
"arraybuffer.prototype.slice": "^1.0.1", | ||
"available-typed-arrays": "^1.0.5", | ||
@@ -91,2 +92,4 @@ "call-bind": "^1.0.2", | ||
"string.prototype.trimstart": "^1.0.6", | ||
"typed-array-buffer": "^1.0.0", | ||
"typed-array-byte-length": "^1.0.0", | ||
"typed-array-byte-offset": "^1.0.0", | ||
@@ -99,2 +102,3 @@ "typed-array-length": "^1.0.4", | ||
"@ljharb/eslint-config": "^21.1.0", | ||
"@unicode/unicode-15.0.0": "^1.3.1", | ||
"array.from": "^1.1.4", | ||
@@ -118,2 +122,3 @@ "array.prototype.filter": "^1.0.2", | ||
"is-core-module": "^2.12.1", | ||
"is-registered-symbol": "^1.0.1", | ||
"make-arrow-function": "^1.2.0", | ||
@@ -120,0 +125,0 @@ "make-async-function": "^1.0.0", |
Sorry, the diff of this file is not supported yet
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
2021039
1828
55391
38
32
1