Save current BZZZ config-ui state before CHORUS branding update

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
anthonyrawlins
2025-08-19 00:19:00 +10:00
parent 6a6a49b7b1
commit c177363a19
16410 changed files with 1789161 additions and 230 deletions

View File

@@ -0,0 +1,130 @@
'use strict';
var $TypeError = require('es-errors/type');
var GetIntrinsic = require('get-intrinsic');
var callBound = require('call-bound');
var hasOwn = require('hasown');
var caseFolding = require('./caseFolding.json');
var IsArray = require('./IsArray');
var isLeadingSurrogate = require('./isLeadingSurrogate');
var isTrailingSurrogate = require('./isTrailingSurrogate');
var $charCodeAt = callBound('%String.prototype.charCodeAt%');
var $fromCharCode = GetIntrinsic('%String.fromCharCode%');
/* eslint func-style: 0 */
function CharSet(test, yieldCh) {
if (typeof test !== 'function') {
throw new $TypeError('Assertion failed: `test` must be a function');
}
if (typeof yieldCh !== 'function') {
throw new $TypeError('Assertion failed: `yield` must be a function');
}
this.test = test;
this.yield = yieldCh;
}
CharSet.prototype.count = function () {
var count = 0;
this.yield(function () { count += 1; });
return count;
};
function testCodeUnits(CharSetElement) {
if (typeof CharSetElement !== 'string') {
throw new $TypeError('Assertion failed: `CharSetElement` must be a string');
}
return CharSetElement.length !== 1;
}
function yieldCodeUnits(emit) {
for (var i = 0; i <= 0xDFFF; i += 1) {
emit($fromCharCode(i));
}
}
function testCodePoints(CharSetElement) {
if (typeof CharSetElement !== 'string') {
throw new $TypeError('Assertion failed: `CharSetElement` must be a string');
}
if (CharSetElement.length === 1) {
return true;
}
if (CharSetElement.length === 2) {
var hi = $charCodeAt(CharSetElement, 0);
var lo = $charCodeAt(CharSetElement, 1);
return isLeadingSurrogate(hi) && isTrailingSurrogate(lo);
}
return false;
}
function yieldCodePoints(emit) {
for (var i = 0; i <= 0xDFFF; i += 1) {
emit($fromCharCode(i));
}
for (var u = 0x10000; u <= 0x10FFFF; u += 1) {
var cp = u - 0x10000;
var high = (cp >> 10) + 0xD800;
var low = (cp & 0x3FF) + 0xDC00;
emit($fromCharCode(high, low));
}
}
function charsToMap(chars) {
if (!IsArray(chars)) {
throw new $TypeError('Assertion failed: `chars` must be an array');
}
var map = { __proto__: null };
for (var i = 0; i < chars.length; i += 1) {
var char = chars[i];
if (typeof char !== 'string' || (char.length !== 1 && char.length !== 2)) {
throw new $TypeError('Assertion failed: `chars` must be an array of strings of length 1');
}
map[char] = true;
}
return map;
}
module.exports = {
CharSet: CharSet,
from: function from(chars) {
var map = charsToMap(chars);
return new CharSet(
function test(CharSetElement) {
return hasOwn(map, CharSetElement);
},
function yieldChar(emit) {
// eslint-disable-next-line no-restricted-syntax
for (var k in map) {
if (hasOwn(map, k)) {
emit(k);
}
}
}
);
},
getCodeUnits: function () {
return new CharSet(testCodeUnits, yieldCodeUnits);
},
getCodePoints: function () {
return new CharSet(testCodePoints, yieldCodePoints);
},
getNonSimpleCaseFoldingCodePoints: function () {
return new CharSet(
function test(CharSetElement) {
return testCodePoints(CharSetElement) && !hasOwn(caseFolding.S, CharSetElement);
},
function yieldChar(emit) {
yieldCodePoints(function (CharSetElement) {
if (!hasOwn(caseFolding.S, CharSetElement)) {
emit(CharSetElement);
}
});
}
);
}
};

View File

