0.1.4 Fix undefined/null return bug

master
David Kebler 2020-01-18 12:03:27 -08:00
parent 6ec7fece2b
commit 9d9c681689
2 changed files with 3 additions and 3 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@uci-utils/to-boolean",
"version": "0.1.3",
"version": "0.1.4",
"description": "function to return a boolean value from sets of default values",
"main": "src/boolean.js",
"scripts": {

View File

@ -5,8 +5,8 @@ function createBoolean (opts={}) {
return (value => {
if (opts.addTrue) rTrue = rTrue.concat(opts.addTrue)
if (opts.addFalse) rFalse = rFalse.concat(opts.addFalse)
if (value===undefined) return opts.undefined==='same' ? undefined : opts.undefined || false
if (value===null) return opts.null==='same' ? null : opts.null || false
if (value===undefined) return opts.undefined==='same' ? undefined : (opts.undefined || false)
if (value===null) return opts.null==='same' ? null : (opts.null || false)
if (!isNaN(Number(value))) return (opts.number==='default' ? !!value : (Number(value) > (opts.number || 0)? true : false))
if (typeof value==='string') {
value = value.trim()