changes
This commit is contained in:
23
node_modules/object-inspect/example/all.js
generated
vendored
Normal file
23
node_modules/object-inspect/example/all.js
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
'use strict';
|
||||
|
||||
var inspect = require('../');
|
||||
var Buffer = require('safer-buffer').Buffer;
|
||||
|
||||
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: Buffer.from('abc'),
|
||||
holes: holes
|
||||
},
|
||||
now: new Date()
|
||||
};
|
||||
obj.self = obj;
|
||||
console.log(inspect(obj));
|
||||
6
node_modules/object-inspect/example/circular.js
generated
vendored
Normal file
6
node_modules/object-inspect/example/circular.js
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
var inspect = require('../');
|
||||
var obj = { a: 1, b: [3, 4] };
|
||||
obj.c = obj;
|
||||
console.log(inspect(obj));
|
||||
5
node_modules/object-inspect/example/fn.js
generated
vendored
Normal file
5
node_modules/object-inspect/example/fn.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
var inspect = require('../');
|
||||
var obj = [1, 2, function f(n) { return n + 5; }, 4];
|
||||
console.log(inspect(obj));
|
||||
10
node_modules/object-inspect/example/inspect.js
generated
vendored
Normal file
10
node_modules/object-inspect/example/inspect.js
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
'use strict';
|
||||
|
||||
/* eslint-env browser */
|
||||
var inspect = require('../');
|
||||
|
||||
var d = document.createElement('div');
|
||||
d.setAttribute('id', 'beep');
|
||||
d.innerHTML = '<b>wooo</b><i>iiiii</i>';
|
||||
|
||||
console.log(inspect([d, { a: 3, b: 4, c: [5, 6, [7, [8, [9]]]] }]));
|
||||
516
node_modules/object-inspect/index.js
generated
vendored
Normal file
516
node_modules/object-inspect/index.js
generated
vendored
Normal file
@@ -0,0 +1,516 @@
|
||||
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 hasWeakMap = typeof WeakMap === 'function' && WeakMap.prototype;
|
||||
var weakMapHas = hasWeakMap ? WeakMap.prototype.has : null;
|
||||
var hasWeakSet = typeof WeakSet === 'function' && WeakSet.prototype;
|
||||
var weakSetHas = hasWeakSet ? WeakSet.prototype.has : null;
|
||||
var hasWeakRef = typeof WeakRef === 'function' && WeakRef.prototype;
|
||||
var weakRefDeref = hasWeakRef ? WeakRef.prototype.deref : null;
|
||||
var booleanValueOf = Boolean.prototype.valueOf;
|
||||
var objectToString = Object.prototype.toString;
|
||||
var functionToString = Function.prototype.toString;
|
||||
var $match = String.prototype.match;
|
||||
var $slice = String.prototype.slice;
|
||||
var $replace = String.prototype.replace;
|
||||
var $toUpperCase = String.prototype.toUpperCase;
|
||||
var $toLowerCase = String.prototype.toLowerCase;
|
||||
var $test = RegExp.prototype.test;
|
||||
var $concat = Array.prototype.concat;
|
||||
var $join = Array.prototype.join;
|
||||
var $arrSlice = Array.prototype.slice;
|
||||
var $floor = Math.floor;
|
||||
var bigIntValueOf = typeof BigInt === 'function' ? BigInt.prototype.valueOf : null;
|
||||
var gOPS = Object.getOwnPropertySymbols;
|
||||
var symToString = typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol' ? Symbol.prototype.toString : null;
|
||||
var hasShammedSymbols = typeof Symbol === 'function' && typeof Symbol.iterator === 'object';
|
||||
// ie, `has-tostringtag/shams
|
||||
var toStringTag = typeof Symbol === 'function' && Symbol.toStringTag && (typeof Symbol.toStringTag === hasShammedSymbols ? 'object' : 'symbol')
|
||||
? Symbol.toStringTag
|
||||
: null;
|
||||
var isEnumerable = Object.prototype.propertyIsEnumerable;
|
||||
|
||||
var gPO = (typeof Reflect === 'function' ? Reflect.getPrototypeOf : Object.getPrototypeOf) || (
|
||||
[].__proto__ === Array.prototype // eslint-disable-line no-proto
|
||||
? function (O) {
|
||||
return O.__proto__; // eslint-disable-line no-proto
|
||||
}
|
||||
: null
|
||||
);
|
||||
|
||||
function addNumericSeparator(num, str) {
|
||||
if (
|
||||
num === Infinity
|
||||
|| num === -Infinity
|
||||
|| num !== num
|
||||
|| (num && num > -1000 && num < 1000)
|
||||
|| $test.call(/e/, str)
|
||||
) {
|
||||
return str;
|
||||
}
|
||||
var sepRegex = /[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;
|
||||
if (typeof num === 'number') {
|
||||
var int = num < 0 ? -$floor(-num) : $floor(num); // trunc(num)
|
||||
if (int !== num) {
|
||||
var intStr = String(int);
|
||||
var dec = $slice.call(str, intStr.length + 1);
|
||||
return $replace.call(intStr, sepRegex, '$&_') + '.' + $replace.call($replace.call(dec, /([0-9]{3})/g, '$&_'), /_$/, '');
|
||||
}
|
||||
}
|
||||
return $replace.call(str, sepRegex, '$&_');
|
||||
}
|
||||
|
||||
var utilInspect = require('./util.inspect');
|
||||
var inspectCustom = utilInspect.custom;
|
||||
var inspectSymbol = isSymbol(inspectCustom) ? inspectCustom : null;
|
||||
|
||||
module.exports = function inspect_(obj, options, depth, seen) {
|
||||
var opts = options || {};
|
||||
|
||||
if (has(opts, 'quoteStyle') && (opts.quoteStyle !== 'single' && opts.quoteStyle !== 'double')) {
|
||||
throw new TypeError('option "quoteStyle" must be "single" or "double"');
|
||||
}
|
||||
if (
|
||||
has(opts, 'maxStringLength') && (typeof opts.maxStringLength === 'number'
|
||||
? opts.maxStringLength < 0 && opts.maxStringLength !== Infinity
|
||||
: opts.maxStringLength !== null
|
||||
)
|
||||
) {
|
||||
throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');
|
||||
}
|
||||
var customInspect = has(opts, 'customInspect') ? opts.customInspect : true;
|
||||
if (typeof customInspect !== 'boolean' && customInspect !== 'symbol') {
|
||||
throw new TypeError('option "customInspect", if provided, must be `true`, `false`, or `\'symbol\'`');
|
||||
}
|
||||
|
||||
if (
|
||||
has(opts, 'indent')
|
||||
&& opts.indent !== null
|
||||
&& opts.indent !== '\t'
|
||||
&& !(parseInt(opts.indent, 10) === opts.indent && opts.indent > 0)
|
||||
) {
|
||||
throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');
|
||||
}
|
||||
if (has(opts, 'numericSeparator') && typeof opts.numericSeparator !== 'boolean') {
|
||||
throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');
|
||||
}
|
||||
var numericSeparator = opts.numericSeparator;
|
||||
|
||||
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';
|
||||
}
|
||||
var str = String(obj);
|
||||
return numericSeparator ? addNumericSeparator(obj, str) : str;
|
||||
}
|
||||
if (typeof obj === 'bigint') {
|
||||
var bigIntStr = String(obj) + 'n';
|
||||
return numericSeparator ? addNumericSeparator(obj, bigIntStr) : bigIntStr;
|
||||
}
|
||||
|
||||
var maxDepth = typeof opts.depth === 'undefined' ? 5 : opts.depth;
|
||||
if (typeof depth === 'undefined') { depth = 0; }
|
||||
if (depth >= maxDepth && maxDepth > 0 && typeof obj === 'object') {
|
||||
return isArray(obj) ? '[Array]' : '[Object]';
|
||||
}
|
||||
|
||||
var indent = getIndent(opts, depth);
|
||||
|
||||
if (typeof seen === 'undefined') {
|
||||
seen = [];
|
||||
} else if (indexOf(seen, obj) >= 0) {
|
||||
return '[Circular]';
|
||||
}
|
||||
|
||||
function inspect(value, from, noIndent) {
|
||||
if (from) {
|
||||
seen = $arrSlice.call(seen);
|
||||
seen.push(from);
|
||||
}
|
||||
if (noIndent) {
|
||||
var newOpts = {
|
||||
depth: opts.depth
|
||||
};
|
||||
if (has(opts, 'quoteStyle')) {
|
||||
newOpts.quoteStyle = opts.quoteStyle;
|
||||
}
|
||||
return inspect_(value, newOpts, depth + 1, seen);
|
||||
}
|
||||
return inspect_(value, opts, depth + 1, seen);
|
||||
}
|
||||
|
||||
if (typeof obj === 'function' && !isRegExp(obj)) { // in older engines, regexes are callable
|
||||
var name = nameOf(obj);
|
||||
var keys = arrObjKeys(obj, inspect);
|
||||
return '[Function' + (name ? ': ' + name : ' (anonymous)') + ']' + (keys.length > 0 ? ' { ' + $join.call(keys, ', ') + ' }' : '');
|
||||
}
|
||||
if (isSymbol(obj)) {
|
||||
var symString = hasShammedSymbols ? $replace.call(String(obj), /^(Symbol\(.*\))_[^)]*$/, '$1') : symToString.call(obj);
|
||||
return typeof obj === 'object' && !hasShammedSymbols ? markBoxed(symString) : symString;
|
||||
}
|
||||
if (isElement(obj)) {
|
||||
var s = '<' + $toLowerCase.call(String(obj.nodeName));
|
||||
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 += '</' + $toLowerCase.call(String(obj.nodeName)) + '>';
|
||||
return s;
|
||||
}
|
||||
if (isArray(obj)) {
|
||||
if (obj.length === 0) { return '[]'; }
|
||||
var xs = arrObjKeys(obj, inspect);
|
||||
if (indent && !singleLineValues(xs)) {
|
||||
return '[' + indentedJoin(xs, indent) + ']';
|
||||
}
|
||||
return '[ ' + $join.call(xs, ', ') + ' ]';
|
||||
}
|
||||
if (isError(obj)) {
|
||||
var parts = arrObjKeys(obj, inspect);
|
||||
if (!('cause' in Error.prototype) && 'cause' in obj && !isEnumerable.call(obj, 'cause')) {
|
||||
return '{ [' + String(obj) + '] ' + $join.call($concat.call('[cause]: ' + inspect(obj.cause), parts), ', ') + ' }';
|
||||
}
|
||||
if (parts.length === 0) { return '[' + String(obj) + ']'; }
|
||||
return '{ [' + String(obj) + '] ' + $join.call(parts, ', ') + ' }';
|
||||
}
|
||||
if (typeof obj === 'object' && customInspect) {
|
||||
if (inspectSymbol && typeof obj[inspectSymbol] === 'function' && utilInspect) {
|
||||
return utilInspect(obj, { depth: maxDepth - depth });
|
||||
} else if (customInspect !== 'symbol' && typeof obj.inspect === 'function') {
|
||||
return obj.inspect();
|
||||
}
|
||||
}
|
||||
if (isMap(obj)) {
|
||||
var mapParts = [];
|
||||
if (mapForEach) {
|
||||
mapForEach.call(obj, function (value, key) {
|
||||
mapParts.push(inspect(key, obj, true) + ' => ' + inspect(value, obj));
|
||||
});
|
||||
}
|
||||
return collectionOf('Map', mapSize.call(obj), mapParts, indent);
|
||||
}
|
||||
if (isSet(obj)) {
|
||||
var setParts = [];
|
||||
if (setForEach) {
|
||||
setForEach.call(obj, function (value) {
|
||||
setParts.push(inspect(value, obj));
|
||||
});
|
||||
}
|
||||
return collectionOf('Set', setSize.call(obj), setParts, indent);
|
||||
}
|
||||
if (isWeakMap(obj)) {
|
||||
return weakCollectionOf('WeakMap');
|
||||
}
|
||||
if (isWeakSet(obj)) {
|
||||
return weakCollectionOf('WeakSet');
|
||||
}
|
||||
if (isWeakRef(obj)) {
|
||||
return weakCollectionOf('WeakRef');
|
||||
}
|
||||
if (isNumber(obj)) {
|
||||
return markBoxed(inspect(Number(obj)));
|
||||
}
|
||||
if (isBigInt(obj)) {
|
||||
return markBoxed(inspect(bigIntValueOf.call(obj)));
|
||||
}
|
||||
if (isBoolean(obj)) {
|
||||
return markBoxed(booleanValueOf.call(obj));
|
||||
}
|
||||
if (isString(obj)) {
|
||||
return markBoxed(inspect(String(obj)));
|
||||
}
|
||||
if (!isDate(obj) && !isRegExp(obj)) {
|
||||
var ys = arrObjKeys(obj, inspect);
|
||||
var isPlainObject = gPO ? gPO(obj) === Object.prototype : obj instanceof Object || obj.constructor === Object;
|
||||
var protoTag = obj instanceof Object ? '' : 'null prototype';
|
||||
var stringTag = !isPlainObject && toStringTag && Object(obj) === obj && toStringTag in obj ? $slice.call(toStr(obj), 8, -1) : protoTag ? 'Object' : '';
|
||||
var constructorTag = isPlainObject || typeof obj.constructor !== 'function' ? '' : obj.constructor.name ? obj.constructor.name + ' ' : '';
|
||||
var tag = constructorTag + (stringTag || protoTag ? '[' + $join.call($concat.call([], stringTag || [], protoTag || []), ': ') + '] ' : '');
|
||||
if (ys.length === 0) { return tag + '{}'; }
|
||||
if (indent) {
|
||||
return tag + '{' + indentedJoin(ys, indent) + '}';
|
||||
}
|
||||
return tag + '{ ' + $join.call(ys, ', ') + ' }';
|
||||
}
|
||||
return String(obj);
|
||||
};
|
||||
|
||||
function wrapQuotes(s, defaultStyle, opts) {
|
||||
var quoteChar = (opts.quoteStyle || defaultStyle) === 'double' ? '"' : "'";
|
||||
return quoteChar + s + quoteChar;
|
||||
}
|
||||
|
||||
function quote(s) {
|
||||
return $replace.call(String(s), /"/g, '"');
|
||||
}
|
||||
|
||||
function isArray(obj) { return toStr(obj) === '[object Array]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj)); }
|
||||
function isDate(obj) { return toStr(obj) === '[object Date]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj)); }
|
||||
function isRegExp(obj) { return toStr(obj) === '[object RegExp]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj)); }
|
||||
function isError(obj) { return toStr(obj) === '[object Error]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj)); }
|
||||
function isString(obj) { return toStr(obj) === '[object String]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj)); }
|
||||
function isNumber(obj) { return toStr(obj) === '[object Number]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj)); }
|
||||
function isBoolean(obj) { return toStr(obj) === '[object Boolean]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj)); }
|
||||
|
||||
// Symbol and BigInt do have Symbol.toStringTag by spec, so that can't be used to eliminate false positives
|
||||
function isSymbol(obj) {
|
||||
if (hasShammedSymbols) {
|
||||
return obj && typeof obj === 'object' && obj instanceof Symbol;
|
||||
}
|
||||
if (typeof obj === 'symbol') {
|
||||
return true;
|
||||
}
|
||||
if (!obj || typeof obj !== 'object' || !symToString) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
symToString.call(obj);
|
||||
return true;
|
||||
} catch (e) {}
|
||||
return false;
|
||||
}
|
||||
|
||||
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; };
|
||||
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 = $match.call(functionToString.call(f), /^function\s*([\w$]+)/);
|
||||
if (m) { return m[1]; }
|
||||
return null;
|
||||
}
|
||||
|
||||
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 || !x || typeof x !== 'object') {
|
||||
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 isWeakMap(x) {
|
||||
if (!weakMapHas || !x || typeof x !== 'object') {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
weakMapHas.call(x, weakMapHas);
|
||||
try {
|
||||
weakSetHas.call(x, weakSetHas);
|
||||
} catch (s) {
|
||||
return true;
|
||||
}
|
||||
return x instanceof WeakMap; // core-js workaround, pre-v2.5.0
|
||||
} catch (e) {}
|
||||
return false;
|
||||
}
|
||||
|
||||
function isWeakRef(x) {
|
||||
if (!weakRefDeref || !x || typeof x !== 'object') {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
weakRefDeref.call(x);
|
||||
return true;
|
||||
} catch (e) {}
|
||||
return false;
|
||||
}
|
||||
|
||||
function isSet(x) {
|
||||
if (!setSize || !x || typeof x !== 'object') {
|
||||
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 isWeakSet(x) {
|
||||
if (!weakSetHas || !x || typeof x !== 'object') {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
weakSetHas.call(x, weakSetHas);
|
||||
try {
|
||||
weakMapHas.call(x, weakMapHas);
|
||||
} catch (s) {
|
||||
return true;
|
||||
}
|
||||
return x instanceof WeakSet; // 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) {
|
||||
if (str.length > opts.maxStringLength) {
|
||||
var remaining = str.length - opts.maxStringLength;
|
||||
var trailer = '... ' + remaining + ' more character' + (remaining > 1 ? 's' : '');
|
||||
return inspectString($slice.call(str, 0, opts.maxStringLength), opts) + trailer;
|
||||
}
|
||||
// eslint-disable-next-line no-control-regex
|
||||
var s = $replace.call($replace.call(str, /(['\\])/g, '\\$1'), /[\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' : '') + $toUpperCase.call(n.toString(16));
|
||||
}
|
||||
|
||||
function markBoxed(str) {
|
||||
return 'Object(' + str + ')';
|
||||
}
|
||||
|
||||
function weakCollectionOf(type) {
|
||||
return type + ' { ? }';
|
||||
}
|
||||
|
||||
function collectionOf(type, size, entries, indent) {
|
||||
var joinedEntries = indent ? indentedJoin(entries, indent) : $join.call(entries, ', ');
|
||||
return type + ' (' + size + ') {' + joinedEntries + '}';
|
||||
}
|
||||
|
||||
function singleLineValues(xs) {
|
||||
for (var i = 0; i < xs.length; i++) {
|
||||
if (indexOf(xs[i], '\n') >= 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function getIndent(opts, depth) {
|
||||
var baseIndent;
|
||||
if (opts.indent === '\t') {
|
||||
baseIndent = '\t';
|
||||
} else if (typeof opts.indent === 'number' && opts.indent > 0) {
|
||||
baseIndent = $join.call(Array(opts.indent + 1), ' ');
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
base: baseIndent,
|
||||
prev: $join.call(Array(depth + 1), baseIndent)
|
||||
};
|
||||
}
|
||||
|
||||
function indentedJoin(xs, indent) {
|
||||
if (xs.length === 0) { return ''; }
|
||||
var lineJoiner = '\n' + indent.prev + indent.base;
|
||||
return lineJoiner + $join.call(xs, ',' + lineJoiner) + '\n' + indent.prev;
|
||||
}
|
||||
|
||||
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) : '';
|
||||
}
|
||||
}
|
||||
var syms = typeof gOPS === 'function' ? gOPS(obj) : [];
|
||||
var symMap;
|
||||
if (hasShammedSymbols) {
|
||||
symMap = {};
|
||||
for (var k = 0; k < syms.length; k++) {
|
||||
symMap['$' + syms[k]] = syms[k];
|
||||
}
|
||||
}
|
||||
|
||||
for (var key in obj) { // eslint-disable-line no-restricted-syntax
|
||||
if (!has(obj, key)) { continue; } // eslint-disable-line no-restricted-syntax, no-continue
|
||||
if (isArr && String(Number(key)) === key && key < obj.length) { continue; } // eslint-disable-line no-restricted-syntax, no-continue
|
||||
if (hasShammedSymbols && symMap['$' + key] instanceof Symbol) {
|
||||
// this is to prevent shammed Symbols, which are stored as strings, from being included in the string key section
|
||||
continue; // eslint-disable-line no-restricted-syntax, no-continue
|
||||
} else if ($test.call(/[^\w$]/, key)) {
|
||||
xs.push(inspect(key, obj) + ': ' + inspect(obj[key], obj));
|
||||
} else {
|
||||
xs.push(key + ': ' + inspect(obj[key], obj));
|
||||
}
|
||||
}
|
||||
if (typeof gOPS === 'function') {
|
||||
for (var j = 0; j < syms.length; j++) {
|
||||
if (isEnumerable.call(obj, syms[j])) {
|
||||
xs.push('[' + inspect(syms[j]) + ']: ' + inspect(obj[syms[j]], obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
return xs;
|
||||
}
|
||||
26
node_modules/object-inspect/test-core-js.js
generated
vendored
Normal file
26
node_modules/object-inspect/test-core-js.js
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
'use strict';
|
||||
|
||||
require('core-js');
|
||||
|
||||
var inspect = require('./');
|
||||
var test = require('tape');
|
||||
|
||||
test('Maps', function (t) {
|
||||
t.equal(inspect(new Map([[1, 2]])), 'Map (1) {1 => 2}');
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('WeakMaps', function (t) {
|
||||
t.equal(inspect(new WeakMap([[{}, 2]])), 'WeakMap { ? }');
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('Sets', function (t) {
|
||||
t.equal(inspect(new Set([[1, 2]])), 'Set (1) {[ 1, 2 ]}');
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('WeakSets', function (t) {
|
||||
t.equal(inspect(new WeakSet([[1, 2]])), 'WeakSet { ? }');
|
||||
t.end();
|
||||
});
|
||||
58
node_modules/object-inspect/test/bigint.js
generated
vendored
Normal file
58
node_modules/object-inspect/test/bigint.js
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
'use strict';
|
||||
|
||||
var inspect = require('../');
|
||||
var test = require('tape');
|
||||
var hasToStringTag = require('has-tostringtag/shams')();
|
||||
|
||||
test('bigint', { skip: typeof BigInt === 'undefined' }, function (t) {
|
||||
t.test('primitives', function (st) {
|
||||
st.plan(3);
|
||||
|
||||
st.equal(inspect(BigInt(-256)), '-256n');
|
||||
st.equal(inspect(BigInt(0)), '0n');
|
||||
st.equal(inspect(BigInt(256)), '256n');
|
||||
});
|
||||
|
||||
t.test('objects', function (st) {
|
||||
st.plan(3);
|
||||
|
||||
st.equal(inspect(Object(BigInt(-256))), 'Object(-256n)');
|
||||
st.equal(inspect(Object(BigInt(0))), 'Object(0n)');
|
||||
st.equal(inspect(Object(BigInt(256))), 'Object(256n)');
|
||||
});
|
||||
|
||||
t.test('syntactic primitives', function (st) {
|
||||
st.plan(3);
|
||||
|
||||
/* eslint-disable no-new-func */
|
||||
st.equal(inspect(Function('return -256n')()), '-256n');
|
||||
st.equal(inspect(Function('return 0n')()), '0n');
|
||||
st.equal(inspect(Function('return 256n')()), '256n');
|
||||
});
|
||||
|
||||
t.test('toStringTag', { skip: !hasToStringTag }, 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.test('numericSeparator', function (st) {
|
||||
st.equal(inspect(BigInt(0), { numericSeparator: false }), '0n', '0n, numericSeparator false');
|
||||
st.equal(inspect(BigInt(0), { numericSeparator: true }), '0n', '0n, numericSeparator true');
|
||||
|
||||
st.equal(inspect(BigInt(1234), { numericSeparator: false }), '1234n', '1234n, numericSeparator false');
|
||||
st.equal(inspect(BigInt(1234), { numericSeparator: true }), '1_234n', '1234n, numericSeparator true');
|
||||
st.equal(inspect(BigInt(-1234), { numericSeparator: false }), '-1234n', '1234n, numericSeparator false');
|
||||
st.equal(inspect(BigInt(-1234), { numericSeparator: true }), '-1_234n', '1234n, numericSeparator true');
|
||||
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.end();
|
||||
});
|
||||
15
node_modules/object-inspect/test/browser/dom.js
generated
vendored
Normal file
15
node_modules/object-inspect/test/browser/dom.js
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
var inspect = require('../../');
|
||||
var test = require('tape');
|
||||
|
||||
test('dom element', function (t) {
|
||||
t.plan(1);
|
||||
|
||||
var d = document.createElement('div');
|
||||
d.setAttribute('id', 'beep');
|
||||
d.innerHTML = '<b>wooo</b><i>iiiii</i>';
|
||||
|
||||
t.equal(
|
||||
inspect([d, { a: 3, b: 4, c: [5, 6, [7, [8, [9]]]] }]),
|
||||
'[ <div id="beep">...</div>, { a: 3, b: 4, c: [ 5, 6, [ 7, [ 8, [Object] ] ] ] } ]'
|
||||
);
|
||||
});
|
||||
16
node_modules/object-inspect/test/circular.js
generated
vendored
Normal file
16
node_modules/object-inspect/test/circular.js
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
var inspect = require('../');
|
||||
var test = require('tape');
|
||||
|
||||
test('circular', function (t) {
|
||||
t.plan(2);
|
||||
var obj = { a: 1, b: [3, 4] };
|
||||
obj.c = obj;
|
||||
t.equal(inspect(obj), '{ a: 1, b: [ 3, 4 ], c: [Circular] }');
|
||||
|
||||
var double = {};
|
||||
double.a = [double];
|
||||
double.b = {};
|
||||
double.b.inner = double.b;
|
||||
double.b.obj = double;
|
||||
t.equal(inspect(double), '{ a: [ [Circular] ], b: { inner: [Circular], obj: [Circular] } }');
|
||||
});
|
||||
12
node_modules/object-inspect/test/deep.js
generated
vendored
Normal file
12
node_modules/object-inspect/test/deep.js
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
var inspect = require('../');
|
||||
var test = require('tape');
|
||||
|
||||
test('deep', function (t) {
|
||||
t.plan(4);
|
||||
var obj = [[[[[[500]]]]]];
|
||||
t.equal(inspect(obj), '[ [ [ [ [ [Array] ] ] ] ] ]');
|
||||
t.equal(inspect(obj, { depth: 4 }), '[ [ [ [ [Array] ] ] ] ]');
|
||||
t.equal(inspect(obj, { depth: 2 }), '[ [ [Array] ] ]');
|
||||
|
||||
t.equal(inspect([[[{ a: 1 }]]], { depth: 3 }), '[ [ [ [Object] ] ] ]');
|
||||
});
|
||||
53
node_modules/object-inspect/test/element.js
generated
vendored
Normal file
53
node_modules/object-inspect/test/element.js
generated
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
var inspect = require('../');
|
||||
var test = require('tape');
|
||||
|
||||
test('element', function (t) {
|
||||
t.plan(3);
|
||||
var elem = {
|
||||
nodeName: 'div',
|
||||
attributes: [{ name: 'class', value: 'row' }],
|
||||
getAttribute: function (key) { return key; },
|
||||
childNodes: []
|
||||
};
|
||||
var obj = [1, elem, 3];
|
||||
t.deepEqual(inspect(obj), '[ 1, <div class="row"></div>, 3 ]');
|
||||
t.deepEqual(inspect(obj, { quoteStyle: 'single' }), "[ 1, <div class='row'></div>, 3 ]");
|
||||
t.deepEqual(inspect(obj, { quoteStyle: 'double' }), '[ 1, <div class="row"></div>, 3 ]');
|
||||
});
|
||||
|
||||
test('element no attr', function (t) {
|
||||
t.plan(1);
|
||||
var elem = {
|
||||
nodeName: 'div',
|
||||
getAttribute: function (key) { return key; },
|
||||
childNodes: []
|
||||
};
|
||||
var obj = [1, elem, 3];
|
||||
t.deepEqual(inspect(obj), '[ 1, <div></div>, 3 ]');
|
||||
});
|
||||
|
||||
test('element with contents', function (t) {
|
||||
t.plan(1);
|
||||
var elem = {
|
||||
nodeName: 'div',
|
||||
getAttribute: function (key) { return key; },
|
||||
childNodes: [{ nodeName: 'b' }]
|
||||
};
|
||||
var obj = [1, elem, 3];
|
||||
t.deepEqual(inspect(obj), '[ 1, <div>...</div>, 3 ]');
|
||||
});
|
||||
|
||||
test('element instance', function (t) {
|
||||
t.plan(1);
|
||||
var h = global.HTMLElement;
|
||||
global.HTMLElement = function (name, attr) {
|
||||
this.nodeName = name;
|
||||
this.attributes = attr;
|
||||
};
|
||||
global.HTMLElement.prototype.getAttribute = function () {};
|
||||
|
||||
var elem = new global.HTMLElement('div', []);
|
||||
var obj = [1, elem, 3];
|
||||
t.deepEqual(inspect(obj), '[ 1, <div></div>, 3 ]');
|
||||
global.HTMLElement = h;
|
||||
});
|
||||
48
node_modules/object-inspect/test/err.js
generated
vendored
Normal file
48
node_modules/object-inspect/test/err.js
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
var test = require('tape');
|
||||
var ErrorWithCause = require('error-cause/Error');
|
||||
|
||||
var inspect = require('../');
|
||||
|
||||
test('type error', function (t) {
|
||||
t.plan(1);
|
||||
var aerr = new TypeError();
|
||||
aerr.foo = 555;
|
||||
aerr.bar = [1, 2, 3];
|
||||
|
||||
var berr = new TypeError('tuv');
|
||||
berr.baz = 555;
|
||||
|
||||
var cerr = new SyntaxError();
|
||||
cerr.message = 'whoa';
|
||||
cerr['a-b'] = 5;
|
||||
|
||||
var withCause = new ErrorWithCause('foo', { cause: 'bar' });
|
||||
var withCausePlus = new ErrorWithCause('foo', { cause: 'bar' });
|
||||
withCausePlus.foo = 'bar';
|
||||
var withUndefinedCause = new ErrorWithCause('foo', { cause: undefined });
|
||||
var withEnumerableCause = new Error('foo');
|
||||
withEnumerableCause.cause = 'bar';
|
||||
|
||||
var obj = [
|
||||
new TypeError(),
|
||||
new TypeError('xxx'),
|
||||
aerr,
|
||||
berr,
|
||||
cerr,
|
||||
withCause,
|
||||
withCausePlus,
|
||||
withUndefinedCause,
|
||||
withEnumerableCause
|
||||
];
|
||||
t.equal(inspect(obj), '[ ' + [
|
||||
'[TypeError]',
|
||||
'[TypeError: xxx]',
|
||||
'{ [TypeError] foo: 555, bar: [ 1, 2, 3 ] }',
|
||||
'{ [TypeError: tuv] baz: 555 }',
|
||||
'{ [SyntaxError: whoa] message: \'whoa\', \'a-b\': 5 }',
|
||||
'cause' in Error.prototype ? '[Error: foo]' : '{ [Error: foo] [cause]: \'bar\' }',
|
||||
'{ [Error: foo] ' + ('cause' in Error.prototype ? '' : '[cause]: \'bar\', ') + 'foo: \'bar\' }',
|
||||
'cause' in Error.prototype ? '[Error: foo]' : '{ [Error: foo] [cause]: undefined }',
|
||||
'{ [Error: foo] cause: \'bar\' }'
|
||||
].join(', ') + ' ]');
|
||||
});
|
||||
29
node_modules/object-inspect/test/fakes.js
generated
vendored
Normal file
29
node_modules/object-inspect/test/fakes.js
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
'use strict';
|
||||
|
||||
var inspect = require('../');
|
||||
var test = require('tape');
|
||||
var hasToStringTag = require('has-tostringtag/shams')();
|
||||
var forEach = require('for-each');
|
||||
|
||||
test('fakes', { skip: !hasToStringTag }, function (t) {
|
||||
forEach([
|
||||
'Array',
|
||||
'Boolean',
|
||||
'Date',
|
||||
'Error',
|
||||
'Number',
|
||||
'RegExp',
|
||||
'String'
|
||||
], function (expected) {
|
||||
var faker = {};
|
||||
faker[Symbol.toStringTag] = expected;
|
||||
|
||||
t.equal(
|
||||
inspect(faker),
|
||||
'{ [Symbol(Symbol.toStringTag)]: \'' + expected + '\' }',
|
||||
'faker masquerading as ' + expected + ' is not shown as one'
|
||||
);
|
||||
});
|
||||
|
||||
t.end();
|
||||
});
|
||||
76
node_modules/object-inspect/test/fn.js
generated
vendored
Normal file
76
node_modules/object-inspect/test/fn.js
generated
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
var inspect = require('../');
|
||||
var test = require('tape');
|
||||
var arrow = require('make-arrow-function')();
|
||||
var functionsHaveConfigurableNames = require('functions-have-names').functionsHaveConfigurableNames();
|
||||
|
||||
test('function', function (t) {
|
||||
t.plan(1);
|
||||
var obj = [1, 2, function f(n) { return n; }, 4];
|
||||
t.equal(inspect(obj), '[ 1, 2, [Function: f], 4 ]');
|
||||
});
|
||||
|
||||
test('function name', function (t) {
|
||||
t.plan(1);
|
||||
var f = (function () {
|
||||
return function () {};
|
||||
}());
|
||||
f.toString = function toStr() { return 'function xxx () {}'; };
|
||||
var obj = [1, 2, f, 4];
|
||||
t.equal(inspect(obj), '[ 1, 2, [Function (anonymous)] { toString: [Function: toStr] }, 4 ]');
|
||||
});
|
||||
|
||||
test('anon function', function (t) {
|
||||
var f = (function () {
|
||||
return function () {};
|
||||
}());
|
||||
var obj = [1, 2, f, 4];
|
||||
t.equal(inspect(obj), '[ 1, 2, [Function (anonymous)], 4 ]');
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('arrow function', { skip: !arrow }, function (t) {
|
||||
t.equal(inspect(arrow), '[Function (anonymous)]');
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('truly nameless function', { skip: !arrow || !functionsHaveConfigurableNames }, function (t) {
|
||||
function f() {}
|
||||
Object.defineProperty(f, 'name', { value: false });
|
||||
t.equal(f.name, false);
|
||||
t.equal(
|
||||
inspect(f),
|
||||
'[Function: f]',
|
||||
'named function with falsy `.name` does not hide its original name'
|
||||
);
|
||||
|
||||
function g() {}
|
||||
Object.defineProperty(g, 'name', { value: true });
|
||||
t.equal(g.name, true);
|
||||
t.equal(
|
||||
inspect(g),
|
||||
'[Function: true]',
|
||||
'named function with truthy `.name` hides its original name'
|
||||
);
|
||||
|
||||
var anon = function () {}; // eslint-disable-line func-style
|
||||
Object.defineProperty(anon, 'name', { value: null });
|
||||
t.equal(anon.name, null);
|
||||
t.equal(
|
||||
inspect(anon),
|
||||
'[Function (anonymous)]',
|
||||
'anon function with falsy `.name` does not hide its anonymity'
|
||||
);
|
||||
|
||||
var anon2 = function () {}; // eslint-disable-line func-style
|
||||
Object.defineProperty(anon2, 'name', { value: 1 });
|
||||
t.equal(anon2.name, 1);
|
||||
t.equal(
|
||||
inspect(anon2),
|
||||
'[Function: 1]',
|
||||
'anon function with truthy `.name` hides its anonymity'
|
||||
);
|
||||
|
||||
t.end();
|
||||
});
|
||||
15
node_modules/object-inspect/test/has.js
generated
vendored
Normal file
15
node_modules/object-inspect/test/has.js
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
'use strict';
|
||||
|
||||
var inspect = require('../');
|
||||
var test = require('tape');
|
||||
var mockProperty = require('mock-property');
|
||||
|
||||
test('when Object#hasOwnProperty is deleted', function (t) {
|
||||
t.plan(1);
|
||||
var arr = [1, , 3]; // eslint-disable-line no-sparse-arrays
|
||||
|
||||
t.teardown(mockProperty(Array.prototype, 1, { value: 2 })); // this is needed to account for "in" vs "hasOwnProperty"
|
||||
t.teardown(mockProperty(Object.prototype, 'hasOwnProperty', { 'delete': true }));
|
||||
|
||||
t.equal(inspect(arr), '[ 1, , 3 ]');
|
||||
});
|
||||
15
node_modules/object-inspect/test/holes.js
generated
vendored
Normal file
15
node_modules/object-inspect/test/holes.js
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
var test = require('tape');
|
||||
var inspect = require('../');
|
||||
|
||||
var xs = ['a', 'b'];
|
||||
xs[5] = 'f';
|
||||
xs[7] = 'j';
|
||||
xs[8] = 'k';
|
||||
|
||||
test('holes', function (t) {
|
||||
t.plan(1);
|
||||
t.equal(
|
||||
inspect(xs),
|
||||
"[ 'a', 'b', , , , 'f', , 'j', 'k' ]"
|
||||
);
|
||||
});
|
||||
271
node_modules/object-inspect/test/indent-option.js
generated
vendored
Normal file
271
node_modules/object-inspect/test/indent-option.js
generated
vendored
Normal file
@@ -0,0 +1,271 @@
|
||||
var test = require('tape');
|
||||
var forEach = require('for-each');
|
||||
|
||||
var inspect = require('../');
|
||||
|
||||
test('bad indent options', function (t) {
|
||||
forEach([
|
||||
undefined,
|
||||
true,
|
||||
false,
|
||||
-1,
|
||||
1.2,
|
||||
Infinity,
|
||||
-Infinity,
|
||||
NaN
|
||||
], function (indent) {
|
||||
t['throws'](
|
||||
function () { inspect('', { indent: indent }); },
|
||||
TypeError,
|
||||
inspect(indent) + ' is invalid'
|
||||
);
|
||||
});
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('simple object with indent', function (t) {
|
||||
t.plan(2);
|
||||
|
||||
var obj = { a: 1, b: 2 };
|
||||
|
||||
var expectedSpaces = [
|
||||
'{',
|
||||
' a: 1,',
|
||||
' b: 2',
|
||||
'}'
|
||||
].join('\n');
|
||||
var expectedTabs = [
|
||||
'{',
|
||||
' a: 1,',
|
||||
' b: 2',
|
||||
'}'
|
||||
].join('\n');
|
||||
|
||||
t.equal(inspect(obj, { indent: 2 }), expectedSpaces, 'two');
|
||||
t.equal(inspect(obj, { indent: '\t' }), expectedTabs, 'tabs');
|
||||
});
|
||||
|
||||
test('two deep object with indent', function (t) {
|
||||
t.plan(2);
|
||||
|
||||
var obj = { a: 1, b: { c: 3, d: 4 } };
|
||||
|
||||
var expectedSpaces = [
|
||||
'{',
|
||||
' a: 1,',
|
||||
' b: {',
|
||||
' c: 3,',
|
||||
' d: 4',
|
||||
' }',
|
||||
'}'
|
||||
].join('\n');
|
||||
var expectedTabs = [
|
||||
'{',
|
||||
' a: 1,',
|
||||
' b: {',
|
||||
' c: 3,',
|
||||
' d: 4',
|
||||
' }',
|
||||
'}'
|
||||
].join('\n');
|
||||
|
||||
t.equal(inspect(obj, { indent: 2 }), expectedSpaces, 'two');
|
||||
t.equal(inspect(obj, { indent: '\t' }), expectedTabs, 'tabs');
|
||||
});
|
||||
|
||||
test('simple array with all single line elements', function (t) {
|
||||
t.plan(2);
|
||||
|
||||
var obj = [1, 2, 3, 'asdf\nsdf'];
|
||||
|
||||
var expected = '[ 1, 2, 3, \'asdf\\nsdf\' ]';
|
||||
|
||||
t.equal(inspect(obj, { indent: 2 }), expected, 'two');
|
||||
t.equal(inspect(obj, { indent: '\t' }), expected, 'tabs');
|
||||
});
|
||||
|
||||
test('array with complex elements', function (t) {
|
||||
t.plan(2);
|
||||
|
||||
var obj = [1, { a: 1, b: { c: 1 } }, 'asdf\nsdf'];
|
||||
|
||||
var expectedSpaces = [
|
||||
'[',
|
||||
' 1,',
|
||||
' {',
|
||||
' a: 1,',
|
||||
' b: {',
|
||||
' c: 1',
|
||||
' }',
|
||||
' },',
|
||||
' \'asdf\\nsdf\'',
|
||||
']'
|
||||
].join('\n');
|
||||
var expectedTabs = [
|
||||
'[',
|
||||
' 1,',
|
||||
' {',
|
||||
' a: 1,',
|
||||
' b: {',
|
||||
' c: 1',
|
||||
' }',
|
||||
' },',
|
||||
' \'asdf\\nsdf\'',
|
||||
']'
|
||||
].join('\n');
|
||||
|
||||
t.equal(inspect(obj, { indent: 2 }), expectedSpaces, 'two');
|
||||
t.equal(inspect(obj, { indent: '\t' }), expectedTabs, 'tabs');
|
||||
});
|
||||
|
||||
test('values', function (t) {
|
||||
t.plan(2);
|
||||
var obj = [{}, [], { 'a-b': 5 }];
|
||||
|
||||
var expectedSpaces = [
|
||||
'[',
|
||||
' {},',
|
||||
' [],',
|
||||
' {',
|
||||
' \'a-b\': 5',
|
||||
' }',
|
||||
']'
|
||||
].join('\n');
|
||||
var expectedTabs = [
|
||||
'[',
|
||||
' {},',
|
||||
' [],',
|
||||
' {',
|
||||
' \'a-b\': 5',
|
||||
' }',
|
||||
']'
|
||||
].join('\n');
|
||||
|
||||
t.equal(inspect(obj, { indent: 2 }), expectedSpaces, 'two');
|
||||
t.equal(inspect(obj, { indent: '\t' }), expectedTabs, 'tabs');
|
||||
});
|
||||
|
||||
test('Map', { skip: typeof Map !== 'function' }, function (t) {
|
||||
var map = new Map();
|
||||
map.set({ a: 1 }, ['b']);
|
||||
map.set(3, NaN);
|
||||
|
||||
var expectedStringSpaces = [
|
||||
'Map (2) {',
|
||||
' { a: 1 } => [ \'b\' ],',
|
||||
' 3 => NaN',
|
||||
'}'
|
||||
].join('\n');
|
||||
var expectedStringTabs = [
|
||||
'Map (2) {',
|
||||
' { a: 1 } => [ \'b\' ],',
|
||||
' 3 => NaN',
|
||||
'}'
|
||||
].join('\n');
|
||||
var expectedStringTabsDoubleQuotes = [
|
||||
'Map (2) {',
|
||||
' { a: 1 } => [ "b" ],',
|
||||
' 3 => NaN',
|
||||
'}'
|
||||
].join('\n');
|
||||
|
||||
t.equal(
|
||||
inspect(map, { indent: 2 }),
|
||||
expectedStringSpaces,
|
||||
'Map keys are not indented (two)'
|
||||
);
|
||||
t.equal(
|
||||
inspect(map, { indent: '\t' }),
|
||||
expectedStringTabs,
|
||||
'Map keys are not indented (tabs)'
|
||||
);
|
||||
t.equal(
|
||||
inspect(map, { indent: '\t', quoteStyle: 'double' }),
|
||||
expectedStringTabsDoubleQuotes,
|
||||
'Map keys are not indented (tabs + double quotes)'
|
||||
);
|
||||
|
||||
t.equal(inspect(new Map(), { indent: 2 }), 'Map (0) {}', 'empty Map should show as empty (two)');
|
||||
t.equal(inspect(new Map(), { indent: '\t' }), 'Map (0) {}', 'empty Map should show as empty (tabs)');
|
||||
|
||||
var nestedMap = new Map();
|
||||
nestedMap.set(nestedMap, map);
|
||||
var expectedNestedSpaces = [
|
||||
'Map (1) {',
|
||||
' [Circular] => Map (2) {',
|
||||
' { a: 1 } => [ \'b\' ],',
|
||||
' 3 => NaN',
|
||||
' }',
|
||||
'}'
|
||||
].join('\n');
|
||||
var expectedNestedTabs = [
|
||||
'Map (1) {',
|
||||
' [Circular] => Map (2) {',
|
||||
' { a: 1 } => [ \'b\' ],',
|
||||
' 3 => NaN',
|
||||
' }',
|
||||
'}'
|
||||
].join('\n');
|
||||
t.equal(inspect(nestedMap, { indent: 2 }), expectedNestedSpaces, 'Map containing a Map should work (two)');
|
||||
t.equal(inspect(nestedMap, { indent: '\t' }), expectedNestedTabs, 'Map containing a Map should work (tabs)');
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('Set', { skip: typeof Set !== 'function' }, function (t) {
|
||||
var set = new Set();
|
||||
set.add({ a: 1 });
|
||||
set.add(['b']);
|
||||
var expectedStringSpaces = [
|
||||
'Set (2) {',
|
||||
' {',
|
||||
' a: 1',
|
||||
' },',
|
||||
' [ \'b\' ]',
|
||||
'}'
|
||||
].join('\n');
|
||||
var expectedStringTabs = [
|
||||
'Set (2) {',
|
||||
' {',
|
||||
' a: 1',
|
||||
' },',
|
||||
' [ \'b\' ]',
|
||||
'}'
|
||||
].join('\n');
|
||||
t.equal(inspect(set, { indent: 2 }), expectedStringSpaces, 'new Set([{ a: 1 }, ["b"]]) should show size and contents (two)');
|
||||
t.equal(inspect(set, { indent: '\t' }), expectedStringTabs, 'new Set([{ a: 1 }, ["b"]]) should show size and contents (tabs)');
|
||||
|
||||
t.equal(inspect(new Set(), { indent: 2 }), 'Set (0) {}', 'empty Set should show as empty (two)');
|
||||
t.equal(inspect(new Set(), { indent: '\t' }), 'Set (0) {}', 'empty Set should show as empty (tabs)');
|
||||
|
||||
var nestedSet = new Set();
|
||||
nestedSet.add(set);
|
||||
nestedSet.add(nestedSet);
|
||||
var expectedNestedSpaces = [
|
||||
'Set (2) {',
|
||||
' Set (2) {',
|
||||
' {',
|
||||
' a: 1',
|
||||
' },',
|
||||
' [ \'b\' ]',
|
||||
' },',
|
||||
' [Circular]',
|
||||
'}'
|
||||
].join('\n');
|
||||
var expectedNestedTabs = [
|
||||
'Set (2) {',
|
||||
' Set (2) {',
|
||||
' {',
|
||||
' a: 1',
|
||||
' },',
|
||||
' [ \'b\' ]',
|
||||
' },',
|
||||
' [Circular]',
|
||||
'}'
|
||||
].join('\n');
|
||||
t.equal(inspect(nestedSet, { indent: 2 }), expectedNestedSpaces, 'Set containing a Set should work (two)');
|
||||
t.equal(inspect(nestedSet, { indent: '\t' }), expectedNestedTabs, 'Set containing a Set should work (tabs)');
|
||||
|
||||
t.end();
|
||||
});
|
||||
139
node_modules/object-inspect/test/inspect.js
generated
vendored
Normal file
139
node_modules/object-inspect/test/inspect.js
generated
vendored
Normal file
@@ -0,0 +1,139 @@
|
||||
var test = require('tape');
|
||||
var hasSymbols = require('has-symbols/shams')();
|
||||
var utilInspect = require('../util.inspect');
|
||||
var repeat = require('string.prototype.repeat');
|
||||
|
||||
var inspect = require('..');
|
||||
|
||||
test('inspect', function (t) {
|
||||
t.plan(5);
|
||||
|
||||
var obj = [{ inspect: function xyzInspect() { return '!XYZ¡'; } }, []];
|
||||
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 or "symbol"' }); },
|
||||
TypeError,
|
||||
'`customInspect` must be a boolean or the string "symbol"'
|
||||
);
|
||||
});
|
||||
|
||||
test('inspect custom symbol', { skip: !hasSymbols || !utilInspect || !utilInspect.custom }, function (t) {
|
||||
t.plan(4);
|
||||
|
||||
var obj = { inspect: function stringInspect() { return 'string'; } };
|
||||
obj[utilInspect.custom] = function custom() { return 'symbol'; };
|
||||
|
||||
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);
|
||||
});
|
||||
|
||||
test('symbols', { skip: !hasSymbols }, function (t) {
|
||||
t.plan(2);
|
||||
|
||||
var obj = { a: 1 };
|
||||
obj[Symbol('test')] = 2;
|
||||
obj[Symbol.iterator] = 3;
|
||||
Object.defineProperty(obj, Symbol('non-enum'), {
|
||||
enumerable: false,
|
||||
value: 4
|
||||
});
|
||||
|
||||
if (typeof Symbol.iterator === 'symbol') {
|
||||
t.equal(inspect(obj), '{ a: 1, [Symbol(test)]: 2, [Symbol(Symbol.iterator)]: 3 }', 'object with symbols');
|
||||
t.equal(inspect([obj, []]), '[ { a: 1, [Symbol(test)]: 2, [Symbol(Symbol.iterator)]: 3 }, [] ]', 'object with symbols in array');
|
||||
} else {
|
||||
// symbol sham key ordering is unreliable
|
||||
t.match(
|
||||
inspect(obj),
|
||||
/^(?:{ a: 1, \[Symbol\(test\)\]: 2, \[Symbol\(Symbol.iterator\)\]: 3 }|{ a: 1, \[Symbol\(Symbol.iterator\)\]: 3, \[Symbol\(test\)\]: 2 })$/,
|
||||
'object with symbols (nondeterministic symbol sham key ordering)'
|
||||
);
|
||||
t.match(
|
||||
inspect([obj, []]),
|
||||
/^\[ (?:{ a: 1, \[Symbol\(test\)\]: 2, \[Symbol\(Symbol.iterator\)\]: 3 }|{ a: 1, \[Symbol\(Symbol.iterator\)\]: 3, \[Symbol\(test\)\]: 2 }), \[\] \]$/,
|
||||
'object with symbols in array (nondeterministic symbol sham key ordering)'
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
test('maxStringLength', function (t) {
|
||||
t['throws'](
|
||||
function () { inspect('', { maxStringLength: -1 }); },
|
||||
TypeError,
|
||||
'maxStringLength must be >= 0, or Infinity, not negative'
|
||||
);
|
||||
|
||||
var str = repeat('a', 1e8);
|
||||
|
||||
t.equal(
|
||||
inspect([str], { maxStringLength: 10 }),
|
||||
'[ \'aaaaaaaaaa\'... 99999990 more characters ]',
|
||||
'maxStringLength option limits output'
|
||||
);
|
||||
|
||||
t.equal(
|
||||
inspect(['f'], { maxStringLength: null }),
|
||||
'[ \'\'... 1 more character ]',
|
||||
'maxStringLength option accepts `null`'
|
||||
);
|
||||
|
||||
t.equal(
|
||||
inspect([str], { maxStringLength: Infinity }),
|
||||
'[ \'' + str + '\' ]',
|
||||
'maxStringLength option accepts ∞'
|
||||
);
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('inspect options', { skip: !utilInspect.custom }, function (t) {
|
||||
var obj = {};
|
||||
obj[utilInspect.custom] = function () {
|
||||
return JSON.stringify(arguments);
|
||||
};
|
||||
t.equal(
|
||||
inspect(obj),
|
||||
utilInspect(obj, { depth: 5 }),
|
||||
'custom symbols will use node\'s inspect'
|
||||
);
|
||||
t.equal(
|
||||
inspect(obj, { depth: 2 }),
|
||||
utilInspect(obj, { depth: 2 }),
|
||||
'a reduced depth will be passed to node\'s inspect'
|
||||
);
|
||||
t.equal(
|
||||
inspect({ d1: obj }, { depth: 3 }),
|
||||
'{ d1: ' + utilInspect(obj, { depth: 2 }) + ' }',
|
||||
'deep objects will receive a reduced depth'
|
||||
);
|
||||
t.equal(
|
||||
inspect({ d1: obj }, { depth: 1 }),
|
||||
'{ d1: [Object] }',
|
||||
'unlike nodejs inspect, customInspect will not be used once the depth is exceeded.'
|
||||
);
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('inspect URL', { skip: typeof URL === 'undefined' }, function (t) {
|
||||
t.match(
|
||||
inspect(new URL('https://nodejs.org')),
|
||||
/nodejs\.org/, // Different environments stringify it differently
|
||||
'url can be inspected'
|
||||
);
|
||||
t.end();
|
||||
});
|
||||
12
node_modules/object-inspect/test/lowbyte.js
generated
vendored
Normal file
12
node_modules/object-inspect/test/lowbyte.js
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
var test = require('tape');
|
||||
var inspect = require('../');
|
||||
|
||||
var obj = { x: 'a\r\nb', y: '\x05! \x1f \x12' };
|
||||
|
||||
test('interpolate low bytes', function (t) {
|
||||
t.plan(1);
|
||||
t.equal(
|
||||
inspect(obj),
|
||||
"{ x: 'a\\r\\nb', y: '\\x05! \\x1F \\x12' }"
|
||||
);
|
||||
});
|
||||
58
node_modules/object-inspect/test/number.js
generated
vendored
Normal file
58
node_modules/object-inspect/test/number.js
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
var test = require('tape');
|
||||
var v = require('es-value-fixtures');
|
||||
var forEach = require('for-each');
|
||||
|
||||
var inspect = require('../');
|
||||
|
||||
test('negative zero', function (t) {
|
||||
t.equal(inspect(0), '0', 'inspect(0) === "0"');
|
||||
t.equal(inspect(Object(0)), 'Object(0)', 'inspect(Object(0)) === "Object(0)"');
|
||||
|
||||
t.equal(inspect(-0), '-0', 'inspect(-0) === "-0"');
|
||||
t.equal(inspect(Object(-0)), 'Object(-0)', 'inspect(Object(-0)) === "Object(-0)"');
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('numericSeparator', function (t) {
|
||||
forEach(v.nonBooleans, function (nonBoolean) {
|
||||
t['throws'](
|
||||
function () { inspect(true, { numericSeparator: nonBoolean }); },
|
||||
TypeError,
|
||||
inspect(nonBoolean) + ' is not a boolean'
|
||||
);
|
||||
});
|
||||
|
||||
t.test('3 digit numbers', function (st) {
|
||||
var failed = false;
|
||||
for (var i = -999; i < 1000; i += 1) {
|
||||
var actual = inspect(i);
|
||||
var actualSepNo = inspect(i, { numericSeparator: false });
|
||||
var actualSepYes = inspect(i, { numericSeparator: true });
|
||||
var expected = String(i);
|
||||
if (actual !== expected || actualSepNo !== expected || actualSepYes !== expected) {
|
||||
failed = true;
|
||||
t.equal(actual, expected);
|
||||
t.equal(actualSepNo, expected);
|
||||
t.equal(actualSepYes, expected);
|
||||
}
|
||||
}
|
||||
|
||||
st.notOk(failed, 'all 3 digit numbers passed');
|
||||
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.equal(inspect(1e3), '1000', '1000');
|
||||
t.equal(inspect(1e3, { numericSeparator: false }), '1000', '1000, numericSeparator false');
|
||||
t.equal(inspect(1e3, { numericSeparator: true }), '1_000', '1000, numericSeparator true');
|
||||
t.equal(inspect(-1e3), '-1000', '-1000');
|
||||
t.equal(inspect(-1e3, { numericSeparator: false }), '-1000', '-1000, numericSeparator false');
|
||||
t.equal(inspect(-1e3, { numericSeparator: true }), '-1_000', '-1000, numericSeparator true');
|
||||
|
||||
t.equal(inspect(1234.5678, { numericSeparator: true }), '1_234.567_8', 'fractional numbers get separators');
|
||||
t.equal(inspect(1234.56789, { numericSeparator: true }), '1_234.567_89', 'fractional numbers get separators');
|
||||
t.equal(inspect(1234.567891, { numericSeparator: true }), '1_234.567_891', 'fractional numbers get separators');
|
||||
|
||||
t.end();
|
||||
});
|
||||
17
node_modules/object-inspect/test/quoteStyle.js
generated
vendored
Normal file
17
node_modules/object-inspect/test/quoteStyle.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
'use strict';
|
||||
|
||||
var inspect = require('../');
|
||||
var test = require('tape');
|
||||
|
||||
test('quoteStyle option', function (t) {
|
||||
t['throws'](function () { inspect(null, { quoteStyle: false }); }, 'false is not a valid value');
|
||||
t['throws'](function () { inspect(null, { quoteStyle: true }); }, 'true is not a valid value');
|
||||
t['throws'](function () { inspect(null, { quoteStyle: '' }); }, '"" is not a valid value');
|
||||
t['throws'](function () { inspect(null, { quoteStyle: {} }); }, '{} is not a valid value');
|
||||
t['throws'](function () { inspect(null, { quoteStyle: [] }); }, '[] is not a valid value');
|
||||
t['throws'](function () { inspect(null, { quoteStyle: 42 }); }, '42 is not a valid value');
|
||||
t['throws'](function () { inspect(null, { quoteStyle: NaN }); }, 'NaN is not a valid value');
|
||||
t['throws'](function () { inspect(null, { quoteStyle: function () {} }); }, 'a function is not a valid value');
|
||||
|
||||
t.end();
|
||||
});
|
||||
40
node_modules/object-inspect/test/toStringTag.js
generated
vendored
Normal file
40
node_modules/object-inspect/test/toStringTag.js
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
'use strict';
|
||||
|
||||
var test = require('tape');
|
||||
var hasToStringTag = require('has-tostringtag/shams')();
|
||||
|
||||
var inspect = require('../');
|
||||
|
||||
test('Symbol.toStringTag', { skip: !hasToStringTag }, function (t) {
|
||||
t.plan(4);
|
||||
|
||||
var obj = { a: 1 };
|
||||
t.equal(inspect(obj), '{ a: 1 }', 'object, no Symbol.toStringTag');
|
||||
|
||||
obj[Symbol.toStringTag] = 'foo';
|
||||
t.equal(inspect(obj), '{ a: 1, [Symbol(Symbol.toStringTag)]: \'foo\' }', 'object with Symbol.toStringTag');
|
||||
|
||||
t.test('null objects', { skip: 'toString' in { __proto__: null } }, function (st) {
|
||||
st.plan(2);
|
||||
|
||||
var dict = { __proto__: null, a: 1 };
|
||||
st.equal(inspect(dict), '[Object: null prototype] { a: 1 }', 'null object with Symbol.toStringTag');
|
||||
|
||||
dict[Symbol.toStringTag] = 'Dict';
|
||||
st.equal(inspect(dict), '[Dict: null prototype] { a: 1, [Symbol(Symbol.toStringTag)]: \'Dict\' }', 'null object with Symbol.toStringTag');
|
||||
});
|
||||
|
||||
t.test('instances', function (st) {
|
||||
st.plan(4);
|
||||
|
||||
function C() {
|
||||
this.a = 1;
|
||||
}
|
||||
st.equal(Object.prototype.toString.call(new C()), '[object Object]', 'instance, no toStringTag, Object.prototype.toString');
|
||||
st.equal(inspect(new C()), 'C { a: 1 }', 'instance, no toStringTag');
|
||||
|
||||
C.prototype[Symbol.toStringTag] = 'Class!';
|
||||
st.equal(Object.prototype.toString.call(new C()), '[object Class!]', 'instance, with toStringTag, Object.prototype.toString');
|
||||
st.equal(inspect(new C()), 'C [Class!] { a: 1 }', 'instance, with toStringTag');
|
||||
});
|
||||
});
|
||||
12
node_modules/object-inspect/test/undef.js
generated
vendored
Normal file
12
node_modules/object-inspect/test/undef.js
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
var test = require('tape');
|
||||
var inspect = require('../');
|
||||
|
||||
var obj = { a: 1, b: [3, 4, undefined, null], c: undefined, d: null };
|
||||
|
||||
test('undef and null', function (t) {
|
||||
t.plan(1);
|
||||
t.equal(
|
||||
inspect(obj),
|
||||
'{ a: 1, b: [ 3, 4, undefined, null ], c: undefined, d: null }'
|
||||
);
|
||||
});
|
||||
211
node_modules/object-inspect/test/values.js
generated
vendored
Normal file
211
node_modules/object-inspect/test/values.js
generated
vendored
Normal file
@@ -0,0 +1,211 @@
|
||||
'use strict';
|
||||
|
||||
var inspect = require('../');
|
||||
var test = require('tape');
|
||||
var mockProperty = require('mock-property');
|
||||
var hasSymbols = require('has-symbols/shams')();
|
||||
var hasToStringTag = require('has-tostringtag/shams')();
|
||||
|
||||
test('values', function (t) {
|
||||
t.plan(1);
|
||||
var obj = [{}, [], { 'a-b': 5 }];
|
||||
t.equal(inspect(obj), '[ {}, [], { \'a-b\': 5 } ]');
|
||||
});
|
||||
|
||||
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) {
|
||||
t.plan(1);
|
||||
t.teardown(mockProperty(Object.prototype, 'hasOwnProperty', { 'delete': true }));
|
||||
|
||||
t.equal(inspect({ a: 1, b: 2 }), '{ a: 1, b: 2 }');
|
||||
});
|
||||
|
||||
test('indexOf seen', function (t) {
|
||||
t.plan(1);
|
||||
var xs = [1, 2, 3, {}];
|
||||
xs.push(xs);
|
||||
|
||||
var seen = [];
|
||||
seen.indexOf = undefined;
|
||||
|
||||
t.equal(
|
||||
inspect(xs, {}, 0, seen),
|
||||
'[ 1, 2, 3, {}, [Circular] ]'
|
||||
);
|
||||
});
|
||||
|
||||
test('seen seen', function (t) {
|
||||
t.plan(1);
|
||||
var xs = [1, 2, 3];
|
||||
|
||||
var seen = [xs];
|
||||
seen.indexOf = undefined;
|
||||
|
||||
t.equal(
|
||||
inspect(xs, {}, 0, seen),
|
||||
'[Circular]'
|
||||
);
|
||||
});
|
||||
|
||||
test('seen seen seen', function (t) {
|
||||
t.plan(1);
|
||||
var xs = [1, 2, 3];
|
||||
|
||||
var seen = [5, xs];
|
||||
seen.indexOf = undefined;
|
||||
|
||||
t.equal(
|
||||
inspect(xs, {}, 0, seen),
|
||||
'[Circular]'
|
||||
);
|
||||
});
|
||||
|
||||
test('symbols', { skip: !hasSymbols }, function (t) {
|
||||
var sym = Symbol('foo');
|
||||
t.equal(inspect(sym), 'Symbol(foo)', 'Symbol("foo") should be "Symbol(foo)"');
|
||||
if (typeof sym === 'symbol') {
|
||||
// Symbol shams are incapable of differentiating boxed from unboxed symbols
|
||||
t.equal(inspect(Object(sym)), 'Object(Symbol(foo))', 'Object(Symbol("foo")) should be "Object(Symbol(foo))"');
|
||||
}
|
||||
|
||||
t.test('toStringTag', { skip: !hasToStringTag }, function (st) {
|
||||
st.plan(1);
|
||||
|
||||
var faker = {};
|
||||
faker[Symbol.toStringTag] = 'Symbol';
|
||||
st.equal(
|
||||
inspect(faker),
|
||||
'{ [Symbol(Symbol.toStringTag)]: \'Symbol\' }',
|
||||
'object lying about being a Symbol inspects as an object'
|
||||
);
|
||||
});
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('Map', { skip: typeof Map !== 'function' }, function (t) {
|
||||
var map = new Map();
|
||||
map.set({ a: 1 }, ['b']);
|
||||
map.set(3, NaN);
|
||||
var expectedString = 'Map (2) {' + inspect({ a: 1 }) + ' => ' + inspect(['b']) + ', 3 => NaN}';
|
||||
t.equal(inspect(map), expectedString, 'new Map([[{ a: 1 }, ["b"]], [3, NaN]]) should show size and contents');
|
||||
t.equal(inspect(new Map()), 'Map (0) {}', 'empty Map should show as empty');
|
||||
|
||||
var nestedMap = new Map();
|
||||
nestedMap.set(nestedMap, map);
|
||||
t.equal(inspect(nestedMap), 'Map (1) {[Circular] => ' + expectedString + '}', 'Map containing a Map should work');
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('WeakMap', { skip: typeof WeakMap !== 'function' }, function (t) {
|
||||
var map = new WeakMap();
|
||||
map.set({ a: 1 }, ['b']);
|
||||
var expectedString = 'WeakMap { ? }';
|
||||
t.equal(inspect(map), expectedString, 'new WeakMap([[{ a: 1 }, ["b"]]]) should not show size or contents');
|
||||
t.equal(inspect(new WeakMap()), 'WeakMap { ? }', 'empty WeakMap should not show as empty');
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('Set', { skip: typeof Set !== 'function' }, function (t) {
|
||||
var set = new Set();
|
||||
set.add({ a: 1 });
|
||||
set.add(['b']);
|
||||
var expectedString = 'Set (2) {' + inspect({ a: 1 }) + ', ' + inspect(['b']) + '}';
|
||||
t.equal(inspect(set), expectedString, 'new Set([{ a: 1 }, ["b"]]) should show size and contents');
|
||||
t.equal(inspect(new Set()), 'Set (0) {}', 'empty Set should show as empty');
|
||||
|
||||
var nestedSet = new Set();
|
||||
nestedSet.add(set);
|
||||
nestedSet.add(nestedSet);
|
||||
t.equal(inspect(nestedSet), 'Set (2) {' + expectedString + ', [Circular]}', 'Set containing a Set should work');
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('WeakSet', { skip: typeof WeakSet !== 'function' }, function (t) {
|
||||
var map = new WeakSet();
|
||||
map.add({ a: 1 });
|
||||
var expectedString = 'WeakSet { ? }';
|
||||
t.equal(inspect(map), expectedString, 'new WeakSet([{ a: 1 }]) should not show size or contents');
|
||||
t.equal(inspect(new WeakSet()), 'WeakSet { ? }', 'empty WeakSet should not show as empty');
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('WeakRef', { skip: typeof WeakRef !== 'function' }, function (t) {
|
||||
var ref = new WeakRef({ a: 1 });
|
||||
var expectedString = 'WeakRef { ? }';
|
||||
t.equal(inspect(ref), expectedString, 'new WeakRef({ a: 1 }) should not show contents');
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('FinalizationRegistry', { skip: typeof FinalizationRegistry !== 'function' }, function (t) {
|
||||
var registry = new FinalizationRegistry(function () {});
|
||||
var expectedString = 'FinalizationRegistry [FinalizationRegistry] {}';
|
||||
t.equal(inspect(registry), expectedString, 'new FinalizationRegistry(function () {}) should work normallys');
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('Strings', function (t) {
|
||||
var str = 'abc';
|
||||
|
||||
t.equal(inspect(str), "'" + str + "'", 'primitive string shows as such');
|
||||
t.equal(inspect(str, { quoteStyle: 'single' }), "'" + str + "'", 'primitive string shows as such, single quoted');
|
||||
t.equal(inspect(str, { quoteStyle: 'double' }), '"' + str + '"', 'primitive string shows as such, double quoted');
|
||||
t.equal(inspect(Object(str)), 'Object(' + inspect(str) + ')', 'String object shows as such');
|
||||
t.equal(inspect(Object(str), { quoteStyle: 'single' }), 'Object(' + inspect(str, { quoteStyle: 'single' }) + ')', 'String object shows as such, single quoted');
|
||||
t.equal(inspect(Object(str), { quoteStyle: 'double' }), 'Object(' + inspect(str, { quoteStyle: 'double' }) + ')', 'String object shows as such, double quoted');
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('Numbers', function (t) {
|
||||
var num = 42;
|
||||
|
||||
t.equal(inspect(num), String(num), 'primitive number shows as such');
|
||||
t.equal(inspect(Object(num)), 'Object(' + inspect(num) + ')', 'Number object shows as such');
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('Booleans', function (t) {
|
||||
t.equal(inspect(true), String(true), 'primitive true shows as such');
|
||||
t.equal(inspect(Object(true)), 'Object(' + inspect(true) + ')', 'Boolean object true shows as such');
|
||||
|
||||
t.equal(inspect(false), String(false), 'primitive false shows as such');
|
||||
t.equal(inspect(Object(false)), 'Object(' + inspect(false) + ')', 'Boolean false object shows as such');
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('Date', function (t) {
|
||||
var now = new Date();
|
||||
t.equal(inspect(now), String(now), 'Date shows properly');
|
||||
t.equal(inspect(new Date(NaN)), 'Invalid Date', 'Invalid Date shows properly');
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('RegExps', function (t) {
|
||||
t.equal(inspect(/a/g), '/a/g', 'regex shows properly');
|
||||
t.equal(inspect(new RegExp('abc', 'i')), '/abc/i', 'new RegExp shows properly');
|
||||
|
||||
var match = 'abc abc'.match(/[ab]+/);
|
||||
delete match.groups; // for node < 10
|
||||
t.equal(inspect(match), '[ \'ab\', index: 0, input: \'abc abc\' ]', 'RegExp match object shows properly');
|
||||
|
||||
t.end();
|
||||
});
|
||||
1
node_modules/object-inspect/util.inspect.js
generated
vendored
Normal file
1
node_modules/object-inspect/util.inspect.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
module.exports = require('util').inspect;
|
||||
Reference in New Issue
Block a user