Skip to content

Commit eab4d95

Browse files
committed
feat(fio): add accessP() operator
1 parent 73ee0f2 commit eab4d95

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/main/FIO.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,15 @@ export class FIO<E1 = unknown, A1 = unknown, R1 = NoEnv> {
130130
return FIO.flatten(FIO.access(cb))
131131
}
132132

133+
/**
134+
* Creates a new FIO instance with the provided environment by invoking a promise returning function.
135+
*/
136+
public static accessP<A1, R1>(
137+
cb: (R: R1) => Promise<A1>
138+
): FIO<Error, A1, R1> {
139+
return FIO.env<R1>().chain(FIO.encaseP(cb))
140+
}
141+
133142
/**
134143
* Converts a [[FIO]] of a function into a [[FIO]] of a value.
135144
*/

0 commit comments

Comments
 (0)