{"_id":"define-options","_rev":"13-1bf0df23bfd05ff081dcda1e64904af7","name":"define-options","description":"Define valid properties for an options litteral, and return a function that can validate the options","dist-tags":{"latest":"0.1.3"},"versions":{"0.0.1":{"name":"define-options","version":"0.0.1","description":"Define valid properties for an options litteral, and return a function that can validate the options","main":"index.js","scripts":{"test":"./node_modules/karma/bin/karma start --single-run","watch":"./node_modules/karma/bin/karma start"},"keywords":["browser","options","validate","util"],"repository":{"type":"git","url":"git@github.com:finn-no/define-options.git"},"issues":"https://github.com/finn-no/define-options/issues","author":{"name":"FINN.no AS"},"license":"MIT","devDependencies":{"es5-shim":"~2.3.0","chai":"~1.9.1","karma-chai":"~0.1.0","mocha":"~1.18.2","karma-mocha":"~0.1.3","karma-phantomjs-launcher":"~0.1.2","karma":"~0.12.1","karma-browserifast":"~0.4.1"},"bugs":{"url":"https://github.com/finn-no/define-options/issues"},"homepage":"https://github.com/finn-no/define-options","_id":"define-options@0.0.1","dist":{"shasum":"e2ea1e4001d322f7482ae311c586cc1dd7c21b78","tarball":"https://registry.npmjs.org/define-options/-/define-options-0.0.1.tgz","integrity":"sha512-pUpcIjJAzbdex9VlUEnW8XxbwIQ1vtrXSNSqUMFojWcVlqmX3NMv8CCQJYRUlXYQqyPqkxm27Ko69H036tYH5Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEDs2eb9EEWShJGs5TwqMKe6hgqiYr42GKG7ewJUOQCLAiAZqVThvvr2Ccx6lwT/plZVabxdMmkGqFY8NdWMd90tfQ=="}]},"_from":".","_npmVersion":"1.3.24","_npmUser":{"name":"gregersrygg","email":"gregersrygg@gmail.com"},"maintainers":[{"name":"gregersrygg","email":"gregersrygg@gmail.com"}]},"0.1.0":{"name":"define-options","version":"0.1.0","description":"Define valid properties for an options litteral, and return a function that can validate the options","main":"index.js","scripts":{"test":"./node_modules/karma/bin/karma start --single-run","watch":"./node_modules/karma/bin/karma start","umd":"umd defineOpts index.js dist/defineOpts.js","min":"uglifyjs dist/defineOpts.js -o dist/defineOpts.min.js","build":"npm run umd && npm run min"},"keywords":["browser","options","validate","util"],"repository":{"type":"git","url":"git@github.com:finn-no/define-options.git"},"issues":"https://github.com/finn-no/define-options/issues","author":{"name":"FINN.no AS"},"license":"MIT","devDependencies":{"es5-shim":"~2.3.0","chai":"~1.9.1","karma-chai":"~0.1.0","mocha":"~1.18.2","karma-mocha":"~0.1.3","karma-phantomjs-launcher":"~0.1.2","karma":"~0.12.1","karma-browserifast":"~0.4.1","umd":"~2.0.0","uglify-js":"~2.4.13"},"bugs":{"url":"https://github.com/finn-no/define-options/issues"},"homepage":"https://github.com/finn-no/define-options","_id":"define-options@0.1.0","dist":{"shasum":"57c7c1161ef7a2fdf62b5b6014fa6c57c98ab7d7","tarball":"https://registry.npmjs.org/define-options/-/define-options-0.1.0.tgz","integrity":"sha512-EIKznPpydNAt3SuAntp4vDya796P4baXLOKTmLDOm1DEF4+QTGPEhPsPaB98fpoTiABiIuXe12l5ZRo32T8sHg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCGt3VRJBaZjfpggCXNXLimoeLz+uQQ1Ojad3YQM7tHCwIhAN8eYm8bNNjftjQRE2542EAQ/BcBobjK3b4Pd3Euw5Fo"}]},"_from":".","_npmVersion":"1.3.24","_npmUser":{"name":"gregersrygg","email":"gregersrygg@gmail.com"},"maintainers":[{"name":"gregersrygg","email":"gregersrygg@gmail.com"}]},"0.1.1":{"name":"define-options","version":"0.1.1","description":"Define valid properties for an options litteral, and return a function that can validate the options","main":"index.js","scripts":{"test":"./node_modules/karma/bin/karma start --single-run","watch":"./node_modules/karma/bin/karma start","umd":"umd defineOpts index.js dist/define-options.js","min":"uglifyjs dist/define-options.js -o dist/define-options.min.js","build":"npm run umd && npm run min"},"keywords":["browser","options","validate","util"],"repository":{"type":"git","url":"git@github.com:finn-no/define-options.git"},"issues":"https://github.com/finn-no/define-options/issues","author":{"name":"FINN.no AS"},"license":"MIT","devDependencies":{"es5-shim":"~2.3.0","chai":"~1.9.1","karma-chai":"~0.1.0","mocha":"~1.18.2","karma-mocha":"~0.1.3","karma-phantomjs-launcher":"~0.1.2","karma":"~0.12.1","karma-browserifast":"~0.4.1","umd":"~2.0.0","uglify-js":"~2.4.13"},"bugs":{"url":"https://github.com/finn-no/define-options/issues"},"homepage":"https://github.com/finn-no/define-options","_id":"define-options@0.1.1","dist":{"shasum":"499ef1fe49ff736936e62ee039e9a52e13195150","tarball":"https://registry.npmjs.org/define-options/-/define-options-0.1.1.tgz","integrity":"sha512-dAXV4pZ9PAbW38+xyEgPa8sCDKHEveSyyQlW9LO158rP33kU7nQD9yjvFtwovl4gJlFmVETTONcZq3Cl81wpJw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCID+pPQKLhcEHeAQ1eTW6aNvRublobNQ5m1blgTXf7heAAiBLqcnMM70VldrsOsiG/UuBI/sPabde3G10LstrT1NPiA=="}]},"_from":".","_npmVersion":"1.3.24","_npmUser":{"name":"gregersrygg","email":"gregersrygg@gmail.com"},"maintainers":[{"name":"gregersrygg","email":"gregersrygg@gmail.com"}]},"0.1.2":{"name":"define-options","version":"0.1.2","description":"Define valid properties for an options litteral, and return a function that can validate the options","main":"index.js","scripts":{"test":"./node_modules/karma/bin/karma start --single-run","watch":"./node_modules/karma/bin/karma start","umd":"umd defineOpts -c index.js dist/define-options.js","min":"uglifyjs dist/define-options.js -o dist/define-options.min.js","build":"npm run umd && npm run min"},"keywords":["browser","options","validate","util"],"repository":{"type":"git","url":"git@github.com:finn-no/define-options.git"},"issues":"https://github.com/finn-no/define-options/issues","author":{"name":"FINN.no AS"},"license":"MIT","devDependencies":{"es5-shim":"~2.3.0","chai":"~1.9.1","karma-chai":"~0.1.0","mocha":"~1.18.2","karma-mocha":"~0.1.3","karma-phantomjs-launcher":"~0.1.2","karma":"~0.12.1","karma-browserifast":"~0.4.1","umd":"~2.0.0","uglify-js":"~2.4.13"},"bugs":{"url":"https://github.com/finn-no/define-options/issues"},"homepage":"https://github.com/finn-no/define-options","_id":"define-options@0.1.2","dist":{"shasum":"b4c1db23bb09693005d82ba91a608523ec99b50f","tarball":"https://registry.npmjs.org/define-options/-/define-options-0.1.2.tgz","integrity":"sha512-iidzT83NLhCmZlRO05OCZJObmFOnz/AtM74/nLi4Byd4uRHlp0Zm1mnoUO+r7/q7YtAuKtL8hRYBCMR7gVca4g==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAP6Y5rgMrAXuFwIauWIYgjcMCRob1cERPwHab3kOBiWAiEAhbPEkURwGQlnfiVnQX12Q0O11v5RfrWokqObxJjH3Xc="}]},"_from":".","_npmVersion":"1.3.24","_npmUser":{"name":"gregersrygg","email":"gregersrygg@gmail.com"},"maintainers":[{"name":"gregersrygg","email":"gregersrygg@gmail.com"}]},"0.1.3":{"name":"define-options","version":"0.1.3","description":"Define valid properties for an options litteral, and return a function that can validate the options","main":"index.js","scripts":{"test":"./node_modules/karma/bin/karma start --single-run","watch":"./node_modules/karma/bin/karma start","umd":"umd defineOpts -c index.js dist/define-options.js","min":"uglifyjs dist/define-options.js -o dist/define-options.min.js","build":"npm run umd && npm run min"},"keywords":["browser","options","validate","util"],"repository":{"type":"git","url":"git@github.com:finn-no/define-options.git"},"issues":"https://github.com/finn-no/define-options/issues","author":{"name":"FINN.no AS"},"license":"MIT","devDependencies":{"es5-shim":"~2.3.0","chai":"~1.9.1","karma-chai":"~0.1.0","mocha":"~1.18.2","karma-mocha":"~0.1.3","karma-phantomjs-launcher":"~0.1.2","karma":"~0.12.1","karma-browserifast":"~0.4.1","umd":"~2.0.0","uglify-js":"~2.4.13"},"bugs":{"url":"https://github.com/finn-no/define-options/issues"},"homepage":"https://github.com/finn-no/define-options","_id":"define-options@0.1.3","dist":{"shasum":"471c907439da590205050e856c8d59373f3a107b","tarball":"https://registry.npmjs.org/define-options/-/define-options-0.1.3.tgz","integrity":"sha512-f9Re5LGyfXT5KjO/eofGuYGfSgrxyiBJ2DhOiSTf7xDcAze1HoUB0Wdi8LvM265eLEOstzjWbkgPlg3Gz9bKqw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICdomZw5iqQ3qIjgJKG82R9tgSfvIJPJs67ZlYq37sshAiEAoIw/bA+KwOR07EjxeQZh0eYDFqEpwFWTY/rwV5L6iiw="}]},"_from":".","_npmVersion":"1.4.3","_npmUser":{"name":"gregersrygg","email":"gregersrygg@gmail.com"},"maintainers":[{"name":"gregersrygg","email":"gregersrygg@gmail.com"}]}},"readme":"define-options\n==============\n\nMicro lib to define valid properties for an options litteral, and return a function that can validate the options.\n\nThe main benefit is self-documenting code. Users of your library doesn't have to scan through the code to see what\nproperties from the options object that is used throughout the code. As a bonus you can easily throw an error early\nif a consumer is using an option with the wrong type, or a required option is missing. They will get a hint from the\nerror message what they did wrong instead of searching for docs.\n\n# API\n\n    var defineOpts   = require('define-options');\n    var validateOpts = defineOpts({\n            optionalParam   : '*             - This parameter can be null, undefined or any value',\n            optionalString  : '?|string      - This is an optional string',\n            aString         : 'string        - Required string. Can be blank.',\n            aNumber         : 'number        - Required number. Can be 0.',\n            aNumberOrString : 'number|string - Required number or string',\n            aStringArray    : 'array         - Required array of any types',\n            aStringArray    : 'string[]      - Required array with strings',\n            aNumberArray    : 'number[]      - Required array with numbers',\n            anObject        : 'object        - Required object',\n            aFunction       : 'function      - Required function',\n            aBboolean       : 'boolean       - Required boolean'\n        });\n\n    function yourAPI(options) {\n      validateOpts(options); // throws an error if options doesn't validate\n\n      // do your stuff\n    }\n\n# Optional options object\nIf all options are optional, the null will not throw an error.\n\n    var validateOpts = defineOpts({ foo: '?|string' });\n    validateOpts();               //all OK\n    validateOpts({foo: 'bar'});   // all OK\n    validateOpts({foo: 123});     // Exception: foo has to be of type ?|string but was number\n\n# Valid types\n\n    'array', 'boolean', 'function', 'number', 'object', 'string'\n\n# Arrays with type\nJust add [] after the type\n\n    'array[]', 'boolean[]', 'function[]', 'number[]', 'object[]', 'string[]'\n\n# Releasing\n\n    npm run build\n    git add dist/\n    git commit -m \"Updated dist files\"\n    npm version [<newversion> | major | minor | patch]\n    git push --follow-tags origin master\n    npm publish\n","maintainers":[{"name":"gregersrygg","email":"gregersrygg@gmail.com"},{"name":"sslash","email":"michaelgunnulfsen@gmail.com"}],"time":{"modified":"2022-06-14T23:28:01.488Z","created":"2014-03-27T08:55:55.861Z","0.0.1":"2014-03-27T08:55:55.861Z","0.1.0":"2014-03-31T08:12:33.923Z","0.1.1":"2014-03-31T08:50:35.856Z","0.1.2":"2014-03-31T09:10:32.047Z","0.1.3":"2014-05-13T09:07:31.255Z"},"homepage":"https://github.com/finn-no/define-options","keywords":["browser","options","validate","util"],"repository":{"type":"git","url":"git@github.com:finn-no/define-options.git"},"author":{"name":"FINN.no AS"},"bugs":{"url":"https://github.com/finn-no/define-options/issues"},"license":"MIT","readmeFilename":"README.md"}