2023-04-04 06:05:47 +03:00
|
|
|
export function _async_generator_delegate(inner, awaitWrap) {
|
2023-03-31 09:15:21 +03:00
|
|
|
var iter = {}, waiting = false;
|
2023-04-04 06:05:47 +03:00
|
|
|
|
2023-03-31 09:15:21 +03:00
|
|
|
function pump(key, value) {
|
|
|
|
waiting = true;
|
|
|
|
value = new Promise(function(resolve) {
|
|
|
|
resolve(inner[key](value));
|
|
|
|
});
|
2023-04-04 06:05:47 +03:00
|
|
|
|
2023-03-31 09:15:21 +03:00
|
|
|
return { done: false, value: awaitWrap(value) };
|
2021-12-05 09:46:09 +03:00
|
|
|
}
|
2023-04-04 06:05:47 +03:00
|
|
|
|
2023-03-31 09:15:21 +03:00
|
|
|
if (typeof Symbol === "function" && Symbol.iterator) {
|
|
|
|
iter[Symbol.iterator] = function() {
|
|
|
|
return this;
|
|
|
|
};
|
|
|
|
}
|
2023-04-04 06:05:47 +03:00
|
|
|
|
2023-03-31 09:15:21 +03:00
|
|
|
iter.next = function(value) {
|
|
|
|
if (waiting) {
|
|
|
|
waiting = false;
|
2023-04-04 06:05:47 +03:00
|
|
|
|
2023-03-31 09:15:21 +03:00
|
|
|
return value;
|
|
|
|
}
|
2023-04-04 06:05:47 +03:00
|
|
|
|
2023-03-31 09:15:21 +03:00
|
|
|
return pump("next", value);
|
2021-12-05 09:46:09 +03:00
|
|
|
};
|
2023-04-04 06:05:47 +03:00
|
|
|
|
2023-03-31 09:15:21 +03:00
|
|
|
if (typeof inner.throw === "function") {
|
|
|
|
iter.throw = function(value) {
|
|
|
|
if (waiting) {
|
|
|
|
waiting = false;
|
|
|
|
throw value;
|
|
|
|
}
|
2023-04-04 06:05:47 +03:00
|
|
|
|
2023-03-31 09:15:21 +03:00
|
|
|
return pump("throw", value);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
if (typeof inner.return === "function") {
|
|
|
|
iter.return = function(value) {
|
|
|
|
return pump("return", value);
|
|
|
|
};
|
|
|
|
}
|
2023-04-04 06:05:47 +03:00
|
|
|
|
2023-03-31 09:15:21 +03:00
|
|
|
return iter;
|
2021-12-05 09:46:09 +03:00
|
|
|
}
|
2023-04-04 06:05:47 +03:00
|
|
|
export { _async_generator_delegate as _ };
|