Update checked-in dependencies

This commit is contained in:
github-actions[bot] 2021-07-27 16:54:26 +00:00
parent 6b0d45a5c6
commit cc1adb825a
4247 changed files with 144820 additions and 149530 deletions

View file

@ -8,7 +8,7 @@
"max-lines": 1,
"max-lines-per-function": 1,
"max-params": [2, 4],
"max-statements": [2, 100],
"max-statements": 0,
"max-statements-per-line": [2, { "max": 2 }],
"no-magic-numbers": 0,
"no-param-reassign": 1,

12
node_modules/object-inspect/.github/FUNDING.yml generated vendored Normal file
View file

@ -0,0 +1,12 @@
# These are supported funding model platforms
github: [ljharb]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: npm/object-inspect
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']

View file

@ -1,15 +0,0 @@
name: Automatic Rebase
on: [pull_request]
jobs:
_:
name: "Automatic Rebase"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: ljharb/rebase@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

4
node_modules/object-inspect/.nycrc generated vendored
View file

@ -4,10 +4,6 @@
"instrumentation": false,
"sourceMap": false,
"reporter": ["text-summary", "text", "html", "json"],
"lines": 93,
"statements": 93,
"functions": 96,
"branches": 89,
"exclude": [
"coverage",
"example",

View file

@ -1,53 +0,0 @@
version: ~> 1.0
language: node_js
os:
- linux
import:
- ljharb/travis-ci:node/all.yml
- ljharb/travis-ci:node/pretest.yml
- ljharb/travis-ci:node/posttest.yml
script:
- 'if [ -n "${COVERAGE-}" ]; then npm run coverage && bash <(curl -s https://codecov.io/bash) -f coverage/*.json; fi'
matrix:
include:
- node_js: "13.7"
env: COVERAGE=true
- node_js: "12.14"
env: COVERAGE=true
- node_js: "10.18"
env: COVERAGE=true
- node_js: "8.17"
env: COVERAGE=true
- node_js: "6.17"
env: COVERAGE=true
- node_js: "4.9"
env: COVERAGE=true
- node_js: "iojs-v1.8"
env: COVERAGE=true
- node_js: "0.12"
env: COVERAGE=true
- node_js: "0.10"
env: COVERAGE=true
- node_js: "0.8"
env: COVERAGE=true
exclude:
- node_js: "13.7"
env: TEST=true
- node_js: "12.14"
env: TEST=true
- node_js: "10.18"
env: TEST=true
- node_js: "8.17"
env: TEST=true
- node_js: "6.17"
env: TEST=true
- node_js: "4.9"
env: TEST=true
- node_js: "iojs-v1.8"
env: TEST=true
- node_js: "0.12"
env: TEST=true
- node_js: "0.10"
env: TEST=true
- node_js: "0.8"
env: TEST=true

129
node_modules/object-inspect/index.js generated vendored
View file

@ -10,14 +10,29 @@ 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 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';
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
);
var inspectCustom = require('./util.inspect').custom;
var inspectSymbol = inspectCustom && isSymbol(inspectCustom) ? inspectCustom : null;
var toStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag !== 'undefined' ? Symbol.toStringTag : null;
module.exports = function inspect_(obj, options, depth, seen) {
var opts = options || {};
@ -34,8 +49,8 @@ module.exports = function inspect_(obj, options, depth, seen) {
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') {
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\'`');
}
if (
@ -66,7 +81,7 @@ module.exports = function inspect_(obj, options, depth, seen) {
}
return String(obj);
}
if (typeof obj === 'bigint') { // eslint-disable-line valid-typeof
if (typeof obj === 'bigint') {
return String(obj) + 'n';
}
@ -103,11 +118,12 @@ module.exports = function inspect_(obj, options, depth, seen) {
if (typeof obj === 'function') {
var name = nameOf(obj);
return '[Function' + (name ? ': ' + name : ' (anonymous)') + ']';
var keys = arrObjKeys(obj, inspect);
return '[Function' + (name ? ': ' + name : ' (anonymous)') + ']' + (keys.length > 0 ? ' { ' + keys.join(', ') + ' }' : '');
}
if (isSymbol(obj)) {
var symString = Symbol.prototype.toString.call(obj);
return typeof obj === 'object' ? markBoxed(symString) : symString;
var symString = hasShammedSymbols ? String(obj).replace(/^(Symbol\(.*\))_[^)]*$/, '$1') : symToString.call(obj);
return typeof obj === 'object' && !hasShammedSymbols ? markBoxed(symString) : symString;
}
if (isElement(obj)) {
var s = '<' + String(obj.nodeName).toLowerCase();
@ -136,7 +152,7 @@ module.exports = function inspect_(obj, options, depth, seen) {
if (typeof obj === 'object' && customInspect) {
if (inspectSymbol && typeof obj[inspectSymbol] === 'function') {
return obj[inspectSymbol]();
} else if (typeof obj.inspect === 'function') {
} else if (customInspect !== 'symbol' && typeof obj.inspect === 'function') {
return obj.inspect();
}
}
@ -160,6 +176,9 @@ module.exports = function inspect_(obj, options, depth, seen) {
if (isWeakSet(obj)) {
return weakCollectionOf('WeakSet');
}
if (isWeakRef(obj)) {
return weakCollectionOf('WeakRef');
}
if (isNumber(obj)) {
return markBoxed(inspect(Number(obj)));
}
@ -174,11 +193,16 @@ module.exports = function inspect_(obj, options, depth, seen) {
}
if (!isDate(obj) && !isRegExp(obj)) {
var ys = arrObjKeys(obj, inspect);
if (ys.length === 0) { return '{}'; }
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 ? toStr(obj).slice(8, -1) : protoTag ? 'Object' : '';
var constructorTag = isPlainObject || typeof obj.constructor !== 'function' ? '' : obj.constructor.name ? obj.constructor.name + ' ' : '';
var tag = constructorTag + (stringTag || protoTag ? '[' + [].concat(stringTag || [], protoTag || []).join(': ') + '] ' : '');
if (ys.length === 0) { return tag + '{}'; }
if (indent) {
return '{' + indentedJoin(ys, indent) + '}';
return tag + '{' + indentedJoin(ys, indent) + '}';
}
return '{ ' + ys.join(', ') + ' }';
return tag + '{ ' + ys.join(', ') + ' }';
}
return String(obj);
};
@ -192,15 +216,42 @@ function quote(s) {
return String(s).replace(/"/g, '&quot;');
}
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 isBigInt(obj) { return toStr(obj) === '[object BigInt]'; }
function isBoolean(obj) { return toStr(obj) === '[object Boolean]'; }
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) {
@ -258,6 +309,17 @@ function isWeakMap(x) {
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;
@ -312,10 +374,14 @@ function inspectString(str, opts) {
function lowbyte(c) {
var n = c.charCodeAt(0);
var x = {
8: 'b', 9: 't', 10: 'n', 12: 'f', 13: 'r'
8: 'b',
9: 't',
10: 'n',
12: 'f',
13: 'r'
}[n];
if (x) { return '\\' + x; }
return '\\x' + (n < 0x10 ? '0' : '') + n.toString(16);
return '\\x' + (n < 0x10 ? '0' : '') + n.toString(16).toUpperCase();
}
function markBoxed(str) {
@ -370,14 +436,33 @@ function arrObjKeys(obj, inspect) {
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 ((/[^\w$]/).test(key)) {
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 ((/[^\w$]/).test(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;
}

View file

@ -1,28 +1,30 @@
{
"name": "object-inspect",
"version": "1.8.0",
"version": "1.11.0",
"description": "string representations of objects in node and the browser",
"main": "index.js",
"devDependencies": {
"@ljharb/eslint-config": "^17.1.0",
"aud": "^1.1.2",
"core-js": "^2.6.11",
"eslint": "^7.1.0",
"@ljharb/eslint-config": "^17.6.0",
"aud": "^1.1.5",
"core-js": "^2.6.12",
"eslint": "^7.30.0",
"for-each": "^0.3.3",
"functions-have-names": "^1.2.2",
"make-arrow-function": "^1.2.0",
"nyc": "^10.3.2",
"safe-publish-latest": "^1.1.4",
"string.prototype.repeat": "^1.0.0",
"tape": "^5.0.1"
"tape": "^5.2.2"
},
"scripts": {
"prepublish": "safe-publish-latest",
"prepublish": "not-in-publish || npm run prepublishOnly",
"prepublishOnly": "safe-publish-latest",
"pretest": "npm run lint",
"lint": "eslint .",
"test": "npm run tests-only",
"pretests-only": "node test-core-js",
"tests-only": "tape test/*.js",
"posttest": "npx aud --production",
"coverage": "nyc npm run tests-only"
"test": "npm run tests-only && npm run test:corejs",
"tests-only": "nyc tape 'test/*.js'",
"test:corejs": "nyc tape test-core-js.js 'test/*.js'",
"posttest": "npx aud --production"
},
"testling": {
"files": [

View file

@ -1,8 +1,15 @@
# object-inspect
# object-inspect <sup>[![Version Badge][2]][1]</sup>
string representations of objects in node and the browser
[![build status](https://secure.travis-ci.com/inspect-js/object-inspect.png)](https://travis-ci.com/inspect-js/object-inspect)
[![github actions][actions-image]][actions-url]
[![coverage][codecov-image]][codecov-url]
[![dependency status][5]][6]
[![dev dependency status][7]][8]
[![License][license-image]][license-url]
[![Downloads][downloads-image]][downloads-url]
[![npm badge][11]][1]
# example
@ -46,7 +53,7 @@ Return a string `s` with the string representation of `obj` up to a depth of `op
Additional options:
- `quoteStyle`: must be "single" or "double", if present. Default `'single'` for strings, `'double'` for HTML elements.
- `maxStringLength`: must be `0`, a positive integer, `Infinity`, or `null`, if present. Default `Infinity`.
- `customInspect`: When `true`, a custom inspect method function will be invoked. Default `true`.
- `customInspect`: When `true`, a custom inspect method function will be invoked (either undere the `util.inspect.custom` symbol, or the `inspect` property). When the string `'symbol'`, only the symbol method will be invoked. Default `true`.
- `indent`: must be "\t", `null`, or a positive integer. Default `null`.
# install
@ -60,3 +67,19 @@ npm install object-inspect
# license
MIT
[1]: https://npmjs.org/package/object-inspect
[2]: https://versionbadg.es/inspect-js/object-inspect.svg
[5]: https://david-dm.org/inspect-js/object-inspect.svg
[6]: https://david-dm.org/inspect-js/object-inspect
[7]: https://david-dm.org/inspect-js/object-inspect/dev-status.svg
[8]: https://david-dm.org/inspect-js/object-inspect#info=devDependencies
[11]: https://nodei.co/npm/object-inspect.png?downloads=true&stars=true
[license-image]: https://img.shields.io/npm/l/object-inspect.svg
[license-url]: LICENSE
[downloads-image]: https://img.shields.io/npm/dm/object-inspect.svg
[downloads-url]: https://npm-stat.com/charts.html?package=object-inspect
[codecov-image]: https://codecov.io/gh/inspect-js/object-inspect/branch/main/graphs/badge.svg
[codecov-url]: https://app.codecov.io/gh/inspect-js/object-inspect/
[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/inspect-js/object-inspect
[actions-url]: https://github.com/inspect-js/object-inspect/actions

View file

@ -1,5 +1,8 @@
'use strict';
var inspect = require('../');
var test = require('tape');
var hasSymbols = require('has-symbols/shams')();
test('bigint', { skip: typeof BigInt === 'undefined' }, function (t) {
t.test('primitives', function (st) {
@ -27,5 +30,17 @@ test('bigint', { skip: typeof BigInt === 'undefined' }, function (t) {
st.equal(inspect(Function('return 256n')()), '256n');
});
t.test('toStringTag', { skip: !hasSymbols || typeof Symbol.toStringTag === 'undefined' }, 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();
});

View file

@ -2,8 +2,15 @@ var inspect = require('../');
var test = require('tape');
test('circular', function (t) {
t.plan(1);
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] } }');
});

View file

@ -2,8 +2,11 @@ var inspect = require('../');
var test = require('tape');
test('deep', function (t) {
t.plan(2);
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] ] ] ]');
});

29
node_modules/object-inspect/test/fakes.js generated vendored Normal file
View file

@ -0,0 +1,29 @@
'use strict';
var inspect = require('../');
var test = require('tape');
var hasSymbols = require('has-symbols/shams')();
var forEach = require('for-each');
test('fakes', { skip: !hasSymbols || typeof Symbol.toStringTag === 'undefined' }, 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();
});

View file

@ -1,5 +1,7 @@
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);
@ -12,9 +14,9 @@ test('function name', function (t) {
var f = (function () {
return function () {};
}());
f.toString = function () { return 'function xxx () {}'; };
f.toString = function toStr() { return 'function xxx () {}'; };
var obj = [1, 2, f, 4];
t.equal(inspect(obj), '[ 1, 2, [Function (anonymous)], 4 ]');
t.equal(inspect(obj), '[ 1, 2, [Function (anonymous)] { toString: [Function: toStr] }, 4 ]');
});
test('anon function', function (t) {
@ -26,3 +28,49 @@ test('anon function', function (t) {
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();
});

View file

@ -1,35 +1,102 @@
var test = require('tape');
var hasSymbols = require('has-symbols')();
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(3);
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 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(3);
t.plan(4);
var obj = { inspect: function stringInspect() { return 'string'; } };
obj[utilInspect.custom] = function custom() { return 'symbol'; };
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] }, [] ]');
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([repeat('a', 1e8)], { maxStringLength: 10 }),
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();
});

View file

@ -7,6 +7,6 @@ test('interpolate low bytes', function (t) {
t.plan(1);
t.equal(
inspect(obj),
"{ x: 'a\\r\\nb', y: '\\x05! \\x1f \\x12' }"
"{ x: 'a\\r\\nb', y: '\\x05! \\x1F \\x12' }"
);
});

40
node_modules/object-inspect/test/toStringTag.js generated vendored Normal file
View file

@ -0,0 +1,40 @@
'use strict';
var test = require('tape');
var hasSymbols = require('has-symbols/shams')();
var inspect = require('../');
test('Symbol.toStringTag', { skip: !hasSymbols || typeof Symbol.toStringTag === 'undefined' }, 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');
});
});

View file

@ -1,5 +1,8 @@
'use strict';
var inspect = require('../');
var test = require('tape');
var hasSymbols = require('has-symbols/shams')();
test('values', function (t) {
t.plan(1);
@ -65,10 +68,26 @@ test('seen seen seen', function (t) {
);
});
test('symbols', { skip: typeof Symbol !== 'function' }, function (t) {
test('symbols', { skip: !hasSymbols }, function (t) {
var sym = Symbol('foo');
t.equal(inspect(sym), 'Symbol(foo)', 'Symbol("foo") should be "Symbol(foo)"');
t.equal(inspect(Object(sym)), 'Object(Symbol(foo))', 'Object(Symbol("foo")) should be "Object(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: !hasSymbols || typeof Symbol.toStringTag === 'undefined' }, 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();
});
@ -123,6 +142,22 @@ test('WeakSet', { skip: typeof WeakSet !== 'function' }, function (t) {
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';
@ -167,5 +202,9 @@ 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();
});