Skip to content

Commit

Permalink
assert.empty() works in repl
Browse files Browse the repository at this point in the history
  • Loading branch information
5long committed Dec 3, 2010
1 parent 614502f commit 22f90ac
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,14 @@ module.exports = util.merge(eA, {

, empty: function(val, msg) {
if (val === ""
|| (val instanceof Array && !val.length)
|| (val instanceof Object && !Object.keys(val).length)) return
fail(val, 0, msg, "length", eA.empty)
|| (Array.isArray(val) && !val.length)
|| (isObject(val) && !Object.keys(val).length)
) return
fail(val, 0, msg, ".length !==", eA.empty)
}

})

function isObject(val) {
return Object.prototype.toString.call(val) === "[object Object]"
}

0 comments on commit 22f90ac

Please sign in to comment.