From c5417454df734df7182e64fc708067fb47b44f93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Valverd=C3=A9?= Date: Tue, 20 Aug 2024 05:47:09 +0200 Subject: [PATCH] makeJsonifiable --- src/Schema/index.ts | 1 + src/Schema/makeJsonifiable.ts | 13 +++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 src/Schema/makeJsonifiable.ts diff --git a/src/Schema/index.ts b/src/Schema/index.ts index 3d6c5f1..30da332 100644 --- a/src/Schema/index.ts +++ b/src/Schema/index.ts @@ -3,6 +3,7 @@ export * from "./DateTime" export * from "./encodedAsJsonValue" export * from "./Jsonifiable" export * from "./Kind" +export * from "./makeJsonifiable" export * as MobX from "./MobX" export * from "./MutableClass" export * from "./MutableTaggedClass" diff --git a/src/Schema/makeJsonifiable.ts b/src/Schema/makeJsonifiable.ts new file mode 100644 index 0000000..a436e41 --- /dev/null +++ b/src/Schema/makeJsonifiable.ts @@ -0,0 +1,13 @@ +import { Schema } from "@effect/schema" +import type { JsonValue } from "type-fest" + + +export const makeJsonifiable = < + JsonifiableA, + JsonifiableI extends JsonValue, + JsonifiableR, +>( + jsonifiable: Schema.Schema +) => + (schema: Schema.Schema) => + jsonifiable.pipe(Schema.compose(schema))