Last change
on this file since 1ad8e64 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.1 KB
|
Line | |
---|
1 | function _asyncGeneratorDelegate(inner, awaitWrap) {
|
---|
2 | var iter = {},
|
---|
3 | waiting = false;
|
---|
4 |
|
---|
5 | function pump(key, value) {
|
---|
6 | waiting = true;
|
---|
7 | value = new Promise(function (resolve) {
|
---|
8 | resolve(inner[key](value));
|
---|
9 | });
|
---|
10 | return {
|
---|
11 | done: false,
|
---|
12 | value: awaitWrap(value)
|
---|
13 | };
|
---|
14 | }
|
---|
15 |
|
---|
16 | ;
|
---|
17 |
|
---|
18 | iter[typeof Symbol !== "undefined" && Symbol.iterator || "@@iterator"] = function () {
|
---|
19 | return this;
|
---|
20 | };
|
---|
21 |
|
---|
22 | iter.next = function (value) {
|
---|
23 | if (waiting) {
|
---|
24 | waiting = false;
|
---|
25 | return value;
|
---|
26 | }
|
---|
27 |
|
---|
28 | return pump("next", value);
|
---|
29 | };
|
---|
30 |
|
---|
31 | if (typeof inner["throw"] === "function") {
|
---|
32 | iter["throw"] = function (value) {
|
---|
33 | if (waiting) {
|
---|
34 | waiting = false;
|
---|
35 | throw value;
|
---|
36 | }
|
---|
37 |
|
---|
38 | return pump("throw", value);
|
---|
39 | };
|
---|
40 | }
|
---|
41 |
|
---|
42 | if (typeof inner["return"] === "function") {
|
---|
43 | iter["return"] = function (value) {
|
---|
44 | if (waiting) {
|
---|
45 | waiting = false;
|
---|
46 | return value;
|
---|
47 | }
|
---|
48 |
|
---|
49 | return pump("return", value);
|
---|
50 | };
|
---|
51 | }
|
---|
52 |
|
---|
53 | return iter;
|
---|
54 | }
|
---|
55 |
|
---|
56 | module.exports = _asyncGeneratorDelegate;
|
---|
57 | module.exports["default"] = module.exports, module.exports.__esModule = true; |
---|
Note:
See
TracBrowser
for help on using the repository browser.