@firebase/util 1.10.1 → 1.10.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/dist/index.cjs.js +2086 -2086
  2. package/dist/index.cjs.js.map +1 -1
  3. package/dist/index.d.ts +39 -39
  4. package/dist/index.esm2017.js +2086 -2086
  5. package/dist/index.esm2017.js.map +1 -1
  6. package/dist/index.node.cjs.js +2103 -2103
  7. package/dist/index.node.cjs.js.map +1 -1
  8. package/dist/index.node.d.ts +39 -39
  9. package/dist/node-esm/index.d.ts +39 -39
  10. package/dist/node-esm/index.node.d.ts +39 -39
  11. package/dist/node-esm/index.node.esm.js +2103 -2103
  12. package/dist/node-esm/index.node.esm.js.map +1 -1
  13. package/dist/node-esm/src/assert.d.ts +24 -24
  14. package/dist/node-esm/src/compat.d.ts +20 -20
  15. package/dist/node-esm/src/constants.d.ts +33 -33
  16. package/dist/node-esm/src/crypt.d.ts +66 -66
  17. package/dist/node-esm/src/deepCopy.d.ts +35 -35
  18. package/dist/node-esm/src/defaults.d.ts +79 -79
  19. package/dist/node-esm/src/deferred.d.ts +28 -28
  20. package/dist/node-esm/src/emulator.d.ts +47 -47
  21. package/dist/node-esm/src/environment.d.ts +90 -90
  22. package/dist/node-esm/src/errors.d.ts +87 -87
  23. package/dist/node-esm/src/exponential_backoff.d.ts +37 -37
  24. package/dist/node-esm/src/formatters.d.ts +20 -20
  25. package/dist/node-esm/src/global.d.ts +22 -22
  26. package/dist/node-esm/src/json.d.ts +29 -29
  27. package/dist/node-esm/src/jwt.d.ts +73 -73
  28. package/dist/node-esm/src/obj.d.ts +30 -30
  29. package/dist/node-esm/src/promise.d.ts +21 -21
  30. package/dist/node-esm/src/query.d.ts +33 -33
  31. package/dist/node-esm/src/sha1.d.ts +84 -84
  32. package/dist/node-esm/src/subscribe.d.ts +49 -49
  33. package/dist/node-esm/src/utf8.d.ts +27 -27
  34. package/dist/node-esm/src/uuid.d.ts +22 -22
  35. package/dist/node-esm/src/validation.d.ts +43 -43
  36. package/dist/node-esm/test/base64.test.d.ts +1 -1
  37. package/dist/node-esm/test/compat.test.d.ts +17 -17
  38. package/dist/node-esm/test/deepCopy.test.d.ts +1 -1
  39. package/dist/node-esm/test/defaults.test.d.ts +1 -1
  40. package/dist/node-esm/test/emulator.test.d.ts +1 -1
  41. package/dist/node-esm/test/environments.test.d.ts +17 -17
  42. package/dist/node-esm/test/errors.test.d.ts +1 -1
  43. package/dist/node-esm/test/exponential_backoff.test.d.ts +17 -17
  44. package/dist/node-esm/test/object.test.d.ts +17 -17
  45. package/dist/node-esm/test/subscribe.test.d.ts +17 -17
  46. package/dist/src/assert.d.ts +24 -24
  47. package/dist/src/compat.d.ts +20 -20
  48. package/dist/src/constants.d.ts +33 -33
  49. package/dist/src/crypt.d.ts +66 -66
  50. package/dist/src/deepCopy.d.ts +35 -35
  51. package/dist/src/defaults.d.ts +79 -79
  52. package/dist/src/deferred.d.ts +28 -28
  53. package/dist/src/emulator.d.ts +47 -47
  54. package/dist/src/environment.d.ts +90 -90
  55. package/dist/src/errors.d.ts +87 -87
  56. package/dist/src/exponential_backoff.d.ts +37 -37
  57. package/dist/src/formatters.d.ts +20 -20
  58. package/dist/src/global.d.ts +22 -22
  59. package/dist/src/json.d.ts +29 -29
  60. package/dist/src/jwt.d.ts +73 -73
  61. package/dist/src/obj.d.ts +30 -30
  62. package/dist/src/promise.d.ts +21 -21
  63. package/dist/src/query.d.ts +33 -33
  64. package/dist/src/sha1.d.ts +84 -84
  65. package/dist/src/subscribe.d.ts +49 -49
  66. package/dist/src/utf8.d.ts +27 -27
  67. package/dist/src/uuid.d.ts +22 -22
  68. package/dist/src/validation.d.ts +43 -43
  69. package/dist/test/base64.test.d.ts +1 -1
  70. package/dist/test/compat.test.d.ts +17 -17
  71. package/dist/test/deepCopy.test.d.ts +1 -1
  72. package/dist/test/defaults.test.d.ts +1 -1
  73. package/dist/test/emulator.test.d.ts +1 -1
  74. package/dist/test/environments.test.d.ts +17 -17
  75. package/dist/test/errors.test.d.ts +1 -1
  76. package/dist/test/exponential_backoff.test.d.ts +17 -17
  77. package/dist/test/object.test.d.ts +17 -17
  78. package/dist/test/subscribe.test.d.ts +17 -17
  79. package/package.json +2 -2
