* Tap the return value of the effected program. * @param handler The function to tap the return value. * @returns * * @since 0.2.1
(
handler: (value: R) => void | Generator<F, void, unknown> | Effected<F, void>,
)
| 967 | * @since 0.2.1 |
| 968 | */ |
| 969 | tap<F extends Effect = never>( |
| 970 | handler: (value: R) => void | Generator<F, void, unknown> | Effected<F, void>, |
| 971 | ): Effected<E | F, R> { |
| 972 | return this.andThen((value) => { |
| 973 | const it = handler(value); |
| 974 | if (!(it instanceof Effected) && !isGenerator(it)) return value; |
| 975 | const iterator = it[Symbol.iterator](); |
| 976 | return { |
| 977 | _effectedIterator: true, |
| 978 | next: (...args: [] | [unknown]) => { |
| 979 | const result = iterator.next(...args); |
| 980 | if (result.done) return { done: true, value }; |
| 981 | return result; |
| 982 | }, |
| 983 | }; |
| 984 | }) as never; |
| 985 | } |
| 986 | |
| 987 | /** |
| 988 | * Combines the return value of the current effected program with another effected program. |
nothing calls this directly
no test coverage detected