UNPKG

@attack-monkey/impure

Version:

A light-weight wrapper for managing impure code

9 lines (6 loc) 216 B
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)) }