https://github.com/jspears/ts-named-params
A little utility for making arguments have named parameters.
https://github.com/jspears/ts-named-params
Last synced: 3 months ago
JSON representation
A little utility for making arguments have named parameters.
- Host: GitHub
- URL: https://github.com/jspears/ts-named-params
- Owner: jspears
- License: mit
- Created: 2022-08-22T23:54:11.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-08-24T17:38:58.000Z (almost 3 years ago)
- Last Synced: 2025-02-09T16:40:51.529Z (4 months ago)
- Language: TypeScript
- Size: 65.4 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
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 stuffFor npm
```sh
$ npm i ts-named-params
``````sh
$ yarn add ts-named-params
```## Usage
Wrap the desired function in the "named" function. Your function should only have 1## `named` usage:
```ts
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:
```ts
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*/```