Comparing version 0.3.0 to 0.3.1
{ | ||
"name": "assert-op", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"description": "assertions using comparison operators", | ||
@@ -5,0 +5,0 @@ "keywords": ["unit test", "test", "assert"], |
@@ -1,10 +0,12 @@ | ||
module.exports = toString | ||
module.exports = function(val, max) { | ||
var txt = toString(val) | ||
return (max && txt.length > max) ? Object.prototype.toString.call(val) : txt | ||
} | ||
function toString(val, max) { | ||
var c = val && (val.constructor || Object), | ||
t = c === Array ? '[' + val.map(toString) +']' | ||
: c === Object ? ('{' + Object.keys(val).map(kv,val) + '}') | ||
: c === String ? ('"'+val.replace(/\f/g, '\\f').replace(/\n/g, '\\n').replace(/\r/g, '\\r').replace(/\t/g, '\\t')+'"') | ||
: ('' + val) | ||
return (max && t.length > max) ? Object.prototype.toString.call(val) : t | ||
function toString(val) { | ||
var c = val && (val.constructor || Object) | ||
return c === Array ? '[' + val.map(toString) +']' | ||
: c === Object ? ('{' + Object.keys(val).map(kv,val) + '}') | ||
: c === String ? ('"'+val.replace(/\f/g, '\\f').replace(/\n/g, '\\n').replace(/\r/g, '\\r').replace(/\t/g, '\\t')+'"') | ||
: ('' + val) | ||
} | ||
@@ -11,0 +13,0 @@ |
@@ -23,2 +23,6 @@ /* eslint no-console: 0, no-loop-func: 0*/ | ||
a('===', toString([1,2],4), '[object Array]') | ||
a('===', toString([1234567890,2345678901]), '[1234567890,2345678901]') | ||
a('===', toString([1234567890,2345678901], 24), '[1234567890,2345678901]') | ||
a('===', toString([1234567890,2345678901], 22), '[object Array]') | ||
//null | ||
@@ -25,0 +29,0 @@ a('===', toString(null), 'null') |
14249
313