MCPcopy Create free account
hub / github.com/WinterTC55/iter-streams / createReadable

Function createReadable

src/push.js:642–673  ·  view source on GitHub ↗

* Create the readable async iterable from a queue.

(queue)

Source from the content-addressed store, hash-verified

640 * Create the readable async iterable from a queue.
641 */
642function createReadable(queue) {
643 var _a;
644 return _a = {},
645 _a[Symbol.asyncIterator] = function () {
646 return {
647 next: function () {
648 return __awaiter(this, void 0, void 0, function () {
649 return __generator(this, function (_a) {
650 return [2 /*return*/, queue.read()];
651 });
652 });
653 },
654 return: function () {
655 return __awaiter(this, void 0, void 0, function () {
656 return __generator(this, function (_a) {
657 queue.consumerReturn();
658 return [2 /*return*/, { value: undefined, done: true }];
659 });
660 });
661 },
662 throw: function (error) {
663 return __awaiter(this, void 0, void 0, function () {
664 return __generator(this, function (_a) {
665 queue.consumerThrow(error);
666 return [2 /*return*/, { value: undefined, done: true }];
667 });
668 });
669 },
670 };
671 },
672 _a;
673}
674// =============================================================================
675// Stream.push() Factory
676// =============================================================================

Callers 1

pushFunction · 0.70

Calls 3

consumerReturnMethod · 0.80
consumerThrowMethod · 0.80
readMethod · 0.45

Tested by

no test coverage detected