fast-equals 6.1.0 → 6.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +6 -4
- package/dist/es/index.mjs +6 -4
- package/package.json +1 -1
package/dist/cjs/index.cjs
CHANGED
|
@@ -71,10 +71,11 @@ function isNullPrototypeComparable(a, b) {
|
|
|
71
71
|
const PREACT_VNODE = '__v';
|
|
72
72
|
const PREACT_OWNER = '__o';
|
|
73
73
|
const REACT_OWNER = '_owner';
|
|
74
|
-
// `Float16Array` is recent enough that it cannot be referenced unguarded, and capturing its
|
|
75
|
-
// availability once keeps that detail out of the comparison itself.
|
|
76
|
-
const HAS_FLOAT_16_ARRAY = typeof Float16Array !== 'undefined';
|
|
77
74
|
const { getOwnPropertyDescriptor, keys } = Object;
|
|
75
|
+
/**
|
|
76
|
+
* Identify the element type of TypedArrays across realms and subclasses.
|
|
77
|
+
*/
|
|
78
|
+
const getTypedArrayTag = getOwnPropertyDescriptor(Object.getPrototypeOf(Int8Array.prototype), Symbol.toStringTag).get;
|
|
78
79
|
/**
|
|
79
80
|
* Whether the values passed are equal based on a [SameValue](https://262.ecma-international.org/7.0/#sec-samevalue) basis.
|
|
80
81
|
* Simplified, this maps to if the two values are referentially equal to one another (`a === b`) or both are `NaN`.
|
|
@@ -326,7 +327,8 @@ function areTypedArraysEqual(a, b) {
|
|
|
326
327
|
// Only float-backed views can hold `NaN`, and the additional check needed to treat it as equal
|
|
327
328
|
// to itself measurably slows the loop, so integer views keep the plain comparison. This is
|
|
328
329
|
// hoisted out of the loop so the cost is paid once per call rather than once per element.
|
|
329
|
-
|
|
330
|
+
const tag = getTypedArrayTag.call(a);
|
|
331
|
+
if (tag === 'Float64Array' || tag === 'Float32Array' || tag === 'Float16Array') {
|
|
330
332
|
while (index-- > 0) {
|
|
331
333
|
// `NaN` is the only value not equal to itself, and it is treated as equal here to match
|
|
332
334
|
// the SameValueZero semantics used for every other numeric comparison in the library.
|
package/dist/es/index.mjs
CHANGED
|
@@ -69,10 +69,11 @@ function isNullPrototypeComparable(a, b) {
|
|
|
69
69
|
const PREACT_VNODE = '__v';
|
|
70
70
|
const PREACT_OWNER = '__o';
|
|
71
71
|
const REACT_OWNER = '_owner';
|
|
72
|
-
// `Float16Array` is recent enough that it cannot be referenced unguarded, and capturing its
|
|
73
|
-
// availability once keeps that detail out of the comparison itself.
|
|
74
|
-
const HAS_FLOAT_16_ARRAY = typeof Float16Array !== 'undefined';
|
|
75
72
|
const { getOwnPropertyDescriptor, keys } = Object;
|
|
73
|
+
/**
|
|
74
|
+
* Identify the element type of TypedArrays across realms and subclasses.
|
|
75
|
+
*/
|
|
76
|
+
const getTypedArrayTag = getOwnPropertyDescriptor(Object.getPrototypeOf(Int8Array.prototype), Symbol.toStringTag).get;
|
|
76
77
|
/**
|
|
77
78
|
* Whether the values passed are equal based on a [SameValue](https://262.ecma-international.org/7.0/#sec-samevalue) basis.
|
|
78
79
|
* Simplified, this maps to if the two values are referentially equal to one another (`a === b`) or both are `NaN`.
|
|
@@ -324,7 +325,8 @@ function areTypedArraysEqual(a, b) {
|
|
|
324
325
|
// Only float-backed views can hold `NaN`, and the additional check needed to treat it as equal
|
|
325
326
|
// to itself measurably slows the loop, so integer views keep the plain comparison. This is
|
|
326
327
|
// hoisted out of the loop so the cost is paid once per call rather than once per element.
|
|
327
|
-
|
|
328
|
+
const tag = getTypedArrayTag.call(a);
|
|
329
|
+
if (tag === 'Float64Array' || tag === 'Float32Array' || tag === 'Float16Array') {
|
|
328
330
|
while (index-- > 0) {
|
|
329
331
|
// `NaN` is the only value not equal to itself, and it is treated as equal here to match
|
|
330
332
|
// the SameValueZero semantics used for every other numeric comparison in the library.
|
package/package.json
CHANGED