Skip to content

Commit 5648cde

Browse files
Review
1 parent bbf2dec commit 5648cde

File tree

7 files changed

+55
-85
lines changed

7 files changed

+55
-85
lines changed
Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @license
3-
* Copyright 2017 Google LLC
3+
* Copyright 2020 Google LLC
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.
@@ -17,51 +17,39 @@
1717

1818
import { isNode, isReactNative } from '@firebase/util';
1919

20-
import {
21-
decodeBase64 as nodeDecodeBase64,
22-
encodeBase64 as nodeEncodeBase64,
23-
isBase64Available as nodeIsBase64Available
24-
} from './node/base64';
25-
import {
26-
decodeBase64 as rnDecodeBase64,
27-
encodeBase64 as rnEncodeBase64,
28-
isBase64Available as rnIsBase64Available
29-
} from './rn/base64';
30-
import {
31-
decodeBase64 as browserDecodeBase64,
32-
encodeBase64 as browserEncodeBase64,
33-
isBase64Available as browserIsBase64Available
34-
} from './browser/base64';
20+
import * as node from './node/base64';
21+
import * as rn from './rn/base64';
22+
import * as browser from './browser/base64';
3523

3624
/** Converts a Base64 encoded string to a binary string. */
3725
export function decodeBase64(encoded: string): string {
3826
if (isNode()) {
39-
return nodeDecodeBase64(encoded);
27+
return node.decodeBase64(encoded);
4028
} else if (isReactNative()) {
41-
return rnDecodeBase64(encoded);
29+
return rn.decodeBase64(encoded);
4230
} else {
43-
return browserDecodeBase64(encoded);
31+
return browser.decodeBase64(encoded);
4432
}
4533
}
4634

4735
/** Converts a binary string to a Base64 encoded string. */
4836
export function encodeBase64(raw: string): string {
4937
if (isNode()) {
50-
return nodeEncodeBase64(raw);
38+
return node.encodeBase64(raw);
5139
} else if (isReactNative()) {
52-
return rnEncodeBase64(raw);
40+
return rn.encodeBase64(raw);
5341
} else {
54-
return browserEncodeBase64(raw);
42+
return browser.encodeBase64(raw);
5543
}
5644
}
5745

5846
/** True if and only if the Base64 conversion functions are available. */
5947
export function isBase64Available(): boolean {
6048
if (isNode()) {
61-
return nodeIsBase64Available();
49+
return node.isBase64Available();
6250
} else if (isReactNative()) {
63-
return rnIsBase64Available();
51+
return rn.isBase64Available();
6452
} else {
65-
return browserIsBase64Available();
53+
return browser.isBase64Available();
6654
}
6755
}
Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @license
3-
* Copyright 2017 Google LLC
3+
* Copyright 2020 Google LLC
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.
@@ -16,38 +16,29 @@
1616
*/
1717

1818
import { isNode, isReactNative } from '@firebase/util';
19-
import {
20-
newConnectivityMonitor as nodeNewConnectivityMonitor,
21-
newConnection as nodeNewConnection
22-
} from './node/connection';
23-
import {
24-
newConnectivityMonitor as rnNewConnectivityMonitor,
25-
newConnection as rnNewConnection
26-
} from './rn/connection';
27-
import {
28-
newConnectivityMonitor as browserNewConnectivityMonitor,
29-
newConnection as browserNewConnection
30-
} from './browser/connection';
19+
import * as node from './node/connection';
20+
import * as rn from './rn/connection';
21+
import * as browser from './browser/connection';
3122
import { ConnectivityMonitor } from '../remote/connectivity_monitor';
3223
import { DatabaseInfo } from '../core/database_info';
3324
import { Connection } from '../remote/connection';
3425

3526
export function newConnectivityMonitor(): ConnectivityMonitor {
3627
if (isNode()) {
37-
return nodeNewConnectivityMonitor();
28+
return node.newConnectivityMonitor();
3829
} else if (isReactNative()) {
39-
return rnNewConnectivityMonitor();
30+
return rn.newConnectivityMonitor();
4031
} else {
41-
return browserNewConnectivityMonitor();
32+
return browser.newConnectivityMonitor();
4233
}
4334
}
4435

4536
export function newConnection(databaseInfo: DatabaseInfo): Promise<Connection> {
4637
if (isNode()) {
47-
return nodeNewConnection(databaseInfo);
38+
return node.newConnection(databaseInfo);
4839
} else if (isReactNative()) {
49-
return rnNewConnection(databaseInfo);
40+
return rn.newConnection(databaseInfo);
5041
} else {
51-
return browserNewConnection(databaseInfo);
42+
return browser.newConnection(databaseInfo);
5243
}
5344
}
Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @license
3-
* Copyright 2017 Google LLC
3+
* Copyright 2020 Google LLC
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.
@@ -16,37 +16,28 @@
1616
*/
1717

