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

Function fromReadableChannel

packages/platform/node-shared/src/NodeStream.ts:83–106  ·  view source on GitHub ↗
(options: {
  readonly evaluate: LazyArg<Readable | NodeJS.ReadableStream>
  readonly onError?: (error: unknown) => E
  /**
   * Maximum number of Node reads per pull (default 4096). Set to Infinity
   * for unbounded batching. Does not control the size of each Node read.
   */
  readonly chunkSize?: number | undefined
  /**
   * Size passed to Node's `read(size)`. Omit to use Node's unsized reads.
   */
  readonly readSize?: number | undefined
  readonly closeOnDone?: boolean | undefined
})

Source from the content-addressed store, hash-verified

81 * @since 4.0.0
82 */
83export const fromReadableChannel = <A = Uint8Array, E = Cause.UnknownError>(options: {
84 readonly evaluate: LazyArg<Readable | NodeJS.ReadableStream>
85 readonly onError?: (error: unknown) => E
86 /**
87 * Maximum number of Node reads per pull (default 4096). Set to Infinity
88 * for unbounded batching. Does not control the size of each Node read.
89 */
90 readonly chunkSize?: number | undefined
91 /**
92 * Size passed to Node's `read(size)`. Omit to use Node's unsized reads.
93 */
94 readonly readSize?: number | undefined
95 readonly closeOnDone?: boolean | undefined
96}): Channel.Channel<Arr.NonEmptyReadonlyArray<A>, E> =>
97 Channel.fromTransform((_, scope) =>
98 readableToPullUnsafe({
99 scope,
100 readable: options.evaluate(),
101 onError: options.onError ?? defaultOnError as any,
102 chunkSize: options.chunkSize,
103 readSize: options.readSize,
104 closeOnDone: options.closeOnDone
105 })
106 )
107
108/**
109 * Creates a `Channel` over a Node `Duplex`, writing upstream chunks with

Callers 1

fromReadableFunction · 0.85

Calls 2

readableToPullUnsafeFunction · 0.85
evaluateMethod · 0.65

Tested by

no test coverage detected