Socket
Socket
Sign inDemoInstall

object-inspect

Package Overview
Dependencies
0
Maintainers
3
Versions
36
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.10.3 to 1.11.0

6

index.js

@@ -52,4 +52,4 @@ var hasMap = typeof Map === 'function' && Map.prototype;

var customInspect = has(opts, 'customInspect') ? opts.customInspect : true;
if (typeof customInspect !== 'boolean') {
throw new TypeError('option "customInspect", if provided, must be `true` or `false`');
if (typeof customInspect !== 'boolean' && customInspect !== 'symbol') {
throw new TypeError('option "customInspect", if provided, must be `true`, `false`, or `\'symbol\'`');
}

@@ -156,3 +156,3 @@

return obj[inspectSymbol]();
} else if (typeof obj.inspect === 'function') {
} else if (customInspect !== 'symbol' && typeof obj.inspect === 'function') {
return obj.inspect();

@@ -159,0 +159,0 @@ }

{
"name": "object-inspect",
"version": "1.10.3",
"version": "1.11.0",
"description": "string representations of objects in node and the browser",

@@ -10,3 +10,3 @@ "main": "index.js",

"core-js": "^2.6.12",
"eslint": "^7.26.0",
"eslint": "^7.30.0",
"for-each": "^0.3.3",

@@ -13,0 +13,0 @@ "functions-have-names": "^1.2.2",

@@ -9,11 +9,16 @@ var test = require('tape');

test('inspect', function (t) {
t.plan(4);
t.plan(5);
var obj = [{ inspect: function xyzInspect() { return '!XYZ¡'; } }, []];
t.equal(inspect(obj), '[ !XYZ¡, [] ]');
t.equal(inspect(obj, { customInspect: true }), '[ !XYZ¡, [] ]');
t.equal(inspect(obj, { customInspect: false }), '[ { inspect: [Function: xyzInspect] }, [] ]');
var stringResult = '[ !XYZ¡, [] ]';
var falseResult = '[ { inspect: [Function: xyzInspect] }, [] ]';
t.equal(inspect(obj), stringResult);
t.equal(inspect(obj, { customInspect: true }), stringResult);
t.equal(inspect(obj, { customInspect: 'symbol' }), falseResult);
t.equal(inspect(obj, { customInspect: false }), falseResult);
t['throws'](
function () { inspect(obj, { customInspect: 'not a boolean' }); },
function () { inspect(obj, { customInspect: 'not a boolean or "symbol"' }); },
TypeError,
'`customInspect` must be a boolean'
'`customInspect` must be a boolean or the string "symbol"'
);

@@ -23,3 +28,3 @@ });

test('inspect custom symbol', { skip: !hasSymbols || !utilInspect || !utilInspect.custom }, function (t) {
t.plan(3);
t.plan(4);

@@ -29,8 +34,13 @@ var obj = { inspect: function stringInspect() { return 'string'; } };

t.equal(inspect([obj, []]), '[ ' + (utilInspect.custom ? 'symbol' : 'string') + ', [] ]');
t.equal(inspect([obj, []], { customInspect: true }), '[ ' + (utilInspect.custom ? 'symbol' : 'string') + ', [] ]');
t.equal(
inspect([obj, []], { customInspect: false }),
'[ { inspect: [Function: stringInspect]' + (utilInspect.custom ? ', [' + inspect(utilInspect.custom) + ']: [Function: custom]' : '') + ' }, [] ]'
);
var symbolResult = '[ symbol, [] ]';
var stringResult = '[ string, [] ]';
var falseResult = '[ { inspect: [Function: stringInspect]' + (utilInspect.custom ? ', [' + inspect(utilInspect.custom) + ']: [Function: custom]' : '') + ' }, [] ]';
var symbolStringFallback = utilInspect.custom ? symbolResult : stringResult;
var symbolFalseFallback = utilInspect.custom ? symbolResult : falseResult;
t.equal(inspect([obj, []]), symbolStringFallback);
t.equal(inspect([obj, []], { customInspect: true }), symbolStringFallback);
t.equal(inspect([obj, []], { customInspect: 'symbol' }), symbolFalseFallback);
t.equal(inspect([obj, []], { customInspect: false }), falseResult);
});

@@ -37,0 +47,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc