mirror of
https://github.com/anomalyco/opencode.git
synced 2026-07-17 12:56:41 +02:00
12 lines
326 B
TypeScript
12 lines
326 B
TypeScript
import { dual } from "effect/Function"
|
|
|
|
export namespace Optional {
|
|
export const map = dual<
|
|
<I, O>(f: (value: I) => O) => (opt: I | undefined) => O | undefined,
|
|
<I, O>(opt: I | undefined, f: (value: I) => O) => O | undefined
|
|
>(2, (opt, f) => {
|
|
if (opt === undefined) return undefined
|
|
return f(opt)
|
|
})
|
|
}
|