curry-named-args
curryNamed is a JavaScript utility that turns any function that receives a single object parameter into a variadic curried version of that function
Examples
The required parameters for the function to be executed need to be specified:
; { return a + b + c;} const sumThreeNumbers = ;sumThreeNumbersparamTypes = a: ParamTypesisRequired b: ParamTypesisRequired c: ParamTypesisRequired; const sum5ToTwoNumbers = ;const sum8ToANumber = ;; // 12
It allows to create multiple functions from an original one:
const sum5ToTwoNumbers = ;const sum3ToTwoNumbers = ;; // 8; // 6
It allows to pass any number of arguments to the returned function:
; // 9; // 11
It allows to pass the arguments in any order:
a: 4c: 8; // 14
Because the required parameters need to be specified, optional parameters can be passed and the function is executed only when all required parameters are passed:
; { if msg console; return a + b + c;} const sumThreeNumbers = ;sumThreeNumbersparamTypes = a: ParamTypesisRequired b: ParamTypesisRequired c: ParamTypesisRequired; b: 2c: 3; // 6b: 2c: 3;// summing...// 6