Skip to content

Commit

Permalink
feat(fio): add accessP() operator
Browse files Browse the repository at this point in the history
  • Loading branch information
tusharmath committed Sep 19, 2019
1 parent 73ee0f2 commit eab4d95
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/main/FIO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,15 @@ export class FIO<E1 = unknown, A1 = unknown, R1 = NoEnv> {
return FIO.flatten(FIO.access(cb))
}

/**
* Creates a new FIO instance with the provided environment by invoking a promise returning function.
*/
public static accessP<A1, R1>(
cb: (R: R1) => Promise<A1>
): FIO<Error, A1, R1> {
return FIO.env<R1>().chain(FIO.encaseP(cb))
}

/**
* Converts a [[FIO]] of a function into a [[FIO]] of a value.
*/
Expand Down

0 comments on commit eab4d95

Please sign in to comment.