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
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"backoff.d.ts","sourceRoot":"","sources":["../../src/backoff/backoff.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,OAAO;IACpB;;;;OAIG;IACH,IAAI,IAAI,MAAM,CAAA;IAEd;;OAEG;IACH,KAAK,IAAI,IAAI,CAAA;CAChB"}
|
package/lib/backoff/backoff.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"backoff.js","sourceRoot":"","sources":["../../src/backoff/backoff.ts"],"names":[],"mappings":""}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Backoff } from "./backoff";
|
|
2
|
-
/**
|
|
3
|
-
* ConstantBackoff always returns the same value.
|
|
4
|
-
*/
|
|
5
|
-
export declare class ConstantBackoff implements Backoff {
|
|
6
|
-
private readonly backoff;
|
|
7
|
-
constructor(backoff: number);
|
|
8
|
-
next(): number;
|
|
9
|
-
reset: () => void;
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=constantbackoff.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constantbackoff.d.ts","sourceRoot":"","sources":["../../src/backoff/constantbackoff.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAElC;;GAEG;AACH,qBAAa,eAAgB,YAAW,OAAO;IAC3C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;gBAErB,OAAO,EAAE,MAAM;IAI3B,IAAI,IAAI,MAAM;IAId,KAAK,aAEJ;CACJ"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ConstantBackoff = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* ConstantBackoff always returns the same value.
|
|
6
|
-
*/
|
|
7
|
-
var ConstantBackoff = /** @class */ (function () {
|
|
8
|
-
function ConstantBackoff(backoff) {
|
|
9
|
-
this.reset = function () {
|
|
10
|
-
// no-op
|
|
11
|
-
};
|
|
12
|
-
this.backoff = backoff;
|
|
13
|
-
}
|
|
14
|
-
ConstantBackoff.prototype.next = function () {
|
|
15
|
-
return this.backoff;
|
|
16
|
-
};
|
|
17
|
-
return ConstantBackoff;
|
|
18
|
-
}());
|
|
19
|
-
exports.ConstantBackoff = ConstantBackoff;
|
|
20
|
-
//# sourceMappingURL=constantbackoff.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constantbackoff.js","sourceRoot":"","sources":["../../src/backoff/constantbackoff.ts"],"names":[],"mappings":";;;AAEA;;GAEG;AACH;IAGI,yBAAY,OAAe;QAQ3B,UAAK,GAAG;YACJ,QAAQ;QACZ,CAAC,CAAA;QATG,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IAC3B,CAAC;IAED,8BAAI,GAAJ;QACI,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAKL,sBAAC;AAAD,CAAC,AAdD,IAcC;AAdY,0CAAe"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Backoff } from "./backoff";
|
|
2
|
-
/**
|
|
3
|
-
* ExponentialBackoff doubles the backoff with every step until a maximum
|
|
4
|
-
* is reached. This is modelled after the binary exponential-backoff algo-
|
|
5
|
-
* rithm used in computer-networking.
|
|
6
|
-
*
|
|
7
|
-
* The calculation-specification is:
|
|
8
|
-
* backoff = k * 2^s with s in [1, expMax].
|
|
9
|
-
*
|
|
10
|
-
* Example: for k=100, expMax=7 the ExponentialBackoff will pro-
|
|
11
|
-
* duce the backoff-series [100, 200, 400, 800, 1600, 3200, 6400].
|
|
12
|
-
*/
|
|
13
|
-
export declare class ExponentialBackoff implements Backoff {
|
|
14
|
-
private readonly initial;
|
|
15
|
-
private readonly expMax;
|
|
16
|
-
private expCurrent;
|
|
17
|
-
private current;
|
|
18
|
-
constructor(initial: number, expMax: number);
|
|
19
|
-
next(): number;
|
|
20
|
-
reset(): void;
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=exponentialbackoff.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exponentialbackoff.d.ts","sourceRoot":"","sources":["../../src/backoff/exponentialbackoff.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAElC;;;;;;;;;;GAUG;AACH,qBAAa,kBAAmB,YAAW,OAAO;IAC9C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,OAAO,CAAS;gBAEZ,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAO3C,IAAI,IAAI,MAAM;IAOd,KAAK;CAIR"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ExponentialBackoff = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* ExponentialBackoff doubles the backoff with every step until a maximum
|
|
6
|
-
* is reached. This is modelled after the binary exponential-backoff algo-
|
|
7
|
-
* rithm used in computer-networking.
|
|
8
|
-
*
|
|
9
|
-
* The calculation-specification is:
|
|
10
|
-
* backoff = k * 2^s with s in [1, expMax].
|
|
11
|
-
*
|
|
12
|
-
* Example: for k=100, expMax=7 the ExponentialBackoff will pro-
|
|
13
|
-
* duce the backoff-series [100, 200, 400, 800, 1600, 3200, 6400].
|
|
14
|
-
*/
|
|
15
|
-
var ExponentialBackoff = /** @class */ (function () {
|
|
16
|
-
function ExponentialBackoff(initial, expMax) {
|
|
17
|
-
this.initial = initial;
|
|
18
|
-
this.expMax = expMax;
|
|
19
|
-
this.expCurrent = 1;
|
|
20
|
-
this.current = this.initial;
|
|
21
|
-
}
|
|
22
|
-
ExponentialBackoff.prototype.next = function () {
|
|
23
|
-
var backoff = this.current;
|
|
24
|
-
if (this.expMax > this.expCurrent++)
|
|
25
|
-
this.current = this.current * 2;
|
|
26
|
-
return backoff;
|
|
27
|
-
};
|
|
28
|
-
ExponentialBackoff.prototype.reset = function () {
|
|
29
|
-
this.expCurrent = 1;
|
|
30
|
-
this.current = this.initial;
|
|
31
|
-
};
|
|
32
|
-
return ExponentialBackoff;
|
|
33
|
-
}());
|
|
34
|
-
exports.ExponentialBackoff = ExponentialBackoff;
|
|
35
|
-
//# sourceMappingURL=exponentialbackoff.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exponentialbackoff.js","sourceRoot":"","sources":["../../src/backoff/exponentialbackoff.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;GAUG;AACH;IAMI,4BAAY,OAAe,EAAE,MAAc;QACvC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC;QACpB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;IAChC,CAAC;IAED,iCAAI,GAAJ;QACI,IAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC7B,IAAI,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,UAAU,EAAE;YAC/B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC;QACpC,OAAO,OAAO,CAAC;IACnB,CAAC;IAED,kCAAK,GAAL;QACI,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC;QACpB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;IAChC,CAAC;IACL,yBAAC;AAAD,CAAC,AAxBD,IAwBC;AAxBY,gDAAkB"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Backoff } from "./backoff";
|
|
2
|
-
/**
|
|
3
|
-
* LinearBackoff increases the backoff-time by a constant number with
|
|
4
|
-
* every step. An optional maximum can be provided as an upper bound
|
|
5
|
-
* to the returned backoff.
|
|
6
|
-
*
|
|
7
|
-
* Example: for initial=0, increment=2000, maximum=8000 the Linear-
|
|
8
|
-
* Backoff will produce the series [0, 2000, 4000, 6000, 8000].
|
|
9
|
-
*/
|
|
10
|
-
export declare class LinearBackoff implements Backoff {
|
|
11
|
-
private readonly initial;
|
|
12
|
-
private readonly increment;
|
|
13
|
-
private readonly maximum?;
|
|
14
|
-
private current;
|
|
15
|
-
constructor(initial: number, increment: number, maximum?: number);
|
|
16
|
-
next(): number;
|
|
17
|
-
reset(): void;
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=linearbackoff.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"linearbackoff.d.ts","sourceRoot":"","sources":["../../src/backoff/linearbackoff.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAElC;;;;;;;GAOG;AACH,qBAAa,aAAc,YAAW,OAAO;IACzC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAS;IAClC,OAAO,CAAC,OAAO,CAAS;gBAEZ,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM;IAOhE,IAAI;IAUJ,KAAK;CAGR"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LinearBackoff = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* LinearBackoff increases the backoff-time by a constant number with
|
|
6
|
-
* every step. An optional maximum can be provided as an upper bound
|
|
7
|
-
* to the returned backoff.
|
|
8
|
-
*
|
|
9
|
-
* Example: for initial=0, increment=2000, maximum=8000 the Linear-
|
|
10
|
-
* Backoff will produce the series [0, 2000, 4000, 6000, 8000].
|
|
11
|
-
*/
|
|
12
|
-
var LinearBackoff = /** @class */ (function () {
|
|
13
|
-
function LinearBackoff(initial, increment, maximum) {
|
|
14
|
-
this.initial = initial;
|
|
15
|
-
this.increment = increment;
|
|
16
|
-
this.maximum = maximum;
|
|
17
|
-
this.current = this.initial;
|
|
18
|
-
}
|
|
19
|
-
LinearBackoff.prototype.next = function () {
|
|
20
|
-
var backoff = this.current;
|
|
21
|
-
var next = this.current + this.increment;
|
|
22
|
-
if (this.maximum === undefined)
|
|
23
|
-
this.current = next;
|
|
24
|
-
else if (next <= this.maximum)
|
|
25
|
-
this.current = next;
|
|
26
|
-
return backoff;
|
|
27
|
-
};
|
|
28
|
-
LinearBackoff.prototype.reset = function () {
|
|
29
|
-
this.current = this.initial;
|
|
30
|
-
};
|
|
31
|
-
return LinearBackoff;
|
|
32
|
-
}());
|
|
33
|
-
exports.LinearBackoff = LinearBackoff;
|
|
34
|
-
//# sourceMappingURL=linearbackoff.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"linearbackoff.js","sourceRoot":"","sources":["../../src/backoff/linearbackoff.ts"],"names":[],"mappings":";;;AAEA;;;;;;;GAOG;AACH;IAMI,uBAAY,OAAe,EAAE,SAAiB,EAAE,OAAgB;QAC5D,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;IAChC,CAAC;IAED,4BAAI,GAAJ;QACI,IAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC7B,IAAM,IAAI,GAAG,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC;QAC3C,IAAI,IAAI,CAAC,OAAO,KAAK,SAAS;YAC1B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;aACnB,IAAI,IAAI,IAAI,IAAI,CAAC,OAAO;YACzB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACxB,OAAO,OAAO,CAAC;IACnB,CAAC;IAED,6BAAK,GAAL;QACI,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;IAChC,CAAC;IACL,oBAAC;AAAD,CAAC,AA1BD,IA0BC;AA1BY,sCAAa"}
|
package/lib/buffer/buffer.d.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Temporary container for generic elements.
|
|
3
|
-
*/
|
|
4
|
-
export interface Buffer<E> {
|
|
5
|
-
/**
|
|
6
|
-
* Length of the buffer, the count of elements
|
|
7
|
-
* that can be read from the buffer.
|
|
8
|
-
* @return the length of the buffer
|
|
9
|
-
*/
|
|
10
|
-
len(): number;
|
|
11
|
-
/**
|
|
12
|
-
* Capacity of the buffer, the total amount of
|
|
13
|
-
* elements the buffer can contain.
|
|
14
|
-
* @return the capacity of the buffer
|
|
15
|
-
*/
|
|
16
|
-
cap(): number;
|
|
17
|
-
/**
|
|
18
|
-
* Reads elements from the buffer.
|
|
19
|
-
* @param es array to read into from the buffer
|
|
20
|
-
* @return the count of elements that were read
|
|
21
|
-
*/
|
|
22
|
-
read(es: E[]): number;
|
|
23
|
-
/**
|
|
24
|
-
* Writes elements to the buffer.
|
|
25
|
-
* @param es array to write to the buffer
|
|
26
|
-
* @return the count of elements that were written
|
|
27
|
-
*/
|
|
28
|
-
write(es: E[]): number;
|
|
29
|
-
/**
|
|
30
|
-
* Applies a function to every element in the buffer.
|
|
31
|
-
* @param fn the function to apply to every element
|
|
32
|
-
* @return: the count of elements that were used
|
|
33
|
-
*/
|
|
34
|
-
forEach(fn: (e: E) => any): number;
|
|
35
|
-
/**
|
|
36
|
-
* Clears the buffer. This effectively removes all
|
|
37
|
-
* items in the buffer.
|
|
38
|
-
*/
|
|
39
|
-
clear(): void;
|
|
40
|
-
}
|
|
41
|
-
//# sourceMappingURL=buffer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"buffer.d.ts","sourceRoot":"","sources":["../../src/buffer/buffer.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,MAAM,CAAC,CAAC;IACrB;;;;OAIG;IACH,GAAG,IAAI,MAAM,CAAA;IAEb;;;;OAIG;IACH,GAAG,IAAI,MAAM,CAAA;IAEb;;;;OAIG;IACH,IAAI,CAAC,EAAE,EAAE,CAAC,EAAE,GAAG,MAAM,CAAA;IAErB;;;;OAIG;IACH,KAAK,CAAC,EAAE,EAAE,CAAC,EAAE,GAAG,MAAM,CAAA;IAEtB;;;;OAIG;IACH,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,GAAG,GAAG,MAAM,CAAA;IAElC;;;OAGG;IACH,KAAK,IAAI,IAAI,CAAA;CAChB"}
|
package/lib/buffer/buffer.js
DELETED
package/lib/buffer/buffer.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"buffer.js","sourceRoot":"","sources":["../../src/buffer/buffer.ts"],"names":[],"mappings":""}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { Buffer } from "./buffer";
|
|
2
|
-
/**
|
|
3
|
-
* LRUBuffer is a buffer that keeps the last n elements. When it is
|
|
4
|
-
* full and written to, the oldest element in the buffer will be
|
|
5
|
-
* replaced. When reading from the LRUBuffer, elements are returned
|
|
6
|
-
* in FIFO-order (queue).
|
|
7
|
-
*
|
|
8
|
-
* LRUBuffer has linear space- and time-requirements. Internally
|
|
9
|
-
* an array is used as a circular-buffer. All memory is allocated
|
|
10
|
-
* on initialization.
|
|
11
|
-
*/
|
|
12
|
-
export declare class LRUBuffer<E> implements Buffer<E> {
|
|
13
|
-
private readonly buffer;
|
|
14
|
-
private writePtr;
|
|
15
|
-
private wrapped;
|
|
16
|
-
constructor(len: number);
|
|
17
|
-
len(): number;
|
|
18
|
-
cap(): number;
|
|
19
|
-
read(es: E[]): number;
|
|
20
|
-
write(es: E[]): number;
|
|
21
|
-
forEach(fn: (e: E) => any): number;
|
|
22
|
-
clear(): void;
|
|
23
|
-
}
|
|
24
|
-
//# sourceMappingURL=lrubuffer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lrubuffer.d.ts","sourceRoot":"","sources":["../../src/buffer/lrubuffer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAC;AAEhC;;;;;;;;;GASG;AACH,qBAAa,SAAS,CAAC,CAAC,CAAE,YAAW,MAAM,CAAC,CAAC,CAAC;IAC1C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAM;IAC7B,OAAO,CAAC,QAAQ,CAAa;IAC7B,OAAO,CAAC,OAAO,CAAkB;gBAErB,GAAG,EAAE,MAAM;IAIvB,GAAG,IAAI,MAAM;IAIb,GAAG,IAAI,MAAM;IAIb,IAAI,CAAC,EAAE,EAAE,CAAC,EAAE,GAAG,MAAM;IAkBrB,KAAK,CAAC,EAAE,EAAE,CAAC,EAAE,GAAG,MAAM;IAatB,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,GAAG,GAAG,MAAM;IAelC,KAAK,IAAI,IAAI;CAIhB"}
|
package/lib/buffer/lrubuffer.js
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LRUBuffer = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* LRUBuffer is a buffer that keeps the last n elements. When it is
|
|
6
|
-
* full and written to, the oldest element in the buffer will be
|
|
7
|
-
* replaced. When reading from the LRUBuffer, elements are returned
|
|
8
|
-
* in FIFO-order (queue).
|
|
9
|
-
*
|
|
10
|
-
* LRUBuffer has linear space- and time-requirements. Internally
|
|
11
|
-
* an array is used as a circular-buffer. All memory is allocated
|
|
12
|
-
* on initialization.
|
|
13
|
-
*/
|
|
14
|
-
var LRUBuffer = /** @class */ (function () {
|
|
15
|
-
function LRUBuffer(len) {
|
|
16
|
-
this.writePtr = 0;
|
|
17
|
-
this.wrapped = false;
|
|
18
|
-
this.buffer = Array(len);
|
|
19
|
-
}
|
|
20
|
-
LRUBuffer.prototype.len = function () {
|
|
21
|
-
return this.wrapped ? this.buffer.length : this.writePtr;
|
|
22
|
-
};
|
|
23
|
-
LRUBuffer.prototype.cap = function () {
|
|
24
|
-
return this.buffer.length;
|
|
25
|
-
};
|
|
26
|
-
LRUBuffer.prototype.read = function (es) {
|
|
27
|
-
if (es === null || es === undefined || es.length === 0 || this.buffer.length === 0)
|
|
28
|
-
return 0;
|
|
29
|
-
if (this.writePtr === 0 && !this.wrapped)
|
|
30
|
-
return 0;
|
|
31
|
-
var first = this.wrapped ? this.writePtr : 0;
|
|
32
|
-
var last = (first - 1) < 0 ?
|
|
33
|
-
this.buffer.length - 1 :
|
|
34
|
-
first - 1;
|
|
35
|
-
for (var i = 0; i < es.length; i++) {
|
|
36
|
-
var r = (first + i) % this.buffer.length;
|
|
37
|
-
es[i] = this.buffer[r];
|
|
38
|
-
if (r === last)
|
|
39
|
-
return i + 1;
|
|
40
|
-
}
|
|
41
|
-
return es.length;
|
|
42
|
-
};
|
|
43
|
-
LRUBuffer.prototype.write = function (es) {
|
|
44
|
-
if (es === null || es === undefined || es.length === 0 || this.buffer.length === 0)
|
|
45
|
-
return 0;
|
|
46
|
-
var start = es.length > this.buffer.length ? es.length - this.buffer.length : 0;
|
|
47
|
-
for (var i = 0; i < es.length - start; i++) {
|
|
48
|
-
this.buffer[this.writePtr] = es[start + i];
|
|
49
|
-
this.writePtr = (this.writePtr + 1) % this.buffer.length;
|
|
50
|
-
if (this.writePtr === 0)
|
|
51
|
-
this.wrapped = true;
|
|
52
|
-
}
|
|
53
|
-
return es.length;
|
|
54
|
-
};
|
|
55
|
-
LRUBuffer.prototype.forEach = function (fn) {
|
|
56
|
-
if (this.writePtr === 0 && !this.wrapped)
|
|
57
|
-
return 0;
|
|
58
|
-
var cur = this.wrapped ? this.writePtr : 0;
|
|
59
|
-
var last = this.wrapped ? (cur - 1) < 0 ? this.buffer.length - 1 : cur - 1 : this.writePtr - 1;
|
|
60
|
-
var len = this.len();
|
|
61
|
-
while (true) {
|
|
62
|
-
fn(this.buffer[cur]);
|
|
63
|
-
if (cur === last)
|
|
64
|
-
break;
|
|
65
|
-
cur = (cur + 1) % this.buffer.length;
|
|
66
|
-
}
|
|
67
|
-
return len;
|
|
68
|
-
};
|
|
69
|
-
LRUBuffer.prototype.clear = function () {
|
|
70
|
-
this.writePtr = 0;
|
|
71
|
-
this.wrapped = false;
|
|
72
|
-
};
|
|
73
|
-
return LRUBuffer;
|
|
74
|
-
}());
|
|
75
|
-
exports.LRUBuffer = LRUBuffer;
|
|
76
|
-
//# sourceMappingURL=lrubuffer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lrubuffer.js","sourceRoot":"","sources":["../../src/buffer/lrubuffer.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;GASG;AACH;IAKI,mBAAY,GAAW;QAHf,aAAQ,GAAW,CAAC,CAAC;QACrB,YAAO,GAAY,KAAK,CAAC;QAG7B,IAAI,CAAC,MAAM,GAAG,KAAK,CAAI,GAAG,CAAC,CAAC;IAChC,CAAC;IAED,uBAAG,GAAH;QACI,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC;IAC7D,CAAC;IAED,uBAAG,GAAH;QACI,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;IAC9B,CAAC;IAED,wBAAI,GAAJ,UAAK,EAAO;QACR,IAAI,EAAE,KAAK,IAAI,IAAI,EAAE,KAAK,SAAS,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC;YAC9E,OAAO,CAAC,CAAC;QACb,IAAI,IAAI,CAAC,QAAQ,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO;YACpC,OAAO,CAAC,CAAC;QACb,IAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC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
2
|
-
/**
|
|
3
|
-
* TimeBuffer keeps the elements that were written to the buffer
|
|
4
|
-
* within maxAge milliseconds. For example, to keep items in the
|
|
5
|
-
* buffer that are less than a minute old, create the buffer with
|
|
6
|
-
* maxAge equal to 60.000.
|
|
7
|
-
*
|
|
8
|
-
* When reading from the TimeBuffer, elements will be returned
|
|
9
|
-
* in FIFO-order (queue).
|
|
10
|
-
*/
|
|
11
|
-
export declare class TimeBuffer<E> implements Buffer<E> {
|
|
12
|
-
private readonly maxAge;
|
|
13
|
-
private tail?;
|
|
14
|
-
private head?;
|
|
15
|
-
constructor(maxAge: number);
|
|
16
|
-
cap(): number;
|
|
17
|
-
len(): number;
|
|
18
|
-
read(es: E[]): number;
|
|
19
|
-
write(es: E[]): number;
|
|
20
|
-
forEach(fn: (e: E) => any): number;
|
|
21
|
-
private putElement;
|
|
22
|
-
private forwardTail;
|
|
23
|
-
clear(): void;
|
|
24
|
-
}
|
|
25
|
-
//# sourceMappingURL=timebuffer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"timebuffer.d.ts","sourceRoot":"","sources":["../../src/buffer/timebuffer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAC;AAEhC;;;;;;;;GAQG;AACH,qBAAa,UAAU,CAAC,CAAC,CAAE,YAAW,MAAM,CAAC,CAAC,CAAC;IAC3C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,IAAI,CAAC,CAA0B;IACvC,OAAO,CAAC,IAAI,CAAC,CAA0B;gBAE3B,MAAM,EAAE,MAAM;IAI1B,GAAG,IAAI,MAAM;IAIb,GAAG,IAAI,MAAM;IAWb,IAAI,CAAC,EAAE,EAAE,CAAC,EAAE,GAAG,MAAM;IAerB,KAAK,CAAC,EAAE,EAAE,CAAC,EAAE,GAAG,MAAM;IAMtB,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,GAAG,GAAG,MAAM;IAYlC,OAAO,CAAC,UAAU;IAYlB,OAAO,CAAC,WAAW;IAenB,KAAK,IAAI,IAAI;CAGhB"}
|
package/lib/buffer/timebuffer.js
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TimeBuffer = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* TimeBuffer keeps the elements that were written to the buffer
|
|
6
|
-
* within maxAge milliseconds. For example, to keep items in the
|
|
7
|
-
* buffer that are less than a minute old, create the buffer with
|
|
8
|
-
* maxAge equal to 60.000.
|
|
9
|
-
*
|
|
10
|
-
* When reading from the TimeBuffer, elements will be returned
|
|
11
|
-
* in FIFO-order (queue).
|
|
12
|
-
*/
|
|
13
|
-
var TimeBuffer = /** @class */ (function () {
|
|
14
|
-
function TimeBuffer(maxAge) {
|
|
15
|
-
this.maxAge = maxAge;
|
|
16
|
-
}
|
|
17
|
-
TimeBuffer.prototype.cap = function () {
|
|
18
|
-
return Number.POSITIVE_INFINITY;
|
|
19
|
-
};
|
|
20
|
-
TimeBuffer.prototype.len = function () {
|
|
21
|
-
this.forwardTail();
|
|
22
|
-
var cur = this.tail;
|
|
23
|
-
var i = 0;
|
|
24
|
-
while (cur !== undefined) {
|
|
25
|
-
i++;
|
|
26
|
-
cur = cur.n;
|
|
27
|
-
}
|
|
28
|
-
return i;
|
|
29
|
-
};
|
|
30
|
-
TimeBuffer.prototype.read = function (es) {
|
|
31
|
-
this.forwardTail();
|
|
32
|
-
if (es.length === 0)
|
|
33
|
-
return 0;
|
|
34
|
-
var cur = this.tail;
|
|
35
|
-
var i = 0;
|
|
36
|
-
while (cur !== undefined) {
|
|
37
|
-
es[i++] = cur.e;
|
|
38
|
-
if (i === es.length)
|
|
39
|
-
break;
|
|
40
|
-
cur = cur.n;
|
|
41
|
-
}
|
|
42
|
-
return i;
|
|
43
|
-
};
|
|
44
|
-
TimeBuffer.prototype.write = function (es) {
|
|
45
|
-
for (var i = 0; i < es.length; i++)
|
|
46
|
-
this.putElement(es[i]);
|
|
47
|
-
return es.length;
|
|
48
|
-
};
|
|
49
|
-
TimeBuffer.prototype.forEach = function (fn) {
|
|
50
|
-
this.forwardTail();
|
|
51
|
-
var cur = this.tail;
|
|
52
|
-
var i = 0;
|
|
53
|
-
while (cur !== undefined) {
|
|
54
|
-
fn(cur.e);
|
|
55
|
-
i++;
|
|
56
|
-
cur = cur.n;
|
|
57
|
-
}
|
|
58
|
-
return i;
|
|
59
|
-
};
|
|
60
|
-
TimeBuffer.prototype.putElement = function (e) {
|
|
61
|
-
var newElement = { e: e, t: Date.now(), n: undefined };
|
|
62
|
-
if (this.tail === undefined)
|
|
63
|
-
this.tail = newElement;
|
|
64
|
-
if (this.head === undefined)
|
|
65
|
-
this.head = newElement;
|
|
66
|
-
else {
|
|
67
|
-
this.head.n = newElement;
|
|
68
|
-
this.head = newElement;
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
TimeBuffer.prototype.forwardTail = function () {
|
|
72
|
-
if (this.tail === undefined)
|
|
73
|
-
return;
|
|
74
|
-
var d = Date.now();
|
|
75
|
-
while (d - this.tail.t > this.maxAge) {
|
|
76
|
-
if (this.tail === this.head) {
|
|
77
|
-
this.tail = undefined;
|
|
78
|
-
this.head = undefined;
|
|
79
|
-
}
|
|
80
|
-
else
|
|
81
|
-
this.tail = this.tail.n;
|
|
82
|
-
if (this.tail === undefined)
|
|
83
|
-
break;
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
TimeBuffer.prototype.clear = function () {
|
|
87
|
-
// TODO
|
|
88
|
-
};
|
|
89
|
-
return TimeBuffer;
|
|
90
|
-
}());
|
|
91
|
-
exports.TimeBuffer = TimeBuffer;
|
|
92
|
-
//# sourceMappingURL=timebuffer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"timebuffer.js","sourceRoot":"","sources":["../../src/buffer/timeb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AAO;IACX,CAAC;IACL,iBAAC;AAAD,CAAC,AAvFD,IAuFC;AAvFY,gCAAU"}
|
package/lib/index.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export * from './backoff/backoff';
|
|
2
|
-
export * from './backoff/constantbackoff';
|
|
3
|
-
export * from './backoff/exponentialbackoff';
|
|
4
|
-
export * from './backoff/linearbackoff';
|
|
5
|
-
export * from './buffer/buffer';
|
|
6
|
-
export * from './buffer/lrubuffer';
|
|
7
|
-
export * from './buffer/timebuffer';
|
|
8
|
-
export * from './websocket';
|
|
9
|
-
export * from './websocketBuilder';
|
|
10
|
-
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,2BAA2B,CAAA;AACzC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,yBAAyB,CAAA;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAA;AAClC,cAAc,qBAAqB,CAAA;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC"}
|
package/lib/index.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
-
};
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
__exportStar(require("./backoff/backoff"), exports);
|
|
14
|
-
__exportStar(require("./backoff/constantbackoff"), exports);
|
|
15
|
-
__exportStar(require("./backoff/exponentialbackoff"), exports);
|
|
16
|
-
__exportStar(require("./backoff/linearbackoff"), exports);
|
|
17
|
-
__exportStar(require("./buffer/buffer"), exports);
|
|
18
|
-
__exportStar(require("./buffer/lrubuffer"), exports);
|
|
19
|
-
__exportStar(require("./buffer/timebuffer"), exports);
|
|
20
|
-
__exportStar(require("./websocket"), exports);
|
|
21
|
-
__exportStar(require("./websocketBuilder"), exports);
|
|
22
|
-
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAkC;AAClC,4DAAyC;AACzC,+DAA4C;AAC5C,0DAAuC;AACvC,kDAAgC;AAChC,qDAAkC;AAClC,sDAAmC;AACnC,8CAA4B;AAC5B,qDAAmC"}
|
package/lib/websocket.d.ts
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { Backoff } from "./backoff/backoff";
|
|
2
|
-
import { Buffer } from "./buffer/buffer";
|
|
3
|
-
export declare enum WebsocketEvents {
|
|
4
|
-
open = "open",
|
|
5
|
-
close = "close",
|
|
6
|
-
error = "error",
|
|
7
|
-
message = "message",
|
|
8
|
-
retry = "retry"
|
|
9
|
-
}
|
|
10
|
-
interface WebsocketEventMap {
|
|
11
|
-
close: CloseEvent;
|
|
12
|
-
error: Event;
|
|
13
|
-
message: MessageEvent;
|
|
14
|
-
open: Event;
|
|
15
|
-
retry: CustomEvent<RetryEventDetails>;
|
|
16
|
-
}
|
|
17
|
-
export interface RetryEventDetails {
|
|
18
|
-
readonly retries: number;
|
|
19
|
-
readonly backoff: number;
|
|
20
|
-
}
|
|
21
|
-
declare type WebsocketBuffer = Buffer<string | ArrayBufferLike | Blob | ArrayBufferView>;
|
|
22
|
-
export declare class Websocket {
|
|
23
|
-
private readonly url;
|
|
24
|
-
private readonly protocols?;
|
|
25
|
-
private readonly buffer?;
|
|
26
|
-
private readonly backoff?;
|
|
27
|
-
private readonly eventListeners;
|
|
28
|
-
private closedByUser;
|
|
29
|
-
private websocket?;
|
|
30
|
-
private retries;
|
|
31
|
-
constructor(url: string, protocols?: string | string[], buffer?: WebsocketBuffer, backoff?: Backoff);
|
|
32
|
-
get underlyingWebsocket(): WebSocket | undefined;
|
|
33
|
-
send(data: string | ArrayBufferLike | Blob | ArrayBufferView): void;
|
|
34
|
-
close(code?: number, reason?: string): void;
|
|
35
|
-
addEventListener<K extends WebsocketEvents>(type: K, listener: (instance: Websocket, ev: WebsocketEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
|
|
36
|
-
removeEventListener<K extends WebsocketEvents>(type: K, listener: (instance: Websocket, ev: WebsocketEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
|
|
37
|
-
private dispatchEvent;
|
|
38
|
-
private tryConnect;
|
|
39
|
-
private handleOpenEvent;
|
|
40
|
-
private handleCloseEvent;
|
|
41
|
-
private handleErrorEvent;
|
|
42
|
-
private handleMessageEvent;
|
|
43
|
-
private handleEvent;
|
|
44
|
-
private reconnect;
|
|
45
|
-
}
|
|
46
|
-
export {};
|
|
47
|
-
//# sourceMappingURL=websocket.d.ts.map
|
package/lib/websocket.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"websocket.d.ts","sourceRoot":"","sources":["../src/websocket.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAC,MAAM,EAAC,MAAM,iBAAiB,CAAC;AAOvC,oBAAY,eAAe;IACvB,IAAI,SAAS;IACb,KAAK,UAAU;IACf,KAAK,UAAU;IACf,OAAO,YAAY;IACnB,KAAK,UAAU;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