pax_global_header 0000666 0000000 0000000 00000000064 13220377077 0014522 g ustar 00root root 0000000 0000000 52 comment=ff3f3275ca14d80103461c8892ed164fea0741dc object-inspect-1.5.0/ 0000775 0000000 0000000 00000000000 13220377077 0014436 5 ustar 00root root 0000000 0000000 object-inspect-1.5.0/.gitignore 0000664 0000000 0000000 00000000215 13220377077 0016424 0 ustar 00root root 0000000 0000000 # gitignore node_modules # Only apps should have lockfiles npm-shrinkwrap.json package-lock.json yarn.lock # Coverage coverage .nyc_output object-inspect-1.5.0/.npmrc 0000664 0000000 0000000 00000000023 13220377077 0015551 0 ustar 00root root 0000000 0000000 package-lock=false object-inspect-1.5.0/.nycrc 0000664 0000000 0000000 00000000424 13220377077 0015555 0 ustar 00root root 0000000 0000000 { "all": true, "check-coverage": true, "instrumentation": false, "sourceMap": false, "reporter": "html", "lines": 95.95, "statements": 95, "functions": 96, "branches": 92, "exclude": [ "coverage", "example", "test", "test-core-js.js" ] } object-inspect-1.5.0/.travis.yml 0000664 0000000 0000000 00000012461 13220377077 0016553 0 ustar 00root root 0000000 0000000 language: node_js os: - linux node_js: - "9.3" - "8.9" - "7.10" - "6.12" - "5.12" - "4.8" - "iojs-v3.3" - "iojs-v2.5" - "iojs-v1.8" - "0.12" - "0.10" - "0.8" - "0.6" before_install: - 'nvm install-latest-npm' install: - 'if [ "${TRAVIS_NODE_VERSION}" = "0.6" ] || [ "${TRAVIS_NODE_VERSION}" = "0.9" ]; then nvm install --latest-npm 0.8 && npm install && nvm use "${TRAVIS_NODE_VERSION}"; else npm install; fi;' script: - 'if [ -n "${PRETEST-}" ]; then npm run pretest ; fi' - 'if [ -n "${POSTTEST-}" ]; then npm run posttest ; fi' - 'if [ -n "${COVERAGE-}" ]; then npm run coverage ; fi' - 'if [ -n "${TEST-}" ]; then npm run tests-only ; fi' sudo: false env: - TEST=true matrix: fast_finish: true include: - node_js: "node" env: COVERAGE=true - node_js: "9.2" env: TEST=true ALLOW_FAILURE=true - node_js: "9.1" env: TEST=true ALLOW_FAILURE=true - node_js: "9.0" env: TEST=true ALLOW_FAILURE=true - node_js: "8.8" env: TEST=true ALLOW_FAILURE=true - node_js: "8.7" env: TEST=true ALLOW_FAILURE=true - node_js: "8.6" env: TEST=true ALLOW_FAILURE=true - node_js: "8.5" env: TEST=true ALLOW_FAILURE=true - node_js: "8.4" env: TEST=true ALLOW_FAILURE=true - node_js: "8.3" env: TEST=true ALLOW_FAILURE=true - node_js: "8.2" env: TEST=true ALLOW_FAILURE=true - node_js: "8.1" env: TEST=true ALLOW_FAILURE=true - node_js: "8.0" env: TEST=true ALLOW_FAILURE=true - node_js: "7.9" env: TEST=true ALLOW_FAILURE=true - node_js: "7.8" env: TEST=true ALLOW_FAILURE=true - node_js: "7.7" env: TEST=true ALLOW_FAILURE=true - node_js: "7.6" env: TEST=true ALLOW_FAILURE=true - node_js: "7.5" env: TEST=true ALLOW_FAILURE=true - node_js: "7.4" env: TEST=true ALLOW_FAILURE=true - node_js: "7.3" env: TEST=true ALLOW_FAILURE=true - node_js: "7.2" env: TEST=true ALLOW_FAILURE=true - node_js: "7.1" env: TEST=true ALLOW_FAILURE=true - node_js: "7.0" env: TEST=true ALLOW_FAILURE=true - node_js: "6.11" env: TEST=true ALLOW_FAILURE=true - node_js: "6.10" env: TEST=true ALLOW_FAILURE=true - node_js: "6.9" env: TEST=true ALLOW_FAILURE=true - node_js: "6.8" env: TEST=true ALLOW_FAILURE=true - node_js: "6.7" env: TEST=true ALLOW_FAILURE=true - node_js: "6.6" env: TEST=true ALLOW_FAILURE=true - node_js: "6.5" env: TEST=true ALLOW_FAILURE=true - node_js: "6.4" env: TEST=true ALLOW_FAILURE=true - node_js: "6.3" env: TEST=true ALLOW_FAILURE=true - node_js: "6.2" env: TEST=true ALLOW_FAILURE=true - node_js: "6.1" env: TEST=true ALLOW_FAILURE=true - node_js: "6.0" env: TEST=true ALLOW_FAILURE=true - node_js: "5.11" env: TEST=true ALLOW_FAILURE=true - node_js: "5.10" env: TEST=true ALLOW_FAILURE=true - node_js: "5.9" env: TEST=true ALLOW_FAILURE=true - node_js: "5.8" env: TEST=true ALLOW_FAILURE=true - node_js: "5.7" env: TEST=true ALLOW_FAILURE=true - node_js: "5.6" env: TEST=true ALLOW_FAILURE=true - node_js: "5.5" env: TEST=true ALLOW_FAILURE=true - node_js: "5.4" env: TEST=true ALLOW_FAILURE=true - node_js: "5.3" env: TEST=true ALLOW_FAILURE=true - node_js: "5.2" env: TEST=true ALLOW_FAILURE=true - node_js: "5.1" env: TEST=true ALLOW_FAILURE=true - node_js: "5.0" env: TEST=true ALLOW_FAILURE=true - node_js: "4.7" env: TEST=true ALLOW_FAILURE=true - node_js: "4.6" env: TEST=true ALLOW_FAILURE=true - node_js: "4.5" env: TEST=true ALLOW_FAILURE=true - node_js: "4.4" env: TEST=true ALLOW_FAILURE=true - node_js: "4.3" env: TEST=true ALLOW_FAILURE=true - node_js: "4.2" env: TEST=true ALLOW_FAILURE=true - node_js: "4.1" env: TEST=true ALLOW_FAILURE=true - node_js: "4.0" env: TEST=true ALLOW_FAILURE=true - node_js: "iojs-v3.2" env: TEST=true ALLOW_FAILURE=true - node_js: "iojs-v3.1" env: TEST=true ALLOW_FAILURE=true - node_js: "iojs-v3.0" env: TEST=true ALLOW_FAILURE=true - node_js: "iojs-v2.4" env: TEST=true ALLOW_FAILURE=true - node_js: "iojs-v2.3" env: TEST=true ALLOW_FAILURE=true - node_js: "iojs-v2.2" env: TEST=true ALLOW_FAILURE=true - node_js: "iojs-v2.1" env: TEST=true ALLOW_FAILURE=true - node_js: "iojs-v2.0" env: TEST=true ALLOW_FAILURE=true - node_js: "iojs-v1.7" env: TEST=true ALLOW_FAILURE=true - node_js: "iojs-v1.6" env: TEST=true ALLOW_FAILURE=true - node_js: "iojs-v1.5" env: TEST=true ALLOW_FAILURE=true - node_js: "iojs-v1.4" env: TEST=true ALLOW_FAILURE=true - node_js: "iojs-v1.3" env: TEST=true ALLOW_FAILURE=true - node_js: "iojs-v1.2" env: TEST=true ALLOW_FAILURE=true - node_js: "iojs-v1.1" env: TEST=true ALLOW_FAILURE=true - node_js: "iojs-v1.0" env: TEST=true ALLOW_FAILURE=true - node_js: "0.11" env: TEST=true ALLOW_FAILURE=true - node_js: "0.9" env: TEST=true ALLOW_FAILURE=true - node_js: "0.4" env: TEST=true ALLOW_FAILURE=true allow_failures: - os: osx - env: TEST=true ALLOW_FAILURE=true object-inspect-1.5.0/LICENSE 0000664 0000000 0000000 00000002061 13220377077 0015442 0 ustar 00root root 0000000 0000000 This software is released under the MIT license: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. object-inspect-1.5.0/example/ 0000775 0000000 0000000 00000000000 13220377077 0016071 5 ustar 00root root 0000000 0000000 object-inspect-1.5.0/example/all.js 0000664 0000000 0000000 00000000512 13220377077 0017175 0 ustar 00root root 0000000 0000000 var inspect = require('../'); var holes = [ 'a', 'b' ]; holes[4] = 'e', holes[6] = 'g'; var obj = { a: 1, b: [ 3, 4, undefined, null ], c: undefined, d: null, e: { regex: /^x/i, buf: new Buffer('abc'), holes: holes }, now: new Date }; obj.self = obj; console.log(inspect(obj)); object-inspect-1.5.0/example/circular.js 0000664 0000000 0000000 00000000144 13220377077 0020232 0 ustar 00root root 0000000 0000000 var inspect = require('../'); var obj = { a: 1, b: [3,4] }; obj.c = obj; console.log(inspect(obj)); object-inspect-1.5.0/example/fn.js 0000664 0000000 0000000 00000000161 13220377077 0017030 0 ustar 00root root 0000000 0000000 var inspect = require('../'); var obj = [ 1, 2, function f (n) { return n + 5 }, 4 ]; console.log(inspect(obj)); object-inspect-1.5.0/example/inspect.js 0000664 0000000 0000000 00000000322 13220377077 0020071 0 ustar 00root root 0000000 0000000 var inspect = require('../'); var d = document.createElement('div'); d.setAttribute('id', 'beep'); d.innerHTML = 'woooiiiii'; console.log(inspect([ d, { a: 3, b : 4, c: [5,6,[7,[8,[9]]]] } ])); object-inspect-1.5.0/index.js 0000664 0000000 0000000 00000017246 13220377077 0016115 0 ustar 00root root 0000000 0000000 var hasMap = typeof Map === 'function' && Map.prototype; var mapSizeDescriptor = Object.getOwnPropertyDescriptor && hasMap ? Object.getOwnPropertyDescriptor(Map.prototype, 'size') : null; var mapSize = hasMap && mapSizeDescriptor && typeof mapSizeDescriptor.get === 'function' ? mapSizeDescriptor.get : null; var mapForEach = hasMap && Map.prototype.forEach; var hasSet = typeof Set === 'function' && Set.prototype; var setSizeDescriptor = Object.getOwnPropertyDescriptor && hasSet ? Object.getOwnPropertyDescriptor(Set.prototype, 'size') : null; var setSize = hasSet && setSizeDescriptor && typeof setSizeDescriptor.get === 'function' ? setSizeDescriptor.get : null; var setForEach = hasSet && Set.prototype.forEach; var booleanValueOf = Boolean.prototype.valueOf; var objectToString = Object.prototype.toString; var inspectCustom = require('./util.inspect').custom; var inspectSymbol = (inspectCustom && isSymbol(inspectCustom)) ? inspectCustom : null; module.exports = function inspect_ (obj, opts, depth, seen) { if (!opts) opts = {}; if (has(opts, 'quoteStyle') && (opts.quoteStyle !== 'single' && opts.quoteStyle !== 'double')) { throw new TypeError('option "quoteStyle" must be "single" or "double"'); } if (typeof obj === 'undefined') { return 'undefined'; } if (obj === null) { return 'null'; } if (typeof obj === 'boolean') { return obj ? 'true' : 'false'; } if (typeof obj === 'string') { return inspectString(obj, opts); } if (typeof obj === 'number') { if (obj === 0) { return Infinity / obj > 0 ? '0' : '-0'; } return String(obj); } var maxDepth = typeof opts.depth === 'undefined' ? 5 : opts.depth; if (typeof depth === 'undefined') depth = 0; if (depth >= maxDepth && maxDepth > 0 && typeof obj === 'object') { return '[Object]'; } if (typeof seen === 'undefined') seen = []; else if (indexOf(seen, obj) >= 0) { return '[Circular]'; } function inspect (value, from) { if (from) { seen = seen.slice(); seen.push(from); } return inspect_(value, opts, depth + 1, seen); } if (typeof obj === 'function') { var name = nameOf(obj); return '[Function' + (name ? ': ' + name : '') + ']'; } if (isSymbol(obj)) { var symString = Symbol.prototype.toString.call(obj); return typeof obj === 'object' ? markBoxed(symString) : symString; } if (isElement(obj)) { var s = '<' + String(obj.nodeName).toLowerCase(); var attrs = obj.attributes || []; for (var i = 0; i < attrs.length; i++) { s += ' ' + attrs[i].name + '=' + wrapQuotes(quote(attrs[i].value), 'double', opts); } s += '>'; if (obj.childNodes && obj.childNodes.length) s += '...'; s += '' + String(obj.nodeName).toLowerCase() + '>'; return s; } if (isArray(obj)) { if (obj.length === 0) return '[]'; return '[ ' + arrObjKeys(obj, inspect).join(', ') + ' ]'; } if (isError(obj)) { var parts = arrObjKeys(obj, inspect); if (parts.length === 0) return '[' + String(obj) + ']'; return '{ [' + String(obj) + '] ' + parts.join(', ') + ' }'; } if (typeof obj === 'object') { if (inspectSymbol && typeof obj[inspectSymbol] === 'function') { return obj[inspectSymbol](); } else if (typeof obj.inspect === 'function') { return obj.inspect(); } } if (isMap(obj)) { var parts = []; mapForEach.call(obj, function (value, key) { parts.push(inspect(key, obj) + ' => ' + inspect(value, obj)); }); return collectionOf('Map', mapSize.call(obj), parts); } if (isSet(obj)) { var parts = []; setForEach.call(obj, function (value ) { parts.push(inspect(value, obj)); }); return collectionOf('Set', setSize.call(obj), parts); } if (isNumber(obj)) { return markBoxed(inspect(Number(obj))); } if (isBoolean(obj)) { return markBoxed(booleanValueOf.call(obj)); } if (isString(obj)) { return markBoxed(inspect(String(obj))); } if (!isDate(obj) && !isRegExp(obj)) { var xs = arrObjKeys(obj, inspect); if (xs.length === 0) return '{}'; return '{ ' + xs.join(', ') + ' }'; } return String(obj); }; function wrapQuotes (s, defaultStyle, opts) { var quoteChar = (opts.quoteStyle || defaultStyle) === 'double' ? '"' : "'"; return quoteChar + s + quoteChar; } function quote (s) { return String(s).replace(/"/g, '"'); } function isArray (obj) { return toStr(obj) === '[object Array]' } function isDate (obj) { return toStr(obj) === '[object Date]' } function isRegExp (obj) { return toStr(obj) === '[object RegExp]' } function isError (obj) { return toStr(obj) === '[object Error]' } function isSymbol (obj) { return toStr(obj) === '[object Symbol]' } function isString (obj) { return toStr(obj) === '[object String]' } function isNumber (obj) { return toStr(obj) === '[object Number]' } function isBoolean (obj) { return toStr(obj) === '[object Boolean]' } var hasOwn = Object.prototype.hasOwnProperty || function (key) { return key in this; }; function has (obj, key) { return hasOwn.call(obj, key); } function toStr (obj) { return objectToString.call(obj); } function nameOf (f) { if (f.name) return f.name; var m = String(f).match(/^function\s*([\w$]+)/); if (m) return m[1]; } function indexOf (xs, x) { if (xs.indexOf) return xs.indexOf(x); for (var i = 0, l = xs.length; i < l; i++) { if (xs[i] === x) return i; } return -1; } function isMap (x) { if (!mapSize) { return false; } try { mapSize.call(x); try { setSize.call(x); } catch (s) { return true; } return x instanceof Map; // core-js workaround, pre-v2.5.0 } catch (e) {} return false; } function isSet (x) { if (!setSize) { return false; } try { setSize.call(x); try { mapSize.call(x); } catch (m) { return true; } return x instanceof Set; // core-js workaround, pre-v2.5.0 } catch (e) {} return false; } function isElement (x) { if (!x || typeof x !== 'object') return false; if (typeof HTMLElement !== 'undefined' && x instanceof HTMLElement) { return true; } return typeof x.nodeName === 'string' && typeof x.getAttribute === 'function' ; } function inspectString (str, opts) { var s = str.replace(/(['\\])/g, '\\$1').replace(/[\x00-\x1f]/g, lowbyte); return wrapQuotes(s, 'single', opts); } function lowbyte (c) { var n = c.charCodeAt(0); var x = { 8: 'b', 9: 't', 10: 'n', 12: 'f', 13: 'r' }[n]; if (x) return '\\' + x; return '\\x' + (n < 0x10 ? '0' : '') + n.toString(16); } function markBoxed (str) { return 'Object(' + str + ')'; } function collectionOf (type, size, entries) { return type + ' (' + size + ') {' + entries.join(', ') + '}'; } function arrObjKeys (obj, inspect) { var isArr = isArray(obj); var xs = []; if (isArr) { xs.length = obj.length; for (var i = 0; i < obj.length; i++) { xs[i] = has(obj, i) ? inspect(obj[i], obj) : ''; } } for (var key in obj) { if (!has(obj, key)) continue; if (isArr && String(Number(key)) === key && key < obj.length) continue; if (/[^\w$]/.test(key)) { xs.push(inspect(key, obj) + ': ' + inspect(obj[key], obj)); } else { xs.push(key + ': ' + inspect(obj[key], obj)); } } return xs; } object-inspect-1.5.0/package.json 0000664 0000000 0000000 00000002212 13220377077 0016721 0 ustar 00root root 0000000 0000000 { "name": "object-inspect", "version": "1.5.0", "description": "string representations of objects in node and the browser", "main": "index.js", "devDependencies": { "core-js": "^2.5.1", "nyc": "^10.3.2", "tape": "^4.8.0" }, "scripts": { "test": "npm run tests-only", "pretests-only": "node test-core-js", "tests-only": "tape test/*.js", "coverage": "nyc npm run tests-only" }, "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": { "type": "git", "url": "git://github.com/substack/object-inspect.git" }, "homepage": "https://github.com/substack/object-inspect", "keywords": [ "inspect", "util.inspect", "object", "stringify", "pretty" ], "author": { "name": "James Halliday", "email": "mail@substack.net", "url": "http://substack.net" }, "license": "MIT", "browser": { "./util.inspect.js": false } } object-inspect-1.5.0/readme.markdown 0000664 0000000 0000000 00000002240 13220377077 0017435 0 ustar 00root root 0000000 0000000 # object-inspect string representations of objects in node and the browser [](https://ci.testling.com/substack/object-inspect) [](http://travis-ci.org/substack/object-inspect) # example ## circular ``` js var inspect = require('object-inspect'); var obj = { a: 1, b: [3,4] }; obj.c = obj; console.log(inspect(obj)); ``` ## dom element ``` js var inspect = require('object-inspect'); var d = document.createElement('div'); d.setAttribute('id', 'beep'); d.innerHTML = 'woooiiiii'; console.log(inspect([ d, { a: 3, b : 4, c: [5,6,[7,[8,[9]]]] } ])); ``` output: ``` [