Skip to content

Commit

Permalink
feat(core): add composeU for union types
Browse files Browse the repository at this point in the history
  • Loading branch information
yarastqt committed May 24, 2019
1 parent f2ce2d3 commit e45bf1a
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions packages/core/core.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,34 @@ export function compose(...fns: Array<HOC<any>>): Composition<any>;
export function compose(...funcs: any[]) {
return funcs.reduce((a, b) => (...args: any[]) => a(b(...args)), (arg: any) => arg);
}

/* tslint:disable:max-line-length */
export function composeU<T1>(fn1: HOC<T1>): Composition<T1>;

export function composeU<T1, T2>(fn1: HOC<T1>, fn2: HOC<T2>):
Composition<T1 | T2>;

export function composeU<T1, T2, T3>(fn1: HOC<T1>, fn2: HOC<T2>, fn3: HOC<T3>):
Composition<T1 | T2 | T3>;

export function composeU<T1, T2, T3, T4>(fn1: HOC<T1>, fn2: HOC<T2>, fn3: HOC<T3>, fn4: HOC<T4>):
Composition<T1 | T2 | T3 | T4>;

export function composeU<T1, T2, T3, T4, T5>(fn1: HOC<T1>, fn2: HOC<T2>, fn3: HOC<T3>, fn4: HOC<T4>, fn5: HOC<T5>):
Composition<T1 | T2 | T3 | T4 | T5>;

export function composeU<T1, T2, T3, T4, T5, T6>(fn1: HOC<T1>, fn2: HOC<T2>, fn3: HOC<T3>, fn4: HOC<T4>, fn5: HOC<T5>, fn6: HOC<T6>):
Composition<T1 | T2 | T3 | T4 | T5 | T6>;

export function composeU<T1, T2, T3, T4, T5, T6, T7>(fn1: HOC<T1>, fn2: HOC<T2>, fn3: HOC<T3>, fn4: HOC<T4>, fn5: HOC<T5>, fn6: HOC<T6>, fn7: HOC<T7>):
Composition<T1 | T2 | T3 | T4 | T5 | T6 | T7>;

export function composeU<T1, T2, T3, T4, T5, T6, T7, T8>(fn1: HOC<T1>, fn2: HOC<T2>, fn3: HOC<T3>, fn4: HOC<T4>, fn5: HOC<T5>, fn6: HOC<T6>, fn7: HOC<T7>, fn8: HOC<T8>):
Composition<T1 | T2 | T3 | T4 | T5 | T6 | T7 | T8>;

export function composeU(...fns: Array<HOC<any>>): Composition<any>;
/* tslint:enable:max-line-length */

export function composeU(...args: any[]) {
return compose(...args);
}

0 comments on commit e45bf1a

Please sign in to comment.