1.1.0 • Published 2 years ago

ts-named-params v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

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