UNPKG
@attack-monkey/impure
Version:
latest (1.0.1)
1.0.1
1.0.0
A light-weight wrapper for managing impure code
github.com/attack-monkey/impure
attack-monkey/impure
@attack-monkey/impure
/
src
/
index.ts
9 lines
(6 loc)
•
216 B
text/typescript
View Raw
1
2
3
4
5
6
7
8
9
export
const
impure = <B>
(
fn1
: () => B
) =>
({
then
:
(
fn2
: (b: B) =>
any
) =>
{
fn2
(
fn1
()) } })
export
const
asyncImpure = <B>
(
fn
: (resolve: (b: B) =>
void
) =>
void
) =>
{
new
Promise
<B>(
resolve
=>
fn
(resolve)) }