Socket
Socket
Sign inDemoInstall

object-inspect

Package Overview
Dependencies
Maintainers
2
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

object-inspect - npm Package Compare versions

Comparing version 1.2.2 to 1.3.0

test-core-js.js

76

index.js

@@ -44,3 +44,3 @@ var hasMap = typeof Map === 'function' && Map.prototype;

}
function inspect (value, from) {

@@ -75,20 +75,6 @@ if (from) {

if (obj.length === 0) return '[]';
var xs = Array(obj.length);
for (var i = 0; i < obj.length; i++) {
xs[i] = has(obj, i) ? inspect(obj[i], obj) : '';
}
return '[ ' + xs.join(', ') + ' ]';
return '[ ' + arrObjKeys(obj, inspect).join(', ') + ' ]';
}
if (isError(obj)) {
var parts = [];
for (var key in obj) {
if (!has(obj, key)) continue;
if (/[^\w$]/.test(key)) {
parts.push(inspect(key) + ': ' + inspect(obj[key]));
}
else {
parts.push(key + ': ' + inspect(obj[key]));
}
}
var parts = arrObjKeys(obj, inspect);
if (parts.length === 0) return '[' + String(obj) + ']';

@@ -124,12 +110,3 @@ return '{ [' + String(obj) + '] ' + parts.join(', ') + ' }';

if (!isDate(obj) && !isRegExp(obj)) {
var xs = [];
var keys = objectKeys(obj);
keys.sort();
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
if (/[^\w$]/.test(key)) {
xs.push(inspect(key) + ': ' + inspect(obj[key], obj));
}
else xs.push(key + ': ' + inspect(obj[key], obj));
}
var xs = arrObjKeys(obj, inspect);
if (xs.length === 0) return '{}';

@@ -141,10 +118,2 @@ return '{ ' + xs.join(', ') + ' }';

function objectKeys(obj) {
var keys = [];
for (var key in obj) {
if (has(obj, key)) keys.push(key);
}
return keys;
}
function quote (s) {

@@ -192,3 +161,8 @@ return String(s).replace(/"/g, '&quot;');

mapSize.call(x);
return true;
try {
setSize.call(x);
} catch (s) {
return true;
}
return x instanceof Map; // core-js workaround, pre-v2.5.0
} catch (e) {}

@@ -204,3 +178,8 @@ return false;

setSize.call(x);
return true;
try {
mapSize.call(x);
} catch (m) {
return true;
}
return x instanceof Set; // core-js workaround, pre-v2.5.0
} catch (e) {}

@@ -236,4 +215,25 @@ return false;

function collectionOf(type, size, entries) {
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;
}
{
"name": "object-inspect",
"version": "1.2.2",
"version": "1.3.0",
"description": "string representations of objects in node and the browser",
"main": "index.js",
"devDependencies": {
"tape": "^4.6.3"
"core-js": "^2.4.1",
"tape": "^4.7.0"
},
"scripts": {
"test": "npm run tests-only",
"pretests-only": "node test-core-js",
"tests-only": "tape test/*.js"

@@ -12,0 +14,0 @@ },

@@ -10,2 +10,12 @@ var inspect = require('../');

test('arrays with properties', function (t) {
t.plan(1);
var arr = [3];
arr.foo = 'bar';
var obj = [1, 2, arr];
obj.baz = 'quux';
obj.index = -1;
t.equal(inspect(obj), '[ 1, 2, [ 3, foo: \'bar\' ], baz: \'quux\', index: -1 ]');
});
test('has', function (t) {

@@ -12,0 +22,0 @@ t.plan(1);

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc