Skip to content

Commit

Permalink
fix: Improve type inference for chain function
Browse files Browse the repository at this point in the history
  • Loading branch information
fResult committed Dec 4, 2023
1 parent 03dd315 commit 076ba5f
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 12 deletions.
8 changes: 5 additions & 3 deletions cdn/radash.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -489,9 +489,11 @@ const guard = (func, shouldGuard) => {
}
};

const chain = (...funcs) => (...args) => {
return funcs.slice(1).reduce((acc, fn) => fn(acc), funcs[0](...args));
};
function chain(...funcs) {
return function forX(initialParam) {
return funcs.reduce((acc, fn) => fn(acc), initialParam);
};
}
const compose = (...funcs) => {
return funcs.reverse().reduce((acc, fn) => fn(acc));
};
Expand Down
8 changes: 5 additions & 3 deletions cdn/radash.js
Original file line number Diff line number Diff line change
Expand Up @@ -492,9 +492,11 @@ var radash = (function (exports) {
}
};

const chain = (...funcs) => (...args) => {
return funcs.slice(1).reduce((acc, fn) => fn(acc), funcs[0](...args));
};
function chain(...funcs) {
return function forX(initialParam) {
return funcs.reduce((acc, fn) => fn(acc), initialParam);
};
}
const compose = (...funcs) => {
return funcs.reverse().reduce((acc, fn) => fn(acc));
};
Expand Down
Loading

0 comments on commit 076ba5f

Please sign in to comment.