@@ -0,0 +1,53 @@
'use strict';
var hasPropertyDescriptors = require('has-property-descriptors');
var $defineProperty = require('es-define-property');
var hasArrayLengthDefineBug = hasPropertyDescriptors.hasArrayLengthDefineBug();
// eslint-disable-next-line global-require
var isArray = hasArrayLengthDefineBug && require('../helpers/IsArray');
var callBound = require('call-bound');
var $isEnumerable = callBound('Object.prototype.propertyIsEnumerable');
// eslint-disable-next-line max-params
module.exports = function DefineOwnProperty(IsDataDescriptor, SameValue, FromPropertyDescriptor, O, P, desc) {
if (!$defineProperty) {
if (!IsDataDescriptor(desc)) {
// ES3 does not support getters/setters
return false;
}
if (!desc['[[Configurable]]'] || !desc['[[Writable]]']) {
return false;
}
// fallback for ES3
if (P in O && $isEnumerable(O, P) !== !!desc['[[Enumerable]]']) {
// a non-enumerable existing property
return false;
}
// property does not exist at all, or exists but is enumerable
var V = desc['[[Value]]'];
// eslint-disable-next-line no-param-reassign
O[P] = V; // will use [[Define]]
return SameValue(O[P], V);
}
if (
hasArrayLengthDefineBug
&& P === 'length'
&& '[[Value]]' in desc
&& isArray(O)
&& O.length !== desc['[[Value]]']
) {
// eslint-disable-next-line no-param-reassign
O.length = desc['[[Value]]'];
return O.length === desc['[[Value]]'];
}
$defineProperty(O, P, FromPropertyDescriptor(desc));
return true;
};

View File

@@ -0,0 +1,12 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $Array = GetIntrinsic('%Array%');
// eslint-disable-next-line global-require
var toStr = !$Array.isArray && require('call-bound')('Object.prototype.toString');
module.exports = $Array.isArray || function IsArray(argument) {
return toStr(argument) === '[object Array]';
};

View File

@@ -0,0 +1,4 @@
'use strict';
// TODO, semver-major: remove
module.exports = require('own-keys');

View File

@@ -0,0 +1,32 @@
'use strict';
// TODO, semver-major: delete this
var $TypeError = require('es-errors/type');
var $SyntaxError = require('es-errors/syntax');
var isMatchRecord = require('./records/match-record');
var isPropertyDescriptor = require('./records/property-descriptor');
var isIteratorRecord = require('./records/iterator-record-2023');
var isPromiseCapabilityRecord = require('./records/promise-capability-record');
var isAsyncGeneratorRequestRecord = require('./records/async-generator-request-record');
var isRegExpRecord = require('./records/regexp-record');
var predicates = {
'Property Descriptor': isPropertyDescriptor,
'Match Record': isMatchRecord,
'Iterator Record': isIteratorRecord,
'PromiseCapability Record': isPromiseCapabilityRecord,
'AsyncGeneratorRequest Record': isAsyncGeneratorRequestRecord,
'RegExp Record': isRegExpRecord
};
module.exports = function assertRecord(Type, recordType, argumentName, value) {
var predicate = predicates[recordType];
if (typeof predicate !== 'function') {
throw new $SyntaxError('unknown record type: ' + recordType);
}
if (!predicate(value)) {
throw new $TypeError(argumentName + ' must be a ' + recordType);
}
};

View File

@@ -0,0 +1,22 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var hasOwn = require('hasown');
var $assign = GetIntrinsic('%Object.assign%', true);
module.exports = function assign(target, source) {
if ($assign) {
return $assign(target, source);
}
// eslint-disable-next-line no-restricted-syntax
for (var key in source) {
if (hasOwn(source, key)) {
// eslint-disable-next-line no-param-reassign
target[key] = source[key];
}
}
return target;
};

View File

@@ -0,0 +1,47 @@
'use strict';
var $pow = require('math-intrinsics/pow');
module.exports = function bytesAsFloat32(rawBytes) {
// return new $Float16Array(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-2019 binary16 value.
If value is a NaN, return NaN.
Return the Number value that corresponds to value.
*/
var bits = (rawBytes[1] << 8) | rawBytes[0];
// extract sign, exponent, mantissa
var sign = bits & 0x8000 ? -1 : 1;
var exponent = (bits & 0x7C00) >> 10;
var mantissa = bits & 0x03FF;
// zero (±0)
if (exponent === 0 && mantissa === 0) {
return sign === 1 ? 0 : -0;
}
// infinities
if (exponent === 0x1F && mantissa === 0) {
return sign === 1 ? Infinity : -Infinity;
}
// NaN
if (exponent === 0x1F && mantissa !== 0) {
return NaN;
}
// remove bias (15)
exponent -= 15;
// subnormals
if (exponent === -15) {
// value = sign * (mantissa) * 2^(1-bias-10) = mantissa * 2^(-14-10)
return sign * mantissa * $pow(2, -24);
}
// normals
// value = sign * (1 + mantissa/2^10) * 2^exponent
return sign * (1 + (mantissa * $pow(2, -10))) * $pow(2, exponent);
};

