Skip to content
A JavaScript utility for creating variadic functions
JavaScript
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
.gitignore
.travis.yml
LICENSE
README.md
package.json
test.js
variadic.js

README.md

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

Something went wrong with that request. Please try again.