ts-named-params
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

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*/

Package Sidebar

Install

npm i ts-named-params

Weekly Downloads

1

Version

1.1.0

License

MIT

Unpacked Size

32.7 kB

Total Files

29

Last publish

Collaborators

  • speajus