MCPcopy Create free account
hub / github.com/angular/dev-infra / consume

Function consume

github-actions/browserstack/set-browserstack-env.js:9798–9836  ·  view source on GitHub ↗
(stream, type)

Source from the content-addressed store, hash-verified

9796 return util.isDisturbed(self) || isLocked(self);
9797 }
9798 function consume(stream, type) {
9799 return __async(this, null, function* () {
9800 assert(!stream[kConsume]);
9801 return new Promise((resolve2, reject) => {
9802 var _a;
9803 if (isUnusable(stream)) {
9804 const rState = stream._readableState;
9805 if (rState.destroyed && rState.closeEmitted === false) {
9806 stream.on("error", (err) => {
9807 reject(err);
9808 }).on("close", () => {
9809 reject(new TypeError("unusable"));
9810 });
9811 } else {
9812 reject((_a = rState.errored) != null ? _a : new TypeError("unusable"));
9813 }
9814 } else {
9815 queueMicrotask(() => {
9816 stream[kConsume] = {
9817 type,
9818 stream,
9819 resolve: resolve2,
9820 reject,
9821 length: 0,
9822 body: []
9823 };
9824 stream.on("error", function(err) {
9825 consumeFinish(this[kConsume], err);
9826 }).on("close", function() {
9827 if (this[kConsume].body !== null) {
9828 consumeFinish(this[kConsume], new RequestAbortedError());
9829 }
9830 });
9831 consumeStart(stream[kConsume]);
9832 });
9833 }
9834 });
9835 });
9836 }
9837 function consumeStart(consume2) {
9838 if (consume2.body === null) {
9839 return;

Callers 5

textMethod · 0.70
jsonMethod · 0.70
blobMethod · 0.70
bytesMethod · 0.70
arrayBufferMethod · 0.70

Calls 5

__asyncFunction · 0.70
isUnusableFunction · 0.70
consumeFinishFunction · 0.70
consumeStartFunction · 0.70
onMethod · 0.45

Tested by

no test coverage detected