MCPcopy
hub / github.com/Effect-TS/effect / pack

Function pack

packages/platform/src/MsgPack.ts:54–82  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

52 * @category constructors
53 */
54export const pack = <IE = never, Done = unknown>(): Channel.Channel<
55 Chunk.Chunk<Uint8Array>,
56 Chunk.Chunk<unknown>,
57 IE | MsgPackError,
58 IE,
59 Done,
60 Done
61> =>
62 Channel.suspend(() => {
63 const packr = new Packr()
64 const loop: Channel.Channel<Chunk.Chunk<Uint8Array>, Chunk.Chunk<unknown>, IE | MsgPackError, IE, Done, Done> =
65 Channel
66 .readWithCause({
67 onInput: (input) =>
68 Channel.zipRight(
69 Channel.flatMap(
70 Effect.try({
71 try: () => Chunk.of(packr.pack(Chunk.toReadonlyArray(input))),
72 catch: (cause) => new MsgPackError({ reason: "Pack", cause })
73 }),
74 Channel.write
75 ),
76 loop
77 ),
78 onFailure: (cause) => Channel.failCause(cause),
79 onDone: Channel.succeed
80 })
81 return loop
82 })
83
84/**
85 * @since 1.0.0

Callers 2

packSchemaFunction · 0.70
duplexFunction · 0.70

Calls 2

failCauseMethod · 0.80
ofMethod · 0.65

Tested by

no test coverage detected