This commit is contained in:
16
node_modules/@petamoriken/float16/lib/DataView.cjs
generated
vendored
Normal file
16
node_modules/@petamoriken/float16/lib/DataView.cjs
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.getFloat16 = getFloat16;
|
||||
exports.setFloat16 = setFloat16;
|
||||
var _arrayIterator = require("./_util/arrayIterator.cjs");
|
||||
var _converter = require("./_util/converter.cjs");
|
||||
var _primordials = require("./_util/primordials.cjs");
|
||||
function getFloat16(dataView, byteOffset, ...opts) {
|
||||
return (0, _converter.convertToNumber)((0, _primordials.DataViewPrototypeGetUint16)(dataView, byteOffset, ...(0, _arrayIterator.safeIfNeeded)(opts)));
|
||||
}
|
||||
function setFloat16(dataView, byteOffset, value, ...opts) {
|
||||
return (0, _primordials.DataViewPrototypeSetUint16)(dataView, byteOffset, (0, _converter.roundToFloat16Bits)(value), ...(0, _arrayIterator.safeIfNeeded)(opts));
|
||||
}
|
||||
690
node_modules/@petamoriken/float16/lib/Float16Array.cjs
generated
vendored
Normal file
690
node_modules/@petamoriken/float16/lib/Float16Array.cjs
generated
vendored
Normal file
@@ -0,0 +1,690 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.isFloat16Array = isFloat16Array;
|
||||
var _arrayIterator = require("./_util/arrayIterator.cjs");
|
||||
var _brand = require("./_util/brand.cjs");
|
||||
var _converter = require("./_util/converter.cjs");
|
||||
var _is = require("./_util/is.cjs");
|
||||
var _messages = require("./_util/messages.cjs");
|
||||
var _primordials = require("./_util/primordials.cjs");
|
||||
var _spec = require("./_util/spec.cjs");
|
||||
const BYTES_PER_ELEMENT = 2;
|
||||
const float16bitsArrays = new _primordials.NativeWeakMap();
|
||||
function isFloat16Array(target) {
|
||||
return (0, _primordials.WeakMapPrototypeHas)(float16bitsArrays, target) || !(0, _primordials.ArrayBufferIsView)(target) && (0, _brand.hasFloat16ArrayBrand)(target);
|
||||
}
|
||||
function assertFloat16Array(target) {
|
||||
if (!isFloat16Array(target)) {
|
||||
throw (0, _primordials.NativeTypeError)(_messages.THIS_IS_NOT_A_FLOAT16ARRAY_OBJECT);
|
||||
}
|
||||
}
|
||||
function assertSpeciesTypedArray(target, count) {
|
||||
const isTargetFloat16Array = isFloat16Array(target);
|
||||
const isTargetTypedArray = (0, _is.isNativeTypedArray)(target);
|
||||
if (!isTargetFloat16Array && !isTargetTypedArray) {
|
||||
throw (0, _primordials.NativeTypeError)(_messages.SPECIES_CONSTRUCTOR_DIDNT_RETURN_TYPEDARRAY_OBJECT);
|
||||
}
|
||||
if (typeof count === "number") {
|
||||
let length;
|
||||
if (isTargetFloat16Array) {
|
||||
const float16bitsArray = getFloat16BitsArray(target);
|
||||
length = (0, _primordials.TypedArrayPrototypeGetLength)(float16bitsArray);
|
||||
} else {
|
||||
length = (0, _primordials.TypedArrayPrototypeGetLength)(target);
|
||||
}
|
||||
if (length < count) {
|
||||
throw (0, _primordials.NativeTypeError)(_messages.DERIVED_CONSTRUCTOR_CREATED_TYPEDARRAY_OBJECT_WHICH_WAS_TOO_SMALL_LENGTH);
|
||||
}
|
||||
}
|
||||
if ((0, _is.isNativeBigIntTypedArray)(target)) {
|
||||
throw (0, _primordials.NativeTypeError)(_messages.CANNOT_MIX_BIGINT_AND_OTHER_TYPES);
|
||||
}
|
||||
}
|
||||
function getFloat16BitsArray(float16) {
|
||||
const float16bitsArray = (0, _primordials.WeakMapPrototypeGet)(float16bitsArrays, float16);
|
||||
if (float16bitsArray !== undefined) {
|
||||
const buffer = (0, _primordials.TypedArrayPrototypeGetBuffer)(float16bitsArray);
|
||||
if ((0, _spec.IsDetachedBuffer)(buffer)) {
|
||||
throw (0, _primordials.NativeTypeError)(_messages.ATTEMPTING_TO_ACCESS_DETACHED_ARRAYBUFFER);
|
||||
}
|
||||
return float16bitsArray;
|
||||
}
|
||||
const buffer = float16.buffer;
|
||||
if ((0, _spec.IsDetachedBuffer)(buffer)) {
|
||||
throw (0, _primordials.NativeTypeError)(_messages.ATTEMPTING_TO_ACCESS_DETACHED_ARRAYBUFFER);
|
||||
}
|
||||
const cloned = (0, _primordials.ReflectConstruct)(Float16Array, [buffer, float16.byteOffset, float16.length], float16.constructor);
|
||||
return (0, _primordials.WeakMapPrototypeGet)(float16bitsArrays, cloned);
|
||||
}
|
||||
function copyToArray(float16bitsArray) {
|
||||
const length = (0, _primordials.TypedArrayPrototypeGetLength)(float16bitsArray);
|
||||
const array = [];
|
||||
for (let i = 0; i < length; ++i) {
|
||||
array[i] = (0, _converter.convertToNumber)(float16bitsArray[i]);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
const TypedArrayPrototypeGetters = new _primordials.NativeWeakSet();
|
||||
for (const key of (0, _primordials.ReflectOwnKeys)(_primordials.TypedArrayPrototype)) {
|
||||
if (key === _primordials.SymbolToStringTag) {
|
||||
continue;
|
||||
}
|
||||
const descriptor = (0, _primordials.ReflectGetOwnPropertyDescriptor)(_primordials.TypedArrayPrototype, key);
|
||||
if ((0, _primordials.ObjectHasOwn)(descriptor, "get") && typeof descriptor.get === "function") {
|
||||
(0, _primordials.WeakSetPrototypeAdd)(TypedArrayPrototypeGetters, descriptor.get);
|
||||
}
|
||||
}
|
||||
const handler = (0, _primordials.ObjectFreeze)({
|
||||
get(target, key, receiver) {
|
||||
if ((0, _is.isCanonicalIntegerIndexString)(key) && (0, _primordials.ObjectHasOwn)(target, key)) {
|
||||
return (0, _converter.convertToNumber)((0, _primordials.ReflectGet)(target, key));
|
||||
}
|
||||
if ((0, _primordials.WeakSetPrototypeHas)(TypedArrayPrototypeGetters, (0, _primordials.ObjectPrototype__lookupGetter__)(target, key))) {
|
||||
return (0, _primordials.ReflectGet)(target, key);
|
||||
}
|
||||
return (0, _primordials.ReflectGet)(target, key, receiver);
|
||||
},
|
||||
set(target, key, value, receiver) {
|
||||
if ((0, _is.isCanonicalIntegerIndexString)(key) && (0, _primordials.ObjectHasOwn)(target, key)) {
|
||||
return (0, _primordials.ReflectSet)(target, key, (0, _converter.roundToFloat16Bits)(value));
|
||||
}
|
||||
return (0, _primordials.ReflectSet)(target, key, value, receiver);
|
||||
},
|
||||
getOwnPropertyDescriptor(target, key) {
|
||||
if ((0, _is.isCanonicalIntegerIndexString)(key) && (0, _primordials.ObjectHasOwn)(target, key)) {
|
||||
const descriptor = (0, _primordials.ReflectGetOwnPropertyDescriptor)(target, key);
|
||||
descriptor.value = (0, _converter.convertToNumber)(descriptor.value);
|
||||
return descriptor;
|
||||
}
|
||||
return (0, _primordials.ReflectGetOwnPropertyDescriptor)(target, key);
|
||||
},
|
||||
defineProperty(target, key, descriptor) {
|
||||
if ((0, _is.isCanonicalIntegerIndexString)(key) && (0, _primordials.ObjectHasOwn)(target, key) && (0, _primordials.ObjectHasOwn)(descriptor, "value")) {
|
||||
descriptor.value = (0, _converter.roundToFloat16Bits)(descriptor.value);
|
||||
return (0, _primordials.ReflectDefineProperty)(target, key, descriptor);
|
||||
}
|
||||
return (0, _primordials.ReflectDefineProperty)(target, key, descriptor);
|
||||
}
|
||||
});
|
||||
class Float16Array {
|
||||
constructor(input, _byteOffset, _length) {
|
||||
let float16bitsArray;
|
||||
if (isFloat16Array(input)) {
|
||||
float16bitsArray = (0, _primordials.ReflectConstruct)(_primordials.NativeUint16Array, [getFloat16BitsArray(input)], new.target);
|
||||
} else if ((0, _is.isObject)(input) && !(0, _is.isAnyArrayBuffer)(input)) {
|
||||
let list;
|
||||
let length;
|
||||
if ((0, _is.isNativeTypedArray)(input)) {
|
||||
list = input;
|
||||
length = (0, _primordials.TypedArrayPrototypeGetLength)(input);
|
||||
const buffer = (0, _primordials.TypedArrayPrototypeGetBuffer)(input);
|
||||
if ((0, _spec.IsDetachedBuffer)(buffer)) {
|
||||
throw (0, _primordials.NativeTypeError)(_messages.ATTEMPTING_TO_ACCESS_DETACHED_ARRAYBUFFER);
|
||||
}
|
||||
if ((0, _is.isNativeBigIntTypedArray)(input)) {
|
||||
throw (0, _primordials.NativeTypeError)(_messages.CANNOT_MIX_BIGINT_AND_OTHER_TYPES);
|
||||
}
|
||||
const data = new _primordials.NativeArrayBuffer(length * BYTES_PER_ELEMENT);
|
||||
float16bitsArray = (0, _primordials.ReflectConstruct)(_primordials.NativeUint16Array, [data], new.target);
|
||||
} else {
|
||||
const iterator = input[_primordials.SymbolIterator];
|
||||
if (iterator != null && typeof iterator !== "function") {
|
||||
throw (0, _primordials.NativeTypeError)(_messages.ITERATOR_PROPERTY_IS_NOT_CALLABLE);
|
||||
}
|
||||
if (iterator != null) {
|
||||
if ((0, _is.isOrdinaryArray)(input)) {
|
||||
list = input;
|
||||
length = input.length;
|
||||
} else {
|
||||
list = [...(input)];
|
||||
length = list.length;
|
||||
}
|
||||
} else {
|
||||
list = input;
|
||||
length = (0, _spec.ToLength)(list.length);
|
||||
}
|
||||
float16bitsArray = (0, _primordials.ReflectConstruct)(_primordials.NativeUint16Array, [length], new.target);
|
||||
}
|
||||
for (let i = 0; i < length; ++i) {
|
||||
float16bitsArray[i] = (0, _converter.roundToFloat16Bits)(list[i]);
|
||||
}
|
||||
} else {
|
||||
float16bitsArray = (0, _primordials.ReflectConstruct)(_primordials.NativeUint16Array, arguments, new.target);
|
||||
}
|
||||
const proxy = new _primordials.NativeProxy(float16bitsArray, handler);
|
||||
(0, _primordials.WeakMapPrototypeSet)(float16bitsArrays, proxy, float16bitsArray);
|
||||
return proxy;
|
||||
}
|
||||
static from(src, ...opts) {
|
||||
const Constructor = this;
|
||||
if (!(0, _primordials.ReflectHas)(Constructor, _brand.brand)) {
|
||||
throw (0, _primordials.NativeTypeError)(_messages.THIS_CONSTRUCTOR_IS_NOT_A_SUBCLASS_OF_FLOAT16ARRAY);
|
||||
}
|
||||
if (Constructor === Float16Array) {
|
||||
if (isFloat16Array(src) && opts.length === 0) {
|
||||
const float16bitsArray = getFloat16BitsArray(src);
|
||||
const uint16 = new _primordials.NativeUint16Array((0, _primordials.TypedArrayPrototypeGetBuffer)(float16bitsArray), (0, _primordials.TypedArrayPrototypeGetByteOffset)(float16bitsArray), (0, _primordials.TypedArrayPrototypeGetLength)(float16bitsArray));
|
||||
return new Float16Array((0, _primordials.TypedArrayPrototypeGetBuffer)((0, _primordials.TypedArrayPrototypeSlice)(uint16)));
|
||||
}
|
||||
if (opts.length === 0) {
|
||||
return new Float16Array((0, _primordials.TypedArrayPrototypeGetBuffer)((0, _primordials.Uint16ArrayFrom)(src, _converter.roundToFloat16Bits)));
|
||||
}
|
||||
const mapFunc = opts[0];
|
||||
const thisArg = opts[1];
|
||||
return new Float16Array((0, _primordials.TypedArrayPrototypeGetBuffer)((0, _primordials.Uint16ArrayFrom)(src, function (val, ...args) {
|
||||
return (0, _converter.roundToFloat16Bits)((0, _primordials.ReflectApply)(mapFunc, this, [val, ...(0, _arrayIterator.safeIfNeeded)(args)]));
|
||||
}, thisArg)));
|
||||
}
|
||||
let list;
|
||||
let length;
|
||||
const iterator = src[_primordials.SymbolIterator];
|
||||
if (iterator != null && typeof iterator !== "function") {
|
||||
throw (0, _primordials.NativeTypeError)(_messages.ITERATOR_PROPERTY_IS_NOT_CALLABLE);
|
||||
}
|
||||
if (iterator != null) {
|
||||
if ((0, _is.isOrdinaryArray)(src)) {
|
||||
list = src;
|
||||
length = src.length;
|
||||
} else if ((0, _is.isOrdinaryNativeTypedArray)(src)) {
|
||||
list = src;
|
||||
length = (0, _primordials.TypedArrayPrototypeGetLength)(src);
|
||||
} else {
|
||||
list = [...src];
|
||||
length = list.length;
|
||||
}
|
||||
} else {
|
||||
if (src == null) {
|
||||
throw (0, _primordials.NativeTypeError)(_messages.CANNOT_CONVERT_UNDEFINED_OR_NULL_TO_OBJECT);
|
||||
}
|
||||
list = (0, _primordials.NativeObject)(src);
|
||||
length = (0, _spec.ToLength)(list.length);
|
||||
}
|
||||
const array = new Constructor(length);
|
||||
if (opts.length === 0) {
|
||||
for (let i = 0; i < length; ++i) {
|
||||
array[i] = list[i];
|
||||
}
|
||||
} else {
|
||||
const mapFunc = opts[0];
|
||||
const thisArg = opts[1];
|
||||
for (let i = 0; i < length; ++i) {
|
||||
array[i] = (0, _primordials.ReflectApply)(mapFunc, thisArg, [list[i], i]);
|
||||
}
|
||||
}
|
||||
return array;
|
||||
}
|
||||
static of(...items) {
|
||||
const Constructor = this;
|
||||
if (!(0, _primordials.ReflectHas)(Constructor, _brand.brand)) {
|
||||
throw (0, _primordials.NativeTypeError)(_messages.THIS_CONSTRUCTOR_IS_NOT_A_SUBCLASS_OF_FLOAT16ARRAY);
|
||||
}
|
||||
const length = items.length;
|
||||
if (Constructor === Float16Array) {
|
||||
const proxy = new Float16Array(length);
|
||||
const float16bitsArray = getFloat16BitsArray(proxy);
|
||||
for (let i = 0; i < length; ++i) {
|
||||
float16bitsArray[i] = (0, _converter.roundToFloat16Bits)(items[i]);
|
||||
}
|
||||
return proxy;
|
||||
}
|
||||
const array = new Constructor(length);
|
||||
for (let i = 0; i < length; ++i) {
|
||||
array[i] = items[i];
|
||||
}
|
||||
return array;
|
||||
}
|
||||
keys() {
|
||||
assertFloat16Array(this);
|
||||
const float16bitsArray = getFloat16BitsArray(this);
|
||||
return (0, _primordials.TypedArrayPrototypeKeys)(float16bitsArray);
|
||||
}
|
||||
values() {
|
||||
assertFloat16Array(this);
|
||||
const float16bitsArray = getFloat16BitsArray(this);
|
||||
return (0, _arrayIterator.wrap)(function* () {
|
||||
for (const val of (0, _primordials.TypedArrayPrototypeValues)(float16bitsArray)) {
|
||||
yield (0, _converter.convertToNumber)(val);
|
||||
}
|
||||
}());
|
||||
}
|
||||
entries() {
|
||||
assertFloat16Array(this);
|
||||
const float16bitsArray = getFloat16BitsArray(this);
|
||||
return (0, _arrayIterator.wrap)(function* () {
|
||||
for (const [i, val] of (0, _primordials.TypedArrayPrototypeEntries)(float16bitsArray)) {
|
||||
yield ([i, (0, _converter.convertToNumber)(val)]);
|
||||
}
|
||||
}());
|
||||
}
|
||||
at(index) {
|
||||
assertFloat16Array(this);
|
||||
const float16bitsArray = getFloat16BitsArray(this);
|
||||
const length = (0, _primordials.TypedArrayPrototypeGetLength)(float16bitsArray);
|
||||
const relativeIndex = (0, _spec.ToIntegerOrInfinity)(index);
|
||||
const k = relativeIndex >= 0 ? relativeIndex : length + relativeIndex;
|
||||
if (k < 0 || k >= length) {
|
||||
return;
|
||||
}
|
||||
return (0, _converter.convertToNumber)(float16bitsArray[k]);
|
||||
}
|
||||
with(index, value) {
|
||||
assertFloat16Array(this);
|
||||
const float16bitsArray = getFloat16BitsArray(this);
|
||||
const length = (0, _primordials.TypedArrayPrototypeGetLength)(float16bitsArray);
|
||||
const relativeIndex = (0, _spec.ToIntegerOrInfinity)(index);
|
||||
const k = relativeIndex >= 0 ? relativeIndex : length + relativeIndex;
|
||||
const number = +value;
|
||||
if (k < 0 || k >= length) {
|
||||
throw (0, _primordials.NativeRangeError)(_messages.OFFSET_IS_OUT_OF_BOUNDS);
|
||||
}
|
||||
const uint16 = new _primordials.NativeUint16Array((0, _primordials.TypedArrayPrototypeGetBuffer)(float16bitsArray), (0, _primordials.TypedArrayPrototypeGetByteOffset)(float16bitsArray), (0, _primordials.TypedArrayPrototypeGetLength)(float16bitsArray));
|
||||
const cloned = new Float16Array((0, _primordials.TypedArrayPrototypeGetBuffer)((0, _primordials.TypedArrayPrototypeSlice)(uint16)));
|
||||
const array = getFloat16BitsArray(cloned);
|
||||
array[k] = (0, _converter.roundToFloat16Bits)(number);
|
||||
return cloned;
|
||||
}
|
||||
map(callback, ...opts) {
|
||||
assertFloat16Array(this);
|
||||
const float16bitsArray = getFloat16BitsArray(this);
|
||||
const length = (0, _primordials.TypedArrayPrototypeGetLength)(float16bitsArray);
|
||||
const thisArg = opts[0];
|
||||
const Constructor = (0, _spec.SpeciesConstructor)(float16bitsArray, Float16Array);
|
||||
if (Constructor === Float16Array) {
|
||||
const proxy = new Float16Array(length);
|
||||
const array = getFloat16BitsArray(proxy);
|
||||
for (let i = 0; i < length; ++i) {
|
||||
const val = (0, _converter.convertToNumber)(float16bitsArray[i]);
|
||||
array[i] = (0, _converter.roundToFloat16Bits)((0, _primordials.ReflectApply)(callback, thisArg, [val, i, this]));
|
||||
}
|
||||
return proxy;
|
||||
}
|
||||
const array = new Constructor(length);
|
||||
assertSpeciesTypedArray(array, length);
|
||||
for (let i = 0; i < length; ++i) {
|
||||
const val = (0, _converter.convertToNumber)(float16bitsArray[i]);
|
||||
array[i] = (0, _primordials.ReflectApply)(callback, thisArg, [val, i, this]);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
filter(callback, ...opts) {
|
||||
assertFloat16Array(this);
|
||||
const float16bitsArray = getFloat16BitsArray(this);
|
||||
const length = (0, _primordials.TypedArrayPrototypeGetLength)(float16bitsArray);
|
||||
const thisArg = opts[0];
|
||||
const kept = [];
|
||||
for (let i = 0; i < length; ++i) {
|
||||
const val = (0, _converter.convertToNumber)(float16bitsArray[i]);
|
||||
if ((0, _primordials.ReflectApply)(callback, thisArg, [val, i, this])) {
|
||||
(0, _primordials.ArrayPrototypePush)(kept, val);
|
||||
}
|
||||
}
|
||||
const Constructor = (0, _spec.SpeciesConstructor)(float16bitsArray, Float16Array);
|
||||
const array = new Constructor(kept);
|
||||
assertSpeciesTypedArray(array);
|
||||
return array;
|
||||
}
|
||||
reduce(callback, ...opts) {
|
||||
assertFloat16Array(this);
|
||||
const float16bitsArray = getFloat16BitsArray(this);
|
||||
const length = (0, _primordials.TypedArrayPrototypeGetLength)(float16bitsArray);
|
||||
if (length === 0 && opts.length === 0) {
|
||||
throw (0, _primordials.NativeTypeError)(_messages.REDUCE_OF_EMPTY_ARRAY_WITH_NO_INITIAL_VALUE);
|
||||
}
|
||||
let accumulator, start;
|
||||
if (opts.length === 0) {
|
||||
accumulator = (0, _converter.convertToNumber)(float16bitsArray[0]);
|
||||
start = 1;
|
||||
} else {
|
||||
accumulator = opts[0];
|
||||
start = 0;
|
||||
}
|
||||
for (let i = start; i < length; ++i) {
|
||||
accumulator = callback(accumulator, (0, _converter.convertToNumber)(float16bitsArray[i]), i, this);
|
||||
}
|
||||
return accumulator;
|
||||
}
|
||||
reduceRight(callback, ...opts) {
|
||||
assertFloat16Array(this);
|
||||
const float16bitsArray = getFloat16BitsArray(this);
|
||||
const length = (0, _primordials.TypedArrayPrototypeGetLength)(float16bitsArray);
|
||||
if (length === 0 && opts.length === 0) {
|
||||
throw (0, _primordials.NativeTypeError)(_messages.REDUCE_OF_EMPTY_ARRAY_WITH_NO_INITIAL_VALUE);
|
||||
}
|
||||
let accumulator, start;
|
||||
if (opts.length === 0) {
|
||||
accumulator = (0, _converter.convertToNumber)(float16bitsArray[length - 1]);
|
||||
start = length - 2;
|
||||
} else {
|
||||
accumulator = opts[0];
|
||||
start = length - 1;
|
||||
}
|
||||
for (let i = start; i >= 0; --i) {
|
||||
accumulator = callback(accumulator, (0, _converter.convertToNumber)(float16bitsArray[i]), i, this);
|
||||
}
|
||||
return accumulator;
|
||||
}
|
||||
forEach(callback, ...opts) {
|
||||
assertFloat16Array(this);
|
||||
const float16bitsArray = getFloat16BitsArray(this);
|
||||
const length = (0, _primordials.TypedArrayPrototypeGetLength)(float16bitsArray);
|
||||
const thisArg = opts[0];
|
||||
for (let i = 0; i < length; ++i) {
|
||||
(0, _primordials.ReflectApply)(callback, thisArg, [(0, _converter.convertToNumber)(float16bitsArray[i]), i, this]);
|
||||
}
|
||||
}
|
||||
find(callback, ...opts) {
|
||||
assertFloat16Array(this);
|
||||
const float16bitsArray = getFloat16BitsArray(this);
|
||||
const length = (0, _primordials.TypedArrayPrototypeGetLength)(float16bitsArray);
|
||||
const thisArg = opts[0];
|
||||
for (let i = 0; i < length; ++i) {
|
||||
const value = (0, _converter.convertToNumber)(float16bitsArray[i]);
|
||||
if ((0, _primordials.ReflectApply)(callback, thisArg, [value, i, this])) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
findIndex(callback, ...opts) {
|
||||
assertFloat16Array(this);
|
||||
const float16bitsArray = getFloat16BitsArray(this);
|
||||
const length = (0, _primordials.TypedArrayPrototypeGetLength)(float16bitsArray);
|
||||
const thisArg = opts[0];
|
||||
for (let i = 0; i < length; ++i) {
|
||||
const value = (0, _converter.convertToNumber)(float16bitsArray[i]);
|
||||
if ((0, _primordials.ReflectApply)(callback, thisArg, [value, i, this])) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
findLast(callback, ...opts) {
|
||||
assertFloat16Array(this);
|
||||
const float16bitsArray = getFloat16BitsArray(this);
|
||||
const length = (0, _primordials.TypedArrayPrototypeGetLength)(float16bitsArray);
|
||||
const thisArg = opts[0];
|
||||
for (let i = length - 1; i >= 0; --i) {
|
||||
const value = (0, _converter.convertToNumber)(float16bitsArray[i]);
|
||||
if ((0, _primordials.ReflectApply)(callback, thisArg, [value, i, this])) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
findLastIndex(callback, ...opts) {
|
||||
assertFloat16Array(this);
|
||||
const float16bitsArray = getFloat16BitsArray(this);
|
||||
const length = (0, _primordials.TypedArrayPrototypeGetLength)(float16bitsArray);
|
||||
const thisArg = opts[0];
|
||||
for (let i = length - 1; i >= 0; --i) {
|
||||
const value = (0, _converter.convertToNumber)(float16bitsArray[i]);
|
||||
if ((0, _primordials.ReflectApply)(callback, thisArg, [value, i, this])) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
every(callback, ...opts) {
|
||||
assertFloat16Array(this);
|
||||
const float16bitsArray = getFloat16BitsArray(this);
|
||||
const length = (0, _primordials.TypedArrayPrototypeGetLength)(float16bitsArray);
|
||||
const thisArg = opts[0];
|
||||
for (let i = 0; i < length; ++i) {
|
||||
if (!(0, _primordials.ReflectApply)(callback, thisArg, [(0, _converter.convertToNumber)(float16bitsArray[i]), i, this])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
some(callback, ...opts) {
|
||||
assertFloat16Array(this);
|
||||
const float16bitsArray = getFloat16BitsArray(this);
|
||||
const length = (0, _primordials.TypedArrayPrototypeGetLength)(float16bitsArray);
|
||||
const thisArg = opts[0];
|
||||
for (let i = 0; i < length; ++i) {
|
||||
if ((0, _primordials.ReflectApply)(callback, thisArg, [(0, _converter.convertToNumber)(float16bitsArray[i]), i, this])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
set(input, ...opts) {
|
||||
assertFloat16Array(this);
|
||||
const float16bitsArray = getFloat16BitsArray(this);
|
||||
const targetOffset = (0, _spec.ToIntegerOrInfinity)(opts[0]);
|
||||
if (targetOffset < 0) {
|
||||
throw (0, _primordials.NativeRangeError)(_messages.OFFSET_IS_OUT_OF_BOUNDS);
|
||||
}
|
||||
if (input == null) {
|
||||
throw (0, _primordials.NativeTypeError)(_messages.CANNOT_CONVERT_UNDEFINED_OR_NULL_TO_OBJECT);
|
||||
}
|
||||
if ((0, _is.isNativeBigIntTypedArray)(input)) {
|
||||
throw (0, _primordials.NativeTypeError)(_messages.CANNOT_MIX_BIGINT_AND_OTHER_TYPES);
|
||||
}
|
||||
if (isFloat16Array(input)) {
|
||||
return (0, _primordials.TypedArrayPrototypeSet)(getFloat16BitsArray(this), getFloat16BitsArray(input), targetOffset);
|
||||
}
|
||||
if ((0, _is.isNativeTypedArray)(input)) {
|
||||
const buffer = (0, _primordials.TypedArrayPrototypeGetBuffer)(input);
|
||||
if ((0, _spec.IsDetachedBuffer)(buffer)) {
|
||||
throw (0, _primordials.NativeTypeError)(_messages.ATTEMPTING_TO_ACCESS_DETACHED_ARRAYBUFFER);
|
||||
}
|
||||
}
|
||||
const targetLength = (0, _primordials.TypedArrayPrototypeGetLength)(float16bitsArray);
|
||||
const src = (0, _primordials.NativeObject)(input);
|
||||
const srcLength = (0, _spec.ToLength)(src.length);
|
||||
if (targetOffset === Infinity || srcLength + targetOffset > targetLength) {
|
||||
throw (0, _primordials.NativeRangeError)(_messages.OFFSET_IS_OUT_OF_BOUNDS);
|
||||
}
|
||||
for (let i = 0; i < srcLength; ++i) {
|
||||
float16bitsArray[i + targetOffset] = (0, _converter.roundToFloat16Bits)(src[i]);
|
||||
}
|
||||
}
|
||||
reverse() {
|
||||
assertFloat16Array(this);
|
||||
const float16bitsArray = getFloat16BitsArray(this);
|
||||
(0, _primordials.TypedArrayPrototypeReverse)(float16bitsArray);
|
||||
return this;
|
||||
}
|
||||
toReversed() {
|
||||
assertFloat16Array(this);
|
||||
const float16bitsArray = getFloat16BitsArray(this);
|
||||
const uint16 = new _primordials.NativeUint16Array((0, _primordials.TypedArrayPrototypeGetBuffer)(float16bitsArray), (0, _primordials.TypedArrayPrototypeGetByteOffset)(float16bitsArray), (0, _primordials.TypedArrayPrototypeGetLength)(float16bitsArray));
|
||||
const cloned = new Float16Array((0, _primordials.TypedArrayPrototypeGetBuffer)((0, _primordials.TypedArrayPrototypeSlice)(uint16)));
|
||||
const clonedFloat16bitsArray = getFloat16BitsArray(cloned);
|
||||
(0, _primordials.TypedArrayPrototypeReverse)(clonedFloat16bitsArray);
|
||||
return cloned;
|
||||
}
|
||||
fill(value, ...opts) {
|
||||
assertFloat16Array(this);
|
||||
const float16bitsArray = getFloat16BitsArray(this);
|
||||
(0, _primordials.TypedArrayPrototypeFill)(float16bitsArray, (0, _converter.roundToFloat16Bits)(value), ...(0, _arrayIterator.safeIfNeeded)(opts));
|
||||
return this;
|
||||
}
|
||||
copyWithin(target, start, ...opts) {
|
||||
assertFloat16Array(this);
|
||||
const float16bitsArray = getFloat16BitsArray(this);
|
||||
(0, _primordials.TypedArrayPrototypeCopyWithin)(float16bitsArray, target, start, ...(0, _arrayIterator.safeIfNeeded)(opts));
|
||||
return this;
|
||||
}
|
||||
sort(compareFn) {
|
||||
assertFloat16Array(this);
|
||||
const float16bitsArray = getFloat16BitsArray(this);
|
||||
const sortCompare = compareFn !== undefined ? compareFn : _spec.defaultCompare;
|
||||
(0, _primordials.TypedArrayPrototypeSort)(float16bitsArray, (x, y) => {
|
||||
return sortCompare((0, _converter.convertToNumber)(x), (0, _converter.convertToNumber)(y));
|
||||
});
|
||||
return this;
|
||||
}
|
||||
toSorted(compareFn) {
|
||||
assertFloat16Array(this);
|
||||
const float16bitsArray = getFloat16BitsArray(this);
|
||||
if (compareFn !== undefined && typeof compareFn !== "function") {
|
||||
throw new _primordials.NativeTypeError(_messages.THE_COMPARISON_FUNCTION_MUST_BE_EITHER_A_FUNCTION_OR_UNDEFINED);
|
||||
}
|
||||
const sortCompare = compareFn !== undefined ? compareFn : _spec.defaultCompare;
|
||||
const uint16 = new _primordials.NativeUint16Array((0, _primordials.TypedArrayPrototypeGetBuffer)(float16bitsArray), (0, _primordials.TypedArrayPrototypeGetByteOffset)(float16bitsArray), (0, _primordials.TypedArrayPrototypeGetLength)(float16bitsArray));
|
||||
const cloned = new Float16Array((0, _primordials.TypedArrayPrototypeGetBuffer)((0, _primordials.TypedArrayPrototypeSlice)(uint16)));
|
||||
const clonedFloat16bitsArray = getFloat16BitsArray(cloned);
|
||||
(0, _primordials.TypedArrayPrototypeSort)(clonedFloat16bitsArray, (x, y) => {
|
||||
return sortCompare((0, _converter.convertToNumber)(x), (0, _converter.convertToNumber)(y));
|
||||
});
|
||||
return cloned;
|
||||
}
|
||||
slice(start, end) {
|
||||
assertFloat16Array(this);
|
||||
const float16bitsArray = getFloat16BitsArray(this);
|
||||
const Constructor = (0, _spec.SpeciesConstructor)(float16bitsArray, Float16Array);
|
||||
if (Constructor === Float16Array) {
|
||||
const uint16 = new _primordials.NativeUint16Array((0, _primordials.TypedArrayPrototypeGetBuffer)(float16bitsArray), (0, _primordials.TypedArrayPrototypeGetByteOffset)(float16bitsArray), (0, _primordials.TypedArrayPrototypeGetLength)(float16bitsArray));
|
||||
return new Float16Array((0, _primordials.TypedArrayPrototypeGetBuffer)((0, _primordials.TypedArrayPrototypeSlice)(uint16, start, end)));
|
||||
}
|
||||
const length = (0, _primordials.TypedArrayPrototypeGetLength)(float16bitsArray);
|
||||
const relativeStart = (0, _spec.ToIntegerOrInfinity)(start);
|
||||
const relativeEnd = end === undefined ? length : (0, _spec.ToIntegerOrInfinity)(end);
|
||||
let k;
|
||||
if (relativeStart === -Infinity) {
|
||||
k = 0;
|
||||
} else if (relativeStart < 0) {
|
||||
k = length + relativeStart > 0 ? length + relativeStart : 0;
|
||||
} else {
|
||||
k = length < relativeStart ? length : relativeStart;
|
||||
}
|
||||
let final;
|
||||
if (relativeEnd === -Infinity) {
|
||||
final = 0;
|
||||
} else if (relativeEnd < 0) {
|
||||
final = length + relativeEnd > 0 ? length + relativeEnd : 0;
|
||||
} else {
|
||||
final = length < relativeEnd ? length : relativeEnd;
|
||||
}
|
||||
const count = final - k > 0 ? final - k : 0;
|
||||
const array = new Constructor(count);
|
||||
assertSpeciesTypedArray(array, count);
|
||||
if (count === 0) {
|
||||
return array;
|
||||
}
|
||||
const buffer = (0, _primordials.TypedArrayPrototypeGetBuffer)(float16bitsArray);
|
||||
if ((0, _spec.IsDetachedBuffer)(buffer)) {
|
||||
throw (0, _primordials.NativeTypeError)(_messages.ATTEMPTING_TO_ACCESS_DETACHED_ARRAYBUFFER);
|
||||
}
|
||||
let n = 0;
|
||||
while (k < final) {
|
||||
array[n] = (0, _converter.convertToNumber)(float16bitsArray[k]);
|
||||
++k;
|
||||
++n;
|
||||
}
|
||||
return array;
|
||||
}
|
||||
subarray(begin, end) {
|
||||
assertFloat16Array(this);
|
||||
const float16bitsArray = getFloat16BitsArray(this);
|
||||
const Constructor = (0, _spec.SpeciesConstructor)(float16bitsArray, Float16Array);
|
||||
const uint16 = new _primordials.NativeUint16Array((0, _primordials.TypedArrayPrototypeGetBuffer)(float16bitsArray), (0, _primordials.TypedArrayPrototypeGetByteOffset)(float16bitsArray), (0, _primordials.TypedArrayPrototypeGetLength)(float16bitsArray));
|
||||
const uint16Subarray = (0, _primordials.TypedArrayPrototypeSubarray)(uint16, begin, end);
|
||||
const array = new Constructor((0, _primordials.TypedArrayPrototypeGetBuffer)(uint16Subarray), (0, _primordials.TypedArrayPrototypeGetByteOffset)(uint16Subarray), (0, _primordials.TypedArrayPrototypeGetLength)(uint16Subarray));
|
||||
assertSpeciesTypedArray(array);
|
||||
return array;
|
||||
}
|
||||
indexOf(element, ...opts) {
|
||||
assertFloat16Array(this);
|
||||
const float16bitsArray = getFloat16BitsArray(this);
|
||||
const length = (0, _primordials.TypedArrayPrototypeGetLength)(float16bitsArray);
|
||||
let from = (0, _spec.ToIntegerOrInfinity)(opts[0]);
|
||||
if (from === Infinity) {
|
||||
return -1;
|
||||
}
|
||||
if (from < 0) {
|
||||
from += length;
|
||||
if (from < 0) {
|
||||
from = 0;
|
||||
}
|
||||
}
|
||||
for (let i = from; i < length; ++i) {
|
||||
if ((0, _primordials.ObjectHasOwn)(float16bitsArray, i) && (0, _converter.convertToNumber)(float16bitsArray[i]) === element) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
lastIndexOf(element, ...opts) {
|
||||
assertFloat16Array(this);
|
||||
const float16bitsArray = getFloat16BitsArray(this);
|
||||
const length = (0, _primordials.TypedArrayPrototypeGetLength)(float16bitsArray);
|
||||
let from = opts.length >= 1 ? (0, _spec.ToIntegerOrInfinity)(opts[0]) : length - 1;
|
||||
if (from === -Infinity) {
|
||||
return -1;
|
||||
}
|
||||
if (from >= 0) {
|
||||
from = from < length - 1 ? from : length - 1;
|
||||
} else {
|
||||
from += length;
|
||||
}
|
||||
for (let i = from; i >= 0; --i) {
|
||||
if ((0, _primordials.ObjectHasOwn)(float16bitsArray, i) && (0, _converter.convertToNumber)(float16bitsArray[i]) === element) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
includes(element, ...opts) {
|
||||
assertFloat16Array(this);
|
||||
const float16bitsArray = getFloat16BitsArray(this);
|
||||
const length = (0, _primordials.TypedArrayPrototypeGetLength)(float16bitsArray);
|
||||
let from = (0, _spec.ToIntegerOrInfinity)(opts[0]);
|
||||
if (from === Infinity) {
|
||||
return false;
|
||||
}
|
||||
if (from < 0) {
|
||||
from += length;
|
||||
if (from < 0) {
|
||||
from = 0;
|
||||
}
|
||||
}
|
||||
const isNaN = (0, _primordials.NumberIsNaN)(element);
|
||||
for (let i = from; i < length; ++i) {
|
||||
const value = (0, _converter.convertToNumber)(float16bitsArray[i]);
|
||||
if (isNaN && (0, _primordials.NumberIsNaN)(value)) {
|
||||
return true;
|
||||
}
|
||||
if (value === element) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
join(separator) {
|
||||
assertFloat16Array(this);
|
||||
const float16bitsArray = getFloat16BitsArray(this);
|
||||
const array = copyToArray(float16bitsArray);
|
||||
return (0, _primordials.ArrayPrototypeJoin)(array, separator);
|
||||
}
|
||||
toLocaleString(...opts) {
|
||||
assertFloat16Array(this);
|
||||
const float16bitsArray = getFloat16BitsArray(this);
|
||||
const array = copyToArray(float16bitsArray);
|
||||
return (0, _primordials.ArrayPrototypeToLocaleString)(array, ...(0, _arrayIterator.safeIfNeeded)(opts));
|
||||
}
|
||||
get [_primordials.SymbolToStringTag]() {
|
||||
if (isFloat16Array(this)) {
|
||||
return "Float16Array";
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.Float16Array = Float16Array;
|
||||
(0, _primordials.ObjectDefineProperty)(Float16Array, "BYTES_PER_ELEMENT", {
|
||||
value: BYTES_PER_ELEMENT
|
||||
});
|
||||
(0, _primordials.ObjectDefineProperty)(Float16Array, _brand.brand, {});
|
||||
(0, _primordials.ReflectSetPrototypeOf)(Float16Array, _primordials.TypedArray);
|
||||
const Float16ArrayPrototype = Float16Array.prototype;
|
||||
(0, _primordials.ObjectDefineProperty)(Float16ArrayPrototype, "BYTES_PER_ELEMENT", {
|
||||
value: BYTES_PER_ELEMENT
|
||||
});
|
||||
(0, _primordials.ObjectDefineProperty)(Float16ArrayPrototype, _primordials.SymbolIterator, {
|
||||
value: Float16ArrayPrototype.values,
|
||||
writable: true,
|
||||
configurable: true
|
||||
});
|
||||
(0, _primordials.ReflectSetPrototypeOf)(Float16ArrayPrototype, _primordials.TypedArrayPrototype);
|
||||
52
node_modules/@petamoriken/float16/lib/_util/arrayIterator.cjs
generated
vendored
Normal file
52
node_modules/@petamoriken/float16/lib/_util/arrayIterator.cjs
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.safeIfNeeded = safeIfNeeded;
|
||||
exports.wrap = wrap;
|
||||
var _primordials = require("./primordials.cjs");
|
||||
const arrayIterators = new _primordials.NativeWeakMap();
|
||||
const SafeIteratorPrototype = (0, _primordials.ObjectCreate)(null, {
|
||||
next: {
|
||||
value: function next() {
|
||||
const arrayIterator = (0, _primordials.WeakMapPrototypeGet)(arrayIterators, this);
|
||||
return (0, _primordials.ArrayIteratorPrototypeNext)(arrayIterator);
|
||||
}
|
||||
},
|
||||
[_primordials.SymbolIterator]: {
|
||||
value: function values() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
});
|
||||
function safeIfNeeded(array) {
|
||||
if (array[_primordials.SymbolIterator] === _primordials.NativeArrayPrototypeSymbolIterator && _primordials.ArrayIteratorPrototype.next === _primordials.ArrayIteratorPrototypeNext) {
|
||||
return array;
|
||||
}
|
||||
const safe = (0, _primordials.ObjectCreate)(SafeIteratorPrototype);
|
||||
(0, _primordials.WeakMapPrototypeSet)(arrayIterators, safe, (0, _primordials.ArrayPrototypeSymbolIterator)(array));
|
||||
return safe;
|
||||
}
|
||||
const generators = new _primordials.NativeWeakMap();
|
||||
const DummyArrayIteratorPrototype = (0, _primordials.ObjectCreate)(_primordials.IteratorPrototype, {
|
||||
next: {
|
||||
value: function next() {
|
||||
const generator = (0, _primordials.WeakMapPrototypeGet)(generators, this);
|
||||
return (0, _primordials.GeneratorPrototypeNext)(generator);
|
||||
},
|
||||
writable: true,
|
||||
configurable: true
|
||||
}
|
||||
});
|
||||
for (const key of (0, _primordials.ReflectOwnKeys)(_primordials.ArrayIteratorPrototype)) {
|
||||
if (key === "next") {
|
||||
continue;
|
||||
}
|
||||
(0, _primordials.ObjectDefineProperty)(DummyArrayIteratorPrototype, key, (0, _primordials.ReflectGetOwnPropertyDescriptor)(_primordials.ArrayIteratorPrototype, key));
|
||||
}
|
||||
function wrap(generator) {
|
||||
const dummy = (0, _primordials.ObjectCreate)(DummyArrayIteratorPrototype);
|
||||
(0, _primordials.WeakMapPrototypeSet)(generators, dummy, generator);
|
||||
return dummy;
|
||||
}
|
||||
27
node_modules/@petamoriken/float16/lib/_util/brand.cjs
generated
vendored
Normal file
27
node_modules/@petamoriken/float16/lib/_util/brand.cjs
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.hasFloat16ArrayBrand = hasFloat16ArrayBrand;
|
||||
var _is = require("./is.cjs");
|
||||
var _messages = require("./messages.cjs");
|
||||
var _primordials = require("./primordials.cjs");
|
||||
const brand = exports.brand = (0, _primordials.SymbolFor)("__Float16Array__");
|
||||
function hasFloat16ArrayBrand(target) {
|
||||
if (!(0, _is.isObjectLike)(target)) {
|
||||
return false;
|
||||
}
|
||||
const prototype = (0, _primordials.ReflectGetPrototypeOf)(target);
|
||||
if (!(0, _is.isObjectLike)(prototype)) {
|
||||
return false;
|
||||
}
|
||||
const constructor = prototype.constructor;
|
||||
if (constructor === undefined) {
|
||||
return false;
|
||||
}
|
||||
if (!(0, _is.isObject)(constructor)) {
|
||||
throw (0, _primordials.NativeTypeError)(_messages.THE_CONSTRUCTOR_PROPERTY_VALUE_IS_NOT_AN_OBJECT);
|
||||
}
|
||||
return (0, _primordials.ReflectHas)(constructor, brand);
|
||||
}
|
||||
111
node_modules/@petamoriken/float16/lib/_util/converter.cjs
generated
vendored
Normal file
111
node_modules/@petamoriken/float16/lib/_util/converter.cjs
generated
vendored
Normal file
@@ -0,0 +1,111 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.convertToNumber = convertToNumber;
|
||||
exports.roundToFloat16 = roundToFloat16;
|
||||
exports.roundToFloat16Bits = roundToFloat16Bits;
|
||||
var _primordials = require("./primordials.cjs");
|
||||
const INVERSE_OF_EPSILON = 1 / _primordials.EPSILON;
|
||||
function roundTiesToEven(num) {
|
||||
return num + INVERSE_OF_EPSILON - INVERSE_OF_EPSILON;
|
||||
}
|
||||
const FLOAT16_MIN_VALUE = 6.103515625e-05;
|
||||
const FLOAT16_MAX_VALUE = 65504;
|
||||
const FLOAT16_EPSILON = 0.0009765625;
|
||||
const FLOAT16_EPSILON_MULTIPLIED_BY_FLOAT16_MIN_VALUE = FLOAT16_EPSILON * FLOAT16_MIN_VALUE;
|
||||
const FLOAT16_EPSILON_DEVIDED_BY_EPSILON = FLOAT16_EPSILON * INVERSE_OF_EPSILON;
|
||||
function roundToFloat16(num) {
|
||||
const number = +num;
|
||||
if (!(0, _primordials.NumberIsFinite)(number) || number === 0) {
|
||||
return number;
|
||||
}
|
||||
const sign = number > 0 ? 1 : -1;
|
||||
const absolute = (0, _primordials.MathAbs)(number);
|
||||
if (absolute < FLOAT16_MIN_VALUE) {
|
||||
return sign * roundTiesToEven(absolute / FLOAT16_EPSILON_MULTIPLIED_BY_FLOAT16_MIN_VALUE) * FLOAT16_EPSILON_MULTIPLIED_BY_FLOAT16_MIN_VALUE;
|
||||
}
|
||||
const temp = (1 + FLOAT16_EPSILON_DEVIDED_BY_EPSILON) * absolute;
|
||||
const result = temp - (temp - absolute);
|
||||
if (result > FLOAT16_MAX_VALUE || (0, _primordials.NumberIsNaN)(result)) {
|
||||
return sign * Infinity;
|
||||
}
|
||||
return sign * result;
|
||||
}
|
||||
const buffer = new _primordials.NativeArrayBuffer(4);
|
||||
const floatView = new _primordials.NativeFloat32Array(buffer);
|
||||
const uint32View = new _primordials.NativeUint32Array(buffer);
|
||||
const baseTable = new _primordials.NativeUint16Array(512);
|
||||
const shiftTable = new _primordials.NativeUint8Array(512);
|
||||
for (let i = 0; i < 256; ++i) {
|
||||
const e = i - 127;
|
||||
if (e < -24) {
|
||||
baseTable[i] = 0x0000;
|
||||
baseTable[i | 0x100] = 0x8000;
|
||||
shiftTable[i] = 24;
|
||||
shiftTable[i | 0x100] = 24;
|
||||
} else if (e < -14) {
|
||||
baseTable[i] = 0x0400 >> -e - 14;
|
||||
baseTable[i | 0x100] = 0x0400 >> -e - 14 | 0x8000;
|
||||
shiftTable[i] = -e - 1;
|
||||
shiftTable[i | 0x100] = -e - 1;
|
||||
} else if (e <= 15) {
|
||||
baseTable[i] = e + 15 << 10;
|
||||
baseTable[i | 0x100] = e + 15 << 10 | 0x8000;
|
||||
shiftTable[i] = 13;
|
||||
shiftTable[i | 0x100] = 13;
|
||||
} else if (e < 128) {
|
||||
baseTable[i] = 0x7c00;
|
||||
baseTable[i | 0x100] = 0xfc00;
|
||||
shiftTable[i] = 24;
|
||||
shiftTable[i | 0x100] = 24;
|
||||
} else {
|
||||
baseTable[i] = 0x7c00;
|
||||
baseTable[i | 0x100] = 0xfc00;
|
||||
shiftTable[i] = 13;
|
||||
shiftTable[i | 0x100] = 13;
|
||||
}
|
||||
}
|
||||
function roundToFloat16Bits(num) {
|
||||
floatView[0] = roundToFloat16(num);
|
||||
const f = uint32View[0];
|
||||
const e = f >> 23 & 0x1ff;
|
||||
return baseTable[e] + ((f & 0x007fffff) >> shiftTable[e]);
|
||||
}
|
||||
const mantissaTable = new _primordials.NativeUint32Array(2048);
|
||||
for (let i = 1; i < 1024; ++i) {
|
||||
let m = i << 13;
|
||||
let e = 0;
|
||||
while ((m & 0x00800000) === 0) {
|
||||
m <<= 1;
|
||||
e -= 0x00800000;
|
||||
}
|
||||
m &= ~0x00800000;
|
||||
e += 0x38800000;
|
||||
mantissaTable[i] = m | e;
|
||||
}
|
||||
for (let i = 1024; i < 2048; ++i) {
|
||||
mantissaTable[i] = 0x38000000 + (i - 1024 << 13);
|
||||
}
|
||||
const exponentTable = new _primordials.NativeUint32Array(64);
|
||||
for (let i = 1; i < 31; ++i) {
|
||||
exponentTable[i] = i << 23;
|
||||
}
|
||||
exponentTable[31] = 0x47800000;
|
||||
exponentTable[32] = 0x80000000;
|
||||
for (let i = 33; i < 63; ++i) {
|
||||
exponentTable[i] = 0x80000000 + (i - 32 << 23);
|
||||
}
|
||||
exponentTable[63] = 0xc7800000;
|
||||
const offsetTable = new _primordials.NativeUint16Array(64);
|
||||
for (let i = 1; i < 64; ++i) {
|
||||
if (i !== 32) {
|
||||
offsetTable[i] = 1024;
|
||||
}
|
||||
}
|
||||
function convertToNumber(float16bits) {
|
||||
const i = float16bits >> 10;
|
||||
uint32View[0] = mantissaTable[offsetTable[i] + (float16bits & 0x3ff)] + exponentTable[i];
|
||||
return floatView[0];
|
||||
}
|
||||
78
node_modules/@petamoriken/float16/lib/_util/is.cjs
generated
vendored
Normal file
78
node_modules/@petamoriken/float16/lib/_util/is.cjs
generated
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.isAnyArrayBuffer = isAnyArrayBuffer;
|
||||
exports.isCanonicalIntegerIndexString = isCanonicalIntegerIndexString;
|
||||
exports.isNativeBigIntTypedArray = isNativeBigIntTypedArray;
|
||||
exports.isNativeTypedArray = isNativeTypedArray;
|
||||
exports.isObject = isObject;
|
||||
exports.isObjectLike = isObjectLike;
|
||||
exports.isOrdinaryArray = isOrdinaryArray;
|
||||
exports.isOrdinaryNativeTypedArray = isOrdinaryNativeTypedArray;
|
||||
exports.isSharedArrayBuffer = isSharedArrayBuffer;
|
||||
var _primordials = require("./primordials.cjs");
|
||||
function isObject(value) {
|
||||
return value !== null && typeof value === "object" || typeof value === "function";
|
||||
}
|
||||
function isObjectLike(value) {
|
||||
return value !== null && typeof value === "object";
|
||||
}
|
||||
function isNativeTypedArray(value) {
|
||||
return (0, _primordials.TypedArrayPrototypeGetSymbolToStringTag)(value) !== undefined;
|
||||
}
|
||||
function isNativeBigIntTypedArray(value) {
|
||||
const typedArrayName = (0, _primordials.TypedArrayPrototypeGetSymbolToStringTag)(value);
|
||||
return typedArrayName === "BigInt64Array" || typedArrayName === "BigUint64Array";
|
||||
}
|
||||
function isArrayBuffer(value) {
|
||||
try {
|
||||
if ((0, _primordials.ArrayIsArray)(value)) {
|
||||
return false;
|
||||
}
|
||||
(0, _primordials.ArrayBufferPrototypeGetByteLength)(value);
|
||||
return true;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
function isSharedArrayBuffer(value) {
|
||||
if (_primordials.NativeSharedArrayBuffer === null) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
(0, _primordials.SharedArrayBufferPrototypeGetByteLength)(value);
|
||||
return true;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
function isAnyArrayBuffer(value) {
|
||||
return isArrayBuffer(value) || isSharedArrayBuffer(value);
|
||||
}
|
||||
function isOrdinaryArray(value) {
|
||||
if (!(0, _primordials.ArrayIsArray)(value)) {
|
||||
return false;
|
||||
}
|
||||
return value[_primordials.SymbolIterator] === _primordials.NativeArrayPrototypeSymbolIterator && _primordials.ArrayIteratorPrototype.next === _primordials.ArrayIteratorPrototypeNext;
|
||||
}
|
||||
function isOrdinaryNativeTypedArray(value) {
|
||||
if (!isNativeTypedArray(value)) {
|
||||
return false;
|
||||
}
|
||||
return value[_primordials.SymbolIterator] === _primordials.NativeTypedArrayPrototypeSymbolIterator && _primordials.ArrayIteratorPrototype.next === _primordials.ArrayIteratorPrototypeNext;
|
||||
}
|
||||
function isCanonicalIntegerIndexString(value) {
|
||||
if (typeof value !== "string") {
|
||||
return false;
|
||||
}
|
||||
const number = +value;
|
||||
if (value !== number + "") {
|
||||
return false;
|
||||
}
|
||||
if (!(0, _primordials.NumberIsFinite)(number)) {
|
||||
return false;
|
||||
}
|
||||
return number === (0, _primordials.MathTrunc)(number);
|
||||
}
|
||||
18
node_modules/@petamoriken/float16/lib/_util/messages.cjs
generated
vendored
Normal file
18
node_modules/@petamoriken/float16/lib/_util/messages.cjs
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
const THIS_IS_NOT_AN_OBJECT = exports.THIS_IS_NOT_AN_OBJECT = "This is not an object";
|
||||
const THIS_IS_NOT_A_FLOAT16ARRAY_OBJECT = exports.THIS_IS_NOT_A_FLOAT16ARRAY_OBJECT = "This is not a Float16Array object";
|
||||
const THIS_CONSTRUCTOR_IS_NOT_A_SUBCLASS_OF_FLOAT16ARRAY = exports.THIS_CONSTRUCTOR_IS_NOT_A_SUBCLASS_OF_FLOAT16ARRAY = "This constructor is not a subclass of Float16Array";
|
||||
const THE_CONSTRUCTOR_PROPERTY_VALUE_IS_NOT_AN_OBJECT = exports.THE_CONSTRUCTOR_PROPERTY_VALUE_IS_NOT_AN_OBJECT = "The constructor property value is not an object";
|
||||
const SPECIES_CONSTRUCTOR_DIDNT_RETURN_TYPEDARRAY_OBJECT = exports.SPECIES_CONSTRUCTOR_DIDNT_RETURN_TYPEDARRAY_OBJECT = "Species constructor didn't return TypedArray object";
|
||||
const DERIVED_CONSTRUCTOR_CREATED_TYPEDARRAY_OBJECT_WHICH_WAS_TOO_SMALL_LENGTH = exports.DERIVED_CONSTRUCTOR_CREATED_TYPEDARRAY_OBJECT_WHICH_WAS_TOO_SMALL_LENGTH = "Derived constructor created TypedArray object which was too small length";
|
||||
const ATTEMPTING_TO_ACCESS_DETACHED_ARRAYBUFFER = exports.ATTEMPTING_TO_ACCESS_DETACHED_ARRAYBUFFER = "Attempting to access detached ArrayBuffer";
|
||||
const CANNOT_CONVERT_UNDEFINED_OR_NULL_TO_OBJECT = exports.CANNOT_CONVERT_UNDEFINED_OR_NULL_TO_OBJECT = "Cannot convert undefined or null to object";
|
||||
const CANNOT_MIX_BIGINT_AND_OTHER_TYPES = exports.CANNOT_MIX_BIGINT_AND_OTHER_TYPES = "Cannot mix BigInt and other types, use explicit conversions";
|
||||
const ITERATOR_PROPERTY_IS_NOT_CALLABLE = exports.ITERATOR_PROPERTY_IS_NOT_CALLABLE = "@@iterator property is not callable";
|
||||
const REDUCE_OF_EMPTY_ARRAY_WITH_NO_INITIAL_VALUE = exports.REDUCE_OF_EMPTY_ARRAY_WITH_NO_INITIAL_VALUE = "Reduce of empty array with no initial value";
|
||||
const THE_COMPARISON_FUNCTION_MUST_BE_EITHER_A_FUNCTION_OR_UNDEFINED = exports.THE_COMPARISON_FUNCTION_MUST_BE_EITHER_A_FUNCTION_OR_UNDEFINED = "The comparison function must be either a function or undefined";
|
||||
const OFFSET_IS_OUT_OF_BOUNDS = exports.OFFSET_IS_OUT_OF_BOUNDS = "Offset is out of bounds";
|
||||
150
node_modules/@petamoriken/float16/lib/_util/primordials.cjs
generated
vendored
Normal file
150
node_modules/@petamoriken/float16/lib/_util/primordials.cjs
generated
vendored
Normal file
@@ -0,0 +1,150 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
var _messages = require("./messages.cjs");
|
||||
function uncurryThis(target) {
|
||||
return (thisArg, ...args) => {
|
||||
return ReflectApply(target, thisArg, args);
|
||||
};
|
||||
}
|
||||
function uncurryThisGetter(target, key) {
|
||||
return uncurryThis(ReflectGetOwnPropertyDescriptor(target, key).get);
|
||||
}
|
||||
const {
|
||||
apply: ReflectApply,
|
||||
construct: ReflectConstruct,
|
||||
defineProperty: ReflectDefineProperty,
|
||||
get: ReflectGet,
|
||||
getOwnPropertyDescriptor: ReflectGetOwnPropertyDescriptor,
|
||||
getPrototypeOf: ReflectGetPrototypeOf,
|
||||
has: ReflectHas,
|
||||
ownKeys: ReflectOwnKeys,
|
||||
set: ReflectSet,
|
||||
setPrototypeOf: ReflectSetPrototypeOf
|
||||
} = Reflect;
|
||||
exports.ReflectSetPrototypeOf = ReflectSetPrototypeOf;
|
||||
exports.ReflectSet = ReflectSet;
|
||||
exports.ReflectOwnKeys = ReflectOwnKeys;
|
||||
exports.ReflectHas = ReflectHas;
|
||||
exports.ReflectGetPrototypeOf = ReflectGetPrototypeOf;
|
||||
exports.ReflectGetOwnPropertyDescriptor = ReflectGetOwnPropertyDescriptor;
|
||||
exports.ReflectGet = ReflectGet;
|
||||
exports.ReflectDefineProperty = ReflectDefineProperty;
|
||||
exports.ReflectConstruct = ReflectConstruct;
|
||||
exports.ReflectApply = ReflectApply;
|
||||
const NativeProxy = exports.NativeProxy = Proxy;
|
||||
const {
|
||||
EPSILON,
|
||||
MAX_SAFE_INTEGER,
|
||||
isFinite: NumberIsFinite,
|
||||
isNaN: NumberIsNaN
|
||||
} = Number;
|
||||
exports.NumberIsNaN = NumberIsNaN;
|
||||
exports.NumberIsFinite = NumberIsFinite;
|
||||
exports.MAX_SAFE_INTEGER = MAX_SAFE_INTEGER;
|
||||
exports.EPSILON = EPSILON;
|
||||
const {
|
||||
iterator: SymbolIterator,
|
||||
species: SymbolSpecies,
|
||||
toStringTag: SymbolToStringTag,
|
||||
for: SymbolFor
|
||||
} = Symbol;
|
||||
exports.SymbolFor = SymbolFor;
|
||||
exports.SymbolToStringTag = SymbolToStringTag;
|
||||
exports.SymbolSpecies = SymbolSpecies;
|
||||
exports.SymbolIterator = SymbolIterator;
|
||||
const NativeObject = exports.NativeObject = Object;
|
||||
const {
|
||||
create: ObjectCreate,
|
||||
defineProperty: ObjectDefineProperty,
|
||||
freeze: ObjectFreeze,
|
||||
is: ObjectIs
|
||||
} = NativeObject;
|
||||
exports.ObjectIs = ObjectIs;
|
||||
exports.ObjectFreeze = ObjectFreeze;
|
||||
exports.ObjectDefineProperty = ObjectDefineProperty;
|
||||
exports.ObjectCreate = ObjectCreate;
|
||||
const ObjectPrototype = NativeObject.prototype;
|
||||
const ObjectPrototype__lookupGetter__ = exports.ObjectPrototype__lookupGetter__ = ObjectPrototype.__lookupGetter__ ? uncurryThis(ObjectPrototype.__lookupGetter__) : (object, key) => {
|
||||
if (object == null) {
|
||||
throw NativeTypeError(_messages.CANNOT_CONVERT_UNDEFINED_OR_NULL_TO_OBJECT);
|
||||
}
|
||||
let target = NativeObject(object);
|
||||
do {
|
||||
const descriptor = ReflectGetOwnPropertyDescriptor(target, key);
|
||||
if (descriptor !== undefined) {
|
||||
if (ObjectHasOwn(descriptor, "get")) {
|
||||
return descriptor.get;
|
||||
}
|
||||
return;
|
||||
}
|
||||
} while ((target = ReflectGetPrototypeOf(target)) !== null);
|
||||
};
|
||||
const ObjectHasOwn = exports.ObjectHasOwn = NativeObject.hasOwn || uncurryThis(ObjectPrototype.hasOwnProperty);
|
||||
const NativeArray = Array;
|
||||
const ArrayIsArray = exports.ArrayIsArray = NativeArray.isArray;
|
||||
const ArrayPrototype = NativeArray.prototype;
|
||||
const ArrayPrototypeJoin = exports.ArrayPrototypeJoin = uncurryThis(ArrayPrototype.join);
|
||||
const ArrayPrototypePush = exports.ArrayPrototypePush = uncurryThis(ArrayPrototype.push);
|
||||
const ArrayPrototypeToLocaleString = exports.ArrayPrototypeToLocaleString = uncurryThis(ArrayPrototype.toLocaleString);
|
||||
const NativeArrayPrototypeSymbolIterator = exports.NativeArrayPrototypeSymbolIterator = ArrayPrototype[SymbolIterator];
|
||||
const ArrayPrototypeSymbolIterator = exports.ArrayPrototypeSymbolIterator = uncurryThis(NativeArrayPrototypeSymbolIterator);
|
||||
const {
|
||||
abs: MathAbs,
|
||||
trunc: MathTrunc
|
||||
} = Math;
|
||||
exports.MathTrunc = MathTrunc;
|
||||
exports.MathAbs = MathAbs;
|
||||
const NativeArrayBuffer = exports.NativeArrayBuffer = ArrayBuffer;
|
||||
const ArrayBufferIsView = exports.ArrayBufferIsView = NativeArrayBuffer.isView;
|
||||
const ArrayBufferPrototype = NativeArrayBuffer.prototype;
|
||||
const ArrayBufferPrototypeSlice = exports.ArrayBufferPrototypeSlice = uncurryThis(ArrayBufferPrototype.slice);
|
||||
const ArrayBufferPrototypeGetByteLength = exports.ArrayBufferPrototypeGetByteLength = uncurryThisGetter(ArrayBufferPrototype, "byteLength");
|
||||
const NativeSharedArrayBuffer = exports.NativeSharedArrayBuffer = typeof SharedArrayBuffer !== "undefined" ? SharedArrayBuffer : null;
|
||||
const SharedArrayBufferPrototypeGetByteLength = exports.SharedArrayBufferPrototypeGetByteLength = NativeSharedArrayBuffer && uncurryThisGetter(NativeSharedArrayBuffer.prototype, "byteLength");
|
||||
const TypedArray = exports.TypedArray = ReflectGetPrototypeOf(Uint8Array);
|
||||
const TypedArrayFrom = TypedArray.from;
|
||||
const TypedArrayPrototype = exports.TypedArrayPrototype = TypedArray.prototype;
|
||||
const NativeTypedArrayPrototypeSymbolIterator = exports.NativeTypedArrayPrototypeSymbolIterator = TypedArrayPrototype[SymbolIterator];
|
||||
const TypedArrayPrototypeKeys = exports.TypedArrayPrototypeKeys = uncurryThis(TypedArrayPrototype.keys);
|
||||
const TypedArrayPrototypeValues = exports.TypedArrayPrototypeValues = uncurryThis(TypedArrayPrototype.values);
|
||||
const TypedArrayPrototypeEntries = exports.TypedArrayPrototypeEntries = uncurryThis(TypedArrayPrototype.entries);
|
||||
const TypedArrayPrototypeSet = exports.TypedArrayPrototypeSet = uncurryThis(TypedArrayPrototype.set);
|
||||
const TypedArrayPrototypeReverse = exports.TypedArrayPrototypeReverse = uncurryThis(TypedArrayPrototype.reverse);
|
||||
const TypedArrayPrototypeFill = exports.TypedArrayPrototypeFill = uncurryThis(TypedArrayPrototype.fill);
|
||||
const TypedArrayPrototypeCopyWithin = exports.TypedArrayPrototypeCopyWithin = uncurryThis(TypedArrayPrototype.copyWithin);
|
||||
const TypedArrayPrototypeSort = exports.TypedArrayPrototypeSort = uncurryThis(TypedArrayPrototype.sort);
|
||||
const TypedArrayPrototypeSlice = exports.TypedArrayPrototypeSlice = uncurryThis(TypedArrayPrototype.slice);
|
||||
const TypedArrayPrototypeSubarray = exports.TypedArrayPrototypeSubarray = uncurryThis(TypedArrayPrototype.subarray);
|
||||
const TypedArrayPrototypeGetBuffer = exports.TypedArrayPrototypeGetBuffer = uncurryThisGetter(TypedArrayPrototype, "buffer");
|
||||
const TypedArrayPrototypeGetByteOffset = exports.TypedArrayPrototypeGetByteOffset = uncurryThisGetter(TypedArrayPrototype, "byteOffset");
|
||||
const TypedArrayPrototypeGetLength = exports.TypedArrayPrototypeGetLength = uncurryThisGetter(TypedArrayPrototype, "length");
|
||||
const TypedArrayPrototypeGetSymbolToStringTag = exports.TypedArrayPrototypeGetSymbolToStringTag = uncurryThisGetter(TypedArrayPrototype, SymbolToStringTag);
|
||||
const NativeUint8Array = exports.NativeUint8Array = Uint8Array;
|
||||
const NativeUint16Array = exports.NativeUint16Array = Uint16Array;
|
||||
const Uint16ArrayFrom = (...args) => {
|
||||
return ReflectApply(TypedArrayFrom, NativeUint16Array, args);
|
||||
};
|
||||
exports.Uint16ArrayFrom = Uint16ArrayFrom;
|
||||
const NativeUint32Array = exports.NativeUint32Array = Uint32Array;
|
||||
const NativeFloat32Array = exports.NativeFloat32Array = Float32Array;
|
||||
const ArrayIteratorPrototype = exports.ArrayIteratorPrototype = ReflectGetPrototypeOf([][SymbolIterator]());
|
||||
const ArrayIteratorPrototypeNext = exports.ArrayIteratorPrototypeNext = uncurryThis(ArrayIteratorPrototype.next);
|
||||
const GeneratorPrototypeNext = exports.GeneratorPrototypeNext = uncurryThis(function* () {}().next);
|
||||
const IteratorPrototype = exports.IteratorPrototype = ReflectGetPrototypeOf(ArrayIteratorPrototype);
|
||||
const DataViewPrototype = DataView.prototype;
|
||||
const DataViewPrototypeGetUint16 = exports.DataViewPrototypeGetUint16 = uncurryThis(DataViewPrototype.getUint16);
|
||||
const DataViewPrototypeSetUint16 = exports.DataViewPrototypeSetUint16 = uncurryThis(DataViewPrototype.setUint16);
|
||||
const NativeTypeError = exports.NativeTypeError = TypeError;
|
||||
const NativeRangeError = exports.NativeRangeError = RangeError;
|
||||
const NativeWeakSet = exports.NativeWeakSet = WeakSet;
|
||||
const WeakSetPrototype = NativeWeakSet.prototype;
|
||||
const WeakSetPrototypeAdd = exports.WeakSetPrototypeAdd = uncurryThis(WeakSetPrototype.add);
|
||||
const WeakSetPrototypeHas = exports.WeakSetPrototypeHas = uncurryThis(WeakSetPrototype.has);
|
||||
const NativeWeakMap = exports.NativeWeakMap = WeakMap;
|
||||
const WeakMapPrototype = NativeWeakMap.prototype;
|
||||
const WeakMapPrototypeGet = exports.WeakMapPrototypeGet = uncurryThis(WeakMapPrototype.get);
|
||||
const WeakMapPrototypeHas = exports.WeakMapPrototypeHas = uncurryThis(WeakMapPrototype.has);
|
||||
const WeakMapPrototypeSet = exports.WeakMapPrototypeSet = uncurryThis(WeakMapPrototype.set);
|
||||
84
node_modules/@petamoriken/float16/lib/_util/spec.cjs
generated
vendored
Normal file
84
node_modules/@petamoriken/float16/lib/_util/spec.cjs
generated
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.IsDetachedBuffer = IsDetachedBuffer;
|
||||
exports.SpeciesConstructor = SpeciesConstructor;
|
||||
exports.ToIntegerOrInfinity = ToIntegerOrInfinity;
|
||||
exports.ToLength = ToLength;
|
||||
exports.defaultCompare = defaultCompare;
|
||||
var _is = require("./is.cjs");
|
||||
var _messages = require("./messages.cjs");
|
||||
var _primordials = require("./primordials.cjs");
|
||||
function ToIntegerOrInfinity(target) {
|
||||
const number = +target;
|
||||
if ((0, _primordials.NumberIsNaN)(number) || number === 0) {
|
||||
return 0;
|
||||
}
|
||||
return (0, _primordials.MathTrunc)(number);
|
||||
}
|
||||
function ToLength(target) {
|
||||
const length = ToIntegerOrInfinity(target);
|
||||
if (length < 0) {
|
||||
return 0;
|
||||
}
|
||||
return length < _primordials.MAX_SAFE_INTEGER ? length : _primordials.MAX_SAFE_INTEGER;
|
||||
}
|
||||
function SpeciesConstructor(target, defaultConstructor) {
|
||||
if (!(0, _is.isObject)(target)) {
|
||||
throw (0, _primordials.NativeTypeError)(_messages.THIS_IS_NOT_AN_OBJECT);
|
||||
}
|
||||
const constructor = target.constructor;
|
||||
if (constructor === undefined) {
|
||||
return defaultConstructor;
|
||||
}
|
||||
if (!(0, _is.isObject)(constructor)) {
|
||||
throw (0, _primordials.NativeTypeError)(_messages.THE_CONSTRUCTOR_PROPERTY_VALUE_IS_NOT_AN_OBJECT);
|
||||
}
|
||||
const species = constructor[_primordials.SymbolSpecies];
|
||||
if (species == null) {
|
||||
return defaultConstructor;
|
||||
}
|
||||
return species;
|
||||
}
|
||||
function IsDetachedBuffer(buffer) {
|
||||
if ((0, _is.isSharedArrayBuffer)(buffer)) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
(0, _primordials.ArrayBufferPrototypeSlice)(buffer, 0, 0);
|
||||
return false;
|
||||
} catch (e) {}
|
||||
return true;
|
||||
}
|
||||
function defaultCompare(x, y) {
|
||||
const isXNaN = (0, _primordials.NumberIsNaN)(x);
|
||||
const isYNaN = (0, _primordials.NumberIsNaN)(y);
|
||||
if (isXNaN && isYNaN) {
|
||||
return 0;
|
||||
}
|
||||
if (isXNaN) {
|
||||
return 1;
|
||||
}
|
||||
if (isYNaN) {
|
||||
return -1;
|
||||
}
|
||||
if (x < y) {
|
||||
return -1;
|
||||
}
|
||||
if (x > y) {
|
||||
return 1;
|
||||
}
|
||||
if (x === 0 && y === 0) {
|
||||
const isXPlusZero = (0, _primordials.ObjectIs)(x, 0);
|
||||
const isYPlusZero = (0, _primordials.ObjectIs)(y, 0);
|
||||
if (!isXPlusZero && isYPlusZero) {
|
||||
return -1;
|
||||
}
|
||||
if (isXPlusZero && !isYPlusZero) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
10
node_modules/@petamoriken/float16/lib/f16round.cjs
generated
vendored
Normal file
10
node_modules/@petamoriken/float16/lib/f16round.cjs
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.f16round = f16round;
|
||||
var _converter = require("./_util/converter.cjs");
|
||||
function f16round(x) {
|
||||
return (0, _converter.roundToFloat16)(x);
|
||||
}
|
||||
16
node_modules/@petamoriken/float16/lib/index.cjs
generated
vendored
Normal file
16
node_modules/@petamoriken/float16/lib/index.cjs
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
var _Float16Array = require("./Float16Array.cjs");
|
||||
exports.Float16Array = _Float16Array.Float16Array;
|
||||
exports.isFloat16Array = _Float16Array.isFloat16Array;
|
||||
var _isTypedArray = require("./isTypedArray.cjs");
|
||||
exports.isTypedArray = _isTypedArray.isTypedArray;
|
||||
var _DataView = require("./DataView.cjs");
|
||||
exports.getFloat16 = _DataView.getFloat16;
|
||||
exports.setFloat16 = _DataView.setFloat16;
|
||||
var _f16round = require("./f16round.cjs");
|
||||
exports.f16round = _f16round.f16round;
|
||||
exports.hfround = _f16round.f16round;
|
||||
11
node_modules/@petamoriken/float16/lib/isTypedArray.cjs
generated
vendored
Normal file
11
node_modules/@petamoriken/float16/lib/isTypedArray.cjs
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.isTypedArray = isTypedArray;
|
||||
var _Float16Array = require("./Float16Array.cjs");
|
||||
var _is = require("./_util/is.cjs");
|
||||
function isTypedArray(target) {
|
||||
return (0, _is.isNativeTypedArray)(target) || (0, _Float16Array.isFloat16Array)(target);
|
||||
}
|
||||
Reference in New Issue
Block a user