efront 3.35.2 → 3.35.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/coms/basic_/#checkPromise.js +1 -1
- package/coms/basic_/Promise.js +29 -22
- package/package.json +1 -1
- package/public/efront.js +1 -1
package/coms/basic_/Promise.js
CHANGED
|
@@ -2,6 +2,7 @@ var window = this;
|
|
|
2
2
|
var Array = window.Array;
|
|
3
3
|
var setTimeout = window.setTimeout;
|
|
4
4
|
var Function = window.Function;
|
|
5
|
+
var Object = window.Object;
|
|
5
6
|
var console = window.console;
|
|
6
7
|
var navigator = window.navigator;
|
|
7
8
|
var requestAnimationFrame = window.setImmediate || window.setTimeout;
|
|
@@ -15,33 +16,40 @@ if (!Promise) {
|
|
|
15
16
|
return pendding instanceof Promise || pendding && isFunction(pendding.then);
|
|
16
17
|
};
|
|
17
18
|
var queue = [];
|
|
19
|
+
var running = false;
|
|
18
20
|
var run = function (q) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
console.warn("在异步过程中发现未处理的异常:", t.ohed[0], t.ohed[1], t.ohed[2]);
|
|
32
|
-
// -->
|
|
33
|
-
throw t.ohed[0];
|
|
21
|
+
running = true;
|
|
22
|
+
while (queue.length) {
|
|
23
|
+
var threads = queue.splice(0, queue.length);
|
|
24
|
+
for (var t of threads) {
|
|
25
|
+
if (!t.oked && !t.ohed) continue;
|
|
26
|
+
var PromiseRejectReactions = t.PromiseRejectReactions.splice(0, t.PromiseRejectReactions.length);
|
|
27
|
+
var PromiseFulfillReactions = t.PromiseFulfillReactions.splice(0, t.PromiseFulfillReactions.length);
|
|
28
|
+
|
|
29
|
+
if (t.oked) {
|
|
30
|
+
for (var r of PromiseFulfillReactions) {
|
|
31
|
+
r.call(null, t.oked[0]);
|
|
32
|
+
}
|
|
34
33
|
}
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
if (t.ohed) {
|
|
35
|
+
var throwed = t.throwed;
|
|
36
|
+
t.throwed = true;
|
|
37
|
+
if (!throwed && PromiseRejectReactions.length) {
|
|
38
|
+
// <!--
|
|
39
|
+
console.warn("在异步过程中发现未处理的异常:", t.ohed[0], t.ohed[1], t.ohed[2]);
|
|
40
|
+
// -->
|
|
41
|
+
throw t.ohed[0];
|
|
42
|
+
}
|
|
43
|
+
for (var r of PromiseRejectReactions) {
|
|
44
|
+
r.apply(null, t.ohed);
|
|
45
|
+
}
|
|
37
46
|
}
|
|
38
47
|
}
|
|
39
|
-
t.PromiseRejectReactions.splice(0, t.PromiseRejectReactions.length);
|
|
40
|
-
t.PromiseFulfillReactions.splice(0, t.PromiseFulfillReactions.length);
|
|
41
48
|
}
|
|
49
|
+
running = false;
|
|
42
50
|
};
|
|
43
51
|
var fire = function (p) {
|
|
44
|
-
if (
|
|
52
|
+
if (running) return queue.push(p);
|
|
45
53
|
queue.push(p);
|
|
46
54
|
requestAnimationFrame(run);
|
|
47
55
|
};
|
|
@@ -59,12 +67,12 @@ if (!Promise) {
|
|
|
59
67
|
fire(p);
|
|
60
68
|
}
|
|
61
69
|
};
|
|
62
|
-
|
|
63
70
|
var ResolvingFunctions_reject = function (e) { //oh
|
|
64
71
|
if (p.oked || p.ohed) return;
|
|
65
72
|
p.ohed = arguments;
|
|
66
73
|
fire(p);
|
|
67
74
|
};
|
|
75
|
+
fire(p);
|
|
68
76
|
executor(ResolvingFunctions_resolve, ResolvingFunctions_reject);
|
|
69
77
|
};
|
|
70
78
|
Promise.prototype = {
|
|
@@ -147,5 +155,4 @@ if (!Promise) {
|
|
|
147
155
|
ok.apply(null, args);
|
|
148
156
|
});
|
|
149
157
|
};
|
|
150
|
-
|
|
151
158
|
}
|