Skip to content

Commit 949360b

Browse files
committed
feat(fio): add FIO.ap static function
1 parent 766e356 commit 949360b

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/main/FIO.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,16 @@ export class FIO<E1 = unknown, A1 = unknown, R1 = NoEnv> {
100100
return new FIO(Tag.Access, cb)
101101
}
102102

103+
/**
104+
* Converts a [[FIO]] of a function into a [[FIO]] of a value.
105+
*/
106+
public static ap<E1, A1, R1, A2>(
107+
fio: FIO<E1, (a: A1) => A2, R1>,
108+
input: A1
109+
): FIO<E1, A2, R1> {
110+
return fio.map(ab => ab(input))
111+
}
112+
103113
/**
104114
* **NOTE:** The default type is set to `never` because it hard for typescript to infer the types based on how we use `res`.
105115
* Using `never` will give users compile time error always while using.

0 commit comments

Comments
 (0)