diff --git a/.idea/workspace.xml b/.idea/workspace.xml index e7c5189..5287ed6 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -3,6 +3,8 @@ + + - + - - + + - + - - + + @@ -34,8 +36,8 @@ - - + + @@ -49,9 +51,9 @@ @@ -138,20 +140,23 @@ + + - + - + - + @@ -173,6 +178,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -216,24 +263,24 @@ - + - - + + - - + + - + - - + + diff --git a/index.js b/index.js index 6aac7bc..707e670 100644 --- a/index.js +++ b/index.js @@ -11,12 +11,22 @@ function nestedEmptyCheck(obj) { return true; } + else if(obj === undefined) { + return true; + } + + else if(typeof obj === "boolean"){ + return false; + } + else if(typeof obj === "number"){ return false; } - else if((typeof obj === "string") && obj != ''){ + else if((typeof obj === "string") && obj.trim() != ''){ return false; + } else if((typeof obj === "string") && obj.trim() === ''){ + return true; } else if(Array.isArray(obj)){ diff --git a/test/index.js b/test/index.js index 577802b..a43d252 100644 --- a/test/index.js +++ b/test/index.js @@ -15,6 +15,9 @@ var i = {a: [], b:{ }}; var j = {a: [], b:{ aa:[11], bb:{}}}; var k ={ system: [ { a: [1,2], c: [5,6], }, 2]} var l = {source: {}, type: "", pool: {}, acquireConnectionTimeout: '', system: [ { a: [], c: [] }, ] } +var m = {a:" "} +var n = {a:true} + test('isEmptyObj Testing', function(assert) { assert.equal(isEmptyObj(a), true); @@ -29,5 +32,8 @@ test('isEmptyObj Testing', function(assert) { assert.equal(isEmptyObj(j), false); assert.equal(isEmptyObj(k), false); assert.equal(isEmptyObj(l), true); + assert.equal(isEmptyObj(m), true); + assert.equal(isEmptyObj(n), false); assert.end() }) +