diff --git a/lib/fns/pipe.ts b/lib/fns/pipe.ts index 079d041..b04fbd5 100644 --- a/lib/fns/pipe.ts +++ b/lib/fns/pipe.ts @@ -19,10 +19,10 @@ import { isNil } from './predicate'; * // => "fallback" * ``` */ -export const pipe2 = (fallback: R2) => (fns: [Unary, Unary]) => (x: T): R2 => { +export const pipe2 = (fallback: C) => (fns: [Unary, Unary]) => (x: A): C => { return isNil(x) ? fallback : (() => { - const [fn1, fn2] = fns; - return fn2(fn1(x)); + const [ab, bc] = fns; + return bc(ab(x)); })(); }; @@ -44,10 +44,10 @@ export const pipe2 = (fallback: R2) => (fns: [Unary, Unary ["fallback"] * ``` */ -export const pipe3 = (fallback: R3) => (fns: [Unary, Unary, Unary]) => (x: T): R3 => { +export const pipe3 = (fallback: D) => (fns: [Unary, Unary, Unary]) => (x: A): D => { return isNil(x) ? fallback : (() => { - const [fn1, fn2, fn3] = fns; - return fn3(fn2(fn1(x))); + const [ab, bc, cd] = fns; + return cd(bc(ab(x))); })(); }; @@ -69,9 +69,9 @@ export const pipe3 = (fallback: R3) => (fns: [Unary, Unary * // => "fallback" * ``` */ -export const pipe4 = (fallback: R4) => (fns: [Unary, Unary, Unary, Unary]) => (x: T): R4 => { +export const pipe4 = (fallback: E) => (fns: [Unary, Unary, Unary, Unary]) => (x: A): E => { return isNil(x) ? fallback : (() => { - const [fn1, fn2, fn3, fn4] = fns; - return fn4(fn3(fn2(fn1(x)))); + const [ab, bc, cd, de] = fns; + return de(cd(bc(ab(x)))); })(); };