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

Function fromArrayBuffer

packages/effect/src/unstable/httpapi/HttpApiClient.ts:1007–1032  ·  view source on GitHub ↗
(schema: Schema.Constraint)

Source from the content-addressed store, hash-verified

1005}
1006
1007function fromArrayBuffer(schema: Schema.Constraint): Schema.Top {
1008 const encoding = HttpApiSchema.getResponseEncoding(schema.ast)
1009 switch (encoding._tag) {
1010 case "Json": {
1011 // handle json codecs that transform void schemas to null
1012 const encodedIsNull = SchemaAST.isNull(SchemaAST.toEncoded(schema.ast))
1013 return encodedIsNull
1014 ? UnknownFromArrayBuffer.pipe(
1015 Schema.decodeTo(
1016 Schema.Unknown,
1017 SchemaTransformation.transform({
1018 decode: (a) => a === undefined ? null : a,
1019 encode: (a) => a === null ? undefined : a
1020 }) as any
1021 )
1022 )
1023 : UnknownFromArrayBuffer
1024 }
1025 case "FormUrlEncoded":
1026 return StringFromArrayBuffer.pipe(Schema.decodeTo(UrlParams.schemaRecord))
1027 case "Uint8Array":
1028 return Uint8ArrayFromArrayBuffer
1029 case "Text":
1030 return StringFromArrayBuffer
1031 }
1032}
1033
1034const statusOrElse = (response: HttpClientResponse.HttpClientResponse) =>
1035 Effect.fail(

Callers 2

onSchemaFunction · 0.85

Calls 2

pipeMethod · 0.65
transformMethod · 0.65

Tested by

no test coverage detected