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

Function stream

packages/platform/node/src/NodeMultipart.ts:36–53  ·  view source on GitHub ↗
(
  source: Readable,
  headers: IncomingHttpHeaders
)

Source from the content-addressed store, hash-verified

34 * @since 4.0.0
35 */
36export const stream = (
37 source: Readable,
38 headers: IncomingHttpHeaders
39): Stream.Stream<Multipart.Part, Multipart.MultipartError> =>
40 Multipart.makeConfig(headers as any).pipe(
41 Effect.map((config) =>
42 NodeStream.fromReadable<MP.Part, Multipart.MultipartError>({
43 evaluate() {
44 const parser = MP.make(config)
45 source.pipe(parser)
46 return parser as any
47 },
48 onError: (error) => convertError(error as any)
49 })
50 ),
51 Stream.unwrap,
52 Stream.map(convertPart)
53 )
54
55/**
56 * Parses multipart data from a Node readable request body and persists file

Callers 1

persistedFunction · 0.70

Calls 3

convertErrorFunction · 0.70
pipeMethod · 0.65
mapMethod · 0.45

Tested by

no test coverage detected