Skip to content

Commit d77adb1

Browse files
Apply functional-style naming pattern to mutation.ts (#5285)
1 parent 8180a2b commit d77adb1

File tree

5 files changed

+55
-55
lines changed

5 files changed

+55
-55
lines changed

packages/firestore/src/local/local_documents_view.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import {
3232
} from '../model/collections';
3333
import { Document, MutableDocument } from '../model/document';
3434
import { DocumentKey } from '../model/document_key';
35-
import { applyMutationToLocalView, PatchMutation } from '../model/mutation';
35+
import { mutationApplyToLocalView, PatchMutation } from '../model/mutation';
3636
import { MutationBatch } from '../model/mutation_batch';
3737
import { ResourcePath } from '../model/path';
3838
import { debugAssert } from '../util/assert';
@@ -251,7 +251,7 @@ export class LocalDocumentsView {
251251
document = MutableDocument.newInvalidDocument(key);
252252
results = results.insert(key, document);
253253
}
254-
applyMutationToLocalView(
254+
mutationApplyToLocalView(
255255
mutation,
256256
document,
257257
batch.localWriteTime

packages/firestore/src/local/local_store_impl.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import {
3434
import { Document } from '../model/document';
3535
import { DocumentKey } from '../model/document_key';
3636
import {
37-
extractMutationBaseValue,
37+
mutationExtractBaseValue,
3838
Mutation,
3939
PatchMutation,
4040
Precondition
@@ -318,7 +318,7 @@ export function localStoreWriteLocally(
318318
const baseMutations: Mutation[] = [];
319319

320320
for (const mutation of mutations) {
321-
const baseValue = extractMutationBaseValue(
321+
const baseValue = mutationExtractBaseValue(
322322
mutation,
323323
existingDocs.get(mutation.key)!
324324
);

packages/firestore/src/model/mutation.ts

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ export function preconditionIsValidForDocument(
204204
*
205205
* Every type of mutation needs to implement its own applyToRemoteDocument() and
206206
* applyToLocalView() to implement the actual behavior of applying the mutation
207-
* to some source document (see `applySetMutationToRemoteDocument()` for an
207+
* to some source document (see `setMutationApplyToRemoteDocument()` for an
208208
* example).
209209
*/
210210
export abstract class Mutation {
@@ -226,22 +226,22 @@ export abstract class Mutation {
226226
* of the document.
227227
* @param mutationResult - The result of applying the mutation from the backend.
228228
*/
229-
export function applyMutationToRemoteDocument(
229+
export function mutationApplyToRemoteDocument(
230230
mutation: Mutation,
231231
document: MutableDocument,
232232
mutationResult: MutationResult
233233
): void {
234-
verifyMutationKeyMatches(mutation, document);
234+
mutationVerifyKeyMatches(mutation, document);
235235
if (mutation instanceof SetMutation) {
236-
applySetMutationToRemoteDocument(mutation, document, mutationResult);
236+
setMutationApplyToRemoteDocument(mutation, document, mutationResult);
237237
} else if (mutation instanceof PatchMutation) {
238-
applyPatchMutationToRemoteDocument(mutation, document, mutationResult);
238+
patchMutationApplyToRemoteDocument(mutation, document, mutationResult);
239239
} else {
240240
debugAssert(
241241
mutation instanceof DeleteMutation,
242242
'Unexpected mutation type: ' + mutation
243243
);
244-
applyDeleteMutationToRemoteDocument(mutation, document, mutationResult);
244+
deleteMutationApplyToRemoteDocument(mutation, document, mutationResult);
245245
}
246246
}
247247

@@ -257,23 +257,23 @@ export function applyMutationToRemoteDocument(
257257
* @param localWriteTime - A timestamp indicating the local write time of the
258258
* batch this mutation is a part of.
259259
*/
260-
export function applyMutationToLocalView(
260+
export function mutationApplyToLocalView(
261261
mutation: Mutation,
262262
document: MutableDocument,
263263
localWriteTime: Timestamp
264264
): void {
265-
verifyMutationKeyMatches(mutation, document);
265+
mutationVerifyKeyMatches(mutation, document);
266266

267267
if (mutation instanceof SetMutation) {
268-
applySetMutationToLocalView(mutation, document, localWriteTime);
268+
setMutationApplyToLocalView(mutation, document, localWriteTime);
269269
} else if (mutation instanceof PatchMutation) {
270-
applyPatchMutationToLocalView(mutation, document, localWriteTime);
270+
patchMutationApplyToLocalView(mutation, document, localWriteTime);
271271
} else {
272272
debugAssert(
273273
mutation instanceof DeleteMutation,
274274
'Unexpected mutation type: ' + mutation
275275
);
276-
applyDeleteMutationToLocalView(mutation, document);
276+
deleteMutationApplyToLocalView(mutation, document);
277277
}
278278
}
279279

@@ -293,7 +293,7 @@ export function applyMutationToLocalView(
293293
* @returns a base value to store along with the mutation, or null for
294294
* idempotent mutations.
295295
*/
296-
export function extractMutationBaseValue(
296+
export function mutationExtractBaseValue(
297297
mutation: Mutation,
298298
document: Document
299299
): ObjectValue | null {
@@ -348,7 +348,7 @@ export function mutationEquals(left: Mutation, right: Mutation): boolean {
348348
return true;
349349
}
350350

351-
function verifyMutationKeyMatches(
351+
function mutationVerifyKeyMatches(
352352
mutation: Mutation,
353353
document: MutableDocument
354354
): void {
@@ -385,12 +385,12 @@ export class SetMutation extends Mutation {
385385
readonly type: MutationType = MutationType.Set;
386386
}
387387

388-
function applySetMutationToRemoteDocument(
388+
function setMutationApplyToRemoteDocument(
389389
mutation: SetMutation,
390390
document: MutableDocument,
391391
mutationResult: MutationResult
392392
): void {
393-
// Unlike applySetMutationToLocalView, if we're applying a mutation to a
393+
// Unlike setMutationApplyToLocalView, if we're applying a mutation to a
394394
// remote document the server has accepted the mutation so the precondition
395395
// must have held.
396396
const newData = mutation.value.clone();
@@ -405,7 +405,7 @@ function applySetMutationToRemoteDocument(
405405
.setHasCommittedMutations();
406406
}
407407

408-
function applySetMutationToLocalView(
408+
function setMutationApplyToLocalView(
409409
mutation: SetMutation,
410410
document: MutableDocument,
411411
localWriteTime: Timestamp
@@ -455,7 +455,7 @@ export class PatchMutation extends Mutation {
455455
readonly type: MutationType = MutationType.Patch;
456456
}
457457

458-
function applyPatchMutationToRemoteDocument(
458+
function patchMutationApplyToRemoteDocument(
459459
mutation: PatchMutation,
460460
document: MutableDocument,
461461
mutationResult: MutationResult
@@ -482,7 +482,7 @@ function applyPatchMutationToRemoteDocument(
482482
.setHasCommittedMutations();
483483
}
484484

485-
function applyPatchMutationToLocalView(
485+
function patchMutationApplyToLocalView(
486486
mutation: PatchMutation,
487487
document: MutableDocument,
488488
localWriteTime: Timestamp
@@ -601,7 +601,7 @@ export class DeleteMutation extends Mutation {
601601
readonly fieldTransforms: FieldTransform[] = [];
602602
}
603603

604-
function applyDeleteMutationToRemoteDocument(
604+
function deleteMutationApplyToRemoteDocument(
605605
mutation: DeleteMutation,
606606
document: MutableDocument,
607607
mutationResult: MutationResult
@@ -619,7 +619,7 @@ function applyDeleteMutationToRemoteDocument(
619619
.setHasCommittedMutations();
620620
}
621621

622-
function applyDeleteMutationToLocalView(
622+
function deleteMutationApplyToLocalView(
623623
mutation: DeleteMutation,
624624
document: MutableDocument
625625
): void {

packages/firestore/src/model/mutation_batch.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ import {
3030
} from './collections';
3131
import { MutableDocument } from './document';
3232
import {
33-
applyMutationToLocalView,
34-
applyMutationToRemoteDocument,
3533
Mutation,
34+
mutationApplyToLocalView,
35+
mutationApplyToRemoteDocument,
3636
mutationEquals,
3737
MutationResult
3838
} from './mutation';
@@ -85,7 +85,7 @@ export class MutationBatch {
8585
const mutation = this.mutations[i];
8686
if (mutation.key.isEqual(document.key)) {
8787
const mutationResult = mutationResults[i];
88-
applyMutationToRemoteDocument(mutation, document, mutationResult);
88+
mutationApplyToRemoteDocument(mutation, document, mutationResult);
8989
}
9090
}
9191
}
@@ -101,14 +101,14 @@ export class MutationBatch {
101101
// transform against a consistent set of values.
102102
for (const mutation of this.baseMutations) {
103103
if (mutation.key.isEqual(document.key)) {
104-
applyMutationToLocalView(mutation, document, this.localWriteTime);
104+
mutationApplyToLocalView(mutation, document, this.localWriteTime);
105105
}
106106
}
107107

108108
// Second, apply all user-provided mutations.
109109
for (const mutation of this.mutations) {
110110
if (mutation.key.isEqual(document.key)) {
111-
applyMutationToLocalView(mutation, document, this.localWriteTime);
111+
mutationApplyToLocalView(mutation, document, this.localWriteTime);
112112
}
113113
}
114114
}

0 commit comments

Comments
 (0)