{"_id":"default-val","_rev":"5-56ba37a3deb1bb3c23ccef734b52cdcc","name":"default-val","description":"Get a default value when a value is nullish or invalid type","dist-tags":{"latest":"0.1.5"},"versions":{"0.1.2":{"name":"default-val","version":"0.1.2","description":"Set default value with type check.","main":"index.js","files":["index.js"],"scripts":{"lint":"eslint .","test":"mocha","coverage":"istanbul cover _mocha","coveralls":"istanbul cover _mocha && istanbul-coveralls","web:build":"browserify index.js --standalone defaultValue | uglifyjs --compress --mangle -o web/default-value.js && node test/web/make.js","web:test":"mocha-phantomjs -p node_modules/.bin/phantomjs test/web/default-value.test.html"},"repository":{"type":"git","url":"git+https://github.com/sttk/default-value.git"},"keywords":["default","value","type","check"],"author":{"name":"Takayuki Sato"},"license":"MIT","bugs":{"url":"https://github.com/sttk/default-value/issues"},"homepage":"https://github.com/sttk/default-value#readme","devDependencies":{"browserify":"^14.1.0","chai":"^3.5.0","eslint":"^3.16.1","istanbul":"^0.4.5","istanbul-coveralls":"^1.0.3","mocha":"^3.2.0","mocha-phantomjs":"^4.1.0","phantomjs":"^2.1.7","uglify-js":"^2.7.5"},"_id":"default-val@0.1.2","_shasum":"753ff2f63716faf3ce3246c55829bf58ec73fa0d","_resolved":"file:default-value-0.1.2.tar.gz","_from":"default-value-0.1.2.tar.gz","_npmVersion":"3.10.3","_nodeVersion":"6.7.0","_npmUser":{"name":"sttk","email":"t110000508260@yahoo.co.jp"},"dist":{"shasum":"753ff2f63716faf3ce3246c55829bf58ec73fa0d","tarball":"https://registry.npmjs.org/default-val/-/default-val-0.1.2.tgz","integrity":"sha512-2oNkJMC5gtqMaOEkqtk5iyMVgqi3DO9snrCcI8STW3CNYn6B9KCboOvxKiZoI8CbtPAiR/KdB65mDMF76IQ6ig==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFgOJmFDeQQ6xp5gavXppkeGJSClZ+1YyvpR8IsOfUdFAiAUxijtYMKDmEIyhTRUewhwJQ0GRuK1nM9Sayutd5LEqg=="}]},"maintainers":[{"name":"sttk","email":"t110000508260@yahoo.co.jp"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/default-val-0.1.2.tgz_1488206605205_0.08636037399992347"}},"0.1.3":{"name":"default-val","version":"0.1.3","description":"Set default value with type check.","main":"index.js","files":["index.js"],"scripts":{"lint":"eslint .","test":"mocha","coverage":"istanbul cover _mocha","coveralls":"istanbul cover _mocha && istanbul-coveralls","web:install":"npm i phantomjs-prebuilt mocha-phantomjs","web:build":"browserify index.js --standalone defaultValue | uglifyjs --compress --mangle -o web/default-value.js && node test/web/make.js","web:test":"mocha-phantomjs -p node_modules/.bin/phantomjs test/web/default-value.test.html"},"repository":{"type":"git","url":"git+https://github.com/sttk/default-value.git"},"keywords":["default","value","type","check"],"author":{"name":"Takayuki Sato"},"license":"MIT","bugs":{"url":"https://github.com/sttk/default-value/issues"},"homepage":"https://github.com/sttk/default-value#readme","devDependencies":{"browserify":"^14.1.0","chai":"^3.5.0","eslint":"^3.16.1","istanbul":"^0.4.5","istanbul-coveralls":"^1.0.3","mocha":"^3.2.0","uglify-js":"^2.8.1"},"_id":"default-val@0.1.3","_shasum":"388d057fc1d741f3648dbfe376da5b863d7e3e75","_resolved":"file:default-value-0.1.3.tar.gz","_from":"default-value-0.1.3.tar.gz","_npmVersion":"3.10.3","_nodeVersion":"6.7.0","_npmUser":{"name":"sttk","email":"t110000508260@yahoo.co.jp"},"dist":{"shasum":"388d057fc1d741f3648dbfe376da5b863d7e3e75","tarball":"https://registry.npmjs.org/default-val/-/default-val-0.1.3.tgz","integrity":"sha512-8Qc63bMR7sCeh66n32T73ePg/8ZE5R8oZpXNqmctxgsLEw9rUeBWm19occdt1cPcoDQwforVhDrb1SIzqkzOIw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCRQ64+Y0Z7dlj0Qiro+Vh+7wvaRGRDpm7GIhnVch4aVwIgaWqxqXCL52tQGKVsp9JFEeHjHsiTZc6LFYYVE5m9Gl8="}]},"maintainers":[{"name":"sttk","email":"t110000508260@yahoo.co.jp"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/default-val-0.1.3.tgz_1488377678130_0.4778878758661449"}},"0.1.4":{"name":"default-val","version":"0.1.4","description":"Get a default value when a value is nullish or invalid type","main":"index.js","files":["index.js"],"scripts":{"lint":"eslint .","test":"mocha","coverage":"istanbul cover _mocha","coveralls":"istanbul cover _mocha && istanbul-coveralls","web:install":"npm i phantomjs-prebuilt mocha-phantomjs","web:build":"browserify index.js --standalone defaultValue | uglifyjs --compress --mangle -o web/default-value.js && node test/web/make.js","web:test":"mocha-phantomjs -p node_modules/.bin/phantomjs test/web/default-value.test.html"},"repository":{"type":"git","url":"git+https://github.com/sttk/default-value.git"},"keywords":["default","value","type","check"],"author":{"name":"Takayuki Sato"},"license":"MIT","bugs":{"url":"https://github.com/sttk/default-value/issues"},"homepage":"https://github.com/sttk/default-value#readme","devDependencies":{"browserify":"^14.1.0","chai":"^3.5.0","eslint":"^3.16.1","istanbul":"^0.4.5","istanbul-coveralls":"^1.0.3","mocha":"^3.2.0","uglify-js":"^2.8.1"},"_id":"default-val@0.1.4","_shasum":"ea975ff47354184705aef310e2861a41c0401f33","_resolved":"file:default-value-0.1.4.tar.gz","_from":"default-value-0.1.4.tar.gz","_npmVersion":"3.10.10","_nodeVersion":"6.10.0","_npmUser":{"name":"sttk","email":"t110000508260@yahoo.co.jp"},"dist":{"shasum":"ea975ff47354184705aef310e2861a41c0401f33","tarball":"https://registry.npmjs.org/default-val/-/default-val-0.1.4.tgz","integrity":"sha512-2HyLAoACKfzIy+QQhnxvWRCcK6j+A1uLc/F3WjPjTXGXwv88M8iKoxOIlLW+/NJoNEF/HNaW4tsJcZH5OVq/Ig==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDlFIXB3qEGU71TjG7YQhLAEu+x7H3jFymPo0nC8uhacgIgF/GY3jYSsZ5TEzk6ei+E7IA25HfT0gP775RVuv6yFk8="}]},"maintainers":[{"name":"sttk","email":"t110000508260@yahoo.co.jp"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/default-val-0.1.4.tgz_1491106522821_0.34485360770486295"}},"0.1.5":{"name":"default-val","version":"0.1.5","description":"Get a default value when a value is nullish or invalid type","main":"index.js","files":["index.js"],"scripts":{"lint":"eslint .","test":"mocha","coverage":"istanbul cover _mocha","coveralls":"istanbul cover _mocha && istanbul-coveralls","web:install":"npm i phantomjs-prebuilt mocha-phantomjs","web:build":"browserify index.js --standalone defaultValue | uglifyjs --compress --mangle -o web/default-value.js && node test/web/make.js","web:test":"mocha-phantomjs -p node_modules/.bin/phantomjs test/web/default-value.test.html"},"repository":{"type":"git","url":"git+https://github.com/sttk/default-value.git"},"keywords":["default","value","type","check"],"author":{"name":"Takayuki Sato"},"license":"MIT","bugs":{"url":"https://github.com/sttk/default-value/issues"},"homepage":"https://github.com/sttk/default-value#readme","devDependencies":{"browserify":"^14.1.0","chai":"^3.5.0","eslint":"^3.16.1","istanbul":"^0.4.5","istanbul-coveralls":"^1.0.3","mocha":"^3.2.0","uglify-js":"^2.8.1"},"_id":"default-val@0.1.5","_shasum":"ffe68ad87abe4619ce7228b7aef2e02dafdae3b0","_resolved":"file:default-value-0.1.5.tar.gz","_from":"default-value-0.1.5.tar.gz","_npmVersion":"3.10.10","_nodeVersion":"6.10.0","_npmUser":{"name":"sttk","email":"t110000508260@yahoo.co.jp"},"dist":{"shasum":"ffe68ad87abe4619ce7228b7aef2e02dafdae3b0","tarball":"https://registry.npmjs.org/default-val/-/default-val-0.1.5.tgz","integrity":"sha512-0CnjcDCSePPBNzfyPUPmvyfdu0q1vCqiX5XcFwGCi1RzRkfGdMmsrprZHgtKgSPydklDx2HcXJT2JCAXIcBqPA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFLq2mhRrw1fjhhya6BdNCuSCBISlshjfBDBQMX2k2C8AiEAsBZufAxyEVdpTWwzpycBQXIhL3ExL9tYUo9kyQwH/Zc="}]},"maintainers":[{"name":"sttk","email":"t110000508260@yahoo.co.jp"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/default-val-0.1.5.tgz_1491117499382_0.3588558549527079"}}},"readme":"[default-value][repo-url] [![NPM][npm-img]][npm-url] [![MIT License][mit-img]][mit-url] [![Build Status][travis-img]][travis-url] [![Build Status][appveyor-img]][appveyor-url] [![Coverage Status][coverage-img]][coverage-url]\n===============\n\nGet a default value when a value is nullish or invalid type\n\nInstall\n-------\n\n```\n$ npm i default-val --save\n```\n\nUsage\n-----\n\n* Load this mudule :\n\n    ```js\n    const defaultValue = require('default-val');\n    ```\n\n* Return the default value when the value is undefined or null :\n\n    ```js\n    defaultValue(undefined, true) // => true\n    defaultValue(null, 123) // => 123\n    ```\n\n* Return the default value when the value is NaN :\n\n    ```js\n    defaultValue(NaN, 123) // => 123\n    defaultValue(Infinity, 123) // => Infinity\n    ```\n\n* Return the default value when the type of the value is invalid :\n\n    ```js\n    defaultValue(987, true) // => true\n    defaultValue(987, 'ABC', 'string') // => 'ABC'\n    defaultValue(987, 'ABC', '[object String]') // => 'ABC'\n    defaultValue(987, 123, '[object String]') // => 123\n    defaultValue(987, new Date(0), '[object Date]') // => new Date(0)\n    ```\n\n* And return the value when it is valid :\n\n    ```js\n    defaultValue(987, 0) // => 987\n    defaultValue(987, 123, 'number') // => 987\n    defaultValue(987, null, 'number') // => 987\n    defaultValue(987, 'ABC', '[object Number]') // => 987\n    ```\n\nAPI\n---\n\n### <u>defaultValue(value, defValue [, type]) => any</u>\n\nReturns the second argument when the first argument is `null`, `undefined` or `NaN`, or the type of the first argument is different from the type of the second argument.\nWhen the third argument is specified, returns the second argument if the type of the first argument is different from the type represented by the third argument.\nThe third argument can be specified the result of `typeof x` or `Object.prototype.toString.call(x)`.\n\n* **Arguments:**\n\n    * **value** [any] : a value to be evaluated.\n    * **defValue** [any] : a default value which is returned if **value** is invalid.\n    * **type** [string] : a type for a valid value. (optional)\n\n* **Return** [any] : **value** if **value** is valid, otherwise **defValue**.\n\nLicense\n-------\n\nCopyright (C) 2017 Takayuki Sato\n\nThis program is free software under [MIT][mit-url] License.\nSee the file LICENSE in this distribution for more details.\n\n[repo-url]: https://github.com/sttk/default-value/\n[npm-img]: https://img.shields.io/badge/npm-v0.1.5-blue.svg\n[npm-url]: https://www.npmjs.org/package/default-val/\n[mit-img]: https://img.shields.io/badge/license-MIT-green.svg\n[mit-url]: https://opensource.org/license.MIT\n[travis-img]: https://travis-ci.org/sttk/default-value.svg?branch=master\n[travis-url]: https://travis-ci.org/sttk/default-value\n[appveyor-img]: https://ci.appveyor.com/api/projects/status/github/sttk/default-value?branch=master&svg=true\n[appveyor-url]: https://ci.appveyor.com/project/sttk/default-value\n[coverage-img]: https://coveralls.io/repos/github/sttk/default-value/badge.svg?branch=master\n[coverage-url]: https://coveralls.io/github/sttk/default-value?branch=master\n\n","maintainers":[{"name":"sttk","email":"t110000508260@yahoo.co.jp"}],"time":{"modified":"2022-06-14T23:18:05.351Z","created":"2017-02-27T14:43:25.463Z","0.1.2":"2017-02-27T14:43:25.463Z","0.1.3":"2017-03-01T14:14:38.367Z","0.1.4":"2017-04-02T04:15:24.651Z","0.1.5":"2017-04-02T07:18:21.307Z"},"homepage":"https://github.com/sttk/default-value#readme","keywords":["default","value","type","check"],"repository":{"type":"git","url":"git+https://github.com/sttk/default-value.git"},"author":{"name":"Takayuki Sato"},"bugs":{"url":"https://github.com/sttk/default-value/issues"},"license":"MIT","readmeFilename":"README.md"}