{"bugs":{"url":"https://github.com/airportyh/getargs/issues"},"dist":{"shasum":"8516605872c980178e01ca70106fccd22521fc7c","tarball":"https://registry.npmjs.org/getargs/-/getargs-0.0.8.tgz","integrity":"sha512-CtvhI92IaUVMEwBW2aug11+shGOs/Ohh8/48hCE237/uVnaJokqXQCPwRclIzIafpk9d3Zd2Z1gIxArz8vokFA==","signatures":[{"sig":"MEYCIQCr7qzU4QyyqawD3SB0mjFAc8lkBQk5lEx6oUbwSN4B/AIhAPWQIAFUCC/+B79r7kjunKKLvF1+3nBjvDBn0nwOlT24","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"index.js","name":"getargs","_from":".","author":{"name":"Toby Ho"},"readme":"getargs\n=======\n\nSimple utility for parsing/processing variable length argument lists for Javascript functions; also verifies argument types and argument list length.\n\n## Install\n\nBower - `bower install getargs`; NPM - `npm install getargs`.\n\n## Usage\n\n    var getArgs = require('getargs')\n\n    function ajax(/* url:string|array, [options]:object, callback:function */){\n      var args = getArgs('url:string|array, [options]:object, callback:function', arguments)\n\n      console.log('url is', args.url)\n      console.log('options is optionally', args.options)\n      console.log('callback', args.callback)\n    }\n\n## Argument Spec Syntax\n\nThe argument spec is a comma delimited string of individual specs, which look like\n\n    argname:type\n\nYou can specify multiple types by using `|`\n\n    argname:type|type|type\n\n* `argname` is the name of the argument, and can be called anything\n* `type` is an optional basic Javascript type. Currently these are supported\n  * `string`\n  * `boolean`\n  * `number`\n  * `object`\n  * `function`\n  * `array`\n\n### Optional Arguments\n\nTo denote optional arguments, you'd surround `argname` with square brackets `[]`.\n\n### Type Verification\n\ngetArgs will throw if the arguments have the wrong types\n\n    var args = getArgs('url:string', [1])\n    // Error: Expected url(pos 0) to be a string\n\n### Argument List Length Verification\n\ngetArgs will throw if there are too many or too few arguments\n\n    > getArgs('a,b', [1])\n    Error: Not enough arguments, expected 2, got 1\n    > getArgs('a,b', [1,1])\n    { a: 1, b: 1 }\n    > getArgs('a,b', [1,1,1])\n    Error: Too many arguments, expected 2, got 3\n\n### Spread Operator\n\nYou can mimick ES6's spread operator\n\n    var args = getArgs('first,...rest', [1,2,3,4])\n    console.log(args.first) // 1\n    console.log(args.rest)  // [2,3,4]\n\n### Set properties on an object\n\nIf you pass an object as its third argument, it will set the arguments as properties on that object.\n\n    getArgs('a,b,c', arguments, this)\n    // Now you can access the arguments by\n    // this.a, this.b, and this.c\n    \n","license":"MIT","scripts":{"test":"mocha tests.js -u tdd"},"_npmUser":{"name":"airportyh","email":"airportyh@gmail.com"},"keywords":["arguments","utility"],"repository":{"url":"git@github.com:airportyh/getargs.git","type":"git"},"_npmVersion":"1.3.8","description":"Utility to handle optional arguments and argument type checking.","maintainers":[{"name":"airportyh","email":"airportyh@gmail.com"}],"dependencies":{},"readmeFilename":"README.md","devDependencies":{"chai":"~1.7.2"},"_id":"getargs@0.0.8","version":"0.0.8"}