https://github.com/cloudhead/vargs
practical variable argument handling in node.js
https://github.com/cloudhead/vargs
Last synced: 11 months ago
JSON representation
practical variable argument handling in node.js
- Host: GitHub
- URL: https://github.com/cloudhead/vargs
- Owner: cloudhead
- License: mit
- Created: 2010-04-08T19:42:05.000Z (almost 16 years ago)
- Default Branch: master
- Last Pushed: 2015-11-05T01:10:28.000Z (over 10 years ago)
- Last Synced: 2025-03-26T09:11:30.792Z (12 months ago)
- Language: JavaScript
- Homepage:
- Size: 120 KB
- Stars: 22
- Watchers: 1
- Forks: 14
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
vargs
=====
> variable argument handling for functions taking a callback
rationale
----------
JavaScript has very poor argument handling. *vargs* tries to make it simpler.
synopsis
--------
var Args = require("vargs").Constructor;
function (/* [arg1, arg2, ...][,callback] */) {
var args = new(Args)(arguments);
args.first; // first argument
args.last; // last argument before callback
args.callback; // callback argument, or an empty function
args.all; // all arguments except callback
args.length; // number of arguments, not including callback
args.callbackGiven(); // returns true or false
args.at(-1); // last argument, including callback
args.array; // all arguments, including callback
}
example
-------
For a real-world example of *vargs*, check