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

Method write

package/cli.js:225–230  ·  view source on GitHub ↗
(q)

Source from the content-addressed store, hash-verified

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
227\r
228`,"latin1")}if(z===null)K.write(`\r
229${w.toString(16)}\r
230`,"latin1");this.bytesWritten+=w;let j=K.write(q);if(K.uncork(),_.onBodySent(q),!j){if(K[OJ].timeout&&K[OJ].timeoutType===pD6){if(K[OJ].timeout.refresh)K[OJ].timeout.refresh()}}return j}end(){let{socket:q,contentLength:K,client:_,bytesWritten:z,expectsPayload:Y,header:$,request:A}=this;if(A.onRequestSent(),q[re]=!1,q[yh])throw q[yh];if(q.destroyed)return;if(z===0)if(Y)q.write(`${$}content-length: 0\r
231\r
232`,"latin1");else q.write(`${$}\r
233`,"latin1");else if(K===null)q.write(`\r

Callers 1

PI7Function · 0.95

Calls 4

toStringMethod · 0.65
writeMethod · 0.45
onBodySentMethod · 0.45
refreshMethod · 0.45

Tested by

no test coverage detected