responseMessage.js 455 B

12345678910111213141516171819
  1. export async function toArrayAsync(it) {
  2. const arr = [];
  3. for await (const o of it) {
  4. arr.push(o);
  5. }
  6. return arr;
  7. }
  8. export async function takeResult(it) {
  9. for await (const o of it) {
  10. if (o.type === 'result') {
  11. return o.result;
  12. }
  13. else if (o.type === 'error') {
  14. throw o.error;
  15. }
  16. }
  17. throw new Error('No result in stream.');
  18. }
  19. //# sourceMappingURL=responseMessage.js.map