Fix errors
This commit is contained in:
@@ -4,14 +4,14 @@ import { Data, Effect, pipe, Schema } from "effect";
|
||||
export class CborDecodeError extends Data.TaggedError("CborDecodeError")<{ cause: unknown }> { }
|
||||
export class CborEncodeError extends Data.TaggedError("CborEncodeError")<{ cause: unknown }> { }
|
||||
|
||||
export function encode(u: unknown): Effect.Effect<Uint8Array, CborEncodeError> {
|
||||
export function encode(u: unknown): Effect.Effect<Uint8Array<ArrayBuffer>, CborEncodeError> {
|
||||
return Effect.try({
|
||||
try: () => cbor.encode(u),
|
||||
try: () => cbor.encode(u) as Uint8Array<ArrayBuffer>,
|
||||
catch: (cause) => new CborEncodeError({ cause }),
|
||||
});
|
||||
}
|
||||
|
||||
export function decode(u: Uint8Array): Effect.Effect<unknown, CborDecodeError> {
|
||||
export function decode(u: Uint8Array<ArrayBuffer>): Effect.Effect<unknown, CborDecodeError> {
|
||||
return Effect.try({
|
||||
try: () => cbor.decode(u),
|
||||
catch: (cause) => new CborDecodeError({ cause }),
|
||||
@@ -28,7 +28,7 @@ export const encodeSchema = <A, I>(schema: Schema.Schema<A, I>) => {
|
||||
|
||||
export const decodeSchema = <A>(schema: Schema.Schema<A, any>) => {
|
||||
const schemaDecoder = Schema.decodeUnknown(schema);
|
||||
return (u: Uint8Array) => pipe(
|
||||
return (u: Uint8Array<ArrayBuffer>) => pipe(
|
||||
decode(u),
|
||||
Effect.flatMap((u) => schemaDecoder(u)),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user