garde
Utility function for dealing with function arguments.
How to include
Node.js / Browserify
In your shell:
$ npm install --save garde
In your javascript:
var garde =
Browser ("classic" way)
Just add a script
tag with either garde.js
or garde.min.js
from this repos root directory.
This makes the Cheiron
variable globally available.
typeof windowgarde// --> 'function'
Warning
This module globally extends the prototype
of Function
with a method invoke
which uses the evil eval
!
But I sorrily JS did not give me another way to call a function with an array of arguments without changing it's context.
API
garde(<f>)
Returns a wrapper function for f
which throws an Exception when the number of arguments passed does not equal f
's arity.
var { return a + b} console// --> 3 console// --> NaN var gAdd = console// --> 3 console// Error: Function needs 2 arguments, got 1
garde(<arity>, <f>)
Instead of checking f
's arity, arity
is used for comparison.
Testing/Building
Installing development dependencies
$ npm install
Running tests
$ npm test
Building for the browser
$ npm run build
$ # for building on file change
$ npm run watch
License
MIT license, see LICENSE
.