variadic

A JavaScript utility for creating variadic functions

This functionality is now available natively in JavaScript
Last updated 10 years ago by blakeembrey .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install variadic 
SYNC missed versions from official npm registry.

Variadic

NPM version Build status Test coverage Gittip

Return a function that accepts a variable number of arguments as the last parameter.

Installation

npm install variadic --save

Usage

var variadic = require('variadic');

var fn = variadic(function (args) {
  return args;
});

fn(); //=> []
fn('a'); //=> ['a']
fn('a', 'b') //=> ['a', 'b'];

var fn = variadic(function (a, b, args) {
  return { a: a, b: b, args: args };
});

fn(); //=> { a: undefined, b: undefined, args: [] }
fn('a'); //=> { a: 'a', b: undefined, args: [] }
fn('a', 'b', 'c', 'd', 'e'); //=> { a: 'a', b: 'b', args: ['c', 'd', 'e'] }

License

MIT

Current Tags

  • 1.0.1                                ...           latest (10 years ago)

4 Versions

  • 1.0.1 [deprecated]           ...           10 years ago
  • 1.0.0 [deprecated]           ...           10 years ago
  • 0.0.2 [deprecated]           ...           11 years ago
  • 0.0.1 [deprecated]           ...           11 years ago
Maintainers (1)
Downloads
Total 0
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (2)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE