You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.1 KiB
56 lines
1.1 KiB
2 years ago
|
function _asyncGeneratorDelegate(inner, awaitWrap) {
|
||
|
var iter = {},
|
||
|
waiting = false;
|
||
|
|
||
|
function pump(key, value) {
|
||
|
waiting = true;
|
||
|
value = new Promise(function (resolve) {
|
||
|
resolve(inner[key](value));
|
||
|
});
|
||
|
return {
|
||
|
done: false,
|
||
|
value: awaitWrap(value)
|
||
|
};
|
||
|
}
|
||
|
|
||
|
;
|
||
|
|
||
|
iter[typeof Symbol !== "undefined" && Symbol.iterator || "@@iterator"] = function () {
|
||
|
return this;
|
||
|
};
|
||
|
|
||
|
iter.next = function (value) {
|
||
|
if (waiting) {
|
||
|
waiting = false;
|
||
|
return value;
|
||
|
}
|
||
|
|
||
|
return pump("next", value);
|
||
|
};
|
||
|
|
||
|
if (typeof inner["throw"] === "function") {
|
||
|
iter["throw"] = function (value) {
|
||
|
if (waiting) {
|
||
|
waiting = false;
|
||
|
throw value;
|
||
|
}
|
||
|
|
||
|
return pump("throw", value);
|
||
|
};
|
||
|
}
|
||
|
|
||
|
if (typeof inner["return"] === "function") {
|
||
|
iter["return"] = function (value) {
|
||
|
if (waiting) {
|
||
|
waiting = false;
|
||
|
return value;
|
||
|
}
|
||
|
|
||
|
return pump("return", value);
|
||
|
};
|
||
|
}
|
||
|
|
||
|
return iter;
|
||
|
}
|
||
|
|
||
|
module.exports = _asyncGeneratorDelegate, module.exports.__esModule = true, module.exports["default"] = module.exports;
|