llonebot-dist 7.0.1 → 7.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/llonebot.js +2336 -10459
- package/llonebot.js.map +1 -1
- package/node_modules/cosmokit/LICENSE +21 -0
- package/node_modules/cosmokit/README.md +24 -0
- package/node_modules/cosmokit/lib/index.cjs +463 -0
- package/node_modules/cosmokit/lib/index.cjs.map +6 -0
- package/node_modules/cosmokit/lib/index.d.ts +142 -0
- package/node_modules/cosmokit/lib/index.mjs +403 -0
- package/node_modules/cosmokit/lib/index.mjs.map +6 -0
- package/node_modules/cosmokit/package.json +56 -0
- package/node_modules/cosmokit/src/array.ts +35 -0
- package/node_modules/cosmokit/src/index.ts +5 -0
- package/node_modules/cosmokit/src/misc.ts +57 -0
- package/node_modules/cosmokit/src/string.ts +101 -0
- package/node_modules/cosmokit/src/time.ts +91 -0
- package/node_modules/cosmokit/src/types.ts +129 -0
- package/node_modules/has-flag/index.d.ts +39 -0
- package/node_modules/has-flag/index.js +8 -0
- package/node_modules/has-flag/license +9 -0
- package/node_modules/has-flag/package.json +46 -0
- package/node_modules/has-flag/readme.md +89 -0
- package/node_modules/object-inspect/CHANGELOG.md +424 -0
- package/node_modules/object-inspect/LICENSE +21 -0
- package/node_modules/object-inspect/example/all.js +23 -0
- package/node_modules/object-inspect/example/circular.js +6 -0
- package/node_modules/object-inspect/example/fn.js +5 -0
- package/node_modules/object-inspect/example/inspect.js +10 -0
- package/node_modules/object-inspect/index.js +544 -0
- package/node_modules/object-inspect/package-support.json +20 -0
- package/node_modules/object-inspect/package.json +105 -0
- package/node_modules/object-inspect/readme.markdown +84 -0
- package/node_modules/object-inspect/test/bigint.js +58 -0
- package/node_modules/object-inspect/test/browser/dom.js +15 -0
- package/node_modules/object-inspect/test/circular.js +16 -0
- package/node_modules/object-inspect/test/deep.js +12 -0
- package/node_modules/object-inspect/test/element.js +53 -0
- package/node_modules/object-inspect/test/err.js +48 -0
- package/node_modules/object-inspect/test/fakes.js +29 -0
- package/node_modules/object-inspect/test/fn.js +76 -0
- package/node_modules/object-inspect/test/global.js +17 -0
- package/node_modules/object-inspect/test/has.js +15 -0
- package/node_modules/object-inspect/test/holes.js +15 -0
- package/node_modules/object-inspect/test/indent-option.js +271 -0
- package/node_modules/object-inspect/test/inspect.js +139 -0
- package/node_modules/object-inspect/test/lowbyte.js +12 -0
- package/node_modules/object-inspect/test/number.js +58 -0
- package/node_modules/object-inspect/test/quoteStyle.js +26 -0
- package/node_modules/object-inspect/test/toStringTag.js +40 -0
- package/node_modules/object-inspect/test/undef.js +12 -0
- package/node_modules/object-inspect/test/values.js +261 -0
- package/node_modules/object-inspect/test-core-js.js +26 -0
- package/node_modules/object-inspect/util.inspect.js +1 -0
- package/node_modules/reggol/LICENSE +21 -0
- package/node_modules/reggol/README.md +8 -0
- package/node_modules/reggol/index.d.ts +79 -0
- package/node_modules/reggol/lib/browser.mjs +299 -0
- package/node_modules/reggol/lib/node.js +31 -0
- package/node_modules/reggol/lib/shared.js +258 -0
- package/node_modules/reggol/lib/shared.mjs +266 -0
- package/node_modules/reggol/node_modules/supports-color/browser.js +24 -0
- package/node_modules/reggol/node_modules/supports-color/index.js +152 -0
- package/node_modules/reggol/node_modules/supports-color/license +9 -0
- package/node_modules/reggol/node_modules/supports-color/package.json +58 -0
- package/node_modules/reggol/node_modules/supports-color/readme.md +77 -0
- package/node_modules/reggol/package.json +65 -0
- package/node_modules/reggol/src/browser.ts +8 -0
- package/node_modules/reggol/src/index.ts +3 -0
- package/node_modules/reggol/src/node.ts +8 -0
- package/node_modules/reggol/src/shared.ts +249 -0
- package/node_modules/supports-color/browser.d.ts +1 -0
- package/node_modules/supports-color/browser.js +35 -0
- package/node_modules/supports-color/index.d.ts +55 -0
- package/node_modules/supports-color/index.js +202 -0
- package/node_modules/supports-color/license +9 -0
- package/node_modules/supports-color/package.json +64 -0
- package/node_modules/supports-color/readme.md +75 -0
- package/package.json +1 -1
- package//344/275/277/347/224/250/350/257/264/346/230/216.txt +2 -2
- package//346/233/264/346/226/260/346/227/245/345/277/227.txt +23 -0
- package/webui/assets/index-DH65Wt1j.css +0 -1
- package/webui/assets/index-fRyBxWld.js +0 -273
- package/webui/index.html +0 -13
- package/webui/logo.jpg +0 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# object-inspect <sup>[![Version Badge][npm-version-svg]][package-url]</sup>
|
|
2
|
+
|
|
3
|
+
string representations of objects in node and the browser
|
|
4
|
+
|
|
5
|
+
[![github actions][actions-image]][actions-url]
|
|
6
|
+
[![coverage][codecov-image]][codecov-url]
|
|
7
|
+
[![License][license-image]][license-url]
|
|
8
|
+
[![Downloads][downloads-image]][downloads-url]
|
|
9
|
+
|
|
10
|
+
[![npm badge][npm-badge-png]][package-url]
|
|
11
|
+
|
|
12
|
+
# example
|
|
13
|
+
|
|
14
|
+
## circular
|
|
15
|
+
|
|
16
|
+
``` js
|
|
17
|
+
var inspect = require('object-inspect');
|
|
18
|
+
var obj = { a: 1, b: [3,4] };
|
|
19
|
+
obj.c = obj;
|
|
20
|
+
console.log(inspect(obj));
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## dom element
|
|
24
|
+
|
|
25
|
+
``` js
|
|
26
|
+
var inspect = require('object-inspect');
|
|
27
|
+
|
|
28
|
+
var d = document.createElement('div');
|
|
29
|
+
d.setAttribute('id', 'beep');
|
|
30
|
+
d.innerHTML = '<b>wooo</b><i>iiiii</i>';
|
|
31
|
+
|
|
32
|
+
console.log(inspect([ d, { a: 3, b : 4, c: [5,6,[7,[8,[9]]]] } ]));
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
output:
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
[ <div id="beep">...</div>, { a: 3, b: 4, c: [ 5, 6, [ 7, [ 8, [ ... ] ] ] ] } ]
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
# methods
|
|
42
|
+
|
|
43
|
+
``` js
|
|
44
|
+
var inspect = require('object-inspect')
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## var s = inspect(obj, opts={})
|
|
48
|
+
|
|
49
|
+
Return a string `s` with the string representation of `obj` up to a depth of `opts.depth`.
|
|
50
|
+
|
|
51
|
+
Additional options:
|
|
52
|
+
- `quoteStyle`: must be "single" or "double", if present. Default `'single'` for strings, `'double'` for HTML elements.
|
|
53
|
+
- `maxStringLength`: must be `0`, a positive integer, `Infinity`, or `null`, if present. Default `Infinity`.
|
|
54
|
+
- `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`.
|
|
55
|
+
- `indent`: must be "\t", `null`, or a positive integer. Default `null`.
|
|
56
|
+
- `numericSeparator`: must be a boolean, if present. Default `false`. If `true`, all numbers will be printed with numeric separators (eg, `1234.5678` will be printed as `'1_234.567_8'`)
|
|
57
|
+
|
|
58
|
+
# install
|
|
59
|
+
|
|
60
|
+
With [npm](https://npmjs.org) do:
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
npm install object-inspect
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
# license
|
|
67
|
+
|
|
68
|
+
MIT
|
|
69
|
+
|
|
70
|
+
[package-url]: https://npmjs.org/package/object-inspect
|
|
71
|
+
[npm-version-svg]: https://versionbadg.es/inspect-js/object-inspect.svg
|
|
72
|
+
[deps-svg]: https://david-dm.org/inspect-js/object-inspect.svg
|
|
73
|
+
[deps-url]: https://david-dm.org/inspect-js/object-inspect
|
|
74
|
+
[dev-deps-svg]: https://david-dm.org/inspect-js/object-inspect/dev-status.svg
|
|
75
|
+
[dev-deps-url]: https://david-dm.org/inspect-js/object-inspect#info=devDependencies
|
|
76
|
+
[npm-badge-png]: https://nodei.co/npm/object-inspect.png?downloads=true&stars=true
|
|
77
|
+
[license-image]: https://img.shields.io/npm/l/object-inspect.svg
|
|
78
|
+
[license-url]: LICENSE
|
|
79
|
+
[downloads-image]: https://img.shields.io/npm/dm/object-inspect.svg
|
|
80
|
+
[downloads-url]: https://npm-stat.com/charts.html?package=object-inspect
|
|
81
|
+
[codecov-image]: https://codecov.io/gh/inspect-js/object-inspect/branch/main/graphs/badge.svg
|
|
82
|
+
[codecov-url]: https://app.codecov.io/gh/inspect-js/object-inspect/
|
|
83
|
+
[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/inspect-js/object-inspect
|
|
84
|
+
[actions-url]: https://github.com/inspect-js/object-inspect/actions
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var inspect = require('../');
|
|
4
|
+
var test = require('tape');
|
|
5
|
+
var hasToStringTag = require('has-tostringtag/shams')();
|
|
6
|
+
|
|
7
|
+
test('bigint', { skip: typeof BigInt === 'undefined' }, function (t) {
|
|
8
|
+
t.test('primitives', function (st) {
|
|
9
|
+
st.plan(3);
|
|
10
|
+
|
|
11
|
+
st.equal(inspect(BigInt(-256)), '-256n');
|
|
12
|
+
st.equal(inspect(BigInt(0)), '0n');
|
|
13
|
+
st.equal(inspect(BigInt(256)), '256n');
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
t.test('objects', function (st) {
|
|
17
|
+
st.plan(3);
|
|
18
|
+
|
|
19
|
+
st.equal(inspect(Object(BigInt(-256))), 'Object(-256n)');
|
|
20
|
+
st.equal(inspect(Object(BigInt(0))), 'Object(0n)');
|
|
21
|
+
st.equal(inspect(Object(BigInt(256))), 'Object(256n)');
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
t.test('syntactic primitives', function (st) {
|
|
25
|
+
st.plan(3);
|
|
26
|
+
|
|
27
|
+
/* eslint-disable no-new-func */
|
|
28
|
+
st.equal(inspect(Function('return -256n')()), '-256n');
|
|
29
|
+
st.equal(inspect(Function('return 0n')()), '0n');
|
|
30
|
+
st.equal(inspect(Function('return 256n')()), '256n');
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
t.test('toStringTag', { skip: !hasToStringTag }, function (st) {
|
|
34
|
+
st.plan(1);
|
|
35
|
+
|
|
36
|
+
var faker = {};
|
|
37
|
+
faker[Symbol.toStringTag] = 'BigInt';
|
|
38
|
+
st.equal(
|
|
39
|
+
inspect(faker),
|
|
40
|
+
'{ [Symbol(Symbol.toStringTag)]: \'BigInt\' }',
|
|
41
|
+
'object lying about being a BigInt inspects as an object'
|
|
42
|
+
);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
t.test('numericSeparator', function (st) {
|
|
46
|
+
st.equal(inspect(BigInt(0), { numericSeparator: false }), '0n', '0n, numericSeparator false');
|
|
47
|
+
st.equal(inspect(BigInt(0), { numericSeparator: true }), '0n', '0n, numericSeparator true');
|
|
48
|
+
|
|
49
|
+
st.equal(inspect(BigInt(1234), { numericSeparator: false }), '1234n', '1234n, numericSeparator false');
|
|
50
|
+
st.equal(inspect(BigInt(1234), { numericSeparator: true }), '1_234n', '1234n, numericSeparator true');
|
|
51
|
+
st.equal(inspect(BigInt(-1234), { numericSeparator: false }), '-1234n', '1234n, numericSeparator false');
|
|
52
|
+
st.equal(inspect(BigInt(-1234), { numericSeparator: true }), '-1_234n', '1234n, numericSeparator true');
|
|
53
|
+
|
|
54
|
+
st.end();
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
t.end();
|
|
58
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
var inspect = require('../../');
|
|
2
|
+
var test = require('tape');
|
|
3
|
+
|
|
4
|
+
test('dom element', function (t) {
|
|
5
|
+
t.plan(1);
|
|
6
|
+
|
|
7
|
+
var d = document.createElement('div');
|
|
8
|
+
d.setAttribute('id', 'beep');
|
|
9
|
+
d.innerHTML = '<b>wooo</b><i>iiiii</i>';
|
|
10
|
+
|
|
11
|
+
t.equal(
|
|
12
|
+
inspect([d, { a: 3, b: 4, c: [5, 6, [7, [8, [9]]]] }]),
|
|
13
|
+
'[ <div id="beep">...</div>, { a: 3, b: 4, c: [ 5, 6, [ 7, [ 8, [Object] ] ] ] } ]'
|
|
14
|
+
);
|
|
15
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
var inspect = require('../');
|
|
2
|
+
var test = require('tape');
|
|
3
|
+
|
|
4
|
+
test('circular', function (t) {
|
|
5
|
+
t.plan(2);
|
|
6
|
+
var obj = { a: 1, b: [3, 4] };
|
|
7
|
+
obj.c = obj;
|
|
8
|
+
t.equal(inspect(obj), '{ a: 1, b: [ 3, 4 ], c: [Circular] }');
|
|
9
|
+
|
|
10
|
+
var double = {};
|
|
11
|
+
double.a = [double];
|
|
12
|
+
double.b = {};
|
|
13
|
+
double.b.inner = double.b;
|
|
14
|
+
double.b.obj = double;
|
|
15
|
+
t.equal(inspect(double), '{ a: [ [Circular] ], b: { inner: [Circular], obj: [Circular] } }');
|
|
16
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
var inspect = require('../');
|
|
2
|
+
var test = require('tape');
|
|
3
|
+
|
|
4
|
+
test('deep', function (t) {
|
|
5
|
+
t.plan(4);
|
|
6
|
+
var obj = [[[[[[500]]]]]];
|
|
7
|
+
t.equal(inspect(obj), '[ [ [ [ [ [Array] ] ] ] ] ]');
|
|
8
|
+
t.equal(inspect(obj, { depth: 4 }), '[ [ [ [ [Array] ] ] ] ]');
|
|
9
|
+
t.equal(inspect(obj, { depth: 2 }), '[ [ [Array] ] ]');
|
|
10
|
+
|
|
11
|
+
t.equal(inspect([[[{ a: 1 }]]], { depth: 3 }), '[ [ [ [Object] ] ] ]');
|
|
12
|
+
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
var inspect = require('../');
|
|
2
|
+
var test = require('tape');
|
|
3
|
+
|
|
4
|
+
test('element', function (t) {
|
|
5
|
+
t.plan(3);
|
|
6
|
+
var elem = {
|
|
7
|
+
nodeName: 'div',
|
|
8
|
+
attributes: [{ name: 'class', value: 'row' }],
|
|
9
|
+
getAttribute: function (key) { return key; },
|
|
10
|
+
childNodes: []
|
|
11
|
+
};
|
|
12
|
+
var obj = [1, elem, 3];
|
|
13
|
+
t.deepEqual(inspect(obj), '[ 1, <div class="row"></div>, 3 ]');
|
|
14
|
+
t.deepEqual(inspect(obj, { quoteStyle: 'single' }), "[ 1, <div class='row'></div>, 3 ]");
|
|
15
|
+
t.deepEqual(inspect(obj, { quoteStyle: 'double' }), '[ 1, <div class="row"></div>, 3 ]');
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
test('element no attr', function (t) {
|
|
19
|
+
t.plan(1);
|
|
20
|
+
var elem = {
|
|
21
|
+
nodeName: 'div',
|
|
22
|
+
getAttribute: function (key) { return key; },
|
|
23
|
+
childNodes: []
|
|
24
|
+
};
|
|
25
|
+
var obj = [1, elem, 3];
|
|
26
|
+
t.deepEqual(inspect(obj), '[ 1, <div></div>, 3 ]');
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
test('element with contents', function (t) {
|
|
30
|
+
t.plan(1);
|
|
31
|
+
var elem = {
|
|
32
|
+
nodeName: 'div',
|
|
33
|
+
getAttribute: function (key) { return key; },
|
|
34
|
+
childNodes: [{ nodeName: 'b' }]
|
|
35
|
+
};
|
|
36
|
+
var obj = [1, elem, 3];
|
|
37
|
+
t.deepEqual(inspect(obj), '[ 1, <div>...</div>, 3 ]');
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
test('element instance', function (t) {
|
|
41
|
+
t.plan(1);
|
|
42
|
+
var h = global.HTMLElement;
|
|
43
|
+
global.HTMLElement = function (name, attr) {
|
|
44
|
+
this.nodeName = name;
|
|
45
|
+
this.attributes = attr;
|
|
46
|
+
};
|
|
47
|
+
global.HTMLElement.prototype.getAttribute = function () {};
|
|
48
|
+
|
|
49
|
+
var elem = new global.HTMLElement('div', []);
|
|
50
|
+
var obj = [1, elem, 3];
|
|
51
|
+
t.deepEqual(inspect(obj), '[ 1, <div></div>, 3 ]');
|
|
52
|
+
global.HTMLElement = h;
|
|
53
|
+
});
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
var test = require('tape');
|
|
2
|
+
var ErrorWithCause = require('error-cause/Error');
|
|
3
|
+
|
|
4
|
+
var inspect = require('../');
|
|
5
|
+
|
|
6
|
+
test('type error', function (t) {
|
|
7
|
+
t.plan(1);
|
|
8
|
+
var aerr = new TypeError();
|
|
9
|
+
aerr.foo = 555;
|
|
10
|
+
aerr.bar = [1, 2, 3];
|
|
11
|
+
|
|
12
|
+
var berr = new TypeError('tuv');
|
|
13
|
+
berr.baz = 555;
|
|
14
|
+
|
|
15
|
+
var cerr = new SyntaxError();
|
|
16
|
+
cerr.message = 'whoa';
|
|
17
|
+
cerr['a-b'] = 5;
|
|
18
|
+
|
|
19
|
+
var withCause = new ErrorWithCause('foo', { cause: 'bar' });
|
|
20
|
+
var withCausePlus = new ErrorWithCause('foo', { cause: 'bar' });
|
|
21
|
+
withCausePlus.foo = 'bar';
|
|
22
|
+
var withUndefinedCause = new ErrorWithCause('foo', { cause: undefined });
|
|
23
|
+
var withEnumerableCause = new Error('foo');
|
|
24
|
+
withEnumerableCause.cause = 'bar';
|
|
25
|
+
|
|
26
|
+
var obj = [
|
|
27
|
+
new TypeError(),
|
|
28
|
+
new TypeError('xxx'),
|
|
29
|
+
aerr,
|
|
30
|
+
berr,
|
|
31
|
+
cerr,
|
|
32
|
+
withCause,
|
|
33
|
+
withCausePlus,
|
|
34
|
+
withUndefinedCause,
|
|
35
|
+
withEnumerableCause
|
|
36
|
+
];
|
|
37
|
+
t.equal(inspect(obj), '[ ' + [
|
|
38
|
+
'[TypeError]',
|
|
39
|
+
'[TypeError: xxx]',
|
|
40
|
+
'{ [TypeError] foo: 555, bar: [ 1, 2, 3 ] }',
|
|
41
|
+
'{ [TypeError: tuv] baz: 555 }',
|
|
42
|
+
'{ [SyntaxError: whoa] message: \'whoa\', \'a-b\': 5 }',
|
|
43
|
+
'cause' in Error.prototype ? '[Error: foo]' : '{ [Error: foo] [cause]: \'bar\' }',
|
|
44
|
+
'{ [Error: foo] ' + ('cause' in Error.prototype ? '' : '[cause]: \'bar\', ') + 'foo: \'bar\' }',
|
|
45
|
+
'cause' in Error.prototype ? '[Error: foo]' : '{ [Error: foo] [cause]: undefined }',
|
|
46
|
+
'{ [Error: foo] cause: \'bar\' }'
|
|
47
|
+
].join(', ') + ' ]');
|
|
48
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var inspect = require('../');
|
|
4
|
+
var test = require('tape');
|
|
5
|
+
var hasToStringTag = require('has-tostringtag/shams')();
|
|
6
|
+
var forEach = require('for-each');
|
|
7
|
+
|
|
8
|
+
test('fakes', { skip: !hasToStringTag }, function (t) {
|
|
9
|
+
forEach([
|
|
10
|
+
'Array',
|
|
11
|
+
'Boolean',
|
|
12
|
+
'Date',
|
|
13
|
+
'Error',
|
|
14
|
+
'Number',
|
|
15
|
+
'RegExp',
|
|
16
|
+
'String'
|
|
17
|
+
], function (expected) {
|
|
18
|
+
var faker = {};
|
|
19
|
+
faker[Symbol.toStringTag] = expected;
|
|
20
|
+
|
|
21
|
+
t.equal(
|
|
22
|
+
inspect(faker),
|
|
23
|
+
'{ [Symbol(Symbol.toStringTag)]: \'' + expected + '\' }',
|
|
24
|
+
'faker masquerading as ' + expected + ' is not shown as one'
|
|
25
|
+
);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
t.end();
|
|
29
|
+
});
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
var inspect = require('../');
|
|
2
|
+
var test = require('tape');
|
|
3
|
+
var arrow = require('make-arrow-function')();
|
|
4
|
+
var functionsHaveConfigurableNames = require('functions-have-names').functionsHaveConfigurableNames();
|
|
5
|
+
|
|
6
|
+
test('function', function (t) {
|
|
7
|
+
t.plan(1);
|
|
8
|
+
var obj = [1, 2, function f(n) { return n; }, 4];
|
|
9
|
+
t.equal(inspect(obj), '[ 1, 2, [Function: f], 4 ]');
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
test('function name', function (t) {
|
|
13
|
+
t.plan(1);
|
|
14
|
+
var f = (function () {
|
|
15
|
+
return function () {};
|
|
16
|
+
}());
|
|
17
|
+
f.toString = function toStr() { return 'function xxx () {}'; };
|
|
18
|
+
var obj = [1, 2, f, 4];
|
|
19
|
+
t.equal(inspect(obj), '[ 1, 2, [Function (anonymous)] { toString: [Function: toStr] }, 4 ]');
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
test('anon function', function (t) {
|
|
23
|
+
var f = (function () {
|
|
24
|
+
return function () {};
|
|
25
|
+
}());
|
|
26
|
+
var obj = [1, 2, f, 4];
|
|
27
|
+
t.equal(inspect(obj), '[ 1, 2, [Function (anonymous)], 4 ]');
|
|
28
|
+
|
|
29
|
+
t.end();
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
test('arrow function', { skip: !arrow }, function (t) {
|
|
33
|
+
t.equal(inspect(arrow), '[Function (anonymous)]');
|
|
34
|
+
|
|
35
|
+
t.end();
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
test('truly nameless function', { skip: !arrow || !functionsHaveConfigurableNames }, function (t) {
|
|
39
|
+
function f() {}
|
|
40
|
+
Object.defineProperty(f, 'name', { value: false });
|
|
41
|
+
t.equal(f.name, false);
|
|
42
|
+
t.equal(
|
|
43
|
+
inspect(f),
|
|
44
|
+
'[Function: f]',
|
|
45
|
+
'named function with falsy `.name` does not hide its original name'
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
function g() {}
|
|
49
|
+
Object.defineProperty(g, 'name', { value: true });
|
|
50
|
+
t.equal(g.name, true);
|
|
51
|
+
t.equal(
|
|
52
|
+
inspect(g),
|
|
53
|
+
'[Function: true]',
|
|
54
|
+
'named function with truthy `.name` hides its original name'
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
var anon = function () {}; // eslint-disable-line func-style
|
|
58
|
+
Object.defineProperty(anon, 'name', { value: null });
|
|
59
|
+
t.equal(anon.name, null);
|
|
60
|
+
t.equal(
|
|
61
|
+
inspect(anon),
|
|
62
|
+
'[Function (anonymous)]',
|
|
63
|
+
'anon function with falsy `.name` does not hide its anonymity'
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
var anon2 = function () {}; // eslint-disable-line func-style
|
|
67
|
+
Object.defineProperty(anon2, 'name', { value: 1 });
|
|
68
|
+
t.equal(anon2.name, 1);
|
|
69
|
+
t.equal(
|
|
70
|
+
inspect(anon2),
|
|
71
|
+
'[Function: 1]',
|
|
72
|
+
'anon function with truthy `.name` hides its anonymity'
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
t.end();
|
|
76
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var inspect = require('../');
|
|
4
|
+
|
|
5
|
+
var test = require('tape');
|
|
6
|
+
var globalThis = require('globalthis')();
|
|
7
|
+
|
|
8
|
+
test('global object', function (t) {
|
|
9
|
+
/* eslint-env browser */
|
|
10
|
+
var expected = typeof window === 'undefined' ? 'globalThis' : 'Window';
|
|
11
|
+
t.equal(
|
|
12
|
+
inspect([globalThis]),
|
|
13
|
+
'[ { [object ' + expected + '] } ]'
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
t.end();
|
|
17
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var inspect = require('../');
|
|
4
|
+
var test = require('tape');
|
|
5
|
+
var mockProperty = require('mock-property');
|
|
6
|
+
|
|
7
|
+
test('when Object#hasOwnProperty is deleted', function (t) {
|
|
8
|
+
t.plan(1);
|
|
9
|
+
var arr = [1, , 3]; // eslint-disable-line no-sparse-arrays
|
|
10
|
+
|
|
11
|
+
t.teardown(mockProperty(Array.prototype, 1, { value: 2 })); // this is needed to account for "in" vs "hasOwnProperty"
|
|
12
|
+
t.teardown(mockProperty(Object.prototype, 'hasOwnProperty', { 'delete': true }));
|
|
13
|
+
|
|
14
|
+
t.equal(inspect(arr), '[ 1, , 3 ]');
|
|
15
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
var test = require('tape');
|
|
2
|
+
var inspect = require('../');
|
|
3
|
+
|
|
4
|
+
var xs = ['a', 'b'];
|
|
5
|
+
xs[5] = 'f';
|
|
6
|
+
xs[7] = 'j';
|
|
7
|
+
xs[8] = 'k';
|
|
8
|
+
|
|
9
|
+
test('holes', function (t) {
|
|
10
|
+
t.plan(1);
|
|
11
|
+
t.equal(
|
|
12
|
+
inspect(xs),
|
|
13
|
+
"[ 'a', 'b', , , , 'f', , 'j', 'k' ]"
|
|
14
|
+
);
|
|
15
|
+
});
|