websocket-ts 1.1.0 → 2.1.1
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/LICENSE +21 -21
- package/README.md +211 -138
- package/package.json +46 -33
- package/src/backoff/backoff.ts +26 -18
- package/src/backoff/constantbackoff.ts +38 -20
- package/src/backoff/exponentialbackoff.ts +78 -38
- package/src/backoff/linearbackoff.ts +88 -37
- package/src/index.ts +23 -9
- package/src/queue/array_queue.ts +41 -0
- package/src/queue/queue.ts +46 -0
- package/src/queue/ring_queue.ts +69 -0
- package/src/websocket.ts +487 -162
- package/src/websocket_buffer.ts +18 -0
- package/src/websocket_builder.ts +274 -0
- package/src/websocket_event.ts +88 -0
- package/src/websocket_options.ts +23 -0
- package/src/websocket_retry_options.ts +22 -0
- package/{tsconfig.json → tsconfig.cjs.json} +71 -71
- package/tsconfig.esm.json +71 -0
- package/jest.config.js +0 -8
- package/lib/backoff/backoff.d.ts +0 -18
- package/lib/backoff/backoff.d.ts.map +0 -1
- package/lib/backoff/backoff.js +0 -3
- package/lib/backoff/backoff.js.map +0 -1
- package/lib/backoff/constantbackoff.d.ts +0 -11
- package/lib/backoff/constantbackoff.d.ts.map +0 -1
- package/lib/backoff/constantbackoff.js +0 -20
- package/lib/backoff/constantbackoff.js.map +0 -1
- package/lib/backoff/exponentialbackoff.d.ts +0 -22
- package/lib/backoff/exponentialbackoff.d.ts.map +0 -1
- package/lib/backoff/exponentialbackoff.js +0 -35
- package/lib/backoff/exponentialbackoff.js.map +0 -1
- package/lib/backoff/linearbackoff.d.ts +0 -19
- package/lib/backoff/linearbackoff.d.ts.map +0 -1
- package/lib/backoff/linearbackoff.js +0 -34
- package/lib/backoff/linearbackoff.js.map +0 -1
- package/lib/buffer/buffer.d.ts +0 -41
- package/lib/buffer/buffer.d.ts.map +0 -1
- package/lib/buffer/buffer.js +0 -3
- package/lib/buffer/buffer.js.map +0 -1
- package/lib/buffer/lrubuffer.d.ts +0 -24
- package/lib/buffer/lrubuffer.d.ts.map +0 -1
- package/lib/buffer/lrubuffer.js +0 -76
- package/lib/buffer/lrubuffer.js.map +0 -1
- package/lib/buffer/timebuffer.d.ts +0 -25
- package/lib/buffer/timebuffer.d.ts.map +0 -1
- package/lib/buffer/timebuffer.js +0 -92
- package/lib/buffer/timebuffer.js.map +0 -1
- package/lib/index.d.ts +0 -10
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js +0 -22
- package/lib/index.js.map +0 -1
- package/lib/websocket.d.ts +0 -47
- package/lib/websocket.d.ts.map +0 -1
- package/lib/websocket.js +0 -120
- package/lib/websocket.js.map +0 -1
- package/lib/websocketBuilder.d.ts +0 -32
- package/lib/websocketBuilder.d.ts.map +0 -1
- package/lib/websocketBuilder.js +0 -68
- package/lib/websocketBuilder.js.map +0 -1
- package/lib/wsbuilder.d.ts +0 -29
- package/lib/wsbuilder.d.ts.map +0 -1
- package/lib/wsbuilder.js +0 -88
- package/lib/wsbuilder.js.map +0 -1
- package/src/buffer/buffer.ts +0 -45
- package/src/buffer/lrubuffer.ts +0 -80
- package/src/buffer/timebuffer.ts +0 -105
- package/src/websocketBuilder.ts +0 -98
- package/test/backoff/constantbackoff.test.ts +0 -21
- package/test/backoff/exponentialbackoff.test.ts +0 -13
- package/test/backoff/linearbackoff.test.ts +0 -32
- package/test/buffer/common.ts +0 -10
- package/test/buffer/lrubuffer.test.ts +0 -128
- package/test/buffer/timebuffer.test.ts +0 -115
- package/test/websocket.test.ts +0 -341
- package/test/websocketBuilder.test.ts +0 -36
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import { Backoff } from "./backoff/backoff";
|
|
2
|
+
import {
|
|
3
|
+
WebsocketEvent,
|
|
4
|
+
WebsocketEventListener,
|
|
5
|
+
WebsocketEventListenerOptions,
|
|
6
|
+
} from "./websocket_event";
|
|
7
|
+
import { Websocket } from "./websocket";
|
|
8
|
+
import { WebsocketBuffer } from "./websocket_buffer";
|
|
9
|
+
import { WebsocketOptions } from "./websocket_options";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Builder for websockets.
|
|
13
|
+
*/
|
|
14
|
+
export class WebsocketBuilder {
|
|
15
|
+
private readonly _url: string;
|
|
16
|
+
|
|
17
|
+
private _protocols?: string | string[];
|
|
18
|
+
private _options?: WebsocketOptions;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Creates a new WebsocketBuilder.
|
|
22
|
+
*
|
|
23
|
+
* @param url the url to connect to
|
|
24
|
+
*/
|
|
25
|
+
constructor(url: string) {
|
|
26
|
+
this._url = url;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Getter for the url.
|
|
31
|
+
*
|
|
32
|
+
* @returns the url
|
|
33
|
+
*/
|
|
34
|
+
get url(): string {
|
|
35
|
+
return this._url;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Adds protocols to the websocket. Subsequent calls to this method will override the previously set protocols.
|
|
40
|
+
*
|
|
41
|
+
* @param protocols the protocols to add
|
|
42
|
+
*/
|
|
43
|
+
public withProtocols(
|
|
44
|
+
protocols: string | string[] | undefined,
|
|
45
|
+
): WebsocketBuilder {
|
|
46
|
+
this._protocols = protocols;
|
|
47
|
+
return this;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Getter for the protocols.
|
|
52
|
+
*
|
|
53
|
+
* @returns the protocols, undefined if no protocols have been set
|
|
54
|
+
*/
|
|
55
|
+
get protocols(): string | string[] | undefined {
|
|
56
|
+
return this._protocols;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Sets the maximum number of retries before giving up. No limit if undefined.
|
|
61
|
+
*
|
|
62
|
+
* @param maxRetries the maximum number of retries before giving up
|
|
63
|
+
*/
|
|
64
|
+
public withMaxRetries(maxRetries: number | undefined): WebsocketBuilder {
|
|
65
|
+
this._options = {
|
|
66
|
+
...this._options,
|
|
67
|
+
retry: { ...this._options?.retry, maxRetries },
|
|
68
|
+
};
|
|
69
|
+
return this;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Getter for the maximum number of retries before giving up.
|
|
74
|
+
*
|
|
75
|
+
* @returns the maximum number of retries before giving up, undefined if no maximum has been set
|
|
76
|
+
*/
|
|
77
|
+
get maxRetries(): number | undefined {
|
|
78
|
+
return this._options?.retry?.maxRetries;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Sets wether to reconnect immediately after a connection has been lost, ignoring the backoff strategy for the first retry.
|
|
83
|
+
*
|
|
84
|
+
* @param instantReconnect wether to reconnect immediately after a connection has been lost
|
|
85
|
+
*/
|
|
86
|
+
public withInstantReconnect(
|
|
87
|
+
instantReconnect: boolean | undefined,
|
|
88
|
+
): WebsocketBuilder {
|
|
89
|
+
this._options = {
|
|
90
|
+
...this._options,
|
|
91
|
+
retry: { ...this._options?.retry, instantReconnect },
|
|
92
|
+
};
|
|
93
|
+
return this;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Getter for wether to reconnect immediately after a connection has been lost, ignoring the backoff strategy for the first retry.
|
|
98
|
+
*
|
|
99
|
+
* @returns wether to reconnect immediately after a connection has been lost, undefined if no value has been set
|
|
100
|
+
*/
|
|
101
|
+
get instantReconnect(): boolean | undefined {
|
|
102
|
+
return this._options?.retry?.instantReconnect;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Adds a backoff to the websocket. Subsequent calls to this method will override the previously set backoff.
|
|
107
|
+
*
|
|
108
|
+
* @param backoff the backoff to add
|
|
109
|
+
*/
|
|
110
|
+
public withBackoff(backoff: Backoff | undefined): WebsocketBuilder {
|
|
111
|
+
this._options = {
|
|
112
|
+
...this._options,
|
|
113
|
+
retry: { ...this._options?.retry, backoff },
|
|
114
|
+
};
|
|
115
|
+
return this;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Getter for the backoff.
|
|
120
|
+
*
|
|
121
|
+
* @returns the backoff, undefined if no backoff has been set
|
|
122
|
+
*/
|
|
123
|
+
get backoff(): Backoff | undefined {
|
|
124
|
+
return this._options?.retry?.backoff;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Adds a buffer to the websocket. Subsequent calls to this method will override the previously set buffer.
|
|
129
|
+
*
|
|
130
|
+
* @param buffer the buffer to add
|
|
131
|
+
*/
|
|
132
|
+
public withBuffer(buffer: WebsocketBuffer | undefined): WebsocketBuilder {
|
|
133
|
+
this._options = { ...this._options, buffer };
|
|
134
|
+
return this;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Getter for the buffer.
|
|
139
|
+
*
|
|
140
|
+
* @returns the buffer, undefined if no buffer has been set
|
|
141
|
+
*/
|
|
142
|
+
get buffer(): WebsocketBuffer | undefined {
|
|
143
|
+
return this._options?.buffer;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Adds an 'open' event listener to the websocket. Subsequent calls to this method will add additional listeners that will be
|
|
148
|
+
* called in the order they were added.
|
|
149
|
+
*
|
|
150
|
+
* @param listener the listener to add
|
|
151
|
+
* @param options the listener options
|
|
152
|
+
*/
|
|
153
|
+
public onOpen(
|
|
154
|
+
listener: WebsocketEventListener<WebsocketEvent.open>,
|
|
155
|
+
options?: WebsocketEventListenerOptions,
|
|
156
|
+
): WebsocketBuilder {
|
|
157
|
+
this.addListener(WebsocketEvent.open, listener, options);
|
|
158
|
+
return this;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Adds an 'close' event listener to the websocket. Subsequent calls to this method will add additional listeners that will be
|
|
163
|
+
* called in the order they were added.
|
|
164
|
+
*
|
|
165
|
+
* @param listener the listener to add
|
|
166
|
+
* @param options the listener options
|
|
167
|
+
*/
|
|
168
|
+
public onClose(
|
|
169
|
+
listener: WebsocketEventListener<WebsocketEvent.close>,
|
|
170
|
+
options?: WebsocketEventListenerOptions,
|
|
171
|
+
): WebsocketBuilder {
|
|
172
|
+
this.addListener(WebsocketEvent.close, listener, options);
|
|
173
|
+
return this;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Adds an 'error' event listener to the websocket. Subsequent calls to this method will add additional listeners that will be
|
|
178
|
+
* called in the order they were added.
|
|
179
|
+
*
|
|
180
|
+
* @param listener the listener to add
|
|
181
|
+
* @param options the listener options
|
|
182
|
+
*/
|
|
183
|
+
public onError(
|
|
184
|
+
listener: WebsocketEventListener<WebsocketEvent.error>,
|
|
185
|
+
options?: WebsocketEventListenerOptions,
|
|
186
|
+
): WebsocketBuilder {
|
|
187
|
+
this.addListener(WebsocketEvent.error, listener, options);
|
|
188
|
+
return this;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Adds an 'message' event listener to the websocket. Subsequent calls to this method will add additional listeners that will be
|
|
193
|
+
* called in the order they were added.
|
|
194
|
+
*
|
|
195
|
+
* @param listener the listener to add
|
|
196
|
+
* @param options the listener options
|
|
197
|
+
*/
|
|
198
|
+
public onMessage(
|
|
199
|
+
listener: WebsocketEventListener<WebsocketEvent.message>,
|
|
200
|
+
options?: WebsocketEventListenerOptions,
|
|
201
|
+
): WebsocketBuilder {
|
|
202
|
+
this.addListener(WebsocketEvent.message, listener, options);
|
|
203
|
+
return this;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Adds an 'retry' event listener to the websocket. Subsequent calls to this method will add additional listeners that will be
|
|
208
|
+
* called in the order they were added.
|
|
209
|
+
*
|
|
210
|
+
* @param listener the listener to add
|
|
211
|
+
* @param options the listener options
|
|
212
|
+
*/
|
|
213
|
+
public onRetry(
|
|
214
|
+
listener: WebsocketEventListener<WebsocketEvent.retry>,
|
|
215
|
+
options?: WebsocketEventListenerOptions,
|
|
216
|
+
): WebsocketBuilder {
|
|
217
|
+
this.addListener(WebsocketEvent.retry, listener, options);
|
|
218
|
+
return this;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Adds an 'reconnect' event listener to the websocket. Subsequent calls to this method will add additional listeners that will be
|
|
223
|
+
* called in the order they were added.
|
|
224
|
+
*
|
|
225
|
+
* @param listener the listener to add
|
|
226
|
+
* @param options the listener options
|
|
227
|
+
*/
|
|
228
|
+
public onReconnect(
|
|
229
|
+
listener: WebsocketEventListener<WebsocketEvent.reconnect>,
|
|
230
|
+
options?: WebsocketEventListenerOptions,
|
|
231
|
+
): WebsocketBuilder {
|
|
232
|
+
this.addListener(WebsocketEvent.reconnect, listener, options);
|
|
233
|
+
return this;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Builds the websocket.
|
|
238
|
+
*
|
|
239
|
+
* @return a new websocket, with the set options
|
|
240
|
+
*/
|
|
241
|
+
public build(): Websocket {
|
|
242
|
+
return new Websocket(this._url, this._protocols, this._options); // instantiate the websocket with the set options
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Adds an event listener to the options.
|
|
247
|
+
*
|
|
248
|
+
* @param event the event to add the listener to
|
|
249
|
+
* @param listener the listener to add
|
|
250
|
+
* @param options the listener options
|
|
251
|
+
*/
|
|
252
|
+
private addListener<K extends WebsocketEvent>(
|
|
253
|
+
event: WebsocketEvent,
|
|
254
|
+
listener: WebsocketEventListener<K>,
|
|
255
|
+
options?: WebsocketEventListenerOptions,
|
|
256
|
+
): WebsocketBuilder {
|
|
257
|
+
this._options = {
|
|
258
|
+
...this._options,
|
|
259
|
+
listeners: {
|
|
260
|
+
open: this._options?.listeners?.open ?? [],
|
|
261
|
+
close: this._options?.listeners?.close ?? [],
|
|
262
|
+
error: this._options?.listeners?.error ?? [],
|
|
263
|
+
message: this._options?.listeners?.message ?? [],
|
|
264
|
+
retry: this._options?.listeners?.retry ?? [],
|
|
265
|
+
reconnect: this._options?.listeners?.reconnect ?? [],
|
|
266
|
+
[event]: [
|
|
267
|
+
...(this._options?.listeners?.[event] ?? []),
|
|
268
|
+
{ listener, options },
|
|
269
|
+
],
|
|
270
|
+
},
|
|
271
|
+
};
|
|
272
|
+
return this;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { Websocket } from "./websocket";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Events that can be fired by the websocket.
|
|
5
|
+
*/
|
|
6
|
+
export enum WebsocketEvent {
|
|
7
|
+
/** Fired when the connection is opened. */
|
|
8
|
+
open = "open",
|
|
9
|
+
|
|
10
|
+
/** Fired when the connection is closed. */
|
|
11
|
+
close = "close",
|
|
12
|
+
|
|
13
|
+
/** Fired when the connection has been closed because of an error, such as when some data couldn't be sent. */
|
|
14
|
+
error = "error",
|
|
15
|
+
|
|
16
|
+
/** Fired when a message is received. */
|
|
17
|
+
message = "message",
|
|
18
|
+
|
|
19
|
+
/** Fired when the websocket tries to reconnect after a connection loss. */
|
|
20
|
+
retry = "retry",
|
|
21
|
+
|
|
22
|
+
/** Fired when the websocket successfully reconnects after a connection loss. */
|
|
23
|
+
reconnect = "reconnect",
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/***
|
|
27
|
+
* Details/properties of a retry-event.
|
|
28
|
+
*/
|
|
29
|
+
export type RetryEventDetail = {
|
|
30
|
+
/** Number of retries that have been made since the connection was lost. */
|
|
31
|
+
readonly retries: number;
|
|
32
|
+
|
|
33
|
+
/** Time (ms) waited since the last connection-retry. */
|
|
34
|
+
readonly backoff: number;
|
|
35
|
+
|
|
36
|
+
/** Timestamp of when the connection was lost or undefined if the connection has never been established. */
|
|
37
|
+
readonly lastConnection: Date | undefined;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Properties of a reconnect-event.
|
|
42
|
+
*/
|
|
43
|
+
export type ReconnectEventDetail = Omit<RetryEventDetail, "backoff">;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Maps websocket events to their corresponding event.
|
|
47
|
+
*/
|
|
48
|
+
export type WebsocketEventMap = {
|
|
49
|
+
[WebsocketEvent.open]: Event;
|
|
50
|
+
[WebsocketEvent.close]: CloseEvent;
|
|
51
|
+
[WebsocketEvent.error]: Event;
|
|
52
|
+
[WebsocketEvent.message]: MessageEvent;
|
|
53
|
+
[WebsocketEvent.retry]: CustomEvent<RetryEventDetail>;
|
|
54
|
+
[WebsocketEvent.reconnect]: CustomEvent<ReconnectEventDetail>;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Listener for websocket events.
|
|
59
|
+
* */
|
|
60
|
+
export type WebsocketEventListener<K extends WebsocketEvent> = (
|
|
61
|
+
instance: Websocket,
|
|
62
|
+
ev: WebsocketEventMap[K],
|
|
63
|
+
) => unknown;
|
|
64
|
+
|
|
65
|
+
export type WebsocketEventListenerParams<K extends WebsocketEvent> = Parameters<
|
|
66
|
+
WebsocketEventListener<K>
|
|
67
|
+
>;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Options for websocket events.
|
|
71
|
+
*/
|
|
72
|
+
export type WebsocketEventListenerOptions = EventListenerOptions &
|
|
73
|
+
AddEventListenerOptions;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Listener for websocket events with options.
|
|
77
|
+
*/
|
|
78
|
+
export type WebsocketEventListenerWithOptions<K extends WebsocketEvent> = {
|
|
79
|
+
readonly listener: WebsocketEventListener<K>;
|
|
80
|
+
readonly options?: WebsocketEventListenerOptions;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Maps websocket events to their corresponding event-listeners.
|
|
85
|
+
*/
|
|
86
|
+
export type WebsocketEventListeners = {
|
|
87
|
+
[K in WebsocketEvent]: WebsocketEventListenerWithOptions<K>[];
|
|
88
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { WebsocketBuffer } from "./websocket_buffer";
|
|
2
|
+
import { WebsocketConnectionRetryOptions } from "./websocket_retry_options";
|
|
3
|
+
import { WebsocketEventListeners } from "./websocket_event";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Options that can be passed to the Websocket constructor.
|
|
7
|
+
*/
|
|
8
|
+
export interface WebsocketOptions {
|
|
9
|
+
/**
|
|
10
|
+
* The Buffer to use.
|
|
11
|
+
*/
|
|
12
|
+
readonly buffer?: WebsocketBuffer;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The options for the connection-retry-strategy.
|
|
16
|
+
*/
|
|
17
|
+
readonly retry?: WebsocketConnectionRetryOptions;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The initial listeners to add to the websocket.
|
|
21
|
+
*/
|
|
22
|
+
readonly listeners?: WebsocketEventListeners;
|
|
23
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Backoff } from "./backoff/backoff";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Options for the websockets retry-strategy.
|
|
5
|
+
*/
|
|
6
|
+
export interface WebsocketConnectionRetryOptions {
|
|
7
|
+
/**
|
|
8
|
+
* The maximum number of retries before giving up. No limit if undefined.
|
|
9
|
+
*/
|
|
10
|
+
readonly maxRetries?: number;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Wether to reconnect immediately after a connection has been lost,
|
|
14
|
+
* ignoring the backoff strategy for the first retry.
|
|
15
|
+
*/
|
|
16
|
+
readonly instantReconnect?: boolean;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* The backoff strategy to use. This is used to determine the delay between connection-retries.
|
|
20
|
+
*/
|
|
21
|
+
readonly backoff?: Backoff;
|
|
22
|
+
}
|
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
/* Visit https://aka.ms/tsconfig.json to read more about this file */
|
|
4
|
-
|
|
5
|
-
/* Basic Options */
|
|
6
|
-
// "incremental": true, /* Enable incremental compilation */
|
|
7
|
-
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
|
|
8
|
-
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
|
|
9
|
-
// "lib": [], /* Specify library files to be included in the compilation. */
|
|
10
|
-
// "allowJs": true, /* Allow javascript files to be compiled. */
|
|
11
|
-
// "checkJs": true, /* Report errors in .js files. */
|
|
12
|
-
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
|
|
13
|
-
"declaration": true,
|
|
14
|
-
"declarationMap": true,
|
|
15
|
-
"sourceMap": true,
|
|
16
|
-
// "outFile": "./", /* Concatenate and emit output to single file. */
|
|
17
|
-
"outDir": "
|
|
18
|
-
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
|
|
19
|
-
// "composite": true, /* Enable project compilation */
|
|
20
|
-
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
|
|
21
|
-
// "removeComments": true, /* Do not emit comments to output. */
|
|
22
|
-
// "noEmit": true, /* Do not emit outputs. */
|
|
23
|
-
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
|
|
24
|
-
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
|
|
25
|
-
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
|
|
26
|
-
|
|
27
|
-
/* Strict Type-Checking Options */
|
|
28
|
-
"strict": true, /* Enable all strict type-checking options. */
|
|
29
|
-
|
|
30
|
-
// "strictNullChecks": true, /* Enable strict null checks. */
|
|
31
|
-
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
|
|
32
|
-
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
|
|
33
|
-
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
|
|
34
|
-
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
|
|
35
|
-
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
|
|
36
|
-
|
|
37
|
-
/* Additional Checks */
|
|
38
|
-
// "noUnusedLocals": true, /* Report errors on unused locals. */
|
|
39
|
-
// "noUnusedParameters": true, /* Report errors on unused parameters. */
|
|
40
|
-
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
|
|
41
|
-
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
|
|
42
|
-
|
|
43
|
-
/* Module Resolution Options */
|
|
44
|
-
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
|
|
45
|
-
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
|
|
46
|
-
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
|
|
47
|
-
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
|
|
48
|
-
// "typeRoots": [], /* List of folders to include type definitions from. */
|
|
49
|
-
// "types": [], /* Type declaration files to be included in compilation. */
|
|
50
|
-
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
|
|
51
|
-
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
|
52
|
-
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
|
|
53
|
-
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
|
54
|
-
|
|
55
|
-
/* Source Map Options */
|
|
56
|
-
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
|
|
57
|
-
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
|
58
|
-
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
|
|
59
|
-
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
|
|
60
|
-
|
|
61
|
-
/* Experimental Options */
|
|
62
|
-
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
|
|
63
|
-
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
|
|
64
|
-
|
|
65
|
-
/* Advanced Options */
|
|
66
|
-
"skipLibCheck": true,
|
|
67
|
-
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
|
|
68
|
-
},
|
|
69
|
-
"include": ["src"],
|
|
70
|
-
"exclude": ["node_modules", "
|
|
71
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
/* Visit https://aka.ms/tsconfig.json to read more about this file */
|
|
4
|
+
|
|
5
|
+
/* Basic Options */
|
|
6
|
+
// "incremental": true, /* Enable incremental compilation */
|
|
7
|
+
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
|
|
8
|
+
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
|
|
9
|
+
// "lib": [], /* Specify library files to be included in the compilation. */
|
|
10
|
+
// "allowJs": true, /* Allow javascript files to be compiled. */
|
|
11
|
+
// "checkJs": true, /* Report errors in .js files. */
|
|
12
|
+
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
|
|
13
|
+
"declaration": true, /* Generates corresponding '.d.ts' file. */
|
|
14
|
+
"declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
|
|
15
|
+
"sourceMap": true, /* Generates corresponding '.map' file. */
|
|
16
|
+
// "outFile": "./", /* Concatenate and emit output to single file. */
|
|
17
|
+
"outDir": "./dist/cjs", /* Redirect output structure to the directory. */
|
|
18
|
+
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
|
|
19
|
+
// "composite": true, /* Enable project compilation */
|
|
20
|
+
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
|
|
21
|
+
// "removeComments": true, /* Do not emit comments to output. */
|
|
22
|
+
// "noEmit": true, /* Do not emit outputs. */
|
|
23
|
+
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
|
|
24
|
+
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
|
|
25
|
+
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
|
|
26
|
+
|
|
27
|
+
/* Strict Type-Checking Options */
|
|
28
|
+
"strict": true, /* Enable all strict type-checking options. */
|
|
29
|
+
"noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
|
|
30
|
+
// "strictNullChecks": true, /* Enable strict null checks. */
|
|
31
|
+
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
|
|
32
|
+
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
|
|
33
|
+
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
|
|
34
|
+
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
|
|
35
|
+
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
|
|
36
|
+
|
|
37
|
+
/* Additional Checks */
|
|
38
|
+
// "noUnusedLocals": true, /* Report errors on unused locals. */
|
|
39
|
+
// "noUnusedParameters": true, /* Report errors on unused parameters. */
|
|
40
|
+
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
|
|
41
|
+
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
|
|
42
|
+
|
|
43
|
+
/* Module Resolution Options */
|
|
44
|
+
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
|
|
45
|
+
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
|
|
46
|
+
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
|
|
47
|
+
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
|
|
48
|
+
// "typeRoots": [], /* List of folders to include type definitions from. */
|
|
49
|
+
// "types": [], /* Type declaration files to be included in compilation. */
|
|
50
|
+
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
|
|
51
|
+
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
|
52
|
+
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
|
|
53
|
+
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
|
54
|
+
|
|
55
|
+
/* Source Map Options */
|
|
56
|
+
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
|
|
57
|
+
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
|
58
|
+
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
|
|
59
|
+
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
|
|
60
|
+
|
|
61
|
+
/* Experimental Options */
|
|
62
|
+
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
|
|
63
|
+
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
|
|
64
|
+
|
|
65
|
+
/* Advanced Options */
|
|
66
|
+
// "skipLibCheck": true, /* Skip type checking of declaration files. */
|
|
67
|
+
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
|
|
68
|
+
},
|
|
69
|
+
"include": ["src", "tests"],
|
|
70
|
+
"exclude": ["node_modules", "dist"]
|
|
71
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
/* Visit https://aka.ms/tsconfig.json to read more about this file */
|
|
4
|
+
|
|
5
|
+
/* Basic Options */
|
|
6
|
+
// "incremental": true, /* Enable incremental compilation */
|
|
7
|
+
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
|
|
8
|
+
"module": "es6", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
|
|
9
|
+
// "lib": [], /* Specify library files to be included in the compilation. */
|
|
10
|
+
// "allowJs": true, /* Allow javascript files to be compiled. */
|
|
11
|
+
// "checkJs": true, /* Report errors in .js files. */
|
|
12
|
+
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
|
|
13
|
+
"declaration": true, /* Generates corresponding '.d.ts' file. */
|
|
14
|
+
"declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
|
|
15
|
+
"sourceMap": true, /* Generates corresponding '.map' file. */
|
|
16
|
+
// "outFile": "./", /* Concatenate and emit output to single file. */
|
|
17
|
+
"outDir": "./dist/esm", /* Redirect output structure to the directory. */
|
|
18
|
+
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
|
|
19
|
+
// "composite": true, /* Enable project compilation */
|
|
20
|
+
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
|
|
21
|
+
// "removeComments": true, /* Do not emit comments to output. */
|
|
22
|
+
// "noEmit": true, /* Do not emit outputs. */
|
|
23
|
+
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
|
|
24
|
+
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
|
|
25
|
+
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
|
|
26
|
+
|
|
27
|
+
/* Strict Type-Checking Options */
|
|
28
|
+
"strict": true, /* Enable all strict type-checking options. */
|
|
29
|
+
"noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
|
|
30
|
+
// "strictNullChecks": true, /* Enable strict null checks. */
|
|
31
|
+
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
|
|
32
|
+
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
|
|
33
|
+
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
|
|
34
|
+
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
|
|
35
|
+
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
|
|
36
|
+
|
|
37
|
+
/* Additional Checks */
|
|
38
|
+
// "noUnusedLocals": true, /* Report errors on unused locals. */
|
|
39
|
+
// "noUnusedParameters": true, /* Report errors on unused parameters. */
|
|
40
|
+
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
|
|
41
|
+
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
|
|
42
|
+
|
|
43
|
+
/* Module Resolution Options */
|
|
44
|
+
"moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
|
|
45
|
+
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
|
|
46
|
+
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
|
|
47
|
+
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
|
|
48
|
+
// "typeRoots": [], /* List of folders to include type definitions from. */
|
|
49
|
+
// "types": [], /* Type declaration files to be included in compilation. */
|
|
50
|
+
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
|
|
51
|
+
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
|
52
|
+
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
|
|
53
|
+
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
|
54
|
+
|
|
55
|
+
/* Source Map Options */
|
|
56
|
+
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
|
|
57
|
+
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
|
58
|
+
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
|
|
59
|
+
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
|
|
60
|
+
|
|
61
|
+
/* Experimental Options */
|
|
62
|
+
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
|
|
63
|
+
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
|
|
64
|
+
|
|
65
|
+
/* Advanced Options */
|
|
66
|
+
// "skipLibCheck": true, /* Skip type checking of declaration files. */
|
|
67
|
+
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
|
|
68
|
+
},
|
|
69
|
+
"include": ["src", "tests"],
|
|
70
|
+
"exclude": ["node_modules", "dist"]
|
|
71
|
+
}
|
package/jest.config.js
DELETED
package/lib/backoff/backoff.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Backoff provides a series of numbers. This series follows
|
|
3
|
-
* a concrete pattern, e.g. be constant, linearly increasing,
|
|
4
|
-
* exponentially increasing etc.
|
|
5
|
-
*/
|
|
6
|
-
export interface Backoff {
|
|
7
|
-
/**
|
|
8
|
-
* Provides the callee with the next number in the
|
|
9
|
-
* series.
|
|
10
|
-
* @return the next number
|
|
11
|
-
*/
|
|
12
|
-
next(): number;
|
|
13
|
-
/**
|
|
14
|
-
* Resets the series to its starting-value.
|
|
15
|
-
*/
|
|
16
|
-
reset(): void;
|
|
17
|
-
}
|
|
18
|
-
//# sourceMappingURL=backoff.d.ts.map
|