object-inspect
Advanced tools
Comparing version 0.1.0 to 0.1.1
23
index.js
@@ -25,3 +25,4 @@ module.exports = function inspect_ (obj, opts, depth, seen) { | ||
else if (typeof obj === 'function') { | ||
return '[Function' + (obj.name ? ': ' + obj.name : '') + ']'; | ||
var name = nameOf(obj); | ||
return '[Function' + (name ? ': ' + name : '') + ']'; | ||
} | ||
@@ -49,8 +50,7 @@ else if (typeof HTMLElement !== 'undefined' && obj instanceof HTMLElement) { | ||
for (var key in obj) { | ||
if ({}.hasOwnProperty.call(obj, key)) { | ||
if (/[^\w$]/.test(key)) { | ||
xs.push(inspect(key) + ': ' + inspect(obj[key], obj)); | ||
} | ||
else xs.push(key + ': ' + inspect(obj[key], obj)); | ||
if (!has(obj, key)) continue; | ||
if (/[^\w$]/.test(key)) { | ||
xs.push(inspect(key) + ': ' + inspect(obj[key], obj)); | ||
} | ||
else xs.push(key + ': ' + inspect(obj[key], obj)); | ||
} | ||
@@ -77,1 +77,12 @@ return '{ ' + xs.join(', ') + ' }'; | ||
} | ||
function has (obj, key) { | ||
if (!{}.hasOwnProperty) return true; | ||
return {}.hasOwnProperty.call(obj, key); | ||
} | ||
function nameOf (f) { | ||
if (f.name) return f.name; | ||
var m = f.toString().match(/^function\s*([\w$]+)/); | ||
if (m) return m[1]; | ||
} |
{ | ||
"name": "object-inspect", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "string representations of objects in node and the browser", | ||
"main": "index.js", | ||
"dependencies": { | ||
"tape": "~1.0.4" | ||
}, | ||
"scripts": { | ||
"test": "tape test/*.js" | ||
}, | ||
"testling": { | ||
"files": [ "test/*.js", "test/browser/*.js" ], | ||
"browsers": [ | ||
"ie/6..latest", | ||
"chrome/latest", | ||
"firefox/latest", | ||
"safari/latest", | ||
"opera/latest", | ||
"iphone/latest", | ||
"ipad/latest", | ||
"android/latest" | ||
] | ||
}, | ||
"repository": { | ||
@@ -7,0 +26,0 @@ "type": "git", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6970
11
114
60
1
+ Addedtape@~1.0.4
+ Addeddeep-equal@0.0.0(transitive)
+ Addeddefined@0.0.0(transitive)
+ Addedjsonify@0.0.1(transitive)
+ Addedtape@1.0.4(transitive)
+ Addedthrough@2.3.8(transitive)