Skip to content

Commit b9df088

Browse files
committed
prepend functions with the class name they operate on
1 parent 7006e28 commit b9df088

File tree

4 files changed

+45
-39
lines changed

4 files changed

+45
-39
lines changed

packages/database/src/api/Query.ts

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ import {
5151
import { Repo } from '../core/Repo';
5252
import {
5353
QueryParams,
54-
limitToFirst,
55-
limitToLast,
56-
startAfter,
57-
startAt,
58-
endAt,
59-
endBefore,
60-
getQueryObject,
61-
orderBy
54+
queryParamsLimitToFirst,
55+
queryParamsLimitToLast,
56+
queryParamsStartAfter,
57+
queryParamsStartAt,
58+
queryParamsEndAt,
59+
queryParamsEndBefore,
60+
queryParamsGetQueryObject,
61+
queryParamsOrderBy
6262
} from '../core/view/QueryParams';
6363
import { Reference } from './Reference';
6464
import { DataSnapshot } from './DataSnapshot';
@@ -365,7 +365,7 @@ export class Query {
365365
return new Query(
366366
this.repo,
367367
this.path,
368-
limitToFirst(this.queryParams_, limit),
368+
queryParamsLimitToFirst(this.queryParams_, limit),
369369
this.orderByCalled_
370370
);
371371
}
@@ -394,7 +394,7 @@ export class Query {
394394
return new Query(
395395
this.repo,
396396
this.path,
397-
limitToLast(this.queryParams_, limit),
397+
queryParamsLimitToLast(this.queryParams_, limit),
398398
this.orderByCalled_
399399
);
400400
}
@@ -426,7 +426,7 @@ export class Query {
426426
);
427427
}
428428
const index = new PathIndex(parsedPath);
429-
const newParams = orderBy(this.queryParams_, index);
429+
const newParams = queryParamsOrderBy(this.queryParams_, index);
430430
Query.validateQueryEndpoints_(newParams);
431431