View File

@@ -0,0 +1,36 @@
'use strict';
var $pow = require('math-intrinsics/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);
};

View File

@@ -0,0 +1,42 @@
'use strict';
var $pow = require('math-intrinsics/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);
};

View File

@@ -0,0 +1,32 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $pow = require('math-intrinsics/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] * $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
};

View File

@@ -0,0 +1,5 @@
'use strict';
// TODO; semver-major: remove
module.exports = require('call-bind');

View File

@@ -0,0 +1,5 @@
'use strict';
// TODO; semver-major: remove
module.exports = require('call-bound');

File diff suppressed because it is too large Load Diff

View 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

View File

@@ -0,0 +1,10 @@
'use strict';
module.exports = function every(array, predicate) {
for (var i = 0; i < array.length; i += 1) {
if (!predicate(array[i], i, array)) {
return false;
}
}
return true;
};

View File

@@ -0,0 +1,7 @@
'use strict';
module.exports = function forEach(array, callback) {
for (var i = 0; i < array.length; i += 1) {
callback(array[i], i, array); // eslint-disable-line callback-return
}
};

View 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;
};

View File

@@ -0,0 +1,27 @@
'use strict';
module.exports = function fromPropertyDescriptor(Desc) {
if (typeof Desc === 'undefined') {
return Desc;
}
var obj = {};
if ('[[Value]]' in Desc) {
obj.value = Desc['[[Value]]'];
}
if ('[[Writable]]' in Desc) {
obj.writable = !!Desc['[[Writable]]'];
}
if ('[[Get]]' in Desc) {
obj.get = Desc['[[Get]]'];
}
if ('[[Set]]' in Desc) {
obj.set = Desc['[[Set]]'];
}
if ('[[Enumerable]]' in Desc) {
obj.enumerable = !!Desc['[[Enumerable]]'];
}
if ('[[Configurable]]' in Desc) {
obj.configurable = !!Desc['[[Configurable]]'];
}
return obj;
};

View File

@@ -0,0 +1,4 @@
'use strict';
// TODO: remove, semver-major
module.exports = require('get-symbol-description/getInferredName');

View File

@@ -0,0 +1,50 @@
'use strict';
var hasSymbols = require('has-symbols')();
var GetIntrinsic = require('get-intrinsic');
var callBound = require('call-bound');
var isString = require('is-string');
var $iterator = GetIntrinsic('%Symbol.iterator%', true);
var $stringSlice = callBound('String.prototype.slice');
var $String = GetIntrinsic('%String%');
var IsArray = require('./IsArray');
module.exports = function getIteratorMethod(ES, iterable) {
var usingIterator;
if (hasSymbols) {
usingIterator = ES.GetMethod(iterable, $iterator);
} else if (IsArray(iterable)) {
usingIterator = function () {
var i = -1;
var arr = this; // eslint-disable-line no-invalid-this
return {
next: function () {
i += 1;
return {
done: i >= arr.length,
value: arr[i]
};
}
};
};
} else if (isString(iterable)) {
usingIterator = function () {
var i = 0;
return {
next: function () {
var nextIndex = ES.AdvanceStringIndex($String(iterable), i, true);
var value = $stringSlice(iterable, i, nextIndex);
i = nextIndex;
var done = nextIndex > iterable.length;
return {
done: done,
value: done ? void undefined : value
};
}
};
};
}
return usingIterator;
};

View File

@@ -0,0 +1,5 @@
'use strict';
// TODO: remove, semver-major
module.exports = require('gopd');

View File

@@ -0,0 +1,4 @@
'use strict';
// TODO, semver-major: remove
module.exports = require('get-proto');

View File

@@ -0,0 +1,4 @@
'use strict';
// TODO: remove, semver-major
module.exports = require('get-symbol-description');

