Skip to content

Commit

Permalink
#57 - function/ - Converted curried methods to use idiomatic currying.
Browse files Browse the repository at this point in the history
  • Loading branch information
elycruz committed Jul 30, 2022
1 parent 3c67afa commit ce970d9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions packages/fjl/src/function/fnOrError.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {typeOf} from '../object/typeOf';
import {curry2, CurryOf2} from "./curry";

export const

Expand All @@ -15,6 +14,7 @@ export const
return f;
},

$fnOrError = curry2(fnOrError) as CurryOf2
$fnOrError = <T>(symbolName: string) => (f: T): T =>
fnOrError(symbolName, f)

;
4 changes: 2 additions & 2 deletions packages/fjl/src/function/trampoline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ export const trampoline = <T, RetT>(fn: Nary<T, RetT>, fnName?: string): Nary<T,
};
},

$trampoline = curry2(trampoline) as CurryOf2;

$trampoline = <T, RetT>(fn: Nary<T, RetT>, fnName?: string): Nary<T, RetT> =>
trampoline(fn, fnName)
9 changes: 7 additions & 2 deletions packages/fjl/src/function/until.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import {curry, CurryOf3} from './curry';
import {Unary, UnaryPred} from "../types";

export const
Expand All @@ -19,4 +18,10 @@ export const
return result;
},

$until = curry(until) as CurryOf3<UnaryPred, Unary>;
$until = <T>(predicate: UnaryPred<T>) =>
(operation: Unary<T>) =>
(startValue: T): T => until(
predicate,
operation,
startValue
);

0 comments on commit ce970d9

Please sign in to comment.