Skip to content

Commit 5feb258

Browse files
committed
Strict Equality Numeric Promotion
1 parent 1c8854d commit 5feb258

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

precision/index.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ export function configurePrecision (engine, constructor, compatible = true) {
141141
engine.addMethod('===', {
142142
method: (args) => {
143143
if (args.length === 2) {
144-
if (args[0].eq && args[1].eq) return args[0].eq(args[1])
144+
if (args[0].eq && (args[1].eq || typeof args[1] === 'number')) return args[0].eq(args[1])
145+
if (args[1].eq && (args[0].eq || typeof args[0] === 'number')) return args[1].eq(args[0])
145146
return args[0] === args[1]
146147
}
147148
for (let i = 1; i < args.length; i++) {
@@ -195,7 +196,8 @@ export function configurePrecision (engine, constructor, compatible = true) {
195196
engine.addMethod('!==', {
196197
method: (args) => {
197198
if (args.length === 2) {
198-
if (args[0].eq && args[1].eq) return !args[0].eq(args[1])
199+
if (args[0].eq && (args[1].eq || typeof args[1] === 'number')) return !args[0].eq(args[1])
200+
if (args[1].eq && (args[0].eq || typeof args[0] === 'number')) return !args[1].eq(args[0])
199201
return args[0] !== args[1]
200202
}
201203
for (let i = 1; i < args.length; i++) {

0 commit comments

Comments
 (0)