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

Function bodyMixinMethods

github-actions/browserstack/set-browserstack-env.js:5791–5851  ·  view source on GitHub ↗
(instance)

Source from the content-addressed store, hash-verified

5789 length = object.size;
5790 if (object.type) {
5791 type = object.type;
5792 }
5793 } else if (typeof object[Symbol.asyncIterator] === "function") {
5794 if (keepalive) {
5795 throw new TypeError("keepalive");
5796 }
5797 if (util.isDisturbed(object) || object.locked) {
5798 throw new TypeError(
5799 "Response body object should not be disturbed or locked"
5800 );
5801 }
5802 stream = object instanceof ReadableStream ? object : ReadableStreamFrom(object);
5803 }
5804 if (typeof source === "string" || util.isBuffer(source)) {
5805 length = Buffer.byteLength(source);
5806 }
5807 if (action != null) {
5808 let _b;
5809 let iterator;
5810 stream = new ReadableStream({
5811 start() {
5812 return __async(this, null, function* () {
5813 iterator = action(object)[Symbol.asyncIterator]();
5814 });
5815 },
5816 pull(controller) {
5817 return __async(this, null, function* () {
5818 const { value, done } = yield iterator.next();
5819 if (done) {
5820 queueMicrotask(() => {
5821 var _a;
5822 controller.close();
5823 (_a = controller.byobRequest) == null ? void 0 : _a.respond(0);
5824 });
5825 } else {
5826 if (!isErrored(stream)) {
5827 const buffer = new Uint8Array(value);
5828 if (buffer.byteLength) {
5829 controller.enqueue(buffer);
5830 }
5831 }
5832 }
5833 return controller.desiredSize > 0;
5834 });
5835 },
5836 cancel(reason) {
5837 return __async(this, null, function* () {
5838 yield iterator.return();
5839 });
5840 },
5841 type: "bytes"
5842 });
5843 }
5844 const body = { stream, source, length };
5845 return [body, type];
5846 }
5847 function safelyExtractBody(object, keepalive = false) {
5848 if (object instanceof ReadableStream) {

Callers 1

mixinBodyFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected