MCPcopy Index your code
hub / github.com/ChinaSiro/claude-code-sourcemap / XI7

Function XI7

package/cli.js:218–223  ·  view source on GitHub ↗
(q,K,_,z,Y,$,A,O)

Source from the content-addressed store, hash-verified

216`;if(Array.isArray(j))for(let D=0;D<j.length;D+=2){let f=j[D+0],G=j[D+1];if(Array.isArray(G))for(let Z=0;Z<G.length;Z++)W+=`${f}: ${G[Z]}\r
217`;else W+=`${f}: ${G}\r
218`}if(jI7.sendHeaders.hasSubscribers)jI7.sendHeaders.publish({request:K,headers:W,socket:X});if(!w||M===0)XI7(P,null,q,K,X,H,W,J);else if(K9.isBuffer(w))XI7(P,w,q,K,X,H,W,J);else if(K9.isBlobLike(w))if(typeof w.stream==="function")PI7(P,w.stream(),q,K,X,H,W,J);else oI5(P,w,q,K,X,H,W,J);else if(K9.isStream(w))rI5(P,w,q,K,X,H,W,J);else if(K9.isIterable(w))PI7(P,w,q,K,X,H,W,J);else z3(!1);return!0}function rI5(q,K,_,z,Y,$,A,O){z3($!==0||_[gZ]===0,"stream body cannot be pipelined");let w=!1,j=new V51({abort:q,socket:Y,request:z,contentLength:$,client:_,expectsPayload:O,header:A}),H=function(P){if(w)return;try{if(!j.write(P)&&this.pause)this.pause()}catch(W){K9.destroy(this,W)}},J=function(){if(w)return;if(K.resume)K.resume()},M=function(){if(queueMicrotask(()=>{K.removeListener("error",X)}),!w){let P=new WI7;queueMicrotask(()=>X(P))}},X=function(P){if(w)return;if(w=!0,z3(Y.destroyed||Y[re]&&_[gZ]<=1),Y.off("drain",J).off("error",X),K.removeListener("data",H).removeListener("end",X).removeListener("close",M),!P)try{j.end()}catch(W){P=W}if(j.destroy(P),P&&(P.code!=="UND_ERR_INFO"||P.message!=="reset"))K9.destroy(K,P);else K9.destroy(K)};if(K.on("data",H).on("end",X).on("error",X).on("close",M),K.resume)K.resume();if(Y.on("drain",J).on("error",X),K.errorEmitted??K.errored)setImmediate(()=>X(K.errored));else if(K.endEmitted??K.readableEnded)setImmediate(()=>X(null));if(K.closeEmitted??K.closed)setImmediate(M)}function XI7(q,K,_,z,Y,$,A,O){try{if(!K)if($===0)Y.write(`${A}content-length: 0\r
219\r
220`,"latin1");else z3($===null,"no body must not have content length"),Y.write(`${A}\r
221`,"latin1");else if(K9.isBuffer(K)){if(z3($===K.byteLength,"buffer body must have content length"),Y.cork(),Y.write(`${A}content-length: ${$}\r
222\r
223`,"latin1"),Y.write(K),Y.uncork(),z.onBodySent(K),!O&&z.reset!==!1)Y[ek]=!0}z.onRequestSent(),_[ie]()}catch(w){q(w)}}async function oI5(q,K,_,z,Y,$,A,O){z3($===K.size,"blob body must have content length");try{if($!=null&&$!==K.size)throw new S_6;let w=Buffer.from(await K.arrayBuffer());if(Y.cork(),Y.write(`${A}content-length: ${$}\r
224\r
225`,"latin1"),Y.write(w),Y.uncork(),z.onBodySent(w),z.onRequestSent(),!O&&z.reset!==!1)Y[ek]=!0;_[ie]()}catch(w){q(w)}}async function PI7(q,K,_,z,Y,$,A,O){z3($!==0||_[gZ]===0,"iterator body cannot be pipelined");let w=null;function j(){if(w){let M=w;w=null,M()}}let H=()=>new Promise((M,X)=>{if(z3(w===null),Y[yh])X(Y[yh]);else w=M});Y.on("close",j).on("drain",j);let J=new V51({abort:q,socket:Y,request:z,contentLength:$,client:_,expectsPayload:O,header:A});try{for await(let M of K){if(Y[yh])throw Y[yh];if(!J.write(M))await H()}J.end()}catch(M){J.destroy(M)}finally{Y.off("close",j).off("drain",j)}}class V51{constructor({abort:q,socket:K,request:_,contentLength:z,client:Y,expectsPayload:$,header:A}){this.socket=K,this.request=_,this.contentLength=z,this.client=Y,this.bytesWritten=0,this.expectsPayload=$,this.header=A,this.abort=q,K[re]=!0}write(q){let{socket:K,request:_,contentLength:z,client:Y,bytesWritten:$,expectsPayload:A,header:O}=this;if(K[yh])throw K[yh];if(K.destroyed)return!1;let w=Buffer.byteLength(q);if(!w)return!0;if(z!==null&&$+w>z){if(Y[T51])throw new S_6;process.emitWarning(new S_6)}if(K.cork(),$===0){if(!A&&_.reset!==!1)K[ek]=!0;if(z===null)K.write(`${O}transfer-encoding: chunked\r
226`,"latin1");else K.write(`${O}content-length: ${z}\r

Callers 1

iI5Function · 0.85

Calls 4

qFunction · 0.70
writeMethod · 0.45
onBodySentMethod · 0.45
onRequestSentMethod · 0.45

Tested by

no test coverage detected