@alesmenzel/vargs

1.2.0 • Public • Published

Vargs

This library enables variable argument pattern with callback as last argument.

Instalation

npm i @alesmenzel/vargs

Usage

Supports ES5, ES6 and ES6 shorthand arrow functions.

const vargs = require('@alesmenzel/vargs');

// ES5
const fnc = vargs(function(a = 15, b, c, callback) {
  console.log({ a, b, c, callback })
});

fnc(() => {});
// { a: 15, b: undefined, c: undefined, callback: [Function] }


// ES6
const fnc = vargs((a = 15, b, c, callback) => {
  console.log({ a, b, c, callback })
});

fnc(() => {});
// { a: 15, b: undefined, c: undefined, callback: [Function] }


// ES6 shorthand
const fnc = vargs((a = 15, b, c, callback) => console.log({ a, b, c, callback }));

fnc(() => {});
// { a: 15, b: undefined, c: undefined, callback: [Function] }

Package Sidebar

Install

npm i @alesmenzel/vargs

Weekly Downloads

2

Version

1.2.0

License

MIT

Unpacked Size

11 kB

Total Files

8

Last publish

Collaborators

  • alesmenzel