diff --git a/src/index.ts b/src/index.ts index e6729613..bf2a9aac 100644 --- a/src/index.ts +++ b/src/index.ts @@ -28,3 +28,10 @@ export const makeNonOptional = (f: (o: Optional) => unknown) => (v: T) => f(Optional.of(v)); + +/** + * Take function that returns a value and make that return an Optional + */ +export const asOptional = (f: (...args: A) => R) => { + return (...args: A) => Optional.of(f(...args)) +} \ No newline at end of file