Skip to content

Commit

Permalink
Add typings for encaseN and refine typings for done
Browse files Browse the repository at this point in the history
  • Loading branch information
Avaq committed Jul 20, 2017
1 parent bf3c89c commit ca62610
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ declare module 'fluture' {
(): void
}

interface Nodeback<E, R> {
(err: E | null, value?: R): void
}

interface FutureConstructor {

<L, R>(computation: (
Expand Down Expand Up @@ -54,8 +58,8 @@ declare module 'fluture' {
export function chain<L, RA, RB>(mapper: (value: RA) => Future<L, RB>, source: Future<L, RA>): Future<L, RB>
export function chain<L, RA, RB>(mapper: (value: RA) => Future<L, RB>): (source: Future<L, RA>) => Future<L, RB>

export function done<L, R>(callback: (err: L | null, value: R | null) => void, source: Future<L, R>): Cancel
export function done<L, R>(callback: (err: L | null, value: R | null) => void): (source: Future<L, R>) => Cancel
export function done<L, R>(callback: Nodeback<L, R>, source: Future<L, R>): Cancel
export function done<L, R>(callback: Nodeback<L, R>): (source: Future<L, R>) => Cancel

export function encase<L, R, A>(fn: (a: A) => R, a: A): Future<L, R>
export function encase<L, R, A>(fn: (a: A) => R): {(a: A): Future<L, R>}
Expand All @@ -73,14 +77,21 @@ declare module 'fluture' {
export function encase3<L, R, A, B, C>(fn: (a: A, b: B, c: C) => R): (a: A) => (b: B, c: C) => Future<L, R>
export function encase3<L, R, A, B, C>(fn: (a: A, b: B, c: C) => R): (a: A) => (b: B) => (c: C) => Future<L, R>

// TODO: Need Help
export function encaseN<L, R>(): Future<L, R>

// TODO: Need Help
export function encaseN2<L, R>(): Future<L, R>

// TODO: Need Help
export function encaseN3<L, R>(): Future<L, R>
export function encaseN<L, R, A>(fn: (a: A, callback: Nodeback<L, R>) => void, a: A): Future<L, R>
export function encaseN<L, R, A>(fn: (a: A, callback: Nodeback<L, R>) => void): (a: A) => Future<L, R>

export function encaseN2<L, R, A, B>(fn: (a: A, b: B, callback: Nodeback<L, R>) => void, a: A, b: B): Future<L, R>
export function encaseN2<L, R, A, B>(fn: (a: A, b: B, callback: Nodeback<L, R>) => void, a: A): (b: B) => Future<L, R>
export function encaseN2<L, R, A, B>(fn: (a: A, b: B, callback: Nodeback<L, R>) => void): (a: A, b: B) => Future<L, R>
export function encaseN2<L, R, A, B>(fn: (a: A, b: B, callback: Nodeback<L, R>) => void): (a: A) => (b: B) => Future<L, R>

export function encaseN3<L, R, A, B, C>(fn: (a: A, b: B, c: C, callback: Nodeback<L, R>) => void, a: A, b: B, c: C): Future<L, R>
export function encaseN3<L, R, A, B, C>(fn: (a: A, b: B, c: C, callback: Nodeback<L, R>) => void, a: A, b: B): (c: C) => Future<L, R>
export function encaseN3<L, R, A, B, C>(fn: (a: A, b: B, c: C, callback: Nodeback<L, R>) => void, a: A): (b: B, c: C) => Future<L, R>
export function encaseN3<L, R, A, B, C>(fn: (a: A, b: B, c: C, callback: Nodeback<L, R>) => void, a: A): (b: B) => (c: C) => Future<L, R>
export function encaseN3<L, R, A, B, C>(fn: (a: A, b: B, c: C, callback: Nodeback<L, R>) => void): (a: A, b: B, c: C) => Future<L, R>
export function encaseN3<L, R, A, B, C>(fn: (a: A, b: B, c: C, callback: Nodeback<L, R>) => void): (a: A) => (b: B, c: C) => Future<L, R>
export function encaseN3<L, R, A, B, C>(fn: (a: A, b: B, c: C, callback: Nodeback<L, R>) => void): (a: A) => (b: B) => (c: C) => Future<L, R>

export function encaseP<L, R>(fn: () => Promise<R>): Future<L, R>

Expand Down

0 comments on commit ca62610

Please sign in to comment.