Skip to content

Commit

Permalink
WIP - toComposable (todo: write some tests)
Browse files Browse the repository at this point in the history
  • Loading branch information
diogob committed Nov 15, 2023
1 parent dd8e621 commit 974ea11
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/constructor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<T extends Composable, R>(fn: T) {
return (async (...args) => {
Expand Down Expand Up @@ -51,6 +51,12 @@ function makeDomainFunction<I, E>(
}
}

function toComposable<O, DF extends DomainFunction<O>>(df: DF) {
return df as unknown as Composable<
(input: unknown, environment: unknown) => O
>
}

function fromComposable<I, E, A extends Composable>(
fn: A,
inputSchema?: ParserSchema<I>,
Expand Down Expand Up @@ -105,5 +111,5 @@ const undefinedSchema: ParserSchema<undefined> = {
},
}

export { dfResultFromcomposable, makeDomainFunction, makeDomainFunction as mdf }
export { dfResultFromcomposable, makeDomainFunction, makeDomainFunction as mdf, fromComposable, toComposable }

0 comments on commit 974ea11

Please sign in to comment.