In Source Code
/**
* Like partial but for unary functions that accept
* a single object argument
*/
export const partob = <T, K, PartialArgs extends Partial<T>>(
fn: (args: T) => K,
argobj: PartialArgs
) => {
return (restobj: Omit<T, keyof PartialArgs>): K =>
fn({
...(argobj as Partial<T>),
...(restobj as Partial<T>)
} as T)
}
This means that the function acceptable to thepartob function must have a single object parameter
Example:
import { partob } from "radash";
- const add = (a: number, b: number) => a + b;
- const addA1 = partob(add, { a: 1 });
+ const addButArgsIsObj = (arg: { a: number; b: number }) => arg.a + arg.b;
+ const addButArgsIsObjA1 = partob(addButArgsIsObj, { a: 1 });
But in the tutorial, it is almost all wrong. The former is not the correct way to write the latter.

In Source Code
This means that the function acceptable to the
partobfunction must have a single object parameterExample:
import { partob } from "radash"; - const add = (a: number, b: number) => a + b; - const addA1 = partob(add, { a: 1 }); + const addButArgsIsObj = (arg: { a: number; b: number }) => arg.a + arg.b; + const addButArgsIsObjA1 = partob(addButArgsIsObj, { a: 1 });But in the tutorial, it is almost all wrong. The former is not the correct way to write the latter.