Skip to content

Commit 175a2e6

Browse files
Remove generic isEqual code
1 parent a4781c8 commit 175a2e6

File tree

3 files changed

+9
-25
lines changed

3 files changed

+9
-25
lines changed

packages/firestore/rollup.config.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ const es5BuildPlugins = [
107107
}),
108108
{
109109
transform(code) {
110-
// Allow Rollup to drop unused classes.
110+
// Allow Rollup to drop unused classes.
111111
// See https://github.com/rollup/rollup/issues/2807
112-
return code.replace(/\/\*\* @class \*\//g, "\/*@__PURE__*\/");
112+
return code.replace(/\/\*\* @class \*\//g, '/*@__PURE__*/');
113113
}
114114
},
115115
json(),
@@ -207,9 +207,9 @@ const nodeBuildPlugins = [
207207
}),
208208
{
209209
transform(code) {
210-
// Allow Rollup to drop unused classes.
210+
// Allow Rollup to drop unused classes.
211211
// See https://github.com/rollup/rollup/issues/2807
212-
return code.replace(/\/\*\* @class \*\//g, "\/*@__PURE__*\/");
212+
return code.replace(/\/\*\* @class \*\//g, '/*@__PURE__*/');
213213
}
214214
},
215215
json(),

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 & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -56,25 +56,6 @@ 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. */
60-
export interface Equatable<T> {
61-
isEqual(other: T): boolean;
62-
}
63-
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-
7859
/** Helper to compare arrays using isEqual(). */
7960
export function arrayEquals<T>(
8061
left: T[],

0 commit comments

Comments
 (0)