Skip to content

Commit e65ca11

Browse files
Merge
1 parent fa16463 commit e65ca11

File tree

2 files changed

+5
-17
lines changed

2 files changed

+5
-17
lines changed

packages/firestore/src/model/mutation.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import { DocumentKey } from './document_key';
3232
import { ObjectValue, ObjectValueBuilder } from './field_value';
3333
import { FieldPath } from './path';
3434
import { TransformOperation } from './transform_operation';
35-
import { arrayEquals, equals } from '../util/misc';
35+
import { arrayEquals } from '../util/misc';
3636

3737
/**
3838
* Provides a set of fields that can be used to partially patch a document.
@@ -180,7 +180,10 @@ export class Precondition {
180180

181181
isEqual(other: Precondition): boolean {
182182
return (
183-
equals(this.updateTime, other.updateTime) && this.exists === other.exists
183+
this.exists === other.exists &&
184+
(this.updateTime
185+
? !!other.updateTime && this.updateTime?.isEqual(other.updateTime)
186+
: !other.updateTime)
184187
);
185188
}
186189
}

packages/firestore/src/util/misc.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -56,25 +56,10 @@ export function primitiveComparator<T>(left: T, right: T): number {
5656
return 0;
5757
}
5858

59-
/** Duck-typed interface for objects that have an isEqual() method. */
6059
export interface Equatable<T> {
6160
isEqual(other: T): boolean;
6261
}
6362

64-
/** Helper to compare nullable (or undefined-able) objects using isEqual(). */
65-
export function equals<T>(
66-
left: Equatable<T> | null | undefined,
67-
right: T | null | undefined
68-
): boolean {
69-
if (left !== null && left !== undefined) {
70-
return !!(right && left.isEqual(right));
71-
} else {
72-
// HACK: Explicitly cast since TypeScript's type narrowing apparently isn't
73-
// smart enough.
74-
return (left as null | undefined) === right;
75-
}
76-
}
77-
7863
/** Helper to compare arrays using isEqual(). */
7964
export function arrayEquals<T>(
8065
left: T[],

0 commit comments

Comments
 (0)