From 974ea11b615872e6e3135025b19875b901babff1 Mon Sep 17 00:00:00 2001 From: Diogo Biazus Date: Wed, 15 Nov 2023 17:53:53 -0500 Subject: [PATCH] WIP - toComposable (todo: write some tests) --- src/constructor.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/constructor.ts b/src/constructor.ts index 5df639fd..8e762da3 100644 --- a/src/constructor.ts +++ b/src/constructor.ts @@ -5,7 +5,7 @@ import type { ParserSchema, SchemaError, } from './types.ts' -import { composable, Composable } from './composable/index.ts' +import { Composable, composable } from './composable/index.ts' function dfResultFromcomposable(fn: T) { return (async (...args) => { @@ -51,6 +51,12 @@ function makeDomainFunction( } } +function toComposable>(df: DF) { + return df as unknown as Composable< + (input: unknown, environment: unknown) => O + > +} + function fromComposable( fn: A, inputSchema?: ParserSchema, @@ -105,5 +111,5 @@ const undefinedSchema: ParserSchema = { }, } -export { dfResultFromcomposable, makeDomainFunction, makeDomainFunction as mdf } +export { dfResultFromcomposable, makeDomainFunction, makeDomainFunction as mdf, fromComposable, toComposable }