Socket
Socket
Sign inDemoInstall

@petamoriken/float16

Package Overview
Dependencies
Maintainers
1
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@petamoriken/float16 - npm Package Compare versions

Comparing version 3.5.1 to 3.5.2

lib/_util/messages.cjs

118

browser/float16.js

@@ -1,2 +0,2 @@

/*! @petamoriken/float16 v3.5.1 | MIT License - https://git.io/float16 */
/*! @petamoriken/float16 v3.5.2 | MIT License - https://git.io/float16 */

@@ -311,2 +311,21 @@ const float16 = (function (exports) {

const CONSTRUCTOR_IS_NOT_A_OBJECT = "Constructor is not a object";
const THIS_IS_NOT_A_OBJECT = "This is not a object";
const THIS_IS_NOT_A_FLOAT16ARRAY = "This is not a Float16Array";
const THIS_CONSTRUCTOR_IS_NOT_A_SUBCLASS_OF_FLOAT16ARRAY =
"This constructor is not a subclass of Float16Array";
const SPECIESCONSTRUCTOR_DIDNT_RETURN_TYPEDARRAY =
"SpeciesConstructor didn't return TypedArray";
const DERIVED_TYPEDARRAY_CONSTRUCTOR_CREATED_AN_ARRAY_WHICH_WAS_TOO_SMALL =
"Derived TypedArray constructor created an array which was too small";
const CANNOT_CONVERT_UNDEFINED_OR_NULL_TO_OBJECT =
"Cannot convert undefined or null to object";
const CANNOT_CONVERT_A_BIGINT_VALUE_TO_A_NUMBER =
"Cannot convert a BigInt value to a number";
const CANNOT_MIX_BIGINT_AND_OTHER_TYPES =
"Cannot mix BigInt and other types, use explicit conversions";
const REDUCE_OF_EMPTY_ARRAY_WITH_NO_INITIAL_VALUE =
"Reduce of empty array with no initial value";
const OFFSET_IS_OUT_OF_BOUNDS = "Offset is out of bounds";
/**

@@ -320,3 +339,3 @@ * returns the nearest half precision float representation of a number.

if (typeof num === "bigint") {
throw NativeTypeError("Cannot convert a BigInt value to a number");
throw NativeTypeError(CANNOT_CONVERT_A_BIGINT_VALUE_TO_A_NUMBER);
}

@@ -492,3 +511,3 @@

if (typeof target === "bigint") {
throw NativeTypeError("Cannot convert a BigInt value to a number");
throw NativeTypeError(CANNOT_CONVERT_A_BIGINT_VALUE_TO_A_NUMBER);
}

@@ -528,3 +547,3 @@

if (!isObject(arrayLike)) {
throw NativeTypeError("This is not a object");
throw NativeTypeError(THIS_IS_NOT_A_OBJECT);
}

@@ -543,3 +562,3 @@

if (!isObject(target)) {
throw NativeTypeError("This is not a object");
throw NativeTypeError(THIS_IS_NOT_A_OBJECT);
}

@@ -552,3 +571,3 @@

if (!isObject(constructor)) {
throw NativeTypeError("Constructor is not a object");
throw NativeTypeError(CONSTRUCTOR_IS_NOT_A_OBJECT);
}

@@ -573,14 +592,14 @@

function defaultCompare(x, y) {
const isNaN_x = NumberIsNaN(x);
const isNaN_y = NumberIsNaN(y);
const isXNaN = NumberIsNaN(x);
const isYNaN = NumberIsNaN(y);
if (isNaN_x && isNaN_y) {
if (isXNaN && isYNaN) {
return 0;
}
if (isNaN_x) {
if (isXNaN) {
return 1;
}
if (isNaN_y) {
if (isYNaN) {
return -1;

@@ -598,10 +617,10 @@ }

if (x === 0 && y === 0) {
const isPlusZero_x = ObjectIs(x, 0);
const isPlusZero_y = ObjectIs(y, 0);
const isXPlusZero = ObjectIs(x, 0);
const isYPlusZero = ObjectIs(y, 0);
if (!isPlusZero_x && isPlusZero_y) {
if (!isXPlusZero && isYPlusZero) {
return -1;
}
if (isPlusZero_x && !isPlusZero_y) {
if (isXPlusZero && !isYPlusZero) {
return 1;

@@ -614,2 +633,4 @@ }

const BYTES_PER_ELEMENT = 2;
const brand = SymbolFor("__Float16Array__");

@@ -622,2 +643,3 @@

* @param {unknown} target
* @throws {TypeError}
* @returns {boolean}

@@ -640,3 +662,3 @@ */

if (!isObject(constructor)) {
throw NativeTypeError("Constructor is not a object");
throw NativeTypeError(CONSTRUCTOR_IS_NOT_A_OBJECT);
}

@@ -662,3 +684,3 @@

if (!isFloat16Array(target)) {
throw new NativeTypeError("This is not a Float16Array");
throw NativeTypeError(THIS_IS_NOT_A_FLOAT16ARRAY);
}

@@ -669,18 +691,32 @@ }

* @param {unknown} target
* @param {number=} count
* @throws {TypeError}
* @returns {asserts target is Uint8Array|Uint8ClampedArray|Uint16Array|Uint32Array|Int8Array|Int16Array|Int32Array|Float16Array|Float32Array|Float64Array}
*/
function assertSpeciesTypedArray(target) {
if (isFloat16Array(target)) {
return;
function assertSpeciesTypedArray(target, count) {
const isTargetFloat16Array = isFloat16Array(target);
const isTargetTypedArray = isTypedArray(target);
if (!isTargetFloat16Array && !isTargetTypedArray) {
throw NativeTypeError(SPECIESCONSTRUCTOR_DIDNT_RETURN_TYPEDARRAY);
}
if (!isTypedArray(target)) {
throw new NativeTypeError("SpeciesConstructor didn't return TypedArray");
if (typeof count === "number") {
let length;
if (isTargetFloat16Array) {
const float16bitsArray = getFloat16BitsArray(target);
length = TypedArrayPrototypeGetLength(float16bitsArray);
} else {
length = TypedArrayPrototypeGetLength(target);
}
if (length < count) {
throw NativeTypeError(
DERIVED_TYPEDARRAY_CONSTRUCTOR_CREATED_AN_ARRAY_WHICH_WAS_TOO_SMALL
);
}
}
if (isBigIntTypedArray(target)) {
throw new NativeTypeError(
"Cannot mix BigInt and other types, use explicit conversions"
);
throw NativeTypeError(CANNOT_MIX_BIGINT_AND_OTHER_TYPES);
}

@@ -776,4 +812,4 @@ }

if (isBigIntTypedArray(input)) {
throw new NativeTypeError(
"Cannot mix BigInt and other types, use explicit conversions"
throw NativeTypeError(
CANNOT_MIX_BIGINT_AND_OTHER_TYPES
);

@@ -793,3 +829,3 @@ }

const data = new BufferConstructor(
length * Float16Array.BYTES_PER_ELEMENT
length * BYTES_PER_ELEMENT
);

@@ -861,3 +897,3 @@ super(data);

throw NativeTypeError(
"This constructor is not a subclass of Float16Array"
THIS_CONSTRUCTOR_IS_NOT_A_SUBCLASS_OF_FLOAT16ARRAY
);

@@ -951,3 +987,3 @@ }

throw NativeTypeError(
"This constructor is not a subclass of Float16Array"
THIS_CONSTRUCTOR_IS_NOT_A_SUBCLASS_OF_FLOAT16ARRAY
);

@@ -1061,3 +1097,3 @@ }

const array = new Constructor(length);
assertSpeciesTypedArray(array);
assertSpeciesTypedArray(array, length);

@@ -1102,3 +1138,3 @@ for (let i = 0; i < length; ++i) {

if (length === 0 && opts.length === 0) {
throw NativeTypeError("Reduce of empty array with no initial value");
throw NativeTypeError(REDUCE_OF_EMPTY_ARRAY_WITH_NO_INITIAL_VALUE);
}

@@ -1134,3 +1170,3 @@

if (length === 0 && opts.length === 0) {
throw NativeTypeError("Reduce of empty array with no initial value");
throw NativeTypeError(REDUCE_OF_EMPTY_ARRAY_WITH_NO_INITIAL_VALUE);
}

@@ -1297,3 +1333,3 @@

if (targetOffset < 0) {
throw NativeRangeError("Offset is out of bounds");
throw NativeRangeError(OFFSET_IS_OUT_OF_BOUNDS);
}

@@ -1303,3 +1339,3 @@

throw NativeTypeError(
"Cannot convert undefined or null to object"
CANNOT_CONVERT_UNDEFINED_OR_NULL_TO_OBJECT
);

@@ -1309,4 +1345,4 @@ }

if (isBigIntTypedArray(input)) {
throw new NativeTypeError(
"Cannot mix BigInt and other types, use explicit conversions"
throw NativeTypeError(
CANNOT_MIX_BIGINT_AND_OTHER_TYPES
);

@@ -1331,3 +1367,3 @@ }

if (targetOffset === Infinity || srcLength + targetOffset > targetLength) {
throw NativeRangeError("Offset is out of bounds");
throw NativeRangeError(OFFSET_IS_OUT_OF_BOUNDS);
}

@@ -1432,3 +1468,3 @@

const array = new Constructor(count);
assertSpeciesTypedArray(array);
assertSpeciesTypedArray(array, count);

@@ -1600,3 +1636,3 @@ if (count === 0) {

ObjectDefineProperty(Float16Array, "BYTES_PER_ELEMENT", {
value: NativeUint16Array.BYTES_PER_ELEMENT,
value: BYTES_PER_ELEMENT,
});

@@ -1611,3 +1647,3 @@

ObjectDefineProperty(Float16ArrayPrototype, "BYTES_PER_ELEMENT", {
value: NativeUint16Array.BYTES_PER_ELEMENT,
value: BYTES_PER_ELEMENT,
});

@@ -1614,0 +1650,0 @@

{
"name": "@petamoriken/float16",
"version": "3.5.1",
"version": "3.5.2",
"description": "half precision floating point for JavaScript",

@@ -5,0 +5,0 @@ "keywords": [

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc