Skip to content

Commit 032925e

Browse files
authored
refactor: compare with undefined directly instead of using typeof (#338)
1 parent e897522 commit 032925e

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/collection.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ export class Collection<Schema extends StandardSchemaV1> {
611611
const { take, cursor, skip } = options
612612

613613
invariant(
614-
typeof skip !== 'undefined' ? Number.isInteger(skip) && skip >= 0 : true,
614+
skip !== undefined ? Number.isInteger(skip) && skip >= 0 : true,
615615
'Failed to query the collection: expected the "skip" pagination option to be a number larger or equal to 0 but got %j',
616616
skip,
617617
)

src/query.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export class Query<T> {
7474
return Object.entries(condition).every(([key, selector]) => {
7575
const actualValue = record[key]
7676

77-
if (typeof actualValue === 'undefined') {
77+
if (actualValue === undefined) {
7878
return false
7979
}
8080

src/relation.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ export abstract class Relation {
417417
returnValue,
418418
)
419419

420-
if (typeof returnValue !== 'undefined') {
420+
if (returnValue !== undefined) {
421421
return returnValue
422422
}
423423

@@ -516,7 +516,7 @@ class One extends Relation {
516516
/**
517517
* @note `null` is a valid value for nullable relations.
518518
*/
519-
if (typeof record !== 'undefined') {
519+
if (record !== undefined) {
520520
return record
521521
}
522522
}

0 commit comments

Comments
 (0)