| 1 | import * as Optic from "../../Optic.ts" |
| 2 | import type * as Schema from "../../Schema.ts" |
| 3 | import * as SchemaParser from "../../SchemaParser.ts" |
| 4 | import * as InternalToCodec from "./toCodec.ts" |
| 5 | |
| 6 | /** @internal */ |
| 7 | export function toIso<S extends Schema.Constraint>(schema: S): Optic.Iso<S["Type"], S["Iso"]> { |
| 8 | const serializer = InternalToCodec.toCodecIso(schema) |
| 9 | return Optic.makeIso(SchemaParser.encodeSync(serializer), SchemaParser.decodeSync(serializer)) |
| 10 | } |
| 11 | |
| 12 | /** @internal */ |
| 13 | export function toIsoSource<S extends Schema.Constraint>(_: S): Optic.Iso<S["Type"], S["Type"]> { |
| 14 | return Optic.id() |
| 15 | } |
| 16 | |
| 17 | /** @internal */ |
| 18 | export function toIsoFocus<S extends Schema.Constraint>(_: S): Optic.Iso<S["Iso"], S["Iso"]> { |
| 19 | return Optic.id() |
| 20 | } |