Skip to content

Commit

Permalink
Moved 'curry' module deprecation notice to the top of the module.
Browse files Browse the repository at this point in the history
  • Loading branch information
elycruz committed Jul 30, 2023
1 parent 2eedeef commit 05c11fd
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions packages/fjl/src/function/curry.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
/**
* @deprecated Use idiomatic currying, when currying is required, instead - `curry*` functions defined here are actually
* doing something that is not really currying - forcing currying on argument tuple sets (`(a, b, c)`) - true currying applies
* each argument to a new function (`(a) => (b) => c`, etc.). Hence why this module is deprecated, and idiomatic curry
* is favored instead.
*
* @author edlc
*
* @memberOf function
*
* @description Curry and CurryN functions.
* @deprecated Use idiomatic currying, when currying is required - `curry*` function defined here are actually doing
* something that is not really currying - forcing currying on argument tuple sets (`(a, b, c)`) - true currying applies
* each argument to a new function (`(a) => (b) => c`, etc.).
*/

import {UnitNary} from '../types';
Expand Down Expand Up @@ -88,7 +92,10 @@ export const
const curriedFn = (...args: any[]): Curried => {
const catedArgs = argsToCurry.concat(args),
canBeCalled = catedArgs.length >= executeArity || executeArity <= 0;
if (!catedArgs.length && !canBeCalled) throw new Error(`${fn.name} expected one or more arguments. Received none.`);

if (!catedArgs.length && !canBeCalled)
throw new Error(`${fn.name} expected one or more arguments. Received none.`);

return canBeCalled ? fn(...catedArgs) :
curryN(executeArity - catedArgs.length, fn.bind(null, ...catedArgs));
};
Expand Down

0 comments on commit 05c11fd

Please sign in to comment.