View File

@@ -0,0 +1,21 @@
'use strict';
var $floor = require('math-intrinsics/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;
};

View 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
};

View File

@@ -0,0 +1,9 @@
'use strict';
var functionName = require('function.prototype.name');
var anon = functionName(function () {});
module.exports = function isAbstractClosure(x) {
return typeof x === 'function' && (!x.prototype || functionName(x) === anon);
};

View File

@@ -0,0 +1,5 @@
'use strict';
module.exports = function isByteValue(value) {
return typeof value === 'number' && value >= 0 && value <= 255 && (value | 0) === value;
};

View File

@@ -0,0 +1,5 @@
'use strict';
module.exports = function isCodePoint(cp) {
return typeof cp === 'number' && cp >= 0 && cp <= 0x10FFFF && (cp | 0) === cp;
};

View File

@@ -0,0 +1,4 @@
'use strict';
// TODO, semver-major: delete
module.exports = require('math-intrinsics/isFinite');

View File

@@ -0,0 +1,10 @@
'use strict';
var isPropertyDescriptor = require('./records/property-descriptor');
module.exports = function isFullyPopulatedPropertyDescriptor(ES, Desc) {
return isPropertyDescriptor(Desc)
&& '[[Enumerable]]' in Desc
&& '[[Configurable]]' in Desc
&& (ES.IsAccessorDescriptor(Desc) || ES.IsDataDescriptor(Desc));
};

View File

@@ -0,0 +1,4 @@
'use strict';
// TODO, semver-major: delete
module.exports = require('math-intrinsics/isInteger');

View File

@@ -0,0 +1,5 @@
'use strict';
module.exports = function isLeadingSurrogate(charCode) {
return typeof charCode === 'number' && charCode >= 0xD800 && charCode <= 0xDBFF;
};

View 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';
};

View File

@@ -0,0 +1,5 @@
'use strict';
module.exports = Number.isNaN || function isNaN(a) {
return a !== a;
};

View File

@@ -0,0 +1,6 @@
'use strict';
// TODO, semver-major: remove
module.exports = function isNegativeZero(x) {
return x === 0 && 1 / x === 1 / -0;
};

View File

@@ -0,0 +1,5 @@
'use strict';
// TODO: remove, semver-major
module.exports = require('es-object-atoms/isObject');

View File

@@ -0,0 +1,13 @@
'use strict';
var $strSlice = require('call-bound')('String.prototype.slice');
module.exports = function isPrefixOf(prefix, string) {
if (prefix === string) {
return true;
}
if (prefix.length > string.length) {
return false;
}
return $strSlice(string, 0, prefix.length) === prefix;
};

View File

@@ -0,0 +1,5 @@
'use strict';
module.exports = function isPrimitive(value) {
return value === null || (typeof value !== 'function' && typeof value !== 'object');
};

View File

@@ -0,0 +1,5 @@
'use strict';
module.exports = function isPropertyKey(argument) {
return typeof argument === 'string' || typeof argument === 'symbol';
};

View File

@@ -0,0 +1,20 @@
'use strict';
var every = require('./every');
module.exports = function isSamePropertyDescriptor(ES, D1, D2) {
var fields = [
'[[Configurable]]',
'[[Enumerable]]',
'[[Get]]',
'[[Set]]',
'[[Value]]',
'[[Writable]]'
];
return every(fields, function (field) {
if ((field in D1) !== (field in D2)) {
return false;
}
return ES.SameValue(D1[field], D2[field]);
});
};

View File

@@ -0,0 +1,16 @@
'use strict';
module.exports = function isSameType(x, y) {
if (x === y) {
return true;
}
if (typeof x === typeof y) {
if (typeof x !== 'object' || typeof y !== 'object') {
return true;
}
return !!x === !!y;
}
return false;
};

View File

@@ -0,0 +1,9 @@
'use strict';
// TODO: semver-major: remove
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');
};

View File

@@ -0,0 +1,5 @@
'use strict';
module.exports = function isStringOrUndefined(item) {
return typeof item === 'string' || typeof item === 'undefined';
};

View File

@@ -0,0 +1,5 @@
'use strict';
module.exports = function isTrailingSurrogate(charCode) {
return typeof charCode === 'number' && charCode >= 0xDC00 && charCode <= 0xDFFF;
};

