Bump the npm group with 2 updates (#1819)
* Bump the npm group with 2 updates Bumps the npm group with 2 updates: [eslint](https://github.com/eslint/eslint) and [eslint-plugin-import](https://github.com/import-js/eslint-plugin-import). Updates `eslint` from 8.45.0 to 8.46.0 - [Release notes](https://github.com/eslint/eslint/releases) - [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md) - [Commits](https://github.com/eslint/eslint/compare/v8.45.0...v8.46.0) Updates `eslint-plugin-import` from 2.27.5 to 2.28.0 - [Release notes](https://github.com/import-js/eslint-plugin-import/releases) - [Changelog](https://github.com/import-js/eslint-plugin-import/blob/main/CHANGELOG.md) - [Commits](https://github.com/import-js/eslint-plugin-import/compare/v2.27.5...v2.28.0) --- updated-dependencies: - dependency-name: eslint dependency-type: direct:development update-type: version-update:semver-minor dependency-group: npm - dependency-name: eslint-plugin-import dependency-type: direct:development update-type: version-update:semver-minor dependency-group: npm ... Signed-off-by: dependabot[bot] <support@github.com> * Update checked-in dependencies --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
parent
a6b0ced86b
commit
e7e35baaf0
1408 changed files with 27215 additions and 9910 deletions
23
node_modules/es-abstract/helpers/assertRecord.js
generated
vendored
23
node_modules/es-abstract/helpers/assertRecord.js
generated
vendored
|
|
@ -6,6 +6,7 @@ var $TypeError = GetIntrinsic('%TypeError%');
|
|||
var $SyntaxError = GetIntrinsic('%SyntaxError%');
|
||||
|
||||
var has = require('has');
|
||||
var isInteger = require('./isInteger');
|
||||
|
||||
var isMatchRecord = require('./isMatchRecord');
|
||||
|
||||
|
|
@ -21,6 +22,9 @@ var predicates = {
|
|||
'[[Writable]]': true
|
||||
};
|
||||
|
||||
if (!Desc) {
|
||||
return false;
|
||||
}
|
||||
for (var key in Desc) { // eslint-disable-line
|
||||
if (has(Desc, key) && !allowed[key]) {
|
||||
return false;
|
||||
|
|
@ -40,7 +44,7 @@ var predicates = {
|
|||
return has(value, '[[Iterator]]') && has(value, '[[NextMethod]]') && has(value, '[[Done]]');
|
||||
},
|
||||
'PromiseCapability Record': function isPromiseCapabilityRecord(value) {
|
||||
return value
|
||||
return !!value
|
||||
&& has(value, '[[Resolve]]')
|
||||
&& typeof value['[[Resolve]]'] === 'function'
|
||||
&& has(value, '[[Reject]]')
|
||||
|
|
@ -50,10 +54,25 @@ var predicates = {
|
|||
&& typeof value['[[Promise]]'].then === 'function';
|
||||
},
|
||||
'AsyncGeneratorRequest Record': function isAsyncGeneratorRequestRecord(value) {
|
||||
return value
|
||||
return !!value
|
||||
&& has(value, '[[Completion]]') // TODO: confirm is a completion record
|
||||
&& has(value, '[[Capability]]')
|
||||
&& 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;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
38
node_modules/es-abstract/helpers/bytesAsFloat32.js
generated
vendored
Normal file
38
node_modules/es-abstract/helpers/bytesAsFloat32.js
generated
vendored
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $pow = GetIntrinsic('%Math.pow%');
|
||||
|
||||
module.exports = function bytesAsFloat32(rawBytes) {
|
||||
// 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);
|
||||
};
|
||||
44
node_modules/es-abstract/helpers/bytesAsFloat64.js
generated
vendored
Normal file
44
node_modules/es-abstract/helpers/bytesAsFloat64.js
generated
vendored
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $pow = GetIntrinsic('%Math.pow%');
|
||||
|
||||
module.exports = function bytesAsFloat64(rawBytes) {
|
||||
// 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);
|
||||
};
|
||||
31
node_modules/es-abstract/helpers/bytesAsInteger.js
generated
vendored
Normal file
31
node_modules/es-abstract/helpers/bytesAsInteger.js
generated
vendored
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $pow = GetIntrinsic('%Math.pow%');
|
||||
var $Number = GetIntrinsic('%Number%');
|
||||
var $BigInt = GetIntrinsic('%BigInt%', true);
|
||||
|
||||
module.exports = function bytesAsInteger(rawBytes, elementSize, isUnsigned, isBigInt) {
|
||||
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 (!isUnsigned) { // 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
|
||||
};
|
||||
1430
node_modules/es-abstract/helpers/caseFolding.json
generated
vendored
Normal file
1430
node_modules/es-abstract/helpers/caseFolding.json
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
21
node_modules/es-abstract/helpers/defaultEndianness.js
generated
vendored
Normal file
21
node_modules/es-abstract/helpers/defaultEndianness.js
generated
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $Uint8Array = GetIntrinsic('%Uint8Array%', true);
|
||||
var $Uint32Array = GetIntrinsic('%Uint32Array%', true);
|
||||
|
||||
var typedArrayBuffer = require('typed-array-buffer');
|
||||
|
||||
var uInt32 = $Uint32Array && new $Uint32Array([0x12345678]);
|
||||
var uInt8 = uInt32 && new $Uint8Array(typedArrayBuffer(uInt32));
|
||||
|
||||
module.exports = uInt8
|
||||
? uInt8[0] === 0x78
|
||||
? 'little'
|
||||
: uInt8[0] === 0x12
|
||||
? 'big'
|
||||
: uInt8[0] === 0x34
|
||||
? 'mixed' // https://developer.mozilla.org/en-US/docs/Glossary/Endianness
|
||||
: 'unknown' // ???
|
||||
: 'indeterminate'; // no way to know
|
||||
33
node_modules/es-abstract/helpers/fractionToBinaryString.js
generated
vendored
Normal file
33
node_modules/es-abstract/helpers/fractionToBinaryString.js
generated
vendored
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
'use strict';
|
||||
|
||||
var MAX_ITER = 1075; // 1023+52 (subnormals) => BIAS+NUM_SIGNFICAND_BITS-1
|
||||
var maxBits = 54; // only 53 bits for fraction
|
||||
|
||||
module.exports = function fractionToBitString(x) {
|
||||
var str = '';
|
||||
if (x === 0) {
|
||||
return str;
|
||||
}
|
||||
var j = MAX_ITER;
|
||||
|
||||
var y;
|
||||
// Each time we multiply by 2 and find a ones digit, add a '1'; otherwise, add a '0'..
|
||||
for (var i = 0; i < MAX_ITER; i += 1) {
|
||||
y = x * 2;
|
||||
if (y >= 1) {
|
||||
x = y - 1; // eslint-disable-line no-param-reassign
|
||||
str += '1';
|
||||
if (j === MAX_ITER) {
|
||||
j = i; // first 1
|
||||
}
|
||||
} else {
|
||||
x = y; // eslint-disable-line no-param-reassign
|
||||
str += '0';
|
||||
}
|
||||
// Stop when we have no more decimals to process or in the event we found a fraction which cannot be represented in a finite number of bits...
|
||||
if (y === 1 || i - j > maxBits) {
|
||||
return str;
|
||||
}
|
||||
}
|
||||
return str;
|
||||
};
|
||||
2
node_modules/es-abstract/helpers/getIteratorMethod.js
generated
vendored
2
node_modules/es-abstract/helpers/getIteratorMethod.js
generated
vendored
|
|
@ -7,7 +7,7 @@ var isString = require('is-string');
|
|||
|
||||
var $iterator = GetIntrinsic('%Symbol.iterator%', true);
|
||||
var $stringSlice = callBound('String.prototype.slice');
|
||||
var $String = GetIntrinsic('%String%', true);
|
||||
var $String = GetIntrinsic('%String%');
|
||||
|
||||
module.exports = function getIteratorMethod(ES, iterable) {
|
||||
var usingIterator;
|
||||
|
|
|
|||
23
node_modules/es-abstract/helpers/intToBinaryString.js
generated
vendored
Normal file
23
node_modules/es-abstract/helpers/intToBinaryString.js
generated
vendored
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $floor = GetIntrinsic('%Math.floor%');
|
||||
|
||||
// https://runestone.academy/ns/books/published/pythonds/BasicDS/ConvertingDecimalNumberstoBinaryNumbers.html#:~:text=The%20Divide%20by%202%20algorithm,have%20a%20remainder%20of%200
|
||||
|
||||
module.exports = function intToBinaryString(x) {
|
||||
var str = '';
|
||||
var y;
|
||||
|
||||
while (x > 0) {
|
||||
y = x / 2;
|
||||
x = $floor(y); // eslint-disable-line no-param-reassign
|
||||
if (y === x) {
|
||||
str = '0' + str;
|
||||
} else {
|
||||
str = '1' + str;
|
||||
}
|
||||
}
|
||||
return str;
|
||||
};
|
||||
28
node_modules/es-abstract/helpers/integerToNBytes.js
generated
vendored
Normal file
28
node_modules/es-abstract/helpers/integerToNBytes.js
generated
vendored
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $Number = GetIntrinsic('%Number%');
|
||||
var $BigInt = GetIntrinsic('%BigInt%', true);
|
||||
|
||||
module.exports = function integerToNBytes(intValue, n, isLittleEndian) {
|
||||
var Z = typeof intValue === 'bigint' ? $BigInt : $Number;
|
||||
/*
|
||||
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 >>>= 0; // eslint-disable-line no-param-reassign
|
||||
}
|
||||
|
||||
var rawBytes = [];
|
||||
for (var i = 0; i < n; i++) {
|
||||
rawBytes[isLittleEndian ? i : n - 1 - i] = $Number(intValue & Z(0xFF));
|
||||
intValue >>= Z(8); // eslint-disable-line no-param-reassign
|
||||
}
|
||||
|
||||
return rawBytes; // step 4
|
||||
};
|
||||
4
node_modules/es-abstract/helpers/isFullyPopulatedPropertyDescriptor.js
generated
vendored
4
node_modules/es-abstract/helpers/isFullyPopulatedPropertyDescriptor.js
generated
vendored
|
|
@ -1,7 +1,9 @@
|
|||
'use strict';
|
||||
|
||||
module.exports = function isFullyPopulatedPropertyDescriptor(ES, Desc) {
|
||||
return '[[Enumerable]]' in Desc
|
||||
return !!Desc
|
||||
&& typeof Desc === 'object'
|
||||
&& '[[Enumerable]]' in Desc
|
||||
&& '[[Configurable]]' in Desc
|
||||
&& (ES.IsAccessorDescriptor(Desc) || ES.IsDataDescriptor(Desc));
|
||||
};
|
||||
|
|
|
|||
18
node_modules/es-abstract/helpers/isInteger.js
generated
vendored
Normal file
18
node_modules/es-abstract/helpers/isInteger.js
generated
vendored
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $abs = GetIntrinsic('%Math.abs%');
|
||||
var $floor = GetIntrinsic('%Math.floor%');
|
||||
|
||||
var $isNaN = require('./isNaN');
|
||||
var $isFinite = require('./isFinite');
|
||||
|
||||
module.exports = function isInteger(argument) {
|
||||
if (typeof argument !== 'number' || $isNaN(argument) || !$isFinite(argument)) {
|
||||
return false;
|
||||
}
|
||||
var absValue = $abs(argument);
|
||||
return $floor(absValue) === absValue;
|
||||
};
|
||||
|
||||
7
node_modules/es-abstract/helpers/isLineTerminator.js
generated
vendored
Normal file
7
node_modules/es-abstract/helpers/isLineTerminator.js
generated
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
// https://262.ecma-international.org/5.1/#sec-7.3
|
||||
|
||||
module.exports = function isLineTerminator(c) {
|
||||
return c === '\n' || c === '\r' || c === '\u2028' || c === '\u2029';
|
||||
};
|
||||
5
node_modules/es-abstract/helpers/isNegativeZero.js
generated
vendored
Normal file
5
node_modules/es-abstract/helpers/isNegativeZero.js
generated
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
'use strict';
|
||||
|
||||
module.exports = function isNegativeZero(x) {
|
||||
return x === 0 && 1 / x === 1 / -0;
|
||||
};
|
||||
7
node_modules/es-abstract/helpers/isStringOrHole.js
generated
vendored
Normal file
7
node_modules/es-abstract/helpers/isStringOrHole.js
generated
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
var canDistinguishSparseFromUndefined = 0 in [undefined]; // IE 6 - 8 have a bug where this returns false
|
||||
|
||||
module.exports = function isStringOrHole(item, index, arr) {
|
||||
return typeof item === 'string' || (canDistinguishSparseFromUndefined ? !(index in arr) : typeof item === 'undefined');
|
||||
};
|
||||
3
node_modules/es-abstract/helpers/maxValue.js
generated
vendored
Normal file
3
node_modules/es-abstract/helpers/maxValue.js
generated
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
'use strict';
|
||||
|
||||
module.exports = Number.MAX_VALUE || 1.7976931348623157e+308;
|
||||
22
node_modules/es-abstract/helpers/typedArrayContructors.js
generated
vendored
Normal file
22
node_modules/es-abstract/helpers/typedArrayContructors.js
generated
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var constructors = {
|
||||
__proto__: null,
|
||||
$Int8Array: GetIntrinsic('%Int8Array%', true),
|
||||
$Uint8Array: GetIntrinsic('%Uint8Array%', true),
|
||||
$Uint8ClampedArray: GetIntrinsic('%Uint8ClampedArray%', true),
|
||||
$Int16Array: GetIntrinsic('%Int16Array%', true),
|
||||
$Uint16Array: GetIntrinsic('%Uint16Array%', true),
|
||||
$Int32Array: GetIntrinsic('%Int32Array%', true),
|
||||
$Uint32Array: GetIntrinsic('%Uint32Array%', true),
|
||||
$BigInt64Array: GetIntrinsic('%BigInt64Array%', true),
|
||||
$BigUint64Array: GetIntrinsic('%BigUint64Array%', true),
|
||||
$Float32Array: GetIntrinsic('%Float32Array%', true),
|
||||
$Float64Array: GetIntrinsic('%Float64Array%', true)
|
||||
};
|
||||
|
||||
module.exports = function getConstructor(kind) {
|
||||
return constructors['$' + kind];
|
||||
};
|
||||
69
node_modules/es-abstract/helpers/valueToFloat32Bytes.js
generated
vendored
Normal file
69
node_modules/es-abstract/helpers/valueToFloat32Bytes.js
generated
vendored
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $abs = GetIntrinsic('%Math.abs%');
|
||||
var $floor = GetIntrinsic('%Math.floor%');
|
||||
var $pow = GetIntrinsic('%Math.pow%');
|
||||
|
||||
var isFinite = require('./isFinite');
|
||||
var isNaN = require('./isNaN');
|
||||
var isNegativeZero = require('./isNegativeZero');
|
||||
|
||||
var maxFiniteFloat32 = 3.4028234663852886e+38; // roughly 2 ** 128 - 1
|
||||
|
||||
module.exports = function valueToFloat32Bytes(value, isLittleEndian) {
|
||||
if (isNaN(value)) {
|
||||
return isLittleEndian ? [0, 0, 192, 127] : [127, 192, 0, 0]; // hardcoded
|
||||
}
|
||||
|
||||
var leastSig;
|
||||
|
||||
if (value === 0) {
|
||||
leastSig = isNegativeZero(value) ? 0x80 : 0;
|
||||
return isLittleEndian ? [0, 0, 0, leastSig] : [leastSig, 0, 0, 0];
|
||||
}
|
||||
|
||||
if ($abs(value) > maxFiniteFloat32 || !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
|
||||
|
||||
var 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) + 0.5;
|
||||
mantissa = $floor(mantissa);
|
||||
|
||||
exponent += 127;
|
||||
exponent <<= 23;
|
||||
|
||||
var result = (sign << 31)
|
||||
| exponent
|
||||
| mantissa;
|
||||
|
||||
var byte0 = result & 255;
|
||||
result >>= 8;
|
||||
var byte1 = result & 255;
|
||||
result >>= 8;
|
||||
var byte2 = result & 255;
|
||||
result >>= 8;
|
||||
var byte3 = result & 255;
|
||||
|
||||
if (isLittleEndian) {
|
||||
return [byte0, byte1, byte2, byte3];
|
||||
}
|
||||
return [byte3, byte2, byte1, byte0];
|
||||
};
|
||||
83
node_modules/es-abstract/helpers/valueToFloat64Bytes.js
generated
vendored
Normal file
83
node_modules/es-abstract/helpers/valueToFloat64Bytes.js
generated
vendored
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $parseInt = GetIntrinsic('%parseInt%');
|
||||
var $abs = GetIntrinsic('%Math.abs%');
|
||||
var $floor = GetIntrinsic('%Math.floor%');
|
||||
|
||||
var callBound = require('call-bind/callBound');
|
||||
|
||||
var $strIndexOf = callBound('String.prototype.indexOf');
|
||||
var $strSlice = callBound('String.prototype.slice');
|
||||
|
||||
var fractionToBitString = require('../helpers/fractionToBinaryString');
|
||||
var intToBinString = require('../helpers/intToBinaryString');
|
||||
var isNegativeZero = require('./isNegativeZero');
|
||||
|
||||
var float64bias = 1023;
|
||||
|
||||
var elevenOnes = '11111111111';
|
||||
var elevenZeroes = '00000000000';
|
||||
var fiftyOneZeroes = elevenZeroes + elevenZeroes + elevenZeroes + elevenZeroes + '0000000';
|
||||
|
||||
// IEEE 754-1985
|
||||
module.exports = function valueToFloat64Bytes(value, isLittleEndian) {
|
||||
var signBit = value < 0 || isNegativeZero(value) ? '1' : '0';
|
||||
var exponentBits;
|
||||
var significandBits;
|
||||
|
||||
if (isNaN(value)) {
|
||||
exponentBits = elevenOnes;
|
||||
significandBits = '1' + fiftyOneZeroes;
|
||||
} else if (!isFinite(value)) {
|
||||
exponentBits = elevenOnes;
|
||||
significandBits = '0' + fiftyOneZeroes;
|
||||
} else if (value === 0) {
|
||||
exponentBits = elevenZeroes;
|
||||
significandBits = '0' + fiftyOneZeroes;
|
||||
} else {
|
||||
value = $abs(value); // eslint-disable-line no-param-reassign
|
||||
|
||||
// Isolate the integer part (digits before the decimal):
|
||||
var integerPart = $floor(value);
|
||||
|
||||
var intBinString = intToBinString(integerPart); // bit string for integer part
|
||||
var fracBinString = fractionToBitString(value - integerPart); // bit string for fractional part
|
||||
|
||||
var numberOfBits;
|
||||
// find exponent needed to normalize integer+fractional parts
|
||||
if (intBinString) {
|
||||
exponentBits = intBinString.length - 1; // move the decimal to the left
|
||||
} else {
|
||||
var first1 = $strIndexOf(fracBinString, '1');
|
||||
if (first1 > -1) {
|
||||
numberOfBits = first1 + 1;
|
||||
}
|
||||
exponentBits = -numberOfBits; // move the decimal to the right
|
||||
}
|
||||
|
||||
significandBits = intBinString + fracBinString;
|
||||
if (exponentBits < 0) {
|
||||
// subnormals
|
||||
if (exponentBits <= -float64bias) {
|
||||
numberOfBits = float64bias - 1; // limit number of removed bits
|
||||
}
|
||||
significandBits = $strSlice(significandBits, numberOfBits); // remove all leading 0s and the first 1 for normal values; for subnormals, remove up to `float64bias - 1` leading bits
|
||||
} else {
|
||||
significandBits = $strSlice(significandBits, 1); // remove the leading '1' (implicit/hidden bit)
|
||||
}
|
||||
exponentBits = $strSlice(elevenZeroes + intToBinString(exponentBits + float64bias), -11); // Convert the exponent to a bit string
|
||||
|
||||
significandBits = $strSlice(significandBits + fiftyOneZeroes + '0', 0, 52); // fill in any trailing zeros and ensure we have only 52 fraction bits
|
||||
}
|
||||
|
||||
var bits = signBit + exponentBits + significandBits;
|
||||
var rawBytes = [];
|
||||
for (var i = 0; i < 8; i++) {
|
||||
var targetIndex = isLittleEndian ? 8 - i - 1 : i;
|
||||
rawBytes[targetIndex] = $parseInt($strSlice(bits, i * 8, (i + 1) * 8), 2);
|
||||
}
|
||||
|
||||
return rawBytes;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue