0
0
mirror of https://github.com/Doodle3D/Doodle3D-API synced 2024-12-23 22:13:48 +01:00
Doodle3D-API/jspm_packages/npm/babel-runtime@5.6.20/helpers/async-to-generator.js

29 lines
727 B
JavaScript
Raw Normal View History

2015-07-15 15:06:18 +02:00
/* */
"use strict";
var _Promise = require("../core-js/promise")["default"];
exports["default"] = function(fn) {
return function() {
var gen = fn.apply(this, arguments);
return new _Promise(function(resolve, reject) {
var callNext = step.bind(null, "next");
var callThrow = step.bind(null, "throw");
function step(key, arg) {
try {
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return ;
}
if (info.done) {
resolve(value);
} else {
_Promise.resolve(value).then(callNext, callThrow);
}
}
callNext();
});
};
};
exports.__esModule = true;