-
Notifications
You must be signed in to change notification settings - Fork 0
Arguments utils
License
alxpborges/Sugar.js
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Mini tutorial on http://art543484.narod.ru/sugar Maybe = Sugar(arguments, object); //New sugar Maybe = Maybe(pattern) //Add pattern Maybe = Maybe.wrong(message) //If function called with unexpected number of arguments then Maybe throw new error with message Maybe = Maybe.def(object) //Define default arguments result = Maybe.end(view, function) //Call function Example: function Point () { sugar(arguments, this) (['x','y']) ([['x','y']]) ([{x:'x',y:'y'}]) .wrong('Point - Unexpected number of arguments') .end('x,y', function(x,y){ this.x = x == null ? null : Number(x); this.y = y == null ? null : Number(y); }); }; Point(2,3); Point([2,3]); Point({x:2, y:3}); Point(4); //Error: Point - Unexpected number of arguments
About
Arguments utils
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published