streamspeed 2.0.2 → 2.0.3
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/dist/index.d.ts +2 -23
- package/dist/index.js +6 -23
- package/dist/index.js.map +1 -1
- package/dist/speedometer.d.ts +0 -8
- package/dist/speedometer.js +0 -8
- package/dist/speedometer.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -12,41 +12,28 @@ declare namespace StreamSpeed {
|
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
declare class StreamSpeed extends EventEmitter {
|
|
15
|
+
static StreamSpeed: typeof StreamSpeed;
|
|
16
|
+
static default: typeof StreamSpeed;
|
|
15
17
|
options: Options;
|
|
16
18
|
private _streams;
|
|
17
19
|
/**
|
|
18
20
|
* Emits speed for a group of streams.
|
|
19
|
-
*
|
|
20
|
-
* @constructor
|
|
21
|
-
* @extends {EventEmitter}
|
|
22
|
-
* @param {Object?} options
|
|
23
|
-
* @param {number?} options.timeUnit The time unit speed will be measured in.
|
|
24
|
-
* @param {number?} options.range Time in ms to calculate speed over.
|
|
25
21
|
*/
|
|
26
22
|
constructor(options?: {});
|
|
27
23
|
/**
|
|
28
24
|
* Updates the group with the latest change in speed.
|
|
29
|
-
*
|
|
30
|
-
* @param {Readable} origstream
|
|
31
|
-
* @param {number} speed
|
|
32
25
|
*/
|
|
33
26
|
_update(origstream: Readable, speed: number): void;
|
|
34
27
|
/**
|
|
35
28
|
* Convenient method that returns list of streams in this group.
|
|
36
|
-
*
|
|
37
|
-
* @return {Array.<Readable>}
|
|
38
29
|
*/
|
|
39
30
|
getStreams(): Readable[];
|
|
40
31
|
/**
|
|
41
32
|
* Add stream to group.
|
|
42
|
-
*
|
|
43
|
-
* @param {Readable} stream
|
|
44
33
|
*/
|
|
45
34
|
add(origstream: Readable): void;
|
|
46
35
|
/**
|
|
47
36
|
* Remove stream from group.
|
|
48
|
-
*
|
|
49
|
-
* @param {Readable} stream
|
|
50
37
|
*/
|
|
51
38
|
remove(stream: Readable): void;
|
|
52
39
|
/**
|
|
@@ -55,19 +42,11 @@ declare class StreamSpeed extends EventEmitter {
|
|
|
55
42
|
getSpeed(): number;
|
|
56
43
|
/**
|
|
57
44
|
* Get an individual stream's speed.
|
|
58
|
-
*
|
|
59
|
-
* @param {Readable} stream
|
|
60
45
|
*/
|
|
61
46
|
getStreamSpeed(stream: Readable): number;
|
|
62
47
|
/**
|
|
63
48
|
* Converts bytes to human readable unit.
|
|
64
49
|
* Thank you Amir from StackOverflow.
|
|
65
|
-
*
|
|
66
|
-
* @param {number} bytes
|
|
67
|
-
* @param {Object} options
|
|
68
|
-
* @param {string} options.timeUnit
|
|
69
|
-
* @param {number?} options.precision
|
|
70
|
-
* @return {string}
|
|
71
50
|
*/
|
|
72
51
|
static toHuman(bytes: number, options?: StreamSpeed.ToHumanOptions): string;
|
|
73
52
|
}
|
package/dist/index.js
CHANGED
|
@@ -5,12 +5,6 @@ const speedometer_1 = require("./speedometer");
|
|
|
5
5
|
class StreamSpeed extends node_events_1.EventEmitter {
|
|
6
6
|
/**
|
|
7
7
|
* Emits speed for a group of streams.
|
|
8
|
-
*
|
|
9
|
-
* @constructor
|
|
10
|
-
* @extends {EventEmitter}
|
|
11
|
-
* @param {Object?} options
|
|
12
|
-
* @param {number?} options.timeUnit The time unit speed will be measured in.
|
|
13
|
-
* @param {number?} options.range Time in ms to calculate speed over.
|
|
14
8
|
*/
|
|
15
9
|
constructor(options = {}) {
|
|
16
10
|
super();
|
|
@@ -22,9 +16,6 @@ class StreamSpeed extends node_events_1.EventEmitter {
|
|
|
22
16
|
}
|
|
23
17
|
/**
|
|
24
18
|
* Updates the group with the latest change in speed.
|
|
25
|
-
*
|
|
26
|
-
* @param {Readable} origstream
|
|
27
|
-
* @param {number} speed
|
|
28
19
|
*/
|
|
29
20
|
_update(origstream, speed) {
|
|
30
21
|
for (const [stream, m] of this._streams) {
|
|
@@ -39,16 +30,12 @@ class StreamSpeed extends node_events_1.EventEmitter {
|
|
|
39
30
|
}
|
|
40
31
|
/**
|
|
41
32
|
* Convenient method that returns list of streams in this group.
|
|
42
|
-
*
|
|
43
|
-
* @return {Array.<Readable>}
|
|
44
33
|
*/
|
|
45
34
|
getStreams() {
|
|
46
35
|
return Array.from(this._streams.keys());
|
|
47
36
|
}
|
|
48
37
|
/**
|
|
49
38
|
* Add stream to group.
|
|
50
|
-
*
|
|
51
|
-
* @param {Readable} stream
|
|
52
39
|
*/
|
|
53
40
|
add(origstream) {
|
|
54
41
|
// Check if stream is already in group.
|
|
@@ -80,8 +67,6 @@ class StreamSpeed extends node_events_1.EventEmitter {
|
|
|
80
67
|
}
|
|
81
68
|
/**
|
|
82
69
|
* Remove stream from group.
|
|
83
|
-
*
|
|
84
|
-
* @param {Readable} stream
|
|
85
70
|
*/
|
|
86
71
|
remove(stream) {
|
|
87
72
|
// Check if stream is in group.
|
|
@@ -99,8 +84,6 @@ class StreamSpeed extends node_events_1.EventEmitter {
|
|
|
99
84
|
}
|
|
100
85
|
/**
|
|
101
86
|
* Get an individual stream's speed.
|
|
102
|
-
*
|
|
103
|
-
* @param {Readable} stream
|
|
104
87
|
*/
|
|
105
88
|
getStreamSpeed(stream) {
|
|
106
89
|
const meta = this._streams.get(stream);
|
|
@@ -112,12 +95,6 @@ class StreamSpeed extends node_events_1.EventEmitter {
|
|
|
112
95
|
/**
|
|
113
96
|
* Converts bytes to human readable unit.
|
|
114
97
|
* Thank you Amir from StackOverflow.
|
|
115
|
-
*
|
|
116
|
-
* @param {number} bytes
|
|
117
|
-
* @param {Object} options
|
|
118
|
-
* @param {string} options.timeUnit
|
|
119
|
-
* @param {number?} options.precision
|
|
120
|
-
* @return {string}
|
|
121
98
|
*/
|
|
122
99
|
static toHuman(bytes, options = {}) {
|
|
123
100
|
const units = ' KMGTPEZYXWVU';
|
|
@@ -132,5 +109,11 @@ class StreamSpeed extends node_events_1.EventEmitter {
|
|
|
132
109
|
return `${prate + units.charAt(t2).replace(' ', '')}B${timeUnit}`;
|
|
133
110
|
}
|
|
134
111
|
}
|
|
112
|
+
StreamSpeed.StreamSpeed = StreamSpeed;
|
|
113
|
+
StreamSpeed.default = StreamSpeed;
|
|
114
|
+
// Statically recognizable exports for Node.js cjs-module-lexer (ESM named import support)
|
|
115
|
+
module.exports = StreamSpeed;
|
|
116
|
+
module.exports.default = StreamSpeed;
|
|
117
|
+
module.exports.StreamSpeed = StreamSpeed;
|
|
135
118
|
module.exports = StreamSpeed;
|
|
136
119
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,6CAA2C;AAC3C,6CAAyD;AACzD,+CAA0D;AAc1D,MAAM,WAAY,SAAQ,0BAAY;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,6CAA2C;AAC3C,6CAAyD;AACzD,+CAA0D;AAc1D,MAAM,WAAY,SAAQ,0BAAY;IAapC;;OAEG;IACH,YAAY,OAAO,GAAG,EAAE;QACtB,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,CAC1B;YACE,QAAQ,EAAE,IAAI;YACd,KAAK,EAAE,IAAI;SACZ,EACD,OAAO,CACR,CAAC;QACF,IAAI,CAAC,QAAQ,GAAG,IAAI,GAAG,EAAE,CAAC;IAC5B,CAAC;IAED;;OAEG;IACH,OAAO,CAAC,UAAoB,EAAE,KAAa;QACzC,KAAK,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YACxC,mBAAmB;YACnB,IAAI,MAAM,KAAK,UAAU,EAAE,CAAC;gBAC1B,SAAS;YACX,CAAC;YAED,sCAAsC;YACtC,KAAK,IAAI,CAAC,CAAC,MAAM,CAAC,QAAQ,EAAE,C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AAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAChE,MAAM,EAAE,GACN,KAAK,GAAG,CAAC;YACP,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,CAAC;YAC5D,CAAC,CAAC,CAAC,CAAC;QACR,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,GAAG,GAAG,CAAC,GAAG,SAAA,IAAI,EAAI,EAAE,CAAA,CAAC,GAAG,GAAG,CAAC;QAC1D,MAAM,KAAK,GAAG,OAAO,CAAC,SAAS;YAC7B,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,SAAS,CAAC;YACrC,CAAC,CAAC,IAAI,CAAC;QACT,OAAO,GAAG,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,QAAQ,EAAE,CAAC;IACpE,CAAC;;AAzIM,uBAAW,GAAG,WAAW,CAAC;AAC1B,mBAAO,GAAG,WAAW,CAAC;AA2I/B,0FAA0F;AAC1F,MAAM,CAAC,OAAO,GAAG,WAAW,CAAC;AAC7B,MAAM,CAAC,OAAO,CAAC,OAAO,GAAG,WAAW,CAAC;AACrC,MAAM,CAAC,OAAO,CAAC,WAAW,GAAG,WAAW,CAAC;AAEzC,iBAAS,WAAW,CAAC"}
|
package/dist/speedometer.d.ts
CHANGED
|
@@ -8,18 +8,10 @@ export declare class Speedometer {
|
|
|
8
8
|
private _lastSpeed;
|
|
9
9
|
/**
|
|
10
10
|
* Helps count the number of bytes per data event in streams.
|
|
11
|
-
*
|
|
12
|
-
* @constructor
|
|
13
|
-
* @param {Object?} options
|
|
14
|
-
* @param {number?} options.timeUnit
|
|
15
|
-
* @param {number?} options.range
|
|
16
11
|
*/
|
|
17
12
|
constructor(options: Options);
|
|
18
13
|
/**
|
|
19
14
|
* Called when new data arrives.
|
|
20
|
-
*
|
|
21
|
-
* @param {Buffer|string} data
|
|
22
|
-
* @param {Function} callback
|
|
23
15
|
*/
|
|
24
16
|
update(data: Buffer, callback: (speed: number) => void): void;
|
|
25
17
|
/**
|
package/dist/speedometer.js
CHANGED
|
@@ -4,11 +4,6 @@ exports.Speedometer = void 0;
|
|
|
4
4
|
class Speedometer {
|
|
5
5
|
/**
|
|
6
6
|
* Helps count the number of bytes per data event in streams.
|
|
7
|
-
*
|
|
8
|
-
* @constructor
|
|
9
|
-
* @param {Object?} options
|
|
10
|
-
* @param {number?} options.timeUnit
|
|
11
|
-
* @param {number?} options.range
|
|
12
7
|
*/
|
|
13
8
|
constructor(options) {
|
|
14
9
|
this.options = options;
|
|
@@ -17,9 +12,6 @@ class Speedometer {
|
|
|
17
12
|
}
|
|
18
13
|
/**
|
|
19
14
|
* Called when new data arrives.
|
|
20
|
-
*
|
|
21
|
-
* @param {Buffer|string} data
|
|
22
|
-
* @param {Function} callback
|
|
23
15
|
*/
|
|
24
16
|
update(data, callback) {
|
|
25
17
|
const now = Date.now();
|
package/dist/speedometer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"speedometer.js","sourceRoot":"","sources":["../src/speedometer.ts"],"names":[],"mappings":";;;AAUA,MAAa,WAAW;IAItB
|
|
1
|
+
{"version":3,"file":"speedometer.js","sourceRoot":"","sources":["../src/speedometer.ts"],"names":[],"mappings":";;;AAUA,MAAa,WAAW;IAItB;;OAEG;IACH,YAAY,OAAgB;QAC1B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;QAClB,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC;IACtB,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,IAAY,EAAE,QAAiC;QACpD,MAAM,GAAG,GAAG,IAA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