MCPcopy
hub / github.com/di-sukharev/opencommit / extractBody

Function extractBody

out/cli.cjs:52112–52244  ·  view source on GitHub ↗
(object, keepalive = false)

Source from the content-addressed store, hash-verified

52110 random = (max) => crypto3.randomInt(0, max);
52111 } catch {
52112 random = (max) => Math.floor(Math.random(max));
52113 }
52114 var ReadableStream7 = globalThis.ReadableStream;
52115 var File5 = NativeFile ?? UndiciFile;
52116 var textEncoder2 = new TextEncoder();
52117 var textDecoder = new TextDecoder();
52118 function extractBody(object, keepalive = false) {
52119 if (!ReadableStream7) {
52120 ReadableStream7 = require("stream/web").ReadableStream;
52121 }
52122 let stream4 = null;
52123 if (object instanceof ReadableStream7) {
52124 stream4 = object;
52125 } else if (isBlobLike3(object)) {
52126 stream4 = object.stream();
52127 } else {
52128 stream4 = new ReadableStream7({
52129 async pull(controller) {
52130 controller.enqueue(
52131 typeof source === "string" ? textEncoder2.encode(source) : source
52132 );
52133 queueMicrotask(() => readableStreamClose(controller));
52134 },
52135 start() {
52136 },
52137 type: void 0
52138 });
52139 }
52140 assert2(isReadableStreamLike(stream4));
52141 let action = null;
52142 let source = null;
52143 let length = null;
52144 let type2 = null;
52145 if (typeof object === "string") {
52146 source = object;
52147 type2 = "text/plain;charset=UTF-8";
52148 } else if (object instanceof URLSearchParams) {
52149 source = object.toString();
52150 type2 = "application/x-www-form-urlencoded;charset=UTF-8";
52151 } else if (isArrayBuffer3(object)) {
52152 source = new Uint8Array(object.slice());
52153 } else if (ArrayBuffer.isView(object)) {
52154 source = new Uint8Array(object.buffer.slice(object.byteOffset, object.byteOffset + object.byteLength));
52155 } else if (util4.isFormDataLike(object)) {
52156 const boundary = `----formdata-undici-0${`${random(1e11)}`.padStart(11, "0")}`;
52157 const prefix = `--${boundary}\r
52158Content-Disposition: form-data`;
52159 const escape2 = (str2) => str2.replace(/\n/g, "%0A").replace(/\r/g, "%0D").replace(/"/g, "%22");
52160 const normalizeLinefeeds = (value) => value.replace(/\r?\n|\r/g, "\r\n");
52161 const blobParts = [];
52162 const rn = new Uint8Array([13, 10]);
52163 length = 0;
52164 let hasUnknownSizeValue = false;
52165 for (const [name, value] of object) {
52166 if (typeof value === "string") {
52167 const chunk2 = textEncoder2.encode(prefix + `; name="${escape2(normalizeLinefeeds(name))}"\r
52168\r
52169${normalizeLinefeeds(value)}\r

Callers 4

safelyExtractBodyFunction · 0.85
constructorMethod · 0.85
jsonMethod · 0.85
constructorMethod · 0.85

Calls 11

isBlobLike3Function · 0.85
isReadableStreamLikeFunction · 0.85
isArrayBuffer3Function · 0.85
escape2Function · 0.85
normalizeLinefeedsFunction · 0.85
ReadableStreamFromFunction · 0.85
encodeMethod · 0.80
streamMethod · 0.45
toStringMethod · 0.45
sliceMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…