object-inspect
Advanced tools
Comparing version 1.10.0 to 1.10.1
12
index.js
@@ -229,4 +229,14 @@ var hasMap = typeof Map === 'function' && Map.prototype; | ||
function isSymbol(obj) { return toStr(obj) === '[object Symbol]'; } | ||
function isBigInt(obj) { return toStr(obj) === '[object BigInt]'; } | ||
function isBigInt(obj) { | ||
if (!obj || typeof obj !== 'object' || !bigIntValueOf) { | ||
return false; | ||
} | ||
try { | ||
bigIntValueOf.call(obj); | ||
return true; | ||
} catch (e) {} | ||
return false; | ||
} | ||
var hasOwn = Object.prototype.hasOwnProperty || function (key) { return key in this; }; | ||
@@ -233,0 +243,0 @@ function has(obj, key) { |
{ | ||
"name": "object-inspect", | ||
"version": "1.10.0", | ||
"version": "1.10.1", | ||
"description": "string representations of objects in node and the browser", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -0,3 +1,6 @@ | ||
'use strict'; | ||
var inspect = require('../'); | ||
var test = require('tape'); | ||
var hasSymbols = require('has-symbols')(); | ||
@@ -30,3 +33,15 @@ test('bigint', { skip: typeof BigInt === 'undefined' }, function (t) { | ||
t.test('toStringTag', { skip: !hasSymbols || typeof Symbol.toStringTag !== 'symbol' }, function (st) { | ||
st.plan(1); | ||
var faker = {}; | ||
faker[Symbol.toStringTag] = 'BigInt'; | ||
st.equal( | ||
inspect(faker), | ||
'{ [Symbol(Symbol.toStringTag)]: \'BigInt\' }', | ||
'object lying about being a BigInt inspects as an object' | ||
); | ||
}); | ||
t.end(); | ||
}); |
51822
1268