diff --git a/src/index.ts b/src/index.ts index 1f2cbd7..d927707 100644 --- a/src/index.ts +++ b/src/index.ts @@ -19,6 +19,10 @@ function deepEqualCore( return options.nanEqual; } + if (typeof a === 'number' && typeof b === 'number' && options.numberPrecision && Math.abs(a - b) < options.numberPrecision) { + return true; + } + // Fast path: if both are primitives (not objects/functions), return false if ( (a === null || typeof a !== 'object' && typeof a !== 'function') && @@ -303,6 +307,7 @@ export function deepEqualCheck( checkPrototypes: options.checkPrototypes ?? false, strictZero: options.strictZero ?? false, maxDepth: options.maxDepth ?? 1000, + numberPrecision: options.numberPrecision ?? false, }; return deepEqualCore(a, b, opts, new WeakMap(), 0);