18 lines
457 B
JavaScript
18 lines
457 B
JavaScript
require('./_pollute/map');
|
|
|
|
module.exports = {
|
|
curry: (fn) => (...args) => (...callArgs) => fn(...[...args, ...callArgs]),
|
|
curryRight: (fn) => (...args) => (...callArgs) =>
|
|
fn(...[...callArgs, ...args]),
|
|
memo: (fn) => {
|
|
const memo = new Map();
|
|
return (...args) => {
|
|
const path = [args.length, ...args];
|
|
if (!memo.hasPath(path)) {
|
|
memo.setPath(path, fn(...args));
|
|
}
|
|
return memo.getPath(path);
|
|
};
|
|
},
|
|
};
|