1818
import { isNode, isReactNative } from '@firebase/util';
19-
import {
20-
getWindow as nodeGetWindow,
21-
getDocument as nodeGetDocument
22-
} from './node/dom';
23-
import {
24-
getWindow as rnGetWindow,
25-
getDocument as rnGetDocument
26-
} from './rn/dom';
27-
import {
28-
getWindow as browserGetWindow,
29-
getDocument as browserGetDocument
30-
} from './browser/dom';
19+
import * as node from './node/dom';
20+
import * as rn from './rn/dom';
21+
import * as browser from './browser/dom';
3122

3223
/** The Platform's 'window' implementation or null if not available. */
3324
export function getWindow(): Window | null {
3425
if (isNode()) {
35-
return nodeGetWindow();
26+
return node.getWindow();
3627
} else if (isReactNative()) {
37-
return rnGetWindow();
28+
return rn.getWindow();
3829
} else {
39-
return browserGetWindow();
30+
return browser.getWindow();
4031
}
4132
}
4233

4334
/** The Platform's 'document' implementation or null if not available. */
4435
export function getDocument(): Document | null {
4536
if (isNode()) {
46-
return nodeGetDocument();
37+
return node.getDocument();
4738
} else if (isReactNative()) {
48-
return rnGetDocument();
39+
return rn.getDocument();
4940
} else {
50-
return browserGetDocument();
41+
return browser.getDocument();
5142
}
5243
}

packages/firestore/src/platform/format_json.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @license
3-
* Copyright 2017 Google LLC
3+
* Copyright 2020 Google LLC
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.
@@ -16,17 +16,17 @@
1616
*/
1717

1818
import { isNode, isReactNative } from '@firebase/util';
19-
import { formatJSON as nodeFormatJSON } from './node/format_json';
20-
import { formatJSON as rnFormatJSON } from './rn/format_json';
21-
import { formatJSON as browserFormatJSON } from './browser/format_json';
19+
import * as node from './node/format_json';
20+
import * as rn from './rn/format_json';
21+
import * as browser from './browser/format_json';
2222

2323
/** Formats an object as a JSON string, suitable for logging. */
2424
export function formatJSON(value: unknown): string {
2525
if (isNode()) {
26-
return nodeFormatJSON(value);
26+
return node.formatJSON(value);
2727
} else if (isReactNative()) {
28-
return rnFormatJSON(value);
28+
return rn.formatJSON(value);
2929
} else {
30-
return browserFormatJSON(value);
30+
return browser.formatJSON(value);
3131
}
3232
}

packages/firestore/src/platform/node/load_protos.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @license
3-
* Copyright 2017 Google LLC
3+
* Copyright 2020 Google LLC
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.

packages/firestore/src/platform/random_bytes.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @license
3-
* Copyright 2017 Google LLC
3+
* Copyright 2020 Google LLC
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.
@@ -16,9 +16,9 @@
1616
*/
1717

1818
import { isNode, isReactNative } from '@firebase/util';
19-
import { randomBytes as nodeRandomBytes } from './node/random_bytes';
20-
import { randomBytes as rnRandomBytes } from './rn/random_bytes';
21-
import { randomBytes as browserRandomBytes } from './browser/random_bytes';
19+
import * as node from './node/random_bytes';
20+
import * as rn from './rn/random_bytes';
21+
import * as browser from './browser/random_bytes';
2222

2323
/**
2424
* Generates `nBytes` of random bytes.
@@ -27,10 +27,10 @@ import { randomBytes as browserRandomBytes } from './browser/random_bytes';
2727
*/
2828
export function randomBytes(nBytes: number): Uint8Array {
2929
if (isNode()) {
30-
return nodeRandomBytes(nBytes);
30+
return node.randomBytes(nBytes);
3131
} else if (isReactNative()) {
32-
return rnRandomBytes(nBytes);
32+
return rn.randomBytes(nBytes);
3333
} else {
34-
return browserRandomBytes(nBytes);
34+
return browser.randomBytes(nBytes);
3535
}
3636
}

packages/firestore/src/platform/serializer.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @license
3-
* Copyright 2017 Google LLC
3+
* Copyright 2020 Google LLC
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.
@@ -16,18 +16,18 @@
1616
*/
1717

1818
import { isNode, isReactNative } from '@firebase/util';
19-
import { newSerializer as nodeNewSerializer } from './node/serializer';
20-
import { newSerializer as rnNewSerializer } from './rn/serializer';
21-
import { newSerializer as browserNewSerializer } from './browser/serializer';
19+
import * as node from './node/serializer';
20+
import * as rn from './rn/serializer';
21+
import * as browser from './browser/serializer';
2222
import { DatabaseId } from '../core/database_info';
2323
import { JsonProtoSerializer } from '../remote/serializer';
2424

2525
export function newSerializer(databaseId: DatabaseId): JsonProtoSerializer {
2626
if (isNode()) {
27-
return nodeNewSerializer(databaseId);
27+
return node.newSerializer(databaseId);
2828
} else if (isReactNative()) {
29-
return rnNewSerializer(databaseId);
29+
return rn.newSerializer(databaseId);
3030
} else {
31-
return browserNewSerializer(databaseId);
31+
return browser.newSerializer(databaseId);
3232
}
3333
}

0 commit comments

Comments
 (0)