Skip to content

Commit

Permalink
refactor(compose): update partial() type args, update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Mar 8, 2019
1 parent 9e4c171 commit 81886fe
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 36 deletions.
31 changes: 16 additions & 15 deletions packages/compose/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,26 @@ This project is part of the

<!-- TOC depthFrom:2 depthTo:3 -->

- [About](#about)
- [Installation](#installation)
- [Dependencies](#dependencies)
- [Usage examples](#usage-examples)
- [Authors](#authors)
- [License](#license)
- [About](#about)
- [Installation](#installation)
- [Dependencies](#dependencies)
- [Usage examples](#usage-examples)
- [Authors](#authors)
- [License](#license)

<!-- /TOC -->

## About

Functional composition helpers:

- [comp()](https://github.com/thi-ng/umbrella/tree/master/packages/compose/src/comp.ts)
- [compL()](https://github.com/thi-ng/umbrella/tree/master/packages/compose/src/comp.ts#L52)
- [juxt()](https://github.com/thi-ng/umbrella/tree/master/packages/compose/src/juxt.ts)
- [partial()](https://github.com/thi-ng/umbrella/tree/master/packages/compose/src/partial.ts)
- [threadFirst()](https://github.com/thi-ng/umbrella/tree/master/packages/compose/src/thread-first.ts)
- [threadLast()](https://github.com/thi-ng/umbrella/tree/master/packages/compose/src/thread-last.ts)
- [comp()](https://github.com/thi-ng/umbrella/tree/master/packages/compose/src/comp.ts)
- [compL()](https://github.com/thi-ng/umbrella/tree/master/packages/compose/src/comp.ts#L52)
- [juxt()](https://github.com/thi-ng/umbrella/tree/master/packages/compose/src/juxt.ts)
- [partial()](https://github.com/thi-ng/umbrella/tree/master/packages/compose/src/partial.ts)
- [threadFirst()](https://github.com/thi-ng/umbrella/tree/master/packages/compose/src/thread-first.ts)
- [threadLast()](https://github.com/thi-ng/umbrella/tree/master/packages/compose/src/thread-last.ts)
- [trampoline()](https://github.com/thi-ng/umbrella/tree/master/packages/compose/src/trampoline.ts)

## Installation

Expand All @@ -37,8 +38,8 @@ yarn add @thi.ng/compose

## Dependencies

- [@thi.ng/api](https://github.com/thi-ng/umbrella/tree/master/packages/api)
- [@thi.ng/errors](https://github.com/thi-ng/umbrella/tree/master/packages/errors)
- [@thi.ng/api](https://github.com/thi-ng/umbrella/tree/master/packages/api)
- [@thi.ng/errors](https://github.com/thi-ng/umbrella/tree/master/packages/errors)

## Usage examples

Expand All @@ -48,7 +49,7 @@ import { comp, compL, juxt } from "@thi.ng/compose";

## Authors

- Karsten Schmidt
- Karsten Schmidt

## License

Expand Down
46 changes: 25 additions & 21 deletions packages/compose/src/partial.ts
Original file line number Diff line number Diff line change
@@ -1,56 +1,60 @@
import {
FnAny,
FnO,
FnO2,
FnO3,
FnO4,
FnO5,
FnO6,
FnO7,
FnO8
} from "@thi.ng/api";
import { illegalArgs } from "@thi.ng/errors";

export function partial<A, T>(
fn: (a: A, ...args: any[]) => T,
a: A
): (...args: any[]) => T;
export function partial<A, B, T>(
fn: (a: A, b: B, ...args: any[]) => T,
a: A,
b: B
): (...args: any[]) => T;
export function partial<A, T>(fn: FnO<A, T>, a: A): FnAny<T>;
export function partial<A, B, T>(fn: FnO2<A, B, T>, a: A, b: B): FnAny<T>;
export function partial<A, B, C, T>(
fn: (a: A, b: B, c: C, ...args: any[]) => T,
fn: FnO3<A, B, C, T>,
a: A,
b: B,
c: C
): (...args: any[]) => T;
): FnAny<T>;
export function partial<A, B, C, D, T>(
fn: (a: A, b: B, c: C, d: D, ...args: any[]) => T,
fn: FnO4<A, B, C, D, T>,
a: A,
b: B,
c: C,
d: D
): (...args: any[]) => T;
): FnAny<T>;
export function partial<A, B, C, D, E, T>(
fn: (a: A, b: B, c: C, d: D, e: E, ...args: any[]) => T,
fn: FnO5<A, B, C, D, E, T>,
a: A,
b: B,
c: C,
d: D,
e: E
): (...args: any[]) => T;
): FnAny<T>;
export function partial<A, B, C, D, E, F, T>(
fn: (a: A, b: B, c: C, d: D, e: E, f: F, ...args: any[]) => T,
fn: FnO6<A, B, C, D, E, F, T>,
a: A,
b: B,
c: C,
d: D,
e: E,
f: F
): (...args: any[]) => T;
): FnAny<T>;
export function partial<A, B, C, D, E, F, G, T>(
fn: (a: A, b: B, c: C, d: D, e: E, f: F, g: G, ...args: any[]) => T,
fn: FnO7<A, B, C, D, E, F, G, T>,
a: A,
b: B,
c: C,
d: D,
e: E,
f: F,
g: G
): (...args: any[]) => T;
): FnAny<T>;
export function partial<A, B, C, D, E, F, G, H, T>(
fn: (a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H, ...args: any[]) => T,
fn: FnO8<A, B, C, D, E, F, G, H, T>,
a: A,
b: B,
c: C,
Expand All @@ -59,7 +63,7 @@ export function partial<A, B, C, D, E, F, G, H, T>(
f: F,
g: G,
h: H
): (...args: any[]) => T;
): FnAny<T>;
export function partial(fn, ...args: any[]) {
let [a, b, c, d, e, f, g, h] = args;
switch (args.length) {
Expand Down

0 comments on commit 81886fe

Please sign in to comment.