432432
return new Query(this.repo, this.path, newParams, /*orderByCalled=*/ true);
@@ -438,7 +438,7 @@ export class Query {
438438
orderByKey(): Query {
439439
validateArgCount('Query.orderByKey', 0, 0, arguments.length);
440440
this.validateNoPreviousOrderByCall_('Query.orderByKey');
441-
const newParams = orderBy(this.queryParams_, KEY_INDEX);
441+
const newParams = queryParamsOrderBy(this.queryParams_, KEY_INDEX);
442442
Query.validateQueryEndpoints_(newParams);
443443
return new Query(this.repo, this.path, newParams, /*orderByCalled=*/ true);
444444
}
@@ -449,7 +449,7 @@ export class Query {
449449
orderByPriority(): Query {
450450
validateArgCount('Query.orderByPriority', 0, 0, arguments.length);
451451
this.validateNoPreviousOrderByCall_('Query.orderByPriority');
452-
const newParams = orderBy(this.queryParams_, PRIORITY_INDEX);
452+
const newParams = queryParamsOrderBy(this.queryParams_, PRIORITY_INDEX);
453453
Query.validateQueryEndpoints_(newParams);
454454
return new Query(this.repo, this.path, newParams, /*orderByCalled=*/ true);
455455
}
@@ -460,7 +460,7 @@ export class Query {
460460
orderByValue(): Query {
461461
validateArgCount('Query.orderByValue', 0, 0, arguments.length);
462462
this.validateNoPreviousOrderByCall_('Query.orderByValue');
463-
const newParams = orderBy(this.queryParams_, VALUE_INDEX);
463+
const newParams = queryParamsOrderBy(this.queryParams_, VALUE_INDEX);
464464
Query.validateQueryEndpoints_(newParams);
465465
return new Query(this.repo, this.path, newParams, /*orderByCalled=*/ true);
466466
}
@@ -473,7 +473,7 @@ export class Query {
473473
validateFirebaseDataArg('Query.startAt', 1, value, this.path, true);
474474
validateKey('Query.startAt', 2, name, true);
475475

476-
const newParams = startAt(this.queryParams_, value, name);
476+
const newParams = queryParamsStartAt(this.queryParams_, value, name);
477477
Query.validateLimit_(newParams);
478478
Query.validateQueryEndpoints_(newParams);
479479
if (this.queryParams_.hasStart()) {
@@ -500,7 +500,7 @@ export class Query {
500500
validateFirebaseDataArg('Query.startAfter', 1, value, this.path, false);
501501
validateKey('Query.startAfter', 2, name, true);
502502

503-
const newParams = startAfter(this.queryParams_, value, name);
503+
const newParams = queryParamsStartAfter(this.queryParams_, value, name);
504504
Query.validateLimit_(newParams);
505505
Query.validateQueryEndpoints_(newParams);
506506
if (this.queryParams_.hasStart()) {
@@ -521,7 +521,7 @@ export class Query {
521521
validateFirebaseDataArg('Query.endAt', 1, value, this.path, true);
522522
validateKey('Query.endAt', 2, name, true);
523523

524-
const newParams = endAt(this.queryParams_, value, name);
524+
const newParams = queryParamsEndAt(this.queryParams_, value, name);
525525
Query.validateLimit_(newParams);
526526
Query.validateQueryEndpoints_(newParams);
527527
if (this.queryParams_.hasEnd()) {
@@ -542,7 +542,7 @@ export class Query {
542542
validateFirebaseDataArg('Query.endBefore', 1, value, this.path, false);
543543
validateKey('Query.endBefore', 2, name, true);
544544

545-
const newParams = endBefore(this.queryParams_, value, name);
545+
const newParams = queryParamsEndBefore(this.queryParams_, value, name);
546546
Query.validateLimit_(newParams);
547547
Query.validateQueryEndpoints_(newParams);
548548
if (this.queryParams_.hasEnd()) {
@@ -599,7 +599,7 @@ export class Query {
599599
* An object representation of the query parameters used by this Query.
600600
*/
601601
queryObject(): object {
602-
return getQueryObject(this.queryParams_);
602+
return queryParamsGetQueryObject(this.queryParams_);
603603
}
604604

605605
queryIdentifier(): string {

packages/database/src/core/ReadonlyRestClient.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import { ServerActions } from './ServerActions';
2828
import { RepoInfo } from './RepoInfo';
2929
import { AuthTokenProvider } from './AuthTokenProvider';
3030
import { Query } from '../api/Query';
31-
import { toRestQueryStringParameters } from './view/QueryParams';
31+
import { queryParamsToRestQueryStringParameters } from './view/QueryParams';
3232

3333
/**
3434
* An implementation of ServerActions that communicates with the server via REST requests.
@@ -95,7 +95,7 @@ export class ReadonlyRestClient extends ServerActions {
9595
const thisListen = {};
9696
this.listens_[listenId] = thisListen;
9797

98-
const queryStringParameters = toRestQueryStringParameters(
98+
const queryStringParameters = queryParamsToRestQueryStringParameters(
9999
query.getQueryParams()
100100
);
101101

@@ -137,7 +137,7 @@ export class ReadonlyRestClient extends ServerActions {
137137
}
138138

139139
get(query: Query): Promise<string> {
140-
const queryStringParameters = toRestQueryStringParameters(
140+
const queryStringParameters = queryParamsToRestQueryStringParameters(
141141
query.getQueryParams()
142142
);
143143

packages/database/src/core/view/QueryParams.ts

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ export class QueryParams {
203203
}
204204
}
205205

206-
export function getNodeFilter(queryParams: QueryParams): NodeFilter {
206+
export function queryParamsGetNodeFilter(queryParams: QueryParams): NodeFilter {
207207
if (queryParams.loadsAllData()) {
208208
return new IndexedFilter(queryParams.getIndex());
209209
} else if (queryParams.hasLimit()) {
@@ -213,15 +213,18 @@ export function getNodeFilter(queryParams: QueryParams): NodeFilter {
213213
}
214214
}
215215

216-
export function limit(queryParams: QueryParams, newLimit: number): QueryParams {
216+
export function queryParamsLimit(
217+
queryParams: QueryParams,
218+
newLimit: number
219+
): QueryParams {
217220
const newParams = queryParams.copy();
218221
newParams.limitSet_ = true;
219222
newParams.limit_ = newLimit;
220223
newParams.viewFrom_ = '';
221224
return newParams;
222225
}
223226

224-
export function limitToFirst(
227+
export function queryParamsLimitToFirst(
225228
queryParams: QueryParams,
226229
newLimit: number
227230
): QueryParams {
@@ -232,7 +235,7 @@ export function limitToFirst(
232235
return newParams;
233236
}
234237

235-
export function limitToLast(
238+
export function queryParamsLimitToLast(
236239
queryParams: QueryParams,
237240
newLimit: number
238241
): QueryParams {
@@ -243,7 +246,7 @@ export function limitToLast(
243246
return newParams;
244247
}
245248

246-
export function startAt(
249+
export function queryParamsStartAt(
247250
queryParams: QueryParams,
248251
indexValue: unknown,
249252
key?: string | null
@@ -264,7 +267,7 @@ export function startAt(
264267
return newParams;
265268
}
266269

267-
export function startAfter(
270+
export function queryParamsStartAfter(
268271
queryParams: QueryParams,
269272
indexValue: unknown,
270273
key?: string | null
@@ -274,21 +277,21 @@ export function startAfter(
274277
if (typeof indexValue === 'string') {
275278
indexValue = successor(indexValue as string);
276279
}
277-
params = startAt(queryParams, indexValue, key);
280+
params = queryParamsStartAt(queryParams, indexValue, key);
278281
} else {
279282
let childKey: string;
280283
if (key == null) {
281284
childKey = MAX_NAME;
282285
} else {
283286
childKey = successor(key);
284287
}
285-
params = startAt(queryParams, indexValue, childKey);
288+
params = queryParamsStartAt(queryParams, indexValue, childKey);
286289
}
287290
params.startAfterSet_ = true;
288291
return params;
289292
}
290293

291-
export function endAt(
294+
export function queryParamsEndAt(
292295
queryParams: QueryParams,
293296
indexValue: unknown,
294297
key?: string | null
@@ -309,7 +312,7 @@ export function endAt(
309312
return newParams;
310313
}
311314

312-
export function endBefore(
315+
export function queryParamsEndBefore(
313316
queryParams: QueryParams,
314317
indexValue: unknown,
315318
key?: string | null
@@ -320,20 +323,23 @@ export function endBefore(
320323
if (typeof indexValue === 'string') {
321324
indexValue = predecessor(indexValue as string);
322325
}
323-
params = endAt(queryParams, indexValue, key);
326+
params = queryParamsEndAt(queryParams, indexValue, key);
324327
} else {
325328
if (key == null) {
326329
childKey = MIN_NAME;
327330
} else {
328331
childKey = predecessor(key);
329332
}
330-
params = endAt(queryParams, indexValue, childKey);
333+
params = queryParamsEndAt(queryParams, indexValue, childKey);
331334
}
332335
params.endBeforeSet_ = true;
333336
return params;
334337
}
335338

336-
export function orderBy(queryParams: QueryParams, index: Index): QueryParams {
339+
export function queryParamsOrderBy(
340+
queryParams: QueryParams,
341+
index: Index
342+
): QueryParams {
337343
const newParams = queryParams.copy();
338344
newParams.index_ = index;
339345
return newParams;
@@ -344,7 +350,7 @@ export function orderBy(queryParams: QueryParams, index: Index): QueryParams {
344350
*
345351
* @return query string parameters
346352
*/
347-
export function toRestQueryStringParameters(
353+
export function queryParamsToRestQueryStringParameters(
348354
queryParams: QueryParams
349355
): Record<string, string | number> {
350356
const qs: Record<string, string | number> = {};
@@ -393,7 +399,7 @@ export function toRestQueryStringParameters(
393399
return qs;
394400
}
395401

396-
export function getQueryObject(
402+
export function queryParamsGetQueryObject(
397403
queryParams: QueryParams
398404
): Record<string, unknown> {
399405
const obj: Record<string, unknown> = {};

packages/database/src/core/view/View.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import { Node } from '../snap/Node';
3434
import { Path, pathGetFront, pathIsEmpty } from '../util/Path';
3535
import { WriteTreeRef } from '../WriteTree';
3636
import { CancelEvent, Event } from './Event';
37-
import { getNodeFilter } from './QueryParams';
37+
import { queryParamsGetNodeFilter } from './QueryParams';
3838

3939
/**
4040
* A view represents a specific location and query that has 1 or more event registrations.
@@ -55,7 +55,7 @@ export class View {
5555
const params = this.query_.getQueryParams();
5656

5757
const indexFilter = new IndexedFilter(params.getIndex());
58-
const filter = getNodeFilter(params);
58+
const filter = queryParamsGetNodeFilter(params);
5959

6060
this.processor_ = new ViewProcessor(filter);
6161

0 commit comments

Comments
 (0)