View File

@@ -0,0 +1,4 @@
'use strict';
// TODO, semver-major: delete
module.exports = require('math-intrinsics/constants/maxSafeInteger');

View File

@@ -0,0 +1,3 @@
'use strict';
module.exports = Number.MAX_VALUE || 1.7976931348623157e+308;

View File

@@ -0,0 +1,4 @@
'use strict';
// TODO, semver-major: delete
module.exports = require('math-intrinsics/mod');

View File

@@ -0,0 +1,6 @@
'use strict';
module.exports = function bigIntMod(BigIntRemainder, bigint, modulo) {
var remain = BigIntRemainder(bigint, modulo);
return remain >= 0 ? remain : remain + modulo;
};

View File

@@ -0,0 +1,9 @@
'use strict';
var callBound = require('call-bound');
var $strSlice = callBound('String.prototype.slice');
module.exports = function padTimeComponent(c, count) {
return $strSlice('00' + c, -(count || 2));
};

View File

@@ -0,0 +1,13 @@
'use strict';
var hasOwn = require('hasown');
var isPromiseCapabilityRecord = require('./promise-capability-record');
module.exports = function isAsyncGeneratorRequestRecord(value) {
return !!value
&& typeof value === 'object'
&& hasOwn(value, '[[Completion]]') // TODO: confirm is a completion record
&& hasOwn(value, '[[Capability]]')
&& isPromiseCapabilityRecord(value['[[Capability]]']);
};

View File

@@ -0,0 +1,18 @@
'use strict';
var hasOwn = require('hasown');
var isDataView = require('is-data-view');
var isInteger = require('../isInteger');
module.exports = function isDataViewWithBufferWitnessRecord(value) {
return !!value
&& typeof value === 'object'
&& hasOwn(value, '[[Object]]')
&& hasOwn(value, '[[CachedBufferByteLength]]')
&& (
(isInteger(value['[[CachedBufferByteLength]]']) && value['[[CachedBufferByteLength]]'] >= 0)
|| value['[[CachedBufferByteLength]]'] === 'DETACHED'
)
&& isDataView(value['[[Object]]']);
};

View File

@@ -0,0 +1,7 @@
'use strict';
var isIteratorRecordNew = require('./iterator-record');
module.exports = function isIteratorRecord(value) {
return isIteratorRecordNew(value) && typeof value['[[NextMethod]]'] === 'function';
};

View File

@@ -0,0 +1,12 @@
'use strict';
var hasOwn = require('hasown');
module.exports = function isIteratorRecord(value) {
return !!value
&& typeof value === 'object'
&& hasOwn(value, '[[Iterator]]')
&& hasOwn(value, '[[NextMethod]]')
&& hasOwn(value, '[[Done]]')
&& typeof value['[[Done]]'] === 'boolean';
};

View File

@@ -0,0 +1,18 @@
'use strict';
var hasOwn = require('hasown');
// https://262.ecma-international.org/13.0/#sec-match-records
module.exports = function isMatchRecord(record) {
return (
!!record
&& typeof record === 'object'
&& hasOwn(record, '[[StartIndex]]')
&& hasOwn(record, '[[EndIndex]]')
&& record['[[StartIndex]]'] >= 0
&& record['[[EndIndex]]'] >= record['[[StartIndex]]']
&& String(parseInt(record['[[StartIndex]]'], 10)) === String(record['[[StartIndex]]'])
&& String(parseInt(record['[[EndIndex]]'], 10)) === String(record['[[EndIndex]]'])
);
};

View File

@@ -0,0 +1,16 @@
'use strict';
var hasOwn = require('hasown');
module.exports = function isPromiseCapabilityRecord(value) {
return !!value
&& typeof value === 'object'
&& hasOwn(value, '[[Resolve]]')
&& typeof value['[[Resolve]]'] === 'function'
&& hasOwn(value, '[[Reject]]')
&& typeof value['[[Reject]]'] === 'function'
&& hasOwn(value, '[[Promise]]')
&& !!value['[[Promise]]']
&& typeof value['[[Promise]]'] === 'object'
&& typeof value['[[Promise]]'].then === 'function';
};

View File

