-
Notifications
You must be signed in to change notification settings - Fork 1
/
7.js
94 lines (94 loc) · 2.91 KB
/
7.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
"use strict";
(self.webpackJsonp = self.webpackJsonp || []).push([
[7],
{
235: function (e, s, t) {
t.d(s, "a", function () {
return h;
});
var i = t(128),
r = t(95),
o = t(61),
h = class {
constructor(e) {
(this.BT = new o.a()),
(this.BU = null),
(this.BV = null),
(this.BW = 0),
(this.endWithValue = (e) => {
this.BW++, this.BT.resolve(e);
}),
(this.BS = e);
}
resetTimeoutAfter(e) {
this.BV = Date.now() + e;
}
cancelReset() {
this.BV = null;
}
reset() {
this.BT.resolveWasCalled() ||
(__LOG__(2)`PromiseRetryLoop: resetting ${this.BS.name}`,
this.BW++,
this.BX());
}
start() {
this.BT.resolveWasCalled() ||
(__LOG__(2)`PromiseRetryLoop: starting ${this.BS.name}`,
0 !== this.BW &&
__LOG__(
4
)`PromiseRetryLoop was called several times. You may have race conditions`,
this.BW++,
this.BX());
}
BX() {
var e = this.BS,
s = this.BW,
t = (0, i.b)(this.BS.timer);
t();
var o = () => {
if (!this.BT.resolveWasCalled() && s === this.BW) {
var h = Date.now();
return (
(this.BU = (0, e.code)(this.endWithValue).then(() => {
if (!this.BT.resolveWasCalled()) {
var s = e.resetDelay;
((void 0 !== s && Date.now() >= h + s) ||
(null != this.BV && this.BV <= Date.now())) &&
(__LOG__(2)`PromiseRetryLoop: resetting ${e.name}`,
(t = (0, i.b)(this.BS.timer))),
(this.BV = null);
var a = t();
return (
__LOG__(
2
)`PromiseRetryLoop: retrying ${e.name} in ${a}ms`,
(0, r.a)(a).then(o)
);
}
})),
this.BU
);
}
};
this.BU = Promise.resolve().then(o);
}
promise() {
return this.BT.resolveWasCalled()
? this.BT.promise
: this.BU
? Promise.race([
this.BT.promise,
this.BU.then(() => this.BT.promise),
])
: Promise.reject(
new Error(
`PromiseRetryLoop ${this.BS.name} had promise() called before start()`
)
);
}
};
},
},
]);