Last change
on this file since 188ee53 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
887 bytes
|
Line | |
---|
1 | function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
---|
2 | try {
|
---|
3 | var info = gen[key](arg);
|
---|
4 | var value = info.value;
|
---|
5 | } catch (error) {
|
---|
6 | reject(error);
|
---|
7 | return;
|
---|
8 | }
|
---|
9 |
|
---|
10 | if (info.done) {
|
---|
11 | resolve(value);
|
---|
12 | } else {
|
---|
13 | Promise.resolve(value).then(_next, _throw);
|
---|
14 | }
|
---|
15 | }
|
---|
16 |
|
---|
17 | function _asyncToGenerator(fn) {
|
---|
18 | return function () {
|
---|
19 | var self = this,
|
---|
20 | args = arguments;
|
---|
21 | return new Promise(function (resolve, reject) {
|
---|
22 | var gen = fn.apply(self, args);
|
---|
23 |
|
---|
24 | function _next(value) {
|
---|
25 | asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
---|
26 | }
|
---|
27 |
|
---|
28 | function _throw(err) {
|
---|
29 | asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
---|
30 | }
|
---|
31 |
|
---|
32 | _next(undefined);
|
---|
33 | });
|
---|
34 | };
|
---|
35 | }
|
---|
36 |
|
---|
37 | module.exports = _asyncToGenerator;
|
---|
38 | module.exports["default"] = module.exports, module.exports.__esModule = true; |
---|
Note:
See
TracBrowser
for help on using the repository browser.