@effect/data
Advanced tools
Comparing version 0.16.0 to 0.16.1
@@ -323,2 +323,28 @@ /** | ||
/** | ||
* Performs left-to-right function composition. The first argument may have any arity, the remaining arguments must be unary. | ||
* | ||
* See also [`pipe`](#pipe). | ||
* | ||
* @example | ||
* import { flow } from "@effect/data/Function" | ||
* | ||
* const len = (s: string): number => s.length | ||
* const double = (n: number): number => n * 2 | ||
* | ||
* const f = flow(len, double) | ||
* | ||
* assert.strictEqual(f('aaa'), 6) | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
export declare function flow<A extends ReadonlyArray<unknown>, B>(ab: (...a: A) => B): (...a: A) => B; | ||
export declare function flow<A extends ReadonlyArray<unknown>, B, C>(ab: (...a: A) => B, bc: (b: B) => C): (...a: A) => C; | ||
export declare function flow<A extends ReadonlyArray<unknown>, B, C, D>(ab: (...a: A) => B, bc: (b: B) => C, cd: (c: C) => D): (...a: A) => D; | ||
export declare function flow<A extends ReadonlyArray<unknown>, B, C, D, E>(ab: (...a: A) => B, bc: (b: B) => C, cd: (c: C) => D, de: (d: D) => E): (...a: A) => E; | ||
export declare function flow<A extends ReadonlyArray<unknown>, B, C, D, E, F>(ab: (...a: A) => B, bc: (b: B) => C, cd: (c: C) => D, de: (d: D) => E, ef: (e: E) => F): (...a: A) => F; | ||
export declare function flow<A extends ReadonlyArray<unknown>, B, C, D, E, F, G>(ab: (...a: A) => B, bc: (b: B) => C, cd: (c: C) => D, de: (d: D) => E, ef: (e: E) => F, fg: (f: F) => G): (...a: A) => G; | ||
export declare function flow<A extends ReadonlyArray<unknown>, B, C, D, E, F, G, H>(ab: (...a: A) => B, bc: (b: B) => C, cd: (c: C) => D, de: (d: D) => E, ef: (e: E) => F, fg: (f: F) => G, gh: (g: G) => H): (...a: A) => H; | ||
export declare function flow<A extends ReadonlyArray<unknown>, B, C, D, E, F, G, H, I>(ab: (...a: A) => B, bc: (b: B) => C, cd: (c: C) => D, de: (d: D) => E, ef: (e: E) => F, fg: (f: F) => G, gh: (g: G) => H, hi: (h: H) => I): (...a: A) => I; | ||
export declare function flow<A extends ReadonlyArray<unknown>, B, C, D, E, F, G, H, I, J>(ab: (...a: A) => B, bc: (b: B) => C, cd: (c: C) => D, de: (d: D) => E, ef: (e: E) => F, fg: (f: F) => G, gh: (g: G) => H, hi: (h: H) => I, ij: (i: I) => J): (...a: A) => J; | ||
/** | ||
* Type hole simulation. | ||
@@ -325,0 +351,0 @@ * |
@@ -6,3 +6,5 @@ "use strict"; | ||
}); | ||
exports.isFunction = exports.identity = exports.hole = exports.flip = exports.dual = exports.constant = exports.constVoid = exports.constUndefined = exports.constTrue = exports.constNull = exports.constFalse = exports.compose = exports.apply = exports.absurd = exports.SK = void 0; | ||
exports.flip = exports.dual = exports.constant = exports.constVoid = exports.constUndefined = exports.constTrue = exports.constNull = exports.constFalse = exports.compose = exports.apply = exports.absurd = exports.SK = void 0; | ||
exports.flow = flow; | ||
exports.isFunction = exports.identity = exports.hole = void 0; | ||
exports.pipe = pipe; | ||
@@ -368,2 +370,41 @@ exports.untupled = exports.unsafeCoerce = exports.tupled = void 0; | ||
} | ||
function flow(ab, bc, cd, de, ef, fg, gh, hi, ij) { | ||
switch (arguments.length) { | ||
case 1: | ||
return ab; | ||
case 2: | ||
return function () { | ||
return bc(ab.apply(this, arguments)); | ||
}; | ||
case 3: | ||
return function () { | ||
return cd(bc(ab.apply(this, arguments))); | ||
}; | ||
case 4: | ||
return function () { | ||
return de(cd(bc(ab.apply(this, arguments)))); | ||
}; | ||
case 5: | ||
return function () { | ||
return ef(de(cd(bc(ab.apply(this, arguments))))); | ||
}; | ||
case 6: | ||
return function () { | ||
return fg(ef(de(cd(bc(ab.apply(this, arguments)))))); | ||
}; | ||
case 7: | ||
return function () { | ||
return gh(fg(ef(de(cd(bc(ab.apply(this, arguments))))))); | ||
}; | ||
case 8: | ||
return function () { | ||
return hi(gh(fg(ef(de(cd(bc(ab.apply(this, arguments)))))))); | ||
}; | ||
case 9: | ||
return function () { | ||
return ij(hi(gh(fg(ef(de(cd(bc(ab.apply(this, arguments))))))))); | ||
}; | ||
} | ||
return; | ||
} | ||
/** | ||
@@ -370,0 +411,0 @@ * Type hole simulation. |
{ | ||
"name": "@effect/data", | ||
"version": "0.16.0", | ||
"version": "0.16.1", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -685,2 +685,127 @@ /** | ||
/** | ||
* Performs left-to-right function composition. The first argument may have any arity, the remaining arguments must be unary. | ||
* | ||
* See also [`pipe`](#pipe). | ||
* | ||
* @example | ||
* import { flow } from "@effect/data/Function" | ||
* | ||
* const len = (s: string): number => s.length | ||
* const double = (n: number): number => n * 2 | ||
* | ||
* const f = flow(len, double) | ||
* | ||
* assert.strictEqual(f('aaa'), 6) | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
export function flow<A extends ReadonlyArray<unknown>, B>(ab: (...a: A) => B): (...a: A) => B | ||
export function flow<A extends ReadonlyArray<unknown>, B, C>(ab: (...a: A) => B, bc: (b: B) => C): (...a: A) => C | ||
export function flow<A extends ReadonlyArray<unknown>, B, C, D>( | ||
ab: (...a: A) => B, | ||
bc: (b: B) => C, | ||
cd: (c: C) => D | ||
): (...a: A) => D | ||
export function flow<A extends ReadonlyArray<unknown>, B, C, D, E>( | ||
ab: (...a: A) => B, | ||
bc: (b: B) => C, | ||
cd: (c: C) => D, | ||
de: (d: D) => E | ||
): (...a: A) => E | ||
export function flow<A extends ReadonlyArray<unknown>, B, C, D, E, F>( | ||
ab: (...a: A) => B, | ||
bc: (b: B) => C, | ||
cd: (c: C) => D, | ||
de: (d: D) => E, | ||
ef: (e: E) => F | ||
): (...a: A) => F | ||
export function flow<A extends ReadonlyArray<unknown>, B, C, D, E, F, G>( | ||
ab: (...a: A) => B, | ||
bc: (b: B) => C, | ||
cd: (c: C) => D, | ||
de: (d: D) => E, | ||
ef: (e: E) => F, | ||
fg: (f: F) => G | ||
): (...a: A) => G | ||
export function flow<A extends ReadonlyArray<unknown>, B, C, D, E, F, G, H>( | ||
ab: (...a: A) => B, | ||
bc: (b: B) => C, | ||
cd: (c: C) => D, | ||
de: (d: D) => E, | ||
ef: (e: E) => F, | ||
fg: (f: F) => G, | ||
gh: (g: G) => H | ||
): (...a: A) => H | ||
export function flow<A extends ReadonlyArray<unknown>, B, C, D, E, F, G, H, I>( | ||
ab: (...a: A) => B, | ||
bc: (b: B) => C, | ||
cd: (c: C) => D, | ||
de: (d: D) => E, | ||
ef: (e: E) => F, | ||
fg: (f: F) => G, | ||
gh: (g: G) => H, | ||
hi: (h: H) => I | ||
): (...a: A) => I | ||
export function flow<A extends ReadonlyArray<unknown>, B, C, D, E, F, G, H, I, J>( | ||
ab: (...a: A) => B, | ||
bc: (b: B) => C, | ||
cd: (c: C) => D, | ||
de: (d: D) => E, | ||
ef: (e: E) => F, | ||
fg: (f: F) => G, | ||
gh: (g: G) => H, | ||
hi: (h: H) => I, | ||
ij: (i: I) => J | ||
): (...a: A) => J | ||
export function flow( | ||
ab: Function, | ||
bc?: Function, | ||
cd?: Function, | ||
de?: Function, | ||
ef?: Function, | ||
fg?: Function, | ||
gh?: Function, | ||
hi?: Function, | ||
ij?: Function | ||
): unknown { | ||
switch (arguments.length) { | ||
case 1: | ||
return ab | ||
case 2: | ||
return function(this: unknown) { | ||
return bc!(ab.apply(this, arguments)) | ||
} | ||
case 3: | ||
return function(this: unknown) { | ||
return cd!(bc!(ab.apply(this, arguments))) | ||
} | ||
case 4: | ||
return function(this: unknown) { | ||
return de!(cd!(bc!(ab.apply(this, arguments)))) | ||
} | ||
case 5: | ||
return function(this: unknown) { | ||
return ef!(de!(cd!(bc!(ab.apply(this, arguments))))) | ||
} | ||
case 6: | ||
return function(this: unknown) { | ||
return fg!(ef!(de!(cd!(bc!(ab.apply(this, arguments)))))) | ||
} | ||
case 7: | ||
return function(this: unknown) { | ||
return gh!(fg!(ef!(de!(cd!(bc!(ab.apply(this, arguments))))))) | ||
} | ||
case 8: | ||
return function(this: unknown) { | ||
return hi!(gh!(fg!(ef!(de!(cd!(bc!(ab.apply(this, arguments)))))))) | ||
} | ||
case 9: | ||
return function(this: unknown) { | ||
return ij!(hi!(gh!(fg!(ef!(de!(cd!(bc!(ab.apply(this, arguments))))))))) | ||
} | ||
} | ||
return | ||
} | ||
/** | ||
* Type hole simulation. | ||
@@ -687,0 +812,0 @@ * |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2935140
61894