Last change
on this file since e29cc2e was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1013 bytes
|
Line | |
---|
1 | export default 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 | } |
---|
Note:
See
TracBrowser
for help on using the repository browser.