Skip to content

Commit 6aa3c38

Browse files
committed
Fix types in packages
1 parent 1a9da23 commit 6aa3c38

File tree

10 files changed

+26
-134
lines changed

10 files changed

+26
-134
lines changed

packages/database/src/core/PersistentConnection.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -948,8 +948,8 @@ export class PersistentConnection extends ServerActions {
948948

949949
// Puts depend on having received the corresponding data update from the server before they complete, so we must
950950
// make sure to send listens before puts.
951-
forEach(this.listens_, (pathString: string, queries: Object) => {
952-
forEach(queries, (key: string, listenSpec: ListenSpec) => {
951+
forEach(this.listens_, (_, queries) => {
952+
forEach(queries, (_, listenSpec) => {
953953
this.sendListen_(listenSpec);
954954
});
955955
});

packages/database/src/core/SparseSnapshotTree.ts

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
import { Path } from './util/Path';
1919
import { PRIORITY_INDEX } from './snap/indexes/PriorityIndex';
20-
import { CountedSet } from './util/CountedSet';
2120
import { Node } from './snap/Node';
2221

2322
/**
@@ -34,9 +33,8 @@ export class SparseSnapshotTree {
3433

3534
/**
3635
* @private
37-
* @type {CountedSet}
3836
*/
39-
private children_: CountedSet<string, SparseSnapshotTree> | null = null;
37+
private children_: Map<string, SparseSnapshotTree> | null = null;
4038

4139
/**
4240
* Gets the node stored at the given path if one exists.
@@ -50,8 +48,8 @@ export class SparseSnapshotTree {
5048
} else if (!path.isEmpty() && this.children_ != null) {
5149
const childKey = path.getFront();
5250
path = path.popFront();
53-
if (this.children_.contains(childKey)) {
54-
const childTree = this.children_.get(childKey) as SparseSnapshotTree;
51+
if (this.children_.has(childKey)) {
52+
const childTree = this.children_.get(childKey);
5553
return childTree.find(path);
5654
} else {
5755
return null;
@@ -76,12 +74,12 @@ export class SparseSnapshotTree {
7674
this.value_ = this.value_.updateChild(path, data);
7775
} else {
7876
if (this.children_ == null) {
79-
this.children_ = new CountedSet<string, SparseSnapshotTree>();
77+
this.children_ = new Map<string, SparseSnapshotTree>();
8078
}
8179

8280
const childKey = path.getFront();
83-
if (!this.children_.contains(childKey)) {
84-
this.children_.add(childKey, new SparseSnapshotTree());
81+
if (!this.children_.has(childKey)) {
82+
this.children_.set(childKey, new SparseSnapshotTree());
8583
}
8684

8785
const child = this.children_.get(childKey) as SparseSnapshotTree;
@@ -120,16 +118,16 @@ export class SparseSnapshotTree {
120118
} else if (this.children_ !== null) {
121119
const childKey = path.getFront();
122120
path = path.popFront();
123-
if (this.children_.contains(childKey)) {
121+
if (this.children_.has(childKey)) {
124122
const safeToRemove = (this.children_.get(
125123
childKey
126124
) as SparseSnapshotTree).forget(path);
127125
if (safeToRemove) {
128-
this.children_.remove(childKey);
126+
this.children_.delete(childKey);
129127
}
130128
}
131129

132-
if (this.children_.isEmpty()) {
130+
if (this.children_.size === 0) {
133131
this.children_ = null;
134132
return true;
135133
} else {
@@ -166,7 +164,7 @@ export class SparseSnapshotTree {
166164
*/
167165
forEachChild(func: (a: string, b: SparseSnapshotTree) => void) {
168166
if (this.children_ !== null) {
169-
this.children_.each((key, tree) => {
167+
this.children_.forEach((tree, key) => {
170168
func(key, tree);
171169
});
172170
}

packages/database/src/core/snap/IndexMap.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export class IndexMap {
7575
// regular child map
7676
return null;
7777
} else {
78-
return sortedMap;
78+
return sortedMap as SortedMap<NamedNode, Node>;
7979
}
8080
}
8181

packages/database/src/core/snap/Node.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export interface Node {
119119
* @param {boolean=} exportFormat True for export format (also wire protocol format).
120120
* @return {*} Value of this node as JSON.
121121
*/
122-
val(exportFormat?: boolean): Object;
122+
val(exportFormat?: boolean): any;
123123

124124
/**
125125
* @return {string} hash representing the node contents.

packages/database/src/core/snap/nodeFromJSON.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,8 @@ export function nodeFromJSON(
113113
}
114114
} else {
115115
let node: Node = ChildrenNode.EMPTY_NODE;
116-
const jsonObj = json as object;
117-
forEach(jsonObj, (key: string, childData: any) => {
118-
if (contains(jsonObj, key)) {
116+
forEach(json, (key, childData) => {
117+
if (contains(json, key)) {
119118
if (key.substring(0, 1) !== '.') {
120119
// ignore metadata nodes.
121120
const childNode = nodeFromJSON(childData);

packages/database/src/core/util/CountedSet.ts

Lines changed: 0 additions & 100 deletions
This file was deleted.

packages/database/src/realtime/BrowserPollConnection.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import {
2424
LUIDGenerator,
2525
splitStringBySize
2626
} from '../core/util/util';
27-
import { CountedSet } from '../core/util/CountedSet';
2827
import { StatsManager } from '../core/stats/StatsManager';
2928
import { PacketReceiver } from './polling/PacketReceiver';
3029
import {
@@ -395,10 +394,7 @@ export interface IFrameElement extends HTMLIFrameElement {
395394
export class FirebaseIFrameScriptHolder {
396395
//We maintain a count of all of the outstanding requests, because if we have too many active at once it can cause
397396
//problems in some browsers.
398-
/**
399-
* @type {CountedSet.<number, number>}
400-
*/
401-
outstandingRequests = new CountedSet<number, number>();
397+
outstandingRequests = new Set<number>();
402398

403399
//A queue of the pending segments waiting for transmission to the server.
404400
pendingSegs: { seg: number; ts: number; d: any }[] = [];
@@ -591,7 +587,7 @@ export class FirebaseIFrameScriptHolder {
591587
if (
592588
this.alive &&
593589
this.sendNewPolls &&
594-
this.outstandingRequests.count() < (this.pendingSegs.length > 0 ? 2 : 1)
590+
this.outstandingRequests.size < (this.pendingSegs.length > 0 ? 2 : 1)
595591
) {
596592
//construct our url
597593
this.currentSerial++;
@@ -670,10 +666,10 @@ export class FirebaseIFrameScriptHolder {
670666
*/
671667
private addLongPollTag_(url: string, serial: number) {
672668
//remember that we sent this request.
673-
this.outstandingRequests.add(serial, 1);
669+
this.outstandingRequests.add(serial);
674670

675671
const doNewRequest = () => {
676-
this.outstandingRequests.remove(serial);
672+
this.outstandingRequests.delete(serial);
677673
this.newRequest_();
678674
};
679675

packages/storage/src/implementation/requestmap.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17-
import * as object from './object';
18-
import * as RequestExports from './request';
17+
import { forEach } from '@firebase/util';
1918
import { Request } from './request';
2019
import * as constants from './constants';
2120

@@ -51,7 +50,7 @@ export class RequestMap {
5150
* Cancels all registered requests.
5251
*/
5352
clear() {
54-
object.forEach(this.map_, (key: string, val: Request<any>) => {
53+
forEach(this.map_, (key: string, val: Request<any>) => {
5554
if (val) {
5655
val.cancel(true);
5756
}

packages/storage/src/implementation/url.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
/**
1919
* @fileoverview Functions to create and manipulate URLs for the server API.
2020
*/
21-
import * as object from './object';
21+
import { forEach } from '@firebase/util';
2222
import { DEFAULT_HOST } from './constants';
2323

2424
export function makeUrl(urlPart: string): string {
@@ -28,7 +28,7 @@ export function makeUrl(urlPart: string): string {
2828
export function makeQueryString(params: { [key: string]: string }): string {
2929
let encode = encodeURIComponent;
3030
let queryPart = '?';
31-
object.forEach(params, function(key, val) {
31+
forEach(params, function(key, val) {
3232
let nextPart = encode(key) + '=' + encode(val);
3333
queryPart = queryPart + nextPart + '&';
3434
});

packages/storage/src/implementation/xhrio_network.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* limitations under the License.
1616
*/
1717
import * as errorsExports from './error';
18-
import * as object from './object';
18+
import { forEach } from '@firebase/util';
1919
import * as promiseimpl from './promise_external';
2020
import * as type from './type';
2121
import * as XhrIoExports from './xhrio';
@@ -65,7 +65,7 @@ export class NetworkXhrIo implements XhrIo {
6565
this.xhr_.open(method, url, true);
6666
if (type.isDef(opt_headers)) {
6767
const headers = opt_headers as Headers;
68-
object.forEach(headers, (key, val) => {
68+
forEach(headers, (key, val) => {
6969
this.xhr_.setRequestHeader(key, val.toString());
7070
});
7171
}

0 commit comments

Comments
 (0)