gingersnap 0.22.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/_virtual/_tslib.cjs +102 -0
- package/_virtual/_tslib.mjs +93 -0
- package/data/AtomicValue.d.ts +15 -0
- package/data/bus.cjs +179 -0
- package/data/bus.d.ts +72 -0
- package/data/bus.mjs +177 -0
- package/data/decoders/index.d.ts +4 -0
- package/data/decoders/json.cjs +12 -0
- package/data/decoders/json.d.ts +7 -0
- package/data/decoders/json.mjs +10 -0
- package/data/decoders/msgpack.cjs +14 -0
- package/data/decoders/msgpack.d.ts +7 -0
- package/data/decoders/msgpack.mjs +12 -0
- package/data/decoders/protobuf.d.ts +13 -0
- package/data/decoders/string.cjs +12 -0
- package/data/decoders/string.d.ts +7 -0
- package/data/decoders/string.mjs +10 -0
- package/data/decoders/type.d.ts +7 -0
- package/data/decoders.cjs +11 -0
- package/data/decoders.mjs +3 -0
- package/data/model/credentials.cjs +114 -0
- package/data/model/credentials.d.ts +61 -0
- package/data/model/credentials.mjs +109 -0
- package/data/model/extra.cjs +88 -0
- package/data/model/extra.d.ts +5 -0
- package/data/model/extra.mjs +66 -0
- package/data/model/index.d.ts +6 -0
- package/data/model/model.cjs +541 -0
- package/data/model/model.d.ts +207 -0
- package/data/model/model.mjs +518 -0
- package/data/model/plugin.cjs +96 -0
- package/data/model/plugin.d.ts +38 -0
- package/data/model/plugin.mjs +72 -0
- package/data/model/property.cjs +310 -0
- package/data/model/property.d.ts +83 -0
- package/data/model/property.mjs +278 -0
- package/data/model/types.cjs +32 -0
- package/data/model/types.d.ts +28 -0
- package/data/model/types.mjs +32 -0
- package/data/model.cjs +43 -0
- package/data/model.mjs +6 -0
- package/data/signal.cjs +47 -0
- package/data/signal.d.ts +17 -0
- package/data/signal.mjs +45 -0
- package/data/store/index.d.ts +4 -0
- package/data/store/json.cjs +58 -0
- package/data/store/json.d.ts +18 -0
- package/data/store/json.mjs +56 -0
- package/data/store/manager.cjs +206 -0
- package/data/store/manager.d.ts +44 -0
- package/data/store/manager.mjs +203 -0
- package/data/store/web.cjs +92 -0
- package/data/store/web.d.ts +25 -0
- package/data/store/web.mjs +89 -0
- package/data/value.cjs +66 -0
- package/data/value.mjs +64 -0
- package/data-structures/array/CyclicalList.cjs +57 -0
- package/data-structures/array/CyclicalList.d.ts +12 -0
- package/data-structures/array/CyclicalList.mjs +55 -0
- package/data-structures/array/Pair.cjs +30 -0
- package/data-structures/array/Pair.d.ts +17 -0
- package/data-structures/array/Pair.mjs +27 -0
- package/data-structures/array/Stack.cjs +96 -0
- package/data-structures/array/Stack.d.ts +41 -0
- package/data-structures/array/Stack.mjs +94 -0
- package/data-structures/array/Triple.cjs +34 -0
- package/data-structures/array/Triple.d.ts +19 -0
- package/data-structures/array/Triple.mjs +31 -0
- package/data-structures/array/Tuple.d.ts +8 -0
- package/data-structures/array/index.d.ts +5 -0
- package/data-structures/array.cjs +15 -0
- package/data-structures/array.mjs +4 -0
- package/data-structures/object/BufferQueue.cjs +98 -0
- package/data-structures/object/BufferQueue.d.ts +21 -0
- package/data-structures/object/BufferQueue.mjs +77 -0
- package/data-structures/object/CyclicalObject.cjs +155 -0
- package/data-structures/object/CyclicalObject.d.ts +74 -0
- package/data-structures/object/CyclicalObject.mjs +134 -0
- package/data-structures/object/Queue.cjs +178 -0
- package/data-structures/object/Queue.d.ts +31 -0
- package/data-structures/object/Queue.mjs +176 -0
- package/data-structures/object/SimpleQueue.cjs +53 -0
- package/data-structures/object/SimpleQueue.d.ts +13 -0
- package/data-structures/object/SimpleQueue.mjs +51 -0
- package/data-structures/object/TimeableObject.cjs +73 -0
- package/data-structures/object/TimeableObject.d.ts +30 -0
- package/data-structures/object/TimeableObject.mjs +71 -0
- package/data-structures/object/WaitableObject.cjs +61 -0
- package/data-structures/object/WaitableObject.d.ts +29 -0
- package/data-structures/object/WaitableObject.mjs +59 -0
- package/data-structures/object/WatchableObject.cjs +251 -0
- package/data-structures/object/WatchableObject.d.ts +88 -0
- package/data-structures/object/WatchableObject.mjs +230 -0
- package/data-structures/object/index.d.ts +7 -0
- package/data-structures/object.cjs +23 -0
- package/data-structures/object.mjs +7 -0
- package/errors/AbortError.cjs +9 -0
- package/errors/AbortError.d.ts +5 -0
- package/errors/AbortError.mjs +7 -0
- package/errors/CallExecutionError.cjs +13 -0
- package/errors/CallExecutionError.d.ts +7 -0
- package/errors/CallExecutionError.mjs +11 -0
- package/errors/FutureCancelled.cjs +11 -0
- package/errors/FutureCancelled.d.ts +6 -0
- package/errors/FutureCancelled.mjs +9 -0
- package/errors/FutureError.cjs +11 -0
- package/errors/FutureError.d.ts +6 -0
- package/errors/FutureError.mjs +9 -0
- package/errors/IllegalArgumentsError.cjs +13 -0
- package/errors/IllegalArgumentsError.d.ts +7 -0
- package/errors/IllegalArgumentsError.mjs +11 -0
- package/errors/IllegalOperationError.cjs +6 -0
- package/errors/IllegalOperationError.d.ts +2 -0
- package/errors/IllegalOperationError.mjs +4 -0
- package/errors/InvalidType.cjs +6 -0
- package/errors/InvalidType.d.ts +2 -0
- package/errors/InvalidType.mjs +4 -0
- package/errors/InvalidValue.cjs +11 -0
- package/errors/InvalidValue.d.ts +4 -0
- package/errors/InvalidValue.mjs +9 -0
- package/errors/MissingArgumentsError.cjs +13 -0
- package/errors/MissingArgumentsError.d.ts +7 -0
- package/errors/MissingArgumentsError.mjs +11 -0
- package/errors/NetworkError.cjs +13 -0
- package/errors/NetworkError.d.ts +8 -0
- package/errors/NetworkError.mjs +11 -0
- package/errors/NoSuchElement.cjs +6 -0
- package/errors/NoSuchElement.d.ts +2 -0
- package/errors/NoSuchElement.mjs +4 -0
- package/errors/NotImplemented.cjs +9 -0
- package/errors/NotImplemented.d.ts +5 -0
- package/errors/NotImplemented.mjs +7 -0
- package/errors/ParsingError.cjs +10 -0
- package/errors/ParsingError.d.ts +5 -0
- package/errors/ParsingError.mjs +8 -0
- package/errors/QueueEmptyError.cjs +6 -0
- package/errors/QueueEmptyError.d.ts +2 -0
- package/errors/QueueEmptyError.mjs +4 -0
- package/errors/QueueFullError.cjs +6 -0
- package/errors/QueueFullError.d.ts +2 -0
- package/errors/QueueFullError.mjs +4 -0
- package/errors/StackEmptyError.cjs +6 -0
- package/errors/StackEmptyError.d.ts +2 -0
- package/errors/StackEmptyError.mjs +4 -0
- package/errors/StackFullError.cjs +6 -0
- package/errors/StackFullError.d.ts +2 -0
- package/errors/StackFullError.mjs +4 -0
- package/errors/StreamEnded.cjs +6 -0
- package/errors/StreamEnded.d.ts +2 -0
- package/errors/StreamEnded.mjs +4 -0
- package/errors/TimeoutError.cjs +11 -0
- package/errors/TimeoutError.d.ts +6 -0
- package/errors/TimeoutError.mjs +9 -0
- package/errors/ValueDestroyedError.cjs +6 -0
- package/errors/ValueDestroyedError.d.ts +2 -0
- package/errors/ValueDestroyedError.mjs +4 -0
- package/errors/VerificationError.cjs +9 -0
- package/errors/VerificationError.d.ts +5 -0
- package/errors/VerificationError.mjs +7 -0
- package/errors/index.d.ts +18 -0
- package/errors.cjs +41 -0
- package/errors.mjs +18 -0
- package/files.cjs +201 -0
- package/files.d.ts +31 -0
- package/files.mjs +180 -0
- package/functools/index.d.ts +31 -0
- package/functools.cjs +371 -0
- package/functools.mjs +334 -0
- package/future/future.cjs +570 -0
- package/future/future.d.ts +208 -0
- package/future/future.mjs +548 -0
- package/future/group.cjs +180 -0
- package/future/group.d.ts +82 -0
- package/future/group.mjs +159 -0
- package/future/index.d.ts +3 -0
- package/future/result.cjs +19 -0
- package/future/result.d.ts +18 -0
- package/future/result.mjs +17 -0
- package/future.cjs +11 -0
- package/future.mjs +3 -0
- package/managers/context.d.ts +8 -0
- package/managers/index.d.ts +1 -0
- package/managers.cjs +2 -0
- package/managers.mjs +1 -0
- package/mocks.cjs +301 -0
- package/mocks.d.ts +125 -0
- package/mocks.mjs +293 -0
- package/networking/EventSourceService.cjs +104 -0
- package/networking/EventSourceService.d.ts +11 -0
- package/networking/EventSourceService.mjs +83 -0
- package/networking/NetworkService.cjs +394 -0
- package/networking/NetworkService.d.ts +97 -0
- package/networking/NetworkService.mjs +373 -0
- package/networking/SocketService.cjs +218 -0
- package/networking/SocketService.d.ts +23 -0
- package/networking/SocketService.mjs +197 -0
- package/networking/decorators/index.d.ts +4 -0
- package/networking/decorators/options.cjs +289 -0
- package/networking/decorators/options.d.ts +148 -0
- package/networking/decorators/options.mjs +242 -0
- package/networking/decorators/requests.cjs +80 -0
- package/networking/decorators/requests.d.ts +34 -0
- package/networking/decorators/requests.mjs +52 -0
- package/networking/decorators/socket.cjs +81 -0
- package/networking/decorators/socket.d.ts +13 -0
- package/networking/decorators/socket.mjs +51 -0
- package/networking/http.cjs +69 -0
- package/networking/http.d.ts +66 -0
- package/networking/http.mjs +69 -0
- package/networking/index.d.ts +39 -0
- package/networking/request.cjs +18 -0
- package/networking/request.d.ts +9 -0
- package/networking/request.mjs +16 -0
- package/networking/types.cjs +37 -0
- package/networking/types.d.ts +132 -0
- package/networking/types.mjs +35 -0
- package/networking.cjs +91 -0
- package/networking.mjs +33 -0
- package/package.json +1 -0
- package/reflection/injector.cjs +43 -0
- package/reflection/injector.d.ts +3 -0
- package/reflection/injector.mjs +40 -0
- package/socket.cjs +239 -0
- package/socket.d.ts +65 -0
- package/socket.mjs +237 -0
- package/store.cjs +12 -0
- package/store.mjs +3 -0
- package/stream/call.cjs +157 -0
- package/stream/call.d.ts +66 -0
- package/stream/call.mjs +154 -0
- package/stream/collector.cjs +217 -0
- package/stream/collector.d.ts +14 -0
- package/stream/collector.mjs +215 -0
- package/stream/index.d.ts +257 -0
- package/stream/observable.cjs +110 -0
- package/stream/observable.d.ts +65 -0
- package/stream/observable.mjs +106 -0
- package/stream/state.cjs +10 -0
- package/stream/state.d.ts +5 -0
- package/stream/state.mjs +8 -0
- package/stream.cjs +1153 -0
- package/stream.mjs +1132 -0
- package/synchronize.cjs +106 -0
- package/synchronize.d.ts +54 -0
- package/synchronize.mjs +103 -0
- package/typing/types.d.ts +24 -0
- package/typing.cjs +2 -0
- package/typing.mjs +1 -0
- package/utils/parser.cjs +37 -0
- package/utils/parser.d.ts +7 -0
- package/utils/parser.mjs +16 -0
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import { FutureResult, InferredFutureResult } from "./result";
|
|
2
|
+
import { Stream } from "../stream";
|
|
3
|
+
type Resolve<T> = (value: T | PromiseLike<T> | Future<T>) => any;
|
|
4
|
+
type Reject = (reason?: Error) => void;
|
|
5
|
+
type Executor<T> = (resolve: Resolve<T>, reject: Reject, signal: AbortSignal) => void | Promise<T | void>;
|
|
6
|
+
type FutureReturnType<T> = T extends Future<infer U> ? U : T;
|
|
7
|
+
export declare const calculatePeriodValue: (period: WaitPeriod) => number;
|
|
8
|
+
/**
|
|
9
|
+
* Duration to wait for something to occur
|
|
10
|
+
*/
|
|
11
|
+
export interface WaitPeriod {
|
|
12
|
+
minutes?: number;
|
|
13
|
+
seconds?: number;
|
|
14
|
+
milliseconds?: number;
|
|
15
|
+
hours?: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Represents an eventual result of some asynchronous operation. Futures are quite similar to Promise, and can be
|
|
19
|
+
* awaited as they are **Thenable** objects
|
|
20
|
+
*/
|
|
21
|
+
export declare class Future<T> {
|
|
22
|
+
private guid;
|
|
23
|
+
private signals;
|
|
24
|
+
private signalRegisteredCallback?;
|
|
25
|
+
private defaultSignal;
|
|
26
|
+
private fulfilled;
|
|
27
|
+
private isRunning;
|
|
28
|
+
private readonly executor;
|
|
29
|
+
private completedResult?;
|
|
30
|
+
private failureResult?;
|
|
31
|
+
private underLyingPromise?;
|
|
32
|
+
private processors;
|
|
33
|
+
private readonly finallyHandlers;
|
|
34
|
+
constructor(executor: Executor<T>, signal?: AbortSignal);
|
|
35
|
+
/**
|
|
36
|
+
* Creates a future that wraps the given future, and prevents it from being cancellable on the call to "cancel" method
|
|
37
|
+
* @param future
|
|
38
|
+
*/
|
|
39
|
+
static shield<K>(future: Future<K>): Future<K>;
|
|
40
|
+
/**
|
|
41
|
+
* Creates a future from the value provided
|
|
42
|
+
* @param value an Executor function (callback for the new Future constructor)
|
|
43
|
+
* @param signal Abort Signal to establish the future with. If not provided, the future will only have the default
|
|
44
|
+
* signals
|
|
45
|
+
*/
|
|
46
|
+
static of<K>(value: Executor<K>, signal?: AbortSignal): Future<K>;
|
|
47
|
+
/**
|
|
48
|
+
* Wraps a promise as a future
|
|
49
|
+
* @param value
|
|
50
|
+
*/
|
|
51
|
+
static wrap<K>(value: Promise<K>): Future<InferredFutureResult<K>>;
|
|
52
|
+
/**
|
|
53
|
+
* Waits for the given future to complete. If not completed within the given timeframe, the given future is cancelled
|
|
54
|
+
* @param value
|
|
55
|
+
* @param timeout wait period object or the number of milliseconds to wait
|
|
56
|
+
*/
|
|
57
|
+
static waitFor<K>(value: Future<K>, timeout: WaitPeriod | number): Future<K>;
|
|
58
|
+
/**
|
|
59
|
+
* Sleeps for the given period. If period is a number, then it's the sleep duration in seconds
|
|
60
|
+
* @param period
|
|
61
|
+
* @param signal
|
|
62
|
+
*/
|
|
63
|
+
static sleep(period: WaitPeriod | number, signal?: AbortSignal): Future<void>;
|
|
64
|
+
/**
|
|
65
|
+
* Returns a future that completes with the given value.
|
|
66
|
+
* Important Note:
|
|
67
|
+
* Passing a Future or Stream to this function will execute it once and yield the result.
|
|
68
|
+
* @param value
|
|
69
|
+
*/
|
|
70
|
+
static completed<T>(value: T): Future<T>;
|
|
71
|
+
/**
|
|
72
|
+
* Returns a future that fails with the given value
|
|
73
|
+
* @param value
|
|
74
|
+
*/
|
|
75
|
+
static exceptionally(value: Error): Future<unknown>;
|
|
76
|
+
/**
|
|
77
|
+
* Returns the first completed or failed. If this is cancelled, then all futures provided will also be cancelled
|
|
78
|
+
* @param futures list of futures
|
|
79
|
+
* @param signal optinal abort signal
|
|
80
|
+
*/
|
|
81
|
+
static firstCompleted<T extends Array<Future<any>>>(futures: T, signal?: AbortSignal): Future<FutureReturnType<T[number]>>;
|
|
82
|
+
/**
|
|
83
|
+
* Awaits all futures completion, and collects the results in an array. If this future is cancelled, then all provided
|
|
84
|
+
* futures will also be cancelled.
|
|
85
|
+
* @param futures list of futures
|
|
86
|
+
* @param signal optional abort signal
|
|
87
|
+
*/
|
|
88
|
+
static collect<T extends Future<any>>(futures: T[], signal?: AbortSignal): Future<Array<FutureReturnType<T>>>;
|
|
89
|
+
/**
|
|
90
|
+
* Awaits futures finishing all possible executions, and returns the same list of futures. Whether each future
|
|
91
|
+
* completed or failed, the future is returned in the array
|
|
92
|
+
* @param futures
|
|
93
|
+
*/
|
|
94
|
+
static collectSettled<T extends Future<any>>(futures: T[]): Future<T[]>;
|
|
95
|
+
/**
|
|
96
|
+
* Creates a future that schedules the provided functor at the given frequency intervals
|
|
97
|
+
* @param functor function to be executed at specified intervals
|
|
98
|
+
* @param frequency interval used to schedule the functor's call
|
|
99
|
+
*/
|
|
100
|
+
static periodic(functor: (signal: AbortSignal) => Promise<any> | Future<any> | any, frequency: WaitPeriod): Future<unknown>;
|
|
101
|
+
/**
|
|
102
|
+
* Unique ID of the future
|
|
103
|
+
*/
|
|
104
|
+
get id(): string;
|
|
105
|
+
/**
|
|
106
|
+
* Changes the future ID
|
|
107
|
+
* @param value
|
|
108
|
+
*/
|
|
109
|
+
set id(value: string);
|
|
110
|
+
/**
|
|
111
|
+
* Checks if the future completed. A completed future is one that ran successfully without termination.
|
|
112
|
+
*/
|
|
113
|
+
get done(): boolean;
|
|
114
|
+
/**
|
|
115
|
+
* Checks if the future failed
|
|
116
|
+
*/
|
|
117
|
+
get failed(): boolean;
|
|
118
|
+
/**
|
|
119
|
+
* Retrieves the result of the future, if there is any
|
|
120
|
+
*/
|
|
121
|
+
get result(): T;
|
|
122
|
+
/**
|
|
123
|
+
* Checks if the future is running
|
|
124
|
+
*/
|
|
125
|
+
get running(): boolean;
|
|
126
|
+
/**
|
|
127
|
+
* Retrieves the error if any occurred
|
|
128
|
+
*/
|
|
129
|
+
get error(): Error;
|
|
130
|
+
/**
|
|
131
|
+
* Convert the future to a stream
|
|
132
|
+
*/
|
|
133
|
+
get stream(): Stream<T>;
|
|
134
|
+
/**
|
|
135
|
+
* Registers additional signal to the current future
|
|
136
|
+
* @param signal
|
|
137
|
+
*/
|
|
138
|
+
registerSignal(signal: AbortSignal): Future<T>;
|
|
139
|
+
/**
|
|
140
|
+
* Removes the given signal from the future
|
|
141
|
+
* @param signal
|
|
142
|
+
*/
|
|
143
|
+
unregisterSignal(signal: AbortSignal): Future<T>;
|
|
144
|
+
/**
|
|
145
|
+
* Runs the future in the background
|
|
146
|
+
*/
|
|
147
|
+
schedule(): this;
|
|
148
|
+
/**
|
|
149
|
+
* Launches the future
|
|
150
|
+
*/
|
|
151
|
+
run(): Promise<T>;
|
|
152
|
+
/**
|
|
153
|
+
* Cancels the future if it is currently running
|
|
154
|
+
*/
|
|
155
|
+
cancel(): void;
|
|
156
|
+
/**
|
|
157
|
+
* Used to chain additional steps to be executed. This creates a new future
|
|
158
|
+
* @param callback
|
|
159
|
+
* @param clone whether the future should be cloned or not.Defaults to true
|
|
160
|
+
*/
|
|
161
|
+
thenApply<K>(callback: (value: FutureResult<T>) => K, clone?: boolean): Future<InferredFutureResult<K>>;
|
|
162
|
+
/**
|
|
163
|
+
* Used to run callback irrespective of the future completing or failing
|
|
164
|
+
* @param callback
|
|
165
|
+
* @param clone whether the future should be cloned or not.Defaults to true
|
|
166
|
+
*/
|
|
167
|
+
finally(callback: (value: Future<T>) => void, clone?: boolean): Future<T>;
|
|
168
|
+
/**
|
|
169
|
+
* Handles any error that occurs in the previous steps inside the future
|
|
170
|
+
* @param callback
|
|
171
|
+
* @param clone whether the future should be cloned or not.Defaults to true
|
|
172
|
+
*/
|
|
173
|
+
catch<K>(callback: (reason: Error) => K, clone?: boolean): Future<InferredFutureResult<T | K>>;
|
|
174
|
+
/**
|
|
175
|
+
* Clones the current future
|
|
176
|
+
*/
|
|
177
|
+
clone(): Future<T>;
|
|
178
|
+
/**
|
|
179
|
+
* Internal. Only to be called by the internal JS runtime during await
|
|
180
|
+
* @private
|
|
181
|
+
*/
|
|
182
|
+
then(onFulfilled: (v: T) => void, onRejected: (reason: unknown) => void): Promise<T>;
|
|
183
|
+
/**
|
|
184
|
+
* Executes the future. Should only be triggered by the JS runtime via then(), or the user via run()
|
|
185
|
+
* @param onFulfilled
|
|
186
|
+
* @param onRejected
|
|
187
|
+
* @private
|
|
188
|
+
*/
|
|
189
|
+
private __run__;
|
|
190
|
+
/**
|
|
191
|
+
* Fires the abort signal
|
|
192
|
+
* @param signal
|
|
193
|
+
* @private
|
|
194
|
+
*/
|
|
195
|
+
private cancelWithSignal;
|
|
196
|
+
/**
|
|
197
|
+
* Checks if any handler exist to process errors
|
|
198
|
+
* @private
|
|
199
|
+
*/
|
|
200
|
+
private findFailureHandler;
|
|
201
|
+
/**
|
|
202
|
+
* Nested processing of a future result
|
|
203
|
+
* @param result
|
|
204
|
+
* @private
|
|
205
|
+
*/
|
|
206
|
+
private postResultProcessing;
|
|
207
|
+
}
|
|
208
|
+
export {};
|