Skip to content

Commit 202db66

Browse files
fix: avoid BigInt literal in closeTo for runtime compat
1 parent 7e1e247 commit 202db66

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

lib/chai/core/assertions.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3147,7 +3147,10 @@ function closeTo(expected, delta, msg) {
31473147
}
31483148
new Assertion(expected, flagMsg, ssfi, true).is.numeric;
31493149

3150-
const abs = (x) => (x < 0n ? -x : x);
3150+
// Avoid emitting BigInt literals in the runtime path; some JS engines
3151+
// (e.g., older Hermes builds on React Native) cannot parse `0n` and will
3152+
// fail at bundle load time. Use number math to keep closeTo compatible.
3153+
const abs = (x) => (x < 0 ? -x : x);
31513154

31523155
// Used to round floating point number precision arithmetics
31533156
// See: https://stackoverflow.com/a/3644302

0 commit comments

Comments
 (0)