package/dist/src/jwt.d.ts CHANGED
@@ -1,73 +1,73 @@
1
- /**
2
- * @license
3
- * Copyright 2017 Google LLC
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
- interface Claims {
18
- [key: string]: {};
19
- }
20
- interface DecodedToken {
21
- header: object;
22
- claims: Claims;
23
- data: object;
24
- signature: string;
25
- }
26
- /**
27
- * Decodes a Firebase auth. token into constituent parts.
28
- *
29
- * Notes:
30
- * - May return with invalid / incomplete claims if there's no native base64 decoding support.
31
- * - Doesn't check if the token is actually valid.
32
- */
33
- export declare const decode: (token: string) => DecodedToken;
34
- interface DecodedToken {
35
- header: object;
36
- claims: Claims;
37
- data: object;
38
- signature: string;
39
- }
40
- /**
41
- * Decodes a Firebase auth. token and checks the validity of its time-based claims. Will return true if the
42
- * token is within the time window authorized by the 'nbf' (not-before) and 'iat' (issued-at) claims.
43
- *
44
- * Notes:
45
- * - May return a false negative if there's no native base64 decoding support.
46
- * - Doesn't check if the token is actually valid.
47
- */
48
- export declare const isValidTimestamp: (token: string) => boolean;
49
- /**
50
- * Decodes a Firebase auth. token and returns its issued at time if valid, null otherwise.
51
- *
52
- * Notes:
53
- * - May return null if there's no native base64 decoding support.
54
- * - Doesn't check if the token is actually valid.
55
- */
56
- export declare const issuedAtTime: (token: string) => number | null;
57
- /**
58
- * Decodes a Firebase auth. token and checks the validity of its format. Expects a valid issued-at time.
59
- *
60
- * Notes:
61
- * - May return a false negative if there's no native base64 decoding support.
62
- * - Doesn't check if the token is actually valid.
63
- */
64
- export declare const isValidFormat: (token: string) => boolean;
65
- /**
66
- * Attempts to peer into an auth token and determine if it's an admin auth token by looking at the claims portion.
67
- *
68
- * Notes:
69
- * - May return a false negative if there's no native base64 decoding support.
70
- * - Doesn't check if the token is actually valid.
71
- */
72
- export declare const isAdmin: (token: string) => boolean;
73
- export {};
1
+ /**
2
+ * @license
3
+ * Copyright 2017 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ interface Claims {
18
+ [key: string]: {};
19
+ }
20
+ interface DecodedToken {
21
+ header: object;
22
+ claims: Claims;
23
+ data: object;
24
+ signature: string;
25
+ }
26
+ /**
27
+ * Decodes a Firebase auth. token into constituent parts.
28
+ *
29
+ * Notes:
30
+ * - May return with invalid / incomplete claims if there's no native base64 decoding support.
31
+ * - Doesn't check if the token is actually valid.
32
+ */
33
+ export declare const decode: (token: string) => DecodedToken;
34
+ interface DecodedToken {
35
+ header: object;
36
+ claims: Claims;
37
+ data: object;
38
+ signature: string;
39
+ }
40
+ /**
41
+ * Decodes a Firebase auth. token and checks the validity of its time-based claims. Will return true if the
42
+ * token is within the time window authorized by the 'nbf' (not-before) and 'iat' (issued-at) claims.
43
+ *
44
+ * Notes:
45
+ * - May return a false negative if there's no native base64 decoding support.
46
+ * - Doesn't check if the token is actually valid.
47
+ */
48
+ export declare const isValidTimestamp: (token: string) => boolean;
49
+ /**
50
+ * Decodes a Firebase auth. token and returns its issued at time if valid, null otherwise.
51
+ *
52
+ * Notes:
53
+ * - May return null if there's no native base64 decoding support.
54
+ * - Doesn't check if the token is actually valid.
55
+ */
56
+ export declare const issuedAtTime: (token: string) => number | null;
57
+ /**
58
+ * Decodes a Firebase auth. token and checks the validity of its format. Expects a valid issued-at time.
59
+ *
60
+ * Notes:
61
+ * - May return a false negative if there's no native base64 decoding support.
62
+ * - Doesn't check if the token is actually valid.
63
+ */
64
+ export declare const isValidFormat: (token: string) => boolean;
65
+ /**
66
+ * Attempts to peer into an auth token and determine if it's an admin auth token by looking at the claims portion.
67
+ *
68
+ * Notes:
69
+ * - May return a false negative if there's no native base64 decoding support.
70
+ * - Doesn't check if the token is actually valid.
71
+ */
72
+ export declare const isAdmin: (token: string) => boolean;
73
+ export {};
package/dist/src/obj.d.ts CHANGED
@@ -1,30 +1,30 @@
1
- /**
2
- * @license
3
- * Copyright 2017 Google LLC
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
- export declare function contains<T extends object>(obj: T, key: string): boolean;
18
- export declare function safeGet<T extends object, K extends keyof T>(obj: T, key: K): T[K] | undefined;
19
- export declare function isEmpty(obj: object): obj is {};
20
- export declare function map<K extends string, V, U>(obj: {
21
- [key in K]: V;
22
- }, fn: (value: V, key: K, obj: {
23
- [key in K]: V;
24
- }) => U, contextObj?: unknown): {
25
- [key in K]: U;
26
- };
27
- /**
28
- * Deep equal two objects. Support Arrays and Objects.
29
- */
30
- export declare function deepEqual(a: object, b: object): boolean;
1
+ /**
2
+ * @license
3
+ * Copyright 2017 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ export declare function contains<T extends object>(obj: T, key: string): boolean;
18
+ export declare function safeGet<T extends object, K extends keyof T>(obj: T, key: K): T[K] | undefined;
19
+ export declare function isEmpty(obj: object): obj is {};
20
+ export declare function map<K extends string, V, U>(obj: {
21
+ [key in K]: V;
22
+ }, fn: (value: V, key: K, obj: {
23
+ [key in K]: V;
24
+ }) => U, contextObj?: unknown): {
25
+ [key in K]: U;
26
+ };
27
+ /**
28
+ * Deep equal two objects. Support Arrays and Objects.
29
+ */
30
+ export declare function deepEqual(a: object, b: object): boolean;
@@ -1,21 +1,21 @@
1
- /**
2
- * @license
3
- * Copyright 2022 Google LLC
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
- /**
18
- * Rejects if the given promise doesn't resolve in timeInMS milliseconds.
19
- * @internal
20
- */
21
- export declare function promiseWithTimeout<T>(promise: Promise<T>, timeInMS?: number): Promise<T>;
1
+ /**
2
+ * @license
3
+ * Copyright 2022 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ /**
18
+ * Rejects if the given promise doesn't resolve in timeInMS milliseconds.
19
+ * @internal
20
+ */
21
+ export declare function promiseWithTimeout<T>(promise: Promise<T>, timeInMS?: number): Promise<T>;
@@ -1,33 +1,33 @@
1
- /**
2
- * @license
3
- * Copyright 2017 Google LLC
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
- /**
18
- * Returns a querystring-formatted string (e.g. &arg=val&arg2=val2) from a
19
- * params object (e.g. {arg: 'val', arg2: 'val2'})
20
- * Note: You must prepend it with ? when adding it to a URL.
21
- */
22
- export declare function querystring(querystringParams: {
23
- [key: string]: string | number;
24
- }): string;
25
- /**
26
- * Decodes a querystring (e.g. ?arg=val&arg2=val2) into a params object
27
- * (e.g. {arg: 'val', arg2: 'val2'})
28
- */
29
- export declare function querystringDecode(querystring: string): Record<string, string>;
30
- /**
31
- * Extract the query string part of a URL, including the leading question mark (if present).
32
- */
33
- export declare function extractQuerystring(url: string): string;
1
+ /**
2
+ * @license
3
+ * Copyright 2017 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ /**
18
+ * Returns a querystring-formatted string (e.g. &arg=val&arg2=val2) from a
19
+ * params object (e.g. {arg: 'val', arg2: 'val2'})
20
+ * Note: You must prepend it with ? when adding it to a URL.
21
+ */
22
+ export declare function querystring(querystringParams: {
23
+ [key: string]: string | number;
24
+ }): string;
25
+ /**
26
+ * Decodes a querystring (e.g. ?arg=val&arg2=val2) into a params object
27
+ * (e.g. {arg: 'val', arg2: 'val2'})
28
+ */
29
+ export declare function querystringDecode(querystring: string): Record<string, string>;
30
+ /**
31
+ * Extract the query string part of a URL, including the leading question mark (if present).
32
+ */
33
+ export declare function extractQuerystring(url: string): string;
@@ -1,84 +1,84 @@
1
- /**
2
- * @license
3
- * Copyright 2017 Google LLC
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
- /**
18
- * @fileoverview SHA-1 cryptographic hash.
19
- * Variable names follow the notation in FIPS PUB 180-3:
20
- * http://csrc.nist.gov/publications/fips/fips180-3/fips180-3_final.pdf.
21
- *
22
- * Usage:
23
- * var sha1 = new sha1();
24
- * sha1.update(bytes);
25
- * var hash = sha1.digest();
26
- *
27
- * Performance:
28
- * Chrome 23: ~400 Mbit/s
29
- * Firefox 16: ~250 Mbit/s
30
- *
31
- */
32
- /**
33
- * SHA-1 cryptographic hash constructor.
34
- *
35
- * The properties declared here are discussed in the above algorithm document.
36
- * @constructor
37
- * @final
38
- * @struct
39
- */
40
- export declare class Sha1 {
41
- /**
42
- * Holds the previous values of accumulated variables a-e in the compress_
43
- * function.
44
- * @private
45
- */
46
- private chain_;
47
- /**
48
- * A buffer holding the partially computed hash result.
49
- * @private
50
- */
51
- private buf_;
52
- /**
53
- * An array of 80 bytes, each a part of the message to be hashed. Referred to
54
- * as the message schedule in the docs.
55
- * @private
56
- */
57
- private W_;
58
- /**
59
- * Contains data needed to pad messages less than 64 bytes.
60
- * @private
61
- */
62
- private pad_;
63
- /**
64
- * @private {number}
65
- */
66
- private inbuf_;
67
- /**
68
- * @private {number}
69
- */
70
- private total_;
71
- blockSize: number;
72
- constructor();
73
- reset(): void;
74
- /**
75
- * Internal compress helper function.
76
- * @param buf Block to compress.
77
- * @param offset Offset of the block in the buffer.
78
- * @private
79
- */
80
- compress_(buf: number[] | Uint8Array | string, offset?: number): void;
81
- update(bytes?: number[] | Uint8Array | string, length?: number): void;
82
- /** @override */
83
- digest(): number[];
84
- }
1
+ /**
2
+ * @license
3
+ * Copyright 2017 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ /**
18
+ * @fileoverview SHA-1 cryptographic hash.
19
+ * Variable names follow the notation in FIPS PUB 180-3:
20
+ * http://csrc.nist.gov/publications/fips/fips180-3/fips180-3_final.pdf.
21
+ *
22
+ * Usage:
23
+ * var sha1 = new sha1();
24
+ * sha1.update(bytes);
25
+ * var hash = sha1.digest();
26
+ *
27
+ * Performance:
28
+ * Chrome 23: ~400 Mbit/s
29
+ * Firefox 16: ~250 Mbit/s
30
+ *
31
+ */
32
+ /**
33
+ * SHA-1 cryptographic hash constructor.
34
+ *
35
+ * The properties declared here are discussed in the above algorithm document.
36
+ * @constructor
37
+ * @final
38
+ * @struct
39
+ */
40
+ export declare class Sha1 {
41
+ /**
42
+ * Holds the previous values of accumulated variables a-e in the compress_
43
+ * function.
44
+ * @private
45
+ */
46
+ private chain_;
47
+ /**
48
+ * A buffer holding the partially computed hash result.
49
+ * @private
50
+ */
51
+ private buf_;
52
+ /**
53
+ * An array of 80 bytes, each a part of the message to be hashed. Referred to
54
+ * as the message schedule in the docs.
55
+ * @private
56
+ */
57
+ private W_;
58
+ /**
59
+ * Contains data needed to pad messages less than 64 bytes.
60
+ * @private
61
+ */
62
+ private pad_;
63
+ /**
64
+ * @private {number}
65
+ */
66
+ private inbuf_;
67
+ /**
68
+ * @private {number}
69
+ */
70
+ private total_;
71
+ blockSize: number;
72
+ constructor();
73
+ reset(): void;
74
+ /**
75
+ * Internal compress helper function.
76
+ * @param buf Block to compress.
77
+ * @param offset Offset of the block in the buffer.
78
+ * @private
79
+ */
80
+ compress_(buf: number[] | Uint8Array | string, offset?: number): void;
81
+ update(bytes?: number[] | Uint8Array | string, length?: number): void;
82
+ /** @override */
83
+ digest(): number[];
84
+ }
@@ -1,49 +1,49 @@
1
- /**
2
- * @license
3
- * Copyright 2017 Google LLC
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
- export declare type NextFn<T> = (value: T) => void;
18
- export declare type ErrorFn = (error: Error) => void;
19
- export declare type CompleteFn = () => void;
20
- export interface Observer<T> {
21
- next: NextFn<T>;
22
- error: ErrorFn;
23
- complete: CompleteFn;
24
- }
25
- export declare type PartialObserver<T> = Partial<Observer<T>>;
26
- export declare type Unsubscribe = () => void;
27
- /**
28
- * The Subscribe interface has two forms - passing the inline function
29
- * callbacks, or a object interface with callback properties.
30
- */
31
- export interface Subscribe<T> {
32
- (next?: NextFn<T>, error?: ErrorFn, complete?: CompleteFn): Unsubscribe;
33
- (observer: PartialObserver<T>): Unsubscribe;
34
- }
35
- export interface Observable<T> {
36
- subscribe: Subscribe<T>;
37
- }
38
- export declare type Executor<T> = (observer: Observer<T>) => void;
39
- /**
40
- * Helper to make a Subscribe function (just like Promise helps make a
41
- * Thenable).
42
- *
43
- * @param executor Function which can make calls to a single Observer
44
- * as a proxy.
45
- * @param onNoObservers Callback when count of Observers goes to zero.
46
- */
47
- export declare function createSubscribe<T>(executor: Executor<T>, onNoObservers?: Executor<T>): Subscribe<T>;
48
- /** Turn synchronous function into one called asynchronously. */
49
- export declare function async(fn: Function, onError?: ErrorFn): Function;
1
+ /**
2
+ * @license
3
+ * Copyright 2017 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ export type NextFn<T> = (value: T) => void;
18
+ export type ErrorFn = (error: Error) => void;
19
+ export type CompleteFn = () => void;
20
+ export interface Observer<T> {
21
+ next: NextFn<T>;
22
+ error: ErrorFn;
23
+ complete: CompleteFn;
24
+ }
25
+ export type PartialObserver<T> = Partial<Observer<T>>;
26
+ export type Unsubscribe = () => void;
27
+ /**
28
+ * The Subscribe interface has two forms - passing the inline function
29
+ * callbacks, or a object interface with callback properties.
30
+ */
31
+ export interface Subscribe<T> {
32
+ (next?: NextFn<T>, error?: ErrorFn, complete?: CompleteFn): Unsubscribe;
33
+ (observer: PartialObserver<T>): Unsubscribe;
34
+ }
35
+ export interface Observable<T> {
36
+ subscribe: Subscribe<T>;
37
+ }
38
+ export type Executor<T> = (observer: Observer<T>) => void;
39
+ /**
40
+ * Helper to make a Subscribe function (just like Promise helps make a
41
+ * Thenable).
42
+ *
43
+ * @param executor Function which can make calls to a single Observer
44
+ * as a proxy.
45
+ * @param onNoObservers Callback when count of Observers goes to zero.
46
+ */
47
+ export declare function createSubscribe<T>(executor: Executor<T>, onNoObservers?: Executor<T>): Subscribe<T>;
48
+ /** Turn synchronous function into one called asynchronously. */
49
+ export declare function async(fn: Function, onError?: ErrorFn): Function;
@@ -1,27 +1,27 @@
1
- /**
2
- * @license
3
- * Copyright 2017 Google LLC
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
- /**
18
- * @param {string} str
19
- * @return {Array}
20
- */
21
- export declare const stringToByteArray: (str: string) => number[];
22
- /**
23
- * Calculate length without actually converting; useful for doing cheaper validation.
24
- * @param {string} str
25
- * @return {number}
26
- */
27
- export declare const stringLength: (str: string) => number;
1
+ /**
2
+ * @license
3
+ * Copyright 2017 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ /**
18
+ * @param {string} str
19
+ * @return {Array}
20
+ */
21
+ export declare const stringToByteArray: (str: string) => number[];
22
+ /**
23
+ * Calculate length without actually converting; useful for doing cheaper validation.
24
+ * @param {string} str
25
+ * @return {number}
26
+ */
27
+ export declare const stringLength: (str: string) => number;