@@ -0,0 +1,36 @@
'use strict';
var $TypeError = require('es-errors/type');
var hasOwn = require('hasown');
var allowed = {
__proto__: null,
'[[Configurable]]': true,
'[[Enumerable]]': true,
'[[Get]]': true,
'[[Set]]': true,
'[[Value]]': true,
'[[Writable]]': true
};
// https://262.ecma-international.org/6.0/#sec-property-descriptor-specification-type
module.exports = function isPropertyDescriptor(Desc) {
if (!Desc || typeof Desc !== 'object') {
return false;
}
for (var key in Desc) { // eslint-disable-line
if (hasOwn(Desc, key) && !allowed[key]) {
return false;
}
}
var isData = hasOwn(Desc, '[[Value]]') || hasOwn(Desc, '[[Writable]]');
var IsAccessor = hasOwn(Desc, '[[Get]]') || hasOwn(Desc, '[[Set]]');
if (isData && IsAccessor) {
throw new $TypeError('Property Descriptors may not be both accessor and data descriptors');
}
return true;
};

View File

@@ -0,0 +1,23 @@
'use strict';
var hasOwn = require('hasown');
var isInteger = require('../isInteger');
module.exports = function isRegExpRecord(value) {
return !!value
&& typeof value === 'object'
&& hasOwn(value, '[[IgnoreCase]]')
&& typeof value['[[IgnoreCase]]'] === 'boolean'
&& hasOwn(value, '[[Multiline]]')
&& typeof value['[[Multiline]]'] === 'boolean'
&& hasOwn(value, '[[DotAll]]')
&& typeof value['[[DotAll]]'] === 'boolean'
&& hasOwn(value, '[[Unicode]]')
&& typeof value['[[Unicode]]'] === 'boolean'
&& hasOwn(value, '[[CapturingGroupsCount]]')
&& typeof value['[[CapturingGroupsCount]]'] === 'number'
&& isInteger(value['[[CapturingGroupsCount]]'])
&& value['[[CapturingGroupsCount]]'] >= 0
&& (!hasOwn(value, '[[UnicodeSets]]') || typeof value['[[UnicodeSets]]'] === 'boolean'); // optional since it was added later
};

View File

@@ -0,0 +1,21 @@
'use strict';
var hasOwn = require('hasown');
var isInteger = require('../isInteger');
module.exports = function isSetRecord(value) {
return !!value
&& typeof value === 'object'
&& hasOwn(value, '[[SetObject]]')
&& value['[[SetObject]]']
&& typeof value['[[SetObject]]'] === 'object'
&& hasOwn(value, '[[Size]]')
&& (
value['[[Size]]'] === Infinity
|| (isInteger(value['[[Size]]']) && value['[[Size]]'] >= 0)
)
&& hasOwn(value, '[[Has]]')
&& typeof value['[[Has]]'] === 'function'
&& hasOwn(value, '[[Keys]]')
&& typeof value['[[Keys]]'] === 'function';
};

View File

@@ -0,0 +1,18 @@
'use strict';
var hasOwn = require('hasown');
var isTypedArray = require('is-typed-array');
var isInteger = require('../isInteger');
module.exports = function isTypedArrayWithBufferWitnessRecord(value) {
return !!value
&& typeof value === 'object'
&& hasOwn(value, '[[Object]]')
&& hasOwn(value, '[[CachedBufferByteLength]]')
&& (
(isInteger(value['[[CachedBufferByteLength]]']) && value['[[CachedBufferByteLength]]'] >= 0)
|| value['[[CachedBufferByteLength]]'] === 'DETACHED'
)
&& isTypedArray(value['[[Object]]']);
};

View File

@@ -0,0 +1,9 @@
'use strict';
module.exports = function reduce(arr, fn, init) {
var acc = init;
for (var i = 0; i < arr.length; i += 1) {
acc = fn(acc, arr[i], i);
}
return acc;
};

View File

@@ -0,0 +1,5 @@
'use strict';
// TODO: remove, semver-major
module.exports = require('safe-regex-test');

View File

@@ -0,0 +1,4 @@
'use strict';
// TODO, semver-major: remove
module.exports = require('set-proto');

View File

@@ -0,0 +1,4 @@
'use strict';
// TODO, semver-major: delete
module.exports = require('math-intrinsics/sign');

View File

