@difizen/libro-common 0.0.2-alpha.0 → 0.1.0

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.
package/es/iter.d.ts DELETED
@@ -1,147 +0,0 @@
1
- /**
2
- * An object which can produce an iterator over its values.
3
- */
4
- export interface IIterable<T> {
5
- /**
6
- * Get an iterator over the object's values.
7
- *
8
- * @returns An iterator which yields the object's values.
9
- *
10
- * #### Notes
11
- * Depending on the iterable, the returned iterator may or may not be
12
- * a new object. A collection or other container-like object should
13
- * typically return a new iterator, while an iterator itself should
14
- * normally return `this`.
15
- */
16
- iter: () => IIterator<T>;
17
- }
18
- /**
19
- * An object which traverses a collection of values.
20
- *
21
- * #### Notes
22
- * An `IIterator` is itself an `IIterable`. Most implementations of
23
- * `IIterator` should simply return `this` from the `iter()` method.
24
- */
25
- export interface IIterator<T> extends IIterable<T> {
26
- /**
27
- * Create an independent clone of the iterator.
28
- *
29
- * @returns A new independent clone of the iterator.
30
- *
31
- * #### Notes
32
- * The cloned iterator can be consumed independently of the current
33
- * iterator. In essence, it is a copy of the iterator value stream
34
- * which starts at the current location.
35
- *
36
- * This can be useful for lookahead and stream duplication.
37
- */
38
- clone: () => IIterator<T>;
39
- /**
40
- * Get the next value from the iterator.
41
- *
42
- * @returns The next value from the iterator, or `undefined`.
43
- *
44
- * #### Notes
45
- * The `undefined` value is used to signal the end of iteration and
46
- * should therefore not be used as a value in a collection.
47
- *
48
- * The use of the `undefined` sentinel is an explicit design choice
49
- * which favors performance over purity. The ES6 iterator design of
50
- * returning a `{ value, done }` pair is suboptimal, as it requires
51
- * an object allocation on each iteration; and an `isDone()` method
52
- * would increase implementation and runtime complexity.
53
- */
54
- next: () => T | undefined;
55
- }
56
- /**
57
- * A type alias for an iterable or builtin array-like object.
58
- */
59
- export type IterableOrArrayLike<T> = IIterable<T> | ArrayLike<T>;
60
- /**
61
- * An iterator for an array-like object.
62
- *
63
- * #### Notes
64
- * This iterator can be used for any builtin JS array-like object.
65
- */
66
- export declare class ArrayIterator<T> implements IIterator<T> {
67
- /**
68
- * Construct a new array iterator.
69
- *
70
- * @param source - The array-like object of interest.
71
- */
72
- constructor(source: ArrayLike<T>);
73
- /**
74
- * Get an iterator over the object's values.
75
- *
76
- * @returns An iterator which yields the object's values.
77
- */
78
- iter(): IIterator<T>;
79
- /**
80
- * Create an independent clone of the iterator.
81
- *
82
- * @returns A new independent clone of the iterator.
83
- */
84
- clone(): IIterator<T>;
85
- /**
86
- * Get the next value from the iterator.
87
- *
88
- * @returns The next value from the iterator, or `undefined`.
89
- */
90
- next(): T | undefined;
91
- private _index;
92
- private _source;
93
- }
94
- /**
95
- * Create an iterator for an iterable object.
96
- *
97
- * @param object - The iterable or array-like object of interest.
98
- *
99
- * @returns A new iterator for the given object.
100
- *
101
- * #### Notes
102
- * This function allows iteration algorithms to operate on user-defined
103
- * iterable types and builtin array-like objects in a uniform fashion.
104
- */
105
- export declare function iter<T>(object: IterableOrArrayLike<T>): IIterator<T>;
106
- /**
107
- * Invoke a function for each value in an iterable.
108
- *
109
- * @param object - The iterable or array-like object of interest.
110
- *
111
- * @param fn - The callback function to invoke for each value.
112
- *
113
- * #### Notes
114
- * Iteration can be terminated early by returning `false` from the
115
- * callback function.
116
- *
117
- * #### Complexity
118
- * Linear.
119
- *
120
- * #### Example
121
- * ```typescript
122
- *
123
- * let data = [5, 7, 0, -2, 9];
124
- *
125
- * each(data, value => { console.log(value); });
126
- * ```
127
- */
128
- export declare function each<T>(object: IterableOrArrayLike<T>, fn: (value: T, index: number) => boolean | void): void;
129
- /**
130
- * Create an array from an iterable of values.
131
- *
132
- * @param object - The iterable or array-like object of interest.
133
- *
134
- * @returns A new array of values from the given object.
135
- *
136
- * #### Example
137
- * ```typescript
138
- *
139
- * let data = [1, 2, 3, 4, 5, 6];
140
- *
141
- * let stream = iter(data);
142
- *
143
- * toArray(stream); // [1, 2, 3, 4, 5, 6];
144
- * ```
145
- */
146
- export declare function toArray<T>(object: IterableOrArrayLike<T>): T[];
147
- //# sourceMappingURL=iter.d.ts.map
package/es/iter.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"iter.d.ts","sourceRoot":"","sources":["../src/iter.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,SAAS,CAAC,CAAC;IAC1B;;;;;;;;;;OAUG;IACH,IAAI,EAAE,MAAM,SAAS,CAAC,CAAC,CAAC,CAAC;CAC1B;AAED;;;;;;GAMG;AACH,MAAM,WAAW,SAAS,CAAC,CAAC,CAAE,SAAQ,SAAS,CAAC,CAAC,CAAC;IAChD;;;;;;;;;;;OAWG;IACH,KAAK,EAAE,MAAM,SAAS,CAAC,CAAC,CAAC,CAAC;IAE1B;;;;;;;;;;;;;;OAcG;IACH,IAAI,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,MAAM,mBAAmB,CAAC,CAAC,IAAI,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;AAEjE;;;;;GAKG;AACH,qBAAa,aAAa,CAAC,CAAC,CAAE,YAAW,SAAS,CAAC,CAAC,CAAC;IACnD;;;;OAIG;gBACS,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;IAIhC;;;;OAIG;IACH,IAAI,IAAI,SAAS,CAAC,CAAC,CAAC;IAIpB;;;;OAIG;IACH,KAAK,IAAI,SAAS,CAAC,CAAC,CAAC;IAMrB;;;;OAIG;IACH,IAAI,IAAI,CAAC,GAAG,SAAS;IAOrB,OAAO,CAAC,MAAM,CAAK;IACnB,OAAO,CAAC,OAAO,CAAe;CAC/B;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,mBAAmB,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAQpE;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,IAAI,CAAC,CAAC,EACpB,MAAM,EAAE,mBAAmB,CAAC,CAAC,CAAC,EAC9B,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,GAAG,IAAI,GAC9C,IAAI,CASN;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,mBAAmB,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAS9D"}
package/es/json.d.ts DELETED
@@ -1,126 +0,0 @@
1
- /**
2
- * A type alias for a JSON primitive.
3
- */
4
- export type JSONPrimitive = boolean | number | string | null;
5
- /**
6
- * A type alias for a JSON value.
7
- */
8
- export type JSONValue = JSONPrimitive | {
9
- [key: string]: JSONValue;
10
- } | JSONValue[];
11
- /**
12
- * A type definition for a JSON object.
13
- */
14
- export type JSONObject = Record<string, JSONValue>;
15
- /**
16
- * A type definition for a JSON array.
17
- */
18
- export type JSONArray = JSONValue[];
19
- /**
20
- * A type definition for a readonly JSON object.
21
- */
22
- export type ReadonlyJSONObject = Readonly<Record<string, ReadonlyJSONValue>>;
23
- /**
24
- * A type definition for a readonly JSON array.
25
- */
26
- export type ReadonlyJSONArray = readonly ReadonlyJSONValue[];
27
- /**
28
- * A type alias for a readonly JSON value.
29
- */
30
- export type ReadonlyJSONValue = JSONPrimitive | Readonly<{
31
- [key: string]: ReadonlyJSONValue;
32
- }> | readonly ReadonlyJSONValue[];
33
- /**
34
- * A type alias for a partial JSON value.
35
- *
36
- * Note: Partial here means that JSON object attributes can be `undefined`.
37
- */
38
- export type PartialJSONValue = JSONPrimitive | Partial<{
39
- [key: string]: PartialJSONValue;
40
- }> | PartialJSONValue[];
41
- /**
42
- * A type definition for a partial JSON array.
43
- *
44
- * Note: Partial here means that JSON object attributes can be `undefined`.
45
- */
46
- export type PartialJSONArray = PartialJSONValue[];
47
- /**
48
- * A type definition for a partial JSON object.
49
- *
50
- * Note: Partial here means that the JSON object attributes can be `undefined`.
51
- */
52
- export type PartialJSONObject = Record<string, PartialJSONValue | undefined>;
53
- /**
54
- * A type definition for a readonly partial JSON object.
55
- *
56
- * Note: Partial here means that JSON object attributes can be `undefined`.
57
- */
58
- export type ReadonlyPartialJSONObject = Readonly<Record<string, ReadonlyPartialJSONValue | undefined>>;
59
- /**
60
- * A type definition for a readonly partial JSON array.
61
- *
62
- * Note: Partial here means that JSON object attributes can be `undefined`.
63
- */
64
- export type ReadonlyPartialJSONArray = readonly ReadonlyPartialJSONValue[];
65
- /**
66
- * A type alias for a readonly partial JSON value.
67
- *
68
- * Note: Partial here means that JSON object attributes can be `undefined`.
69
- */
70
- export type ReadonlyPartialJSONValue = JSONPrimitive | {
71
- readonly [key: string]: ReadonlyPartialJSONValue | undefined;
72
- } | readonly ReadonlyPartialJSONValue[];
73
- /**
74
- * A shared frozen empty JSONObject
75
- */
76
- export declare const emptyObject: Readonly<Record<string, ReadonlyJSONValue>>;
77
- /**
78
- * A shared frozen empty JSONArray
79
- */
80
- export declare const emptyArray: ReadonlyJSONArray;
81
- /**
82
- * Test whether a JSON value is a primitive.
83
- *
84
- * @param value - The JSON value of interest.
85
- *
86
- * @returns `true` if the value is a primitive,`false` otherwise.
87
- */
88
- export declare function isPrimitive(value: ReadonlyPartialJSONValue): value is JSONPrimitive;
89
- /**
90
- * Test whether a JSON value is an array.
91
- *
92
- * @param value - The JSON value of interest.
93
- *
94
- * @returns `true` if the value is a an array, `false` otherwise.
95
- */
96
- export declare function isArray(value: JSONValue): value is JSONArray;
97
- export declare function isArray(value: PartialJSONValue): value is PartialJSONArray;
98
- export declare function isArray(value: ReadonlyPartialJSONValue): value is ReadonlyPartialJSONArray;
99
- /**
100
- * Test whether a JSON value is an object.
101
- *
102
- * @param value - The JSON value of interest.
103
- *
104
- * @returns `true` if the value is a an object, `false` otherwise.
105
- */
106
- export declare function isObject(value: JSONValue): value is JSONObject;
107
- export declare function isObject(value: PartialJSONValue): value is PartialJSONObject;
108
- /**
109
- * Compare two JSON values for deep equality.
110
- *
111
- * @param first - The first JSON value of interest.
112
- *
113
- * @param second - The second JSON value of interest.
114
- *
115
- * @returns `true` if the values are equivalent, `false` otherwise.
116
- */
117
- export declare function deepEqual(first: ReadonlyPartialJSONValue, second: ReadonlyPartialJSONValue): boolean;
118
- /**
119
- * Create a deep copy of a JSON value.
120
- *
121
- * @param value - The JSON value to copy.
122
- *
123
- * @returns A deep copy of the given JSON value.
124
- */
125
- export declare function deepCopy<T extends ReadonlyPartialJSONValue>(value: T): T;
126
- //# sourceMappingURL=json.d.ts.map
package/es/json.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../src/json.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;AAE7D;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,aAAa,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,GAAG,SAAS,EAAE,CAAC;AAEnF;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;AAEnD;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,SAAS,EAAE,CAAC;AAEpC;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC,CAAC;AAE7E;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,SAAS,iBAAiB,EAAE,CAAC;AAE7D;;GAEG;AACH,MAAM,MAAM,iBAAiB,GACzB,aAAa,GACb,QAAQ,CAAC;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,iBAAiB,CAAA;CAAE,CAAC,GAC9C,SAAS,iBAAiB,EAAE,CAAC;AAEjC;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GACxB,aAAa,GACb,OAAO,CAAC;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K,IAAI,iBAAiB,CAAC;AAM9E;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CACvB,KAAK,EAAE,wBAAwB,EAC/B,MAAM,EAAE,wBAAwB,GAC/B,OAAO,CAiCT;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,wBAAwB,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAaxE"}
package/es/path.d.ts DELETED
@@ -1,97 +0,0 @@
1
- /**
2
- * The namespace for path-related functions.
3
- *
4
- * Note that Jupyter server paths do not start with a leading slash.
5
- */
6
- export declare namespace PathExt {
7
- /**
8
- * Join all arguments together and normalize the resulting path.
9
- * Arguments must be strings. In v0.8, non-string arguments were silently ignored. In v0.10 and up, an exception is thrown.
10
- *
11
- * @param paths - The string paths to join.
12
- */
13
- function join(...paths: string[]): string;
14
- /**
15
- * Return the last portion of a path. Similar to the Unix basename command.
16
- * Often used to extract the file name from a fully qualified path.
17
- *
18
- * @param path - The path to evaluate.
19
- *
20
- * @param ext - An extension to remove from the result.
21
- */
22
- function basename(path: string, ext?: string): string;
23
- /**
24
- * Get the directory name of a path, similar to the Unix dirname command.
25
- * When an empty path is given, returns the root path.
26
- *
27
- * @param path - The file path.
28
- */
29
- function dirname(path: string): string;
30
- /**
31
- * Get the extension of the path.
32
- *
33
- * @param path - The file path.
34
- *
35
- * @returns the extension of the file.
36
- *
37
- * #### Notes
38
- * The extension is the string from the last occurrence of the `.`
39
- * character to end of string in the last portion of the path, inclusive.
40
- * If there is no `.` in the last portion of the path, or if the first
41
- * character of the basename of path [[basename]] is `.`, then an
42
- * empty string is returned.
43
- */
44
- function extname(path: string): string;
45
- /**
46
- * Normalize a string path, reducing '..' and '.' parts.
47
- * When multiple slashes are found, they're replaced by a single one; when the path contains a trailing slash, it is preserved. On Windows backslashes are used.
48
- * When an empty path is given, returns the root path.
49
- *
50
- * @param path - The string path to normalize.
51
- */
52
- function normalize(path: string): string;
53
- /**
54
- * Resolve a sequence of paths or path segments into an absolute path.
55
- * The root path in the application has no leading slash, so it is removed.
56
- *
57
- * @param parts - The paths to join.
58
- *
59
- * #### Notes
60
- * The right-most parameter is considered {to}. Other parameters are considered an array of {from}.
61
- *
62
- * Starting from leftmost {from} parameter, resolves {to} to an absolute path.
63
- *
64
- * If {to} isn't already absolute, {from} arguments are prepended in right to left order, until an absolute path is found. If after using all {from} paths still no absolute path is found, the current working directory is used as well. The resulting path is normalized, and trailing slashes are removed unless the path gets resolved to the root directory.
65
- */
66
- function resolve(...parts: string[]): string;
67
- /**
68
- * Solve the relative path from {from} to {to}.
69
- *
70
- * @param from - The source path.
71
- *
72
- * @param to - The target path.
73
- *
74
- * #### Notes
75
- * If from and to each resolve to the same path (after calling
76
- * path.resolve() on each), a zero-length string is returned.
77
- * If a zero-length string is passed as from or to, `/`
78
- * will be used instead of the zero-length strings.
79
- */
80
- function relative(from: string, to: string): string;
81
- /**
82
- * Normalize a file extension to be of the type `'.foo'`.
83
- *
84
- * @param extension - the file extension.
85
- *
86
- * #### Notes
87
- * Adds a leading dot if not present and converts to lower case.
88
- */
89
- function normalizeExtension(extension: string): string;
90
- /**
91
- * Remove the leading slash from a path.
92
- *
93
- * @param path: the path from which to remove a leading slash.
94
- */
95
- function removeSlash(path: string): string;
96
- }
97
- //# sourceMappingURL=path.d.ts.map
package/es/path.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../src/path.ts"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,yBAAiB,OAAO,CAAC;IACvB;;;;;OAKG;IACH,SAAgB,IAAI,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAG/C;IAED;;;;;;;OAOG;IACH,SAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAE3D;IAED;;;;;OAKG;IACH,SAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAG5C;IAED;;;;;;;;;;;;;OAaG;IACH,SAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE5C;IAED;;;;;;OAMG;IACH,SAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAK9C;IAED;;;;;;;;;;;;OAYG;IACH,SAAgB,OAAO,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAElD;IAED;;;;;;;;;;;;OAYG;IACH,SAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAEzD;IAED;;;;;;;OAOG;IACH,SAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAK5D;IAED;;;;OAIG;IACH,SAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAKhD;CACF"}
@@ -1,3 +0,0 @@
1
- export { Poll } from './poll.js';
2
- export * from './protocol.js';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/polling/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,cAAc,eAAe,CAAC"}
@@ -1,193 +0,0 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- import type { Event } from '@difizen/mana-common';
3
- import { Emitter, Deferred } from '@difizen/mana-common';
4
- import type { IPoll } from './protocol.js';
5
- /**
6
- * A class that wraps an asynchronous function to poll at a regular interval
7
- * with exponential increases to the interval length if the poll fails.
8
- *
9
- * @typeparam T - The resolved type of the factory's promises.
10
- * Defaults to `any`.
11
- *
12
- * @typeparam U - The rejected type of the factory's promises.
13
- * Defaults to `any`.
14
- *
15
- * @typeparam V - An optional type to extend the phases supported by a poll.
16
- * Defaults to `standby`, which already exists in the `Phase` type.
17
- */
18
- export declare class Poll<T = any, U = any, V extends string = 'standby'> implements IPoll<T, U, V> {
19
- protected disposeEmitter: Emitter<void>;
20
- protected _factory: Poll.Factory<T, U, V>;
21
- protected _frequency: IPoll.Frequency;
22
- protected _standby: Poll.Standby | (() => boolean | Poll.Standby);
23
- protected _state: IPoll.State<T, U, V>;
24
- protected _tick: Deferred<this>;
25
- protected tickedEmitter: Emitter<IPoll.State<T, U, V>>;
26
- protected _timeout?: NodeJS.Timeout | undefined;
27
- disposed: boolean;
28
- /**
29
- * Instantiate a new poll with exponential backoff in case of failure.
30
- *
31
- * @param options - The poll instantiation options.
32
- */
33
- constructor(options: Poll.IOptions<T, U, V>);
34
- /**
35
- * The name of the poll.
36
- */
37
- readonly name: string;
38
- /**
39
- * A signal emitted when the poll is disposed.
40
- */
41
- get onDispose(): Event<void>;
42
- /**
43
- * The polling frequency parameters.
44
- */
45
- get frequency(): IPoll.Frequency;
46
- set frequency(frequency: IPoll.Frequency);
47
- /**
48
- * Whether the poll is disposed.
49
- */
50
- get isDisposed(): boolean;
51
- /**
52
- * Indicates when the poll switches to standby.
53
- */
54
- get standby(): Poll.Standby | (() => boolean | Poll.Standby);
55
- set standby(standby: Poll.Standby | (() => boolean | Poll.Standby));
56
- /**
57
- * The poll state, which is the content of the current poll tick.
58
- */
59
- get state(): IPoll.State<T, U, V>;
60
- /**
61
- * A promise that resolves when the poll next ticks.
62
- */
63
- get tick(): Promise<this>;
64
- /**
65
- * A signal emitted when the poll ticks and fires off a new request.
66
- */
67
- get ticked(): Event<IPoll.State<T, U, V>>;
68
- /**
69
- * Return an async iterator that yields every tick.
70
- */
71
- [Symbol.asyncIterator](): AsyncIterableIterator<IPoll.State<T, U, V>>;
72
- /**
73
- * Dispose the poll.
74
- */
75
- dispose(): void;
76
- /**
77
- * Refreshes the poll. Schedules `refreshed` tick if necessary.
78
- *
79
- * @returns A promise that resolves after tick is scheduled and never rejects.
80
- *
81
- * #### Notes
82
- * The returned promise resolves after the tick is scheduled, but before
83
- * the polling action is run. To wait until after the poll action executes,
84
- * await the `poll.tick` promise: `await poll.refresh(); await poll.tick;`
85
- */
86
- refresh(): Promise<void>;
87
- /**
88
- * Schedule the next poll tick.
89
- *
90
- * @param next - The next poll state data to schedule. Defaults to standby.
91
- *
92
- * @param next.cancel - Cancels state transition if function returns `true`.
93
- *
94
- * @returns A promise that resolves when the next poll state is active.
95
- *
96
- * #### Notes
97
- * This method is not meant to be invoked by user code typically. It is public
98
- * to allow poll instances to be composed into classes that schedule ticks.
99
- */
100
- schedule(next?: Partial<IPoll.State<T, U, V> & {
101
- cancel: (last: IPoll.State<T, U, V>) => boolean;
102
- }>): Promise<void>;
103
- /**
104
- * Starts the poll. Schedules `started` tick if necessary.
105
- *
106
- * @returns A promise that resolves after tick is scheduled and never rejects.
107
- */
108
- start(): Promise<void>;
109
- /**
110
- * Stops the poll. Schedules `stopped` tick if necessary.
111
- *
112
- * @returns A promise that resolves after tick is scheduled and never rejects.
113
- */
114
- stop(): Promise<void>;
115
- /**
116
- * Execute a new poll factory promise or stand by if necessary.
117
- */
118
- protected _execute(): void;
119
- }
120
- /**
121
- * A namespace for `Poll` types, interfaces, and statics.
122
- */
123
- export declare namespace Poll {
124
- /**
125
- * A promise factory that returns an individual poll request.
126
- *
127
- * @typeparam T - The resolved type of the factory's promises.
128
- *
129
- * @typeparam U - The rejected type of the factory's promises.
130
- *
131
- * @typeparam V - The type to extend the phases supported by a poll.
132
- */
133
- type Factory<T, U, V extends string> = (state: IPoll.State<T, U, V>) => Promise<T>;
134
- /**
135
- * Indicates when the poll switches to standby.
136
- */
137
- type Standby = 'never' | 'when-hidden';
138
- /**
139
- * Instantiation options for polls.
140
- *
141
- * @typeparam T - The resolved type of the factory's promises.
142
- *
143
- * @typeparam U - The rejected type of the factory's promises.
144
- *
145
- * @typeparam V - The type to extend the phases supported by a poll.
146
- */
147
- interface IOptions<T, U, V extends string> {
148
- /**
149
- * Whether to begin polling automatically; defaults to `true`.
150
- */
151
- auto?: boolean;
152
- /**
153
- * A factory function that is passed a poll tick and returns a poll promise.
154
- */
155
- factory: Factory<T, U, V>;
156
- /**
157
- * The polling frequency parameters.
158
- */
159
- frequency?: Partial<IPoll.Frequency>;
160
- /**
161
- * The name of the poll.
162
- * Defaults to `'unknown'`.
163
- */
164
- name?: string;
165
- /**
166
- * Indicates when the poll switches to standby or a function that returns
167
- * a boolean or a `Poll.Standby` value to indicate whether to stand by.
168
- * Defaults to `'when-hidden'`.
169
- *
170
- * #### Notes
171
- * If a function is passed in, for any given context, it should be
172
- * idempotent and safe to call multiple times. It will be called before each
173
- * tick execution, but may be called by clients as well.
174
- */
175
- standby?: Standby | (() => boolean | Standby);
176
- }
177
- /**
178
- * An interval value (0ms) that indicates the poll should tick immediately.
179
- */
180
- const IMMEDIATE = 0;
181
- /**
182
- * Delays are 32-bit integers in many browsers so intervals need to be capped.
183
- *
184
- * #### Notes
185
- * https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout#Maximum_delay_value
186
- */
187
- const MAX_INTERVAL = 2147483647;
188
- /**
189
- * An interval value that indicates the poll should never tick.
190
- */
191
- const NEVER: number;
192
- }
193
- //# sourceMappingURL=poll.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"poll.d.ts","sourceRoot":"","sources":["../../src/polling/poll.ts"],"names":[],"mappings":";AAIA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAIzD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAE3C;;;;;;;;;;;;GAYG;AACH,qBAAa,IAAI,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,MAAM,GAAG,SAAS,CAC9D,YAAW,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IAEzB,SAAS,CAAC,cAAc,gBAAuB;IAC/C,SAAS,CAAC,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,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