ts-named-params
v1.1.0
Published
A little helper for named parameters.
Downloads
18
Maintainers
Readme
ts-named-params
A little utility for making arguments have named parameters. It has no runtime dependencies, and does its best to preserve types.
Installation
Pretty standard stuff
For npm
$ npm i ts-named-params
$ yarn add ts-named-params
Usage
Wrap the desired function in the "named" function. Your function should only have 1
named
usage:
import {named} from 'ts-named-params';
const foo = named((v:{name:string, age:number})=>{
return `${v.name}, ${v.age}`
});
const result = foo('name', 'joe', 'age', 1);
/*joe, 1*/
bound
usage:
import {bound} from 'ts-named-params';
const foo = bound((v:{name:string, age:number})=>{
return `${v.name}, ${v.age}`
}, 'name', 'age');
const result = foo('joe', 1);
/*joe, 1*/