@@ -0,0 +1,10 @@
'use strict';
module.exports = function some(array, predicate) {
for (var i = 0; i < array.length; i += 1) {
if (predicate(array[i], i, array)) {
return true;
}
}
return false;
};

View File

@@ -0,0 +1,19 @@
'use strict';
var HoursPerDay = 24;
var MinutesPerHour = 60;
var SecondsPerMinute = 60;
var msPerSecond = 1e3;
var msPerMinute = msPerSecond * SecondsPerMinute;
var msPerHour = msPerMinute * MinutesPerHour;
var msPerDay = 86400000;
module.exports = {
HoursPerDay: HoursPerDay,
MinutesPerHour: MinutesPerHour,
SecondsPerMinute: SecondsPerMinute,
msPerSecond: msPerSecond,
msPerMinute: msPerMinute,
msPerHour: msPerHour,
msPerDay: msPerDay
};

View File

@@ -0,0 +1,7 @@
'use strict';
var $DateGetTime = require('call-bound')('Date.prototype.getTime');
module.exports = function timeValue(x) {
return $DateGetTime(x);
};

View File

@@ -0,0 +1,23 @@
'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),
$Float16Array: GetIntrinsic('%Float16Array%', true),
$Float32Array: GetIntrinsic('%Float32Array%', true),
$Float64Array: GetIntrinsic('%Float64Array%', true)
};
module.exports = function getConstructor(kind) {
return constructors['$' + kind];
};

View File

@@ -0,0 +1,73 @@
'use strict';
var $abs = require('math-intrinsics/abs');
var $floor = require('math-intrinsics/floor');
var $pow = require('math-intrinsics/pow');
var isFinite = require('math-intrinsics/isFinite');
var isNaN = require('math-intrinsics/isNaN');
var isNegativeZero = require('math-intrinsics/isNegativeZero');
var maxFiniteFloat16 = 65504; // 2**16 - 2**5
module.exports = function valueToFloat16Bytes(value, isLittleEndian) {
// NaN → exponent=all-ones, mantissa MSB=1 → 0x7e00
if (isNaN(value)) {
return isLittleEndian
? [0x00, 0x7e]
: [0x7e, 0x00];
}
var leastSig;
// ±0 → just the sign bit
if (value === 0) {
leastSig = isNegativeZero(value) ? 0x80 : 0x00;
return isLittleEndian
? [0x00, leastSig]
: [leastSig, 0x00];
}
// ±∞ → exponent=all-ones, mantissa=0 → 0x7c00 or 0xfc00
if ($abs(value) > maxFiniteFloat16 || !isFinite(value)) {
leastSig = value < 0 ? 0xfc : 0x7c;
return isLittleEndian
? [0x00, leastSig]
: [leastSig, 0x00];
}
var sign = value < 0 ? 1 : 0;
value = $abs(value); // eslint-disable-line no-param-reassign
// normalize to [1,2)
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
}
// build mantissa (10 bits)
var mantissa = value - 1;
mantissa *= $pow(2, 10) + 0.5;
mantissa = $floor(mantissa);
// apply bias (15) and shift into place
exponent += 15;
exponent <<= 10;
// pack sign, exponent, mantissa
var result = (sign << 15) | exponent | mantissa;
// split into two bytes
var byte0 = result & 0xFF;
result >>= 8;
var byte1 = result & 0xFF;
return isLittleEndian
? [byte0, byte1]
: [byte1, byte0];
};

View File

@@ -0,0 +1,67 @@
'use strict';
var $abs = require('math-intrinsics/abs');
var $floor = require('math-intrinsics/floor');
var $pow = require('math-intrinsics/pow');
var isFinite = require('math-intrinsics/isFinite');
var isNaN = require('math-intrinsics/isNaN');
var isNegativeZero = require('math-intrinsics/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];
};

View File

@@ -0,0 +1,83 @@
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $parseInt = GetIntrinsic('%parseInt%');
var $abs = require('math-intrinsics/abs');
var $floor = require('math-intrinsics/floor');
var isNegativeZero = require('math-intrinsics/isNegativeZero');
var callBound = require('call-bound');
var $strIndexOf = callBound('String.prototype.indexOf');
var $strSlice = callBound('String.prototype.slice');
var fractionToBitString = require('../helpers/fractionToBinaryString');
var intToBinString = require('../helpers/intToBinaryString');
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;
};