MCPcopy Create free account
hub / github.com/Effect-TS/effect / fileContentLength

Function fileContentLength

packages/effect/src/unstable/http/HttpBody.ts:487–498  ·  view source on GitHub ↗
(
  size: FileSystem.SizeInput,
  options?: {
    readonly bytesToRead?: FileSystem.SizeInput | undefined
    readonly offset?: FileSystem.SizeInput | undefined
  }
)

Source from the content-addressed store, hash-verified

485): Stream => new Stream(body, contentType ?? "application/octet-stream", contentLength)
486
487const fileContentLength = (
488 size: FileSystem.SizeInput,
489 options?: {
490 readonly bytesToRead?: FileSystem.SizeInput | undefined
491 readonly offset?: FileSystem.SizeInput | undefined
492 }
493): number => {
494 const available = Math.max(0, Number(size) - Number(options?.offset ?? 0))
495 return options?.bytesToRead === undefined
496 ? available
497 : Math.min(available, Math.max(0, Number(options.bytesToRead)))
498}
499
500/**
501 * Creates a streaming HTTP body for a file path.

Callers 2

fileFunction · 0.85
fileFromInfoFunction · 0.85

Calls 1

NumberInterface · 0.50

Tested by

no test coverage detected