Permalink
Browse files

assert.empty() works in repl

  • Loading branch information...
1 parent 614502f commit 22f90acfe125aff60ce2c0adfcd36a958c1ef7f4 @5long committed Dec 3, 2010
Showing with 8 additions and 3 deletions.
  1. +8 −3 src/assert.js
View
@@ -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.