MCPcopy Index your code
hub / github.com/tinyhttp/tinyhttp / writetop

Function writetop

packages/session/src/index.ts:397–423  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

395 }
396
397 function writetop() {
398 if (!sync) return ret
399
400 if (chunk == null) {
401 ret = true
402 return ret
403 }
404
405 const contentLength = Number(res.getHeader('Content-Length'))
406
407 if (!isNaN(contentLength) && contentLength > 0) {
408 // measure chunk
409 chunk = !Buffer.isBuffer(chunk) ? Buffer.from(chunk, encoding) : chunk
410 encoding = undefined
411
412 if (chunk.length !== 0) {
413 ret = _write.call(res, chunk.slice(0, chunk.length - 1), encoding)
414 chunk = chunk.slice(chunk.length - 1, chunk.length)
415 return ret
416 }
417 }
418
419 ret = _write.call(res, chunk, encoding)
420 sync = false
421
422 return ret
423 }
424
425 // no session to save
426 if (!session) return _end.call(res, chunk, encoding)

Callers 1

SessionManagerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected