{"_id":"arguejs","_rev":"294258","name":"arguejs","description":"ArgueJS is a library that allows you to delightfully extend your methods's signatures with optional parameters, default values and type-checking.","dist-tags":{"latest":"0.2.3"},"maintainers":[{"name":"zvictor","email":"victor0110@msn.com"}],"time":{"modified":"2021-06-03T18:55:31.000Z","created":"2013-04-11T18:14:20.759Z","0.2.3":"2013-05-13T01:53:50.567Z","0.2.2":"2013-05-10T21:21:08.971Z","0.2.1":"2013-05-08T18:32:05.844Z","0.2.0":"2013-05-08T03:27:46.134Z","0.1.3":"2013-04-16T22:07:19.537Z","0.1.2":"2013-04-16T20:54:14.957Z","0.1.1":"2013-04-12T20:35:39.290Z","0.1.0":"2013-04-11T18:14:20.759Z"},"users":{"phgyorgygulyas":true,"lassevolkmann":true},"author":{"name":"José Victor Duarte","url":"http://zvictor.net/"},"repository":{"type":"git","url":"git://github.com/zvictor/ArgueJS.git"},"versions":{"0.2.3":{"name":"arguejs","version":"0.2.3","description":"ArgueJS is a library that allows you to delightfully extend your methods's signatures with optional parameters, default values and type-checking.","main":"argue.js","directories":{"test":"test"},"scripts":{"test":"karma start"},"repository":{"type":"git","url":"git://github.com/zvictor/ArgueJS.git"},"maintainers":[{"name":"zvictor","email":"victor0110@msn.com"}],"contributors":[],"bugs":{"url":"http://github.com/zvictor/ArgueJS/issues"},"devDependencies":{"karma":"*"},"keywords":["arguejs","argue","arguments","parameters"],"author":{"name":"José Victor Duarte","url":"http://zvictor.net/"},"license":"BSD","readmeFilename":"README.md","_id":"arguejs@0.2.3","dist":{"shasum":"b6f939f5fe0e3cd1f3f93e2aa9262424bf312af7","size":109500,"noattachment":false,"key":"/arguejs/-/arguejs-0.2.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/arguejs/download/arguejs-0.2.3.tgz"},"_from":".","_npmVersion":"1.2.18","_npmUser":{"name":"zvictor","email":"victor0110@msn.com"},"publish_time":1368410030567,"_hasShrinkwrap":false,"_cnpm_publish_time":1368410030567},"0.2.2":{"name":"arguejs","version":"0.2.2","description":"ArgueJS is a library that allows you to delightfully extend your methods's signatures with optional parameters, default values and type-checking.","main":"argue.js","directories":{"test":"test"},"scripts":{"test":"karma start"},"repository":{"type":"git","url":"git://github.com/zvictor/ArgueJS.git"},"maintainers":[{"name":"zvictor","email":"victor0110@msn.com"}],"contributors":[],"bugs":{"url":"http://github.com/zvictor/ArgueJS/issues"},"devDependencies":{"karma":"*"},"keywords":["arguejs","argue","arguments","parameters"],"author":{"name":"José Victor Duarte","url":"http://zvictor.net/"},"license":"BSD","readmeFilename":"README.md","_id":"arguejs@0.2.2","dist":{"shasum":"2062b04879dbbe2bd1bf8f6c50d682c05025c9f5","size":109309,"noattachment":false,"key":"/arguejs/-/arguejs-0.2.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/arguejs/download/arguejs-0.2.2.tgz"},"_from":".","_npmVersion":"1.2.18","_npmUser":{"name":"zvictor","email":"victor0110@msn.com"},"publish_time":1368220868971,"_hasShrinkwrap":false,"_cnpm_publish_time":1368220868971},"0.2.1":{"name":"arguejs","version":"0.2.1","description":"ArgueJS is a library that allows you to delightfully extend your methods's signatures with optional parameters, default values and type-checking.","main":"argue.js","directories":{"test":"test"},"scripts":{"test":"karma start"},"repository":{"type":"git","url":"git://github.com/zvictor/ArgueJS.git"},"maintainers":[{"name":"zvictor","email":"victor0110@msn.com"}],"contributors":[],"bugs":{"url":"http://github.com/zvictor/ArgueJS/issues"},"devDependencies":{"karma":"*"},"keywords":["arguejs","argue","arguments","parameters"],"author":{"name":"José Victor Duarte","url":"http://zvictor.net/"},"license":"BSD","readmeFilename":"README.md","_id":"arguejs@0.2.1","dist":{"shasum":"fb271c8db26384f23cbf026374c0e9c875d759fe","size":108920,"noattachment":false,"key":"/arguejs/-/arguejs-0.2.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/arguejs/download/arguejs-0.2.1.tgz"},"_from":".","_npmVersion":"1.2.18","_npmUser":{"name":"zvictor","email":"victor0110@msn.com"},"publish_time":1368037925844,"_hasShrinkwrap":false,"_cnpm_publish_time":1368037925844},"0.2.0":{"name":"arguejs","version":"0.2.0","description":"ArgueJS is a library that allows you to delightfully extend your methods's signatures with optional parameters, default values and type-checking.","main":"argue.js","directories":{"test":"test"},"scripts":{"test":"karma start"},"repository":{"type":"git","url":"git://github.com/zvictor/ArgueJS.git"},"maintainers":[{"name":"zvictor","email":"victor0110@msn.com"}],"contributors":[],"bugs":{"url":"http://github.com/zvictor/ArgueJS/issues"},"devDependencies":{"karma":"*"},"keywords":["arguejs","argue","arguments","parameters"],"author":{"name":"José Victor Duarte","url":"http://zvictor.net/"},"license":"BSD","readmeFilename":"README.md","_id":"arguejs@0.2.0","dist":{"shasum":"990a05e40d851937d1847c8381027fa800a8ebe9","size":108419,"noattachment":false,"key":"/arguejs/-/arguejs-0.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/arguejs/download/arguejs-0.2.0.tgz"},"_from":".","_npmVersion":"1.2.18","_npmUser":{"name":"zvictor","email":"victor0110@msn.com"},"publish_time":1367983666134,"_hasShrinkwrap":false,"_cnpm_publish_time":1367983666134},"0.1.3":{"name":"arguejs","version":"0.1.3","description":"ArgueJS is a library that allows you to delightfully extend your methods's signatures with optional parameters, default values and type-checking.","main":"argue.js","directories":{"test":"test"},"scripts":{"test":"karma start"},"repository":{"type":"git","url":"git://github.com/zvictor/ArgueJS.git"},"keywords":["arguejs","argue","arguments","parameters"],"author":{"name":"zvictor"},"license":"BSD","readmeFilename":"README.md","_id":"arguejs@0.1.3","dist":{"shasum":"2dead4ab46f189e2521c1f420bd2a3a5e691ecbf","size":49499,"noattachment":false,"key":"/arguejs/-/arguejs-0.1.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/arguejs/download/arguejs-0.1.3.tgz"},"_npmVersion":"1.1.69","_npmUser":{"name":"zvictor","email":"victor0110@msn.com"},"maintainers":[{"name":"zvictor","email":"victor0110@msn.com"}],"publish_time":1366150039537,"_hasShrinkwrap":false,"_cnpm_publish_time":1366150039537},"0.1.2":{"name":"arguejs","version":"0.1.2","description":"ArgueJS is a library that allows you to delightfully extend your methods's signatures with optional parameters, default values and type-checking.","main":"argue.js","directories":{"test":"test"},"scripts":{"test":"karma start"},"repository":{"type":"git","url":"git://github.com/zvictor/ArgueJS.git"},"keywords":["arguejs","argue","arguments","parameters"],"author":{"name":"zvictor"},"license":"BSD","readmeFilename":"README.md","_id":"arguejs@0.1.2","dist":{"shasum":"446ad16141d62afb9ed44112c1a4bcc182064c7d","size":49430,"noattachment":false,"key":"/arguejs/-/arguejs-0.1.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/arguejs/download/arguejs-0.1.2.tgz"},"_npmVersion":"1.1.69","_npmUser":{"name":"zvictor","email":"victor0110@msn.com"},"maintainers":[{"name":"zvictor","email":"victor0110@msn.com"}],"publish_time":1366145654957,"_hasShrinkwrap":false,"_cnpm_publish_time":1366145654957},"0.1.1":{"name":"arguejs","version":"0.1.1","description":"ArgueJS is a library that allows you to delightfully extend your methods's signatures with optional parameters, default values and type-checking.","main":"argue.js","directories":{"test":"test"},"scripts":{"test":"karma start"},"repository":{"type":"git","url":"git://github.com/zvictor/ArgueJS.git"},"keywords":["arguejs","argue","arguments","parameters"],"author":{"name":"zvictor"},"license":"BSD","readmeFilename":"README.md","_id":"arguejs@0.1.1","dist":{"shasum":"e75c5d6e0693bccbb6f429d00c1bcb2c10365010","size":47910,"noattachment":false,"key":"/arguejs/-/arguejs-0.1.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/arguejs/download/arguejs-0.1.1.tgz"},"_npmVersion":"1.1.69","_npmUser":{"name":"zvictor","email":"victor0110@msn.com"},"maintainers":[{"name":"zvictor","email":"victor0110@msn.com"}],"publish_time":1365798939290,"_hasShrinkwrap":false,"_cnpm_publish_time":1365798939290},"0.1.0":{"name":"arguejs","version":"0.1.0","description":"ArgueJS is a library that allows you to delightfully extend your methods's signatures with optional parameters, default values and type-checking.","main":"argue.js","directories":{"test":"test"},"scripts":{"test":"karma start"},"repository":{"type":"git","url":"git://github.com/zvictor/ArgueJS.git"},"keywords":["arguejs","argue","arguments","parameters"],"author":{"name":"zvictor"},"license":"BSD","readmeFilename":"README.md","_id":"arguejs@0.1.0","dist":{"shasum":"933a72fc28b7d6eb18470cbf92a64e45b2865ad9","size":58353,"noattachment":false,"key":"/arguejs/-/arguejs-0.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/arguejs/download/arguejs-0.1.0.tgz"},"_npmVersion":"1.1.69","_npmUser":{"name":"zvictor","email":"victor0110@msn.com"},"maintainers":[{"name":"zvictor","email":"victor0110@msn.com"}],"publish_time":1365704060759,"_hasShrinkwrap":false,"_cnpm_publish_time":1365704060759}},"readme":"#ArgueJS\n\nArgueJS is a library that allows you to delightfully extend your methods's signatures with [optional parameters](#optional-parameters),\n[default values](#default-values) and [type-checking](#type-checking).\n\n### example\nLet's suppose we want to rewrite the well known [method range](http://underscorejs.org/#range) from [underscorejs](http://underscorejs.org/#range).\n\nNote that documentation says its method signature is `range([start], stop, [step])`. With ArgueJS we could type just this way:\n```javascript\nfunction range(){ \n  arguments = __({start: [Number, 0], stop: Number, step: [Number, 1]})\n\n  for(var i = arguments.start; i < arguments.stop; i += arguments.step)\n    console.log(i);\n}\n```\n```javascript\n>>> range(3)\n 0\n 1\n 2\n>>> range(3, 5)\n 3\n 4\n>>> range(0, 5, 2)\n 0\n 2\n 4\n```\n\n## Installation\nArgueJS is available for both node.js and the browser.\n\n###Node.js\n\nPackage is available through npm:\n\n```bash\n$ npm install arguejs\n```\n\n### Browser\n\nInclude the ArgueJS browser build in your pages.\n\n```html\n<script src=\"argue.js\" type=\"text/javascript\"></script>\n```\n\nThis will provide `__` as a global object, or `define` it if you are using AMD.\n\nThe latest version will be available for hot-linking at http://raw.github.com/zvictor/ArgueJS/master/argue.js.\nIf you prefer to host yourself, use the `argue.js` file from the root of the github project.\n\n## Getting started\nWhen writing your JavaScript methods with ArgueJS,\nhave in mind that you will not use conventional parameters definition as you used before.\nActually, all your methods should be defined without them.\n\nJust at the beggining of your method scope,\nyou should pass an object defining your method signature into a call to `__` and save its reference for later.\n\n```javascript\nfunction person(){\n  var paramDefinition = {name: String, age: Number};\n  arguments = __(paramDefinition);\n  // String name is now referenced by arguments.name\n  // Number age is now referenced by arguments.age\n  return arguments;\n}\n```\n```javascript\n>>> Person('John', 27).name\n 'John'\n>>> Person('John', 27).age\n 27\n```\n\n## Type-checking\n\nType-checking ensures your arguments are what you expected, and throws errors when not.\n\n*example:*\n```javascript\nfunction age(){\n  arguments = __({born: Date})\n  // ...\n```\n```javascript\n>>> age('01/10/1988')\n Error: parameter 'born' waiting for a Date argument but received a String\n```\n\n### Avoid type-checking\n\nThe [special data type](#special-data-types) `undefined` can be used to allow the parameter to be of *any* type.\n\n*example:*\n```javascript\nfunction Book(){\n  arguments = __({title: undefined})\n  // ...\n  return arguments.title;\n}\n```\n```javascript\n>>> book('Animal Farm: a Fairy Story')\n 'Animal Farm: a Fairy Story'\n>>> book(1984)\n 1984\n```\n\n### Data types\n* String\n* Number\n* Boolean\n* Array\n* Function\n* Object\n* Date\n* RegExp\n\n### Special data types:\n* undefined\n\n## Optional parameters\n\nOptional parameters are great to avoid a mess of conditional clauses at the beggining of your method.\nTo make a parameter optional, **declare its type inside of an Array**, like this: `{name: [String]}`\n\n*example:*\n```javascript\nfunction unique(){\n  arguments = __({array: Array, isSorted: [Boolean], iterator: [Function])\n  // Array array is required\n  // Boolean isSorted is optional\n  // Function iterator is optional\n  \n  // ...\n```\nIf no value is passed to an optional parameter, then its argument value will be `undefined`.\nTo set a default value for your parameter, take a look at [default values](#default-values).\n\n### Default values\n\nWhen writing methods, sometimes you want to override the value of an undefined argument by a default value.\nThe sintax to do this is similiar to [optional parameters](#optional-parameters).\nThat is because a *parameter with default value is an optional parameter* by itself.\n\nTo set a default value for a parameter **declare its type and its default value inside of an Array**,\nlike this: `{name: [String, 'unknown']}`\n\n*example:*\n```javascript\nfunction unique(){\n  arguments = __({array: Array, isSorted: [Boolean, false], iterator: [Function, function(element){\n    return element;\n  }])\n  // Array array is required\n  // Boolean isSorted is optional and its default value is false\n  // Function iterator is optional and its default value is the function declared above\n  \n  // ...\n```\n\nIf you do not care about its type, but just want it to have a default value,\nyou should type your parameter as `undefined`\n\n*example:*\n```javascript\n  arguments = __({name: [undefined, 'unknown']);\n```\n\n-------------------------------\n\n## Contributing\n\nThis project is in its very early stages and any help, suggestion or posted issue will be very appreciated.","_attachments":{},"readmeFilename":"README.md","bugs":{"url":"http://github.com/zvictor/ArgueJS/issues"},"license":"BSD"}