Skip to content

Commit 52d3655

Browse files
authored
replace with early return
1 parent cf0a815 commit 52d3655

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/helpers/query/cast$expr.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,10 @@ const dateOperators = new Set([
6969
const expressionOperator = new Set(['$not']);
7070

7171
module.exports = function cast$expr(val, schema, strictQuery) {
72-
if ((typeof val !== 'object' || val === null) && typeof val !== 'boolean') {
72+
if (typeof val === 'boolean') {
73+
return val;
74+
}
75+
if (typeof val !== 'object' || val === null) {
7376
throw new Error('`$expr` must be an object or boolean literal');
7477
}
7578

0 commit comments

Comments
 (0)