responseMessage.js 588 B

1234567891011121314151617181920212223
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.toArrayAsync = toArrayAsync;
  4. exports.takeResult = takeResult;
  5. async function toArrayAsync(it) {
  6. const arr = [];
  7. for await (const o of it) {
  8. arr.push(o);
  9. }
  10. return arr;
  11. }
  12. async function takeResult(it) {
  13. for await (const o of it) {
  14. if (o.type === 'result') {
  15. return o.result;
  16. }
  17. else if (o.type === 'error') {
  18. throw o.error;
  19. }
  20. }
  21. throw new Error('No result in stream.');
  22. }
  23. //# sourceMappingURL=responseMessage.js.map