Skip to content

Commit af0dbb8

Browse files
fix(request): renamed vars
1 parent 36bd4ea commit af0dbb8

10 files changed

+68
-66
lines changed

packages/operators/src/transfer/interceptTransfer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,9 @@ const convertStreamToResponse = (stream, resp) => {
103103
);
104104
};
105105

106-
const onStreamPull = async (controller, operators, bytes, total, period) => {
106+
const onStreamPull = async (controller, operators, bytes, total, time) => {
107107
controller.enqueue(new Uint8Array(bytes));
108-
operators.map(operator => operator.next({ value: bytes, total, period }));
108+
operators.map(operator => operator.next({ bytes, total, time }));
109109
};
110110

111111
const onStreamEnd = (controller, operators) => {

packages/operators/src/transfer/stats/Bandwidth.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ const calcBandwidth = (byteRatio, timeRatio) => {
1616
return source =>
1717
source.pipe(
1818
switchMap(stats => {
19-
let noBandwidth = stats.value === stats.total ? EMPTY : of(0).pipe(delay(500));
19+
let noBandwidth = stats.length === stats.total ? EMPTY : of(0).pipe(delay(500));
2020
return concat(calcTransmittableBytes(stats, byteRatio, timeRatio), noBandwidth);
2121
})
2222
);
2323
};
2424

2525
const calcTransmittableBytes = (stats, byteRatio, timeRatio) => {
26-
return of(stats).pipe(map(({ value, period }) => (value / period) * byteRatio * timeRatio));
26+
return of(stats).pipe(map(({ length, time }) => (length / time) * byteRatio * timeRatio));
2727
};

packages/operators/src/transfer/stats/Bandwidth.test.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ describe('Bandwidth', () => {
2222
const time = Date.now();
2323

2424
const triggerVal = {
25-
a: { value: new TextEncoder().encode('abcd'), total: 20, period: time },
26-
b: { value: new TextEncoder().encode('edgh'), total: 20, period: time },
27-
c: { value: new TextEncoder().encode('ijkl'), total: 20, period: time },
28-
d: { value: new TextEncoder().encode('mnop'), total: 20, period: time },
29-
e: { value: new TextEncoder().encode('qrst'), total: 20, period: time }
25+
a: { bytes: new TextEncoder().encode('abcd'), total: 20, time },
26+
b: { bytes: new TextEncoder().encode('edgh'), total: 20, time },
27+
c: { bytes: new TextEncoder().encode('ijkl'), total: 20, time },
28+
d: { bytes: new TextEncoder().encode('mnop'), total: 20, time },
29+
e: { bytes: new TextEncoder().encode('qrst'), total: 20, time }
3030
};
3131

3232
const expectedVal = {
@@ -49,11 +49,11 @@ describe('Bandwidth', () => {
4949
const time = Date.now();
5050

5151
const triggerVal = {
52-
a: { value: new TextEncoder().encode('abcd'), total: 20, period: time },
53-
b: { value: new TextEncoder().encode('edgh'), total: 20, period: time },
54-
c: { value: new TextEncoder().encode('ijkl'), total: 20, period: time },
55-
d: { value: new TextEncoder().encode('mnop'), total: 20, period: time },
56-
e: { value: new TextEncoder().encode('qrst'), total: 20, period: time }
52+
a: { bytes: new TextEncoder().encode('abcd'), total: 20, time },
53+
b: { bytes: new TextEncoder().encode('edgh'), total: 20, time },
54+
c: { bytes: new TextEncoder().encode('ijkl'), total: 20, time },
55+
d: { bytes: new TextEncoder().encode('mnop'), total: 20, time },
56+
e: { bytes: new TextEncoder().encode('qrst'), total: 20, time }
5757
};
5858

5959
const expectedVal = {

packages/operators/src/transfer/stats/ElapsedTime.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ export default {
99
};
1010

1111
const calcElapsedTime = timeRatio => {
12-
return source => source.pipe(map(({ period }) => period / timeRatio));
12+
return source => source.pipe(map(({ time }) => time / timeRatio));
1313
};

packages/operators/src/transfer/stats/ElapsedTime.test.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ describe('ElapsedTime', () => {
2222
const time = Date.now();
2323

2424
const triggerVal = {
25-
a: { value: new TextEncoder().encode('abc'), total: 26, period: time },
26-
b: { value: new TextEncoder().encode('def'), total: 26, period: time },
27-
c: { value: new TextEncoder().encode('ghi'), total: 26, period: time },
28-
d: { value: new TextEncoder().encode('jkl'), total: 26, period: time },
29-
e: { value: new TextEncoder().encode('mno'), total: 26, period: time },
30-
f: { value: new TextEncoder().encode('pqr'), total: 26, period: time },
31-
g: { value: new TextEncoder().encode('stu'), total: 26, period: time },
32-
h: { value: new TextEncoder().encode('vwx'), total: 26, period: time },
33-
i: { value: new TextEncoder().encode('yz'), total: 26, period: time }
25+
a: { bytes: new TextEncoder().encode('abc'), total: 26, time },
26+
b: { bytes: new TextEncoder().encode('def'), total: 26, time },
27+
c: { bytes: new TextEncoder().encode('ghi'), total: 26, time },
28+
d: { bytes: new TextEncoder().encode('jkl'), total: 26, time },
29+
e: { bytes: new TextEncoder().encode('mno'), total: 26, time },
30+
f: { bytes: new TextEncoder().encode('pqr'), total: 26, time },
31+
g: { bytes: new TextEncoder().encode('stu'), total: 26, time },
32+
h: { bytes: new TextEncoder().encode('vwx'), total: 26, time },
33+
i: { bytes: new TextEncoder().encode('yz'), total: 26, time }
3434
};
3535

3636
const expectedVal = {
@@ -57,15 +57,15 @@ describe('ElapsedTime', () => {
5757
const time = Date.now();
5858

5959
const triggerVal = {
60-
a: { value: new TextEncoder().encode('abc'), total: 26, period: time },
61-
b: { value: new TextEncoder().encode('def'), total: 26, period: time },
62-
c: { value: new TextEncoder().encode('ghi'), total: 26, period: time },
63-
d: { value: new TextEncoder().encode('jkl'), total: 26, period: time },
64-
e: { value: new TextEncoder().encode('mno'), total: 26, period: time },
65-
f: { value: new TextEncoder().encode('pqr'), total: 26, period: time },
66-
g: { value: new TextEncoder().encode('stu'), total: 26, period: time },
67-
h: { value: new TextEncoder().encode('vwx'), total: 26, period: time },
68-
i: { value: new TextEncoder().encode('yz'), total: 26, period: time }
60+
a: { bytes: new TextEncoder().encode('abc'), total: 26, time },
61+
b: { bytes: new TextEncoder().encode('def'), total: 26, time },
62+
c: { bytes: new TextEncoder().encode('ghi'), total: 26, time },
63+
d: { bytes: new TextEncoder().encode('jkl'), total: 26, time },
64+
e: { bytes: new TextEncoder().encode('mno'), total: 26, time },
65+
f: { bytes: new TextEncoder().encode('pqr'), total: 26, time },
66+
g: { bytes: new TextEncoder().encode('stu'), total: 26, time },
67+
h: { bytes: new TextEncoder().encode('vwx'), total: 26, time },
68+
i: { bytes: new TextEncoder().encode('yz'), total: 26, time }
6969
};
7070

7171
const expectedVal = {

packages/operators/src/transfer/stats/Progress.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ export default {
1414
};
1515

1616
const calcPercentageProgress = () => {
17-
return source => source.pipe(map(({ value, total }) => Math.floor((value / total) * 100)));
17+
return source => source.pipe(map(({ length, total }) => Math.floor((length / total) * 100)));
1818
};

packages/operators/src/transfer/stats/Progress.test.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ describe('Progress', () => {
1313

1414
test('calc progress', async () => {
1515
const triggerVal = {
16-
a: { value: new TextEncoder().encode('abc'), total: 26, period: 10 },
17-
b: { value: new TextEncoder().encode('def'), total: 26, period: 20 },
18-
c: { value: new TextEncoder().encode('ghi'), total: 26, period: 30 },
19-
d: { value: new TextEncoder().encode('jkl'), total: 26, period: 40 },
20-
e: { value: new TextEncoder().encode('mno'), total: 26, period: 50 },
21-
f: { value: new TextEncoder().encode('pqr'), total: 26, period: 60 },
22-
g: { value: new TextEncoder().encode('stu'), total: 26, period: 70 },
23-
h: { value: new TextEncoder().encode('vwx'), total: 26, period: 80 },
24-
i: { value: new TextEncoder().encode('yz'), total: 26, period: 90 }
16+
a: { bytes: new TextEncoder().encode('abc'), total: 26 },
17+
b: { bytes: new TextEncoder().encode('def'), total: 26 },
18+
c: { bytes: new TextEncoder().encode('ghi'), total: 26 },
19+
d: { bytes: new TextEncoder().encode('jkl'), total: 26 },
20+
e: { bytes: new TextEncoder().encode('mno'), total: 26 },
21+
f: { bytes: new TextEncoder().encode('pqr'), total: 26 },
22+
g: { bytes: new TextEncoder().encode('stu'), total: 26 },
23+
h: { bytes: new TextEncoder().encode('vwx'), total: 26 },
24+
i: { bytes: new TextEncoder().encode('yz'), total: 26 }
2525
};
2626

2727
const expectedVal = {

packages/operators/src/transfer/stats/TimeEstimate.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ const calcTimeEstimate = timeRatio => {
2727
return source =>
2828
source.pipe(
2929
switchMap(stats => {
30-
let noEstimation = stats.value === stats.total ? EMPTY : of(Infinity).pipe(delay(500));
30+
let noEstimation = stats.length === stats.total ? EMPTY : of(Infinity).pipe(delay(500));
3131
return concat(calcEstimation(stats, timeRatio), noEstimation);
3232
})
3333
);
3434
};
3535

3636
const calcEstimation = (stats, timeRatio) => {
3737
return of(stats).pipe(
38-
map(({ value, total, period }) => Math.ceil((total - value) * (period / value)) / timeRatio)
38+
map(({ length, total, time }) => Math.ceil((total - length) * (time / length)) / timeRatio)
3939
);
4040
};

packages/operators/src/transfer/stats/TimeEstimate.test.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ describe('TimeEstimate', () => {
2222
const time = Date.now();
2323

2424
const triggerVal = {
25-
a: { value: new TextEncoder().encode('abcd'), total: 20, period: time },
26-
b: { value: new TextEncoder().encode('edgh'), total: 20, period: time },
27-
c: { value: new TextEncoder().encode('ijkl'), total: 20, period: time },
28-
d: { value: new TextEncoder().encode('mnop'), total: 20, period: time },
29-
e: { value: new TextEncoder().encode('qrst'), total: 20, period: time }
25+
a: { bytes: new TextEncoder().encode('abcd'), total: 20, time },
26+
b: { bytes: new TextEncoder().encode('edgh'), total: 20, time },
27+
c: { bytes: new TextEncoder().encode('ijkl'), total: 20, time },
28+
d: { bytes: new TextEncoder().encode('mnop'), total: 20, time },
29+
e: { bytes: new TextEncoder().encode('qrst'), total: 20, time }
3030
};
3131

3232
const expectedVal = {
@@ -49,11 +49,11 @@ describe('TimeEstimate', () => {
4949
const time = Date.now();
5050

5151
const triggerVal = {
52-
a: { value: new TextEncoder().encode('abcd'), total: 20, period: time },
53-
b: { value: new TextEncoder().encode('edgh'), total: 20, period: time },
54-
c: { value: new TextEncoder().encode('ijkl'), total: 20, period: time },
55-
d: { value: new TextEncoder().encode('mnop'), total: 20, period: time },
56-
e: { value: new TextEncoder().encode('qrst'), total: 20, period: time }
52+
a: { bytes: new TextEncoder().encode('abcd'), total: 20, time },
53+
b: { bytes: new TextEncoder().encode('edgh'), total: 20, time },
54+
c: { bytes: new TextEncoder().encode('ijkl'), total: 20, time },
55+
d: { bytes: new TextEncoder().encode('mnop'), total: 20, time },
56+
e: { bytes: new TextEncoder().encode('qrst'), total: 20, time }
5757
};
5858

5959
const expectedVal = {
@@ -76,11 +76,11 @@ describe('TimeEstimate', () => {
7676
const time = Date.now();
7777

7878
const triggerVal = {
79-
a: { value: new TextEncoder().encode('abcd'), total: 20, period: time },
80-
b: { value: new TextEncoder().encode('edgh'), total: 20, period: time },
81-
c: { value: new TextEncoder().encode('ijkl'), total: 20, period: time },
82-
d: { value: new TextEncoder().encode('mnop'), total: 20, period: time },
83-
e: { value: new TextEncoder().encode('qrst'), total: 20, period: time }
79+
a: { bytes: new TextEncoder().encode('abcd'), total: 20, time },
80+
b: { bytes: new TextEncoder().encode('edgh'), total: 20, time },
81+
c: { bytes: new TextEncoder().encode('ijkl'), total: 20, time },
82+
d: { bytes: new TextEncoder().encode('mnop'), total: 20, time },
83+
e: { bytes: new TextEncoder().encode('qrst'), total: 20, time }
8484
};
8585

8686
const expectedVal = {

packages/operators/src/transfer/stats/utils.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,14 @@ export const calcReceivedStats = () => {
1616
return source =>
1717
source.pipe(
1818
scan(
19-
(acc, { value, total, period }) => ({
20-
value: acc.value + value.byteLength,
21-
total,
22-
period: Date.now() - period
23-
}),
24-
{ value: 0, total: 0, period: 0 }
19+
(acc, { bytes, total, time }) => {
20+
return {
21+
length: acc.length + bytes.byteLength,
22+
total,
23+
time: Date.now() - time
24+
};
25+
},
26+
{ length: 0, total: 0, time: 0 }
2527
)
2628
);
2729
};

0 commit comments

Comments
 (0)