pi-dent-agent 0.2.2 → 0.2.4

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.
Files changed (55) hide show
  1. package/index.ts +5 -1
  2. package/lib/config.ts +59 -0
  3. package/lib/engine.ts +4 -1
  4. package/lib/script-render.ts +1 -1
  5. package/lib/script-runner.ts +70 -4
  6. package/lib/script-tool-calls.ts +116 -0
  7. package/lib/script-tool-log.ts +143 -0
  8. package/lib/script-tool-types.ts +258 -0
  9. package/lib/script-tool.ts +103 -9
  10. package/lib/script-worker.ts +92 -1
  11. package/lib/search-tool.ts +1 -1
  12. package/lib/tools.ts +13 -5
  13. package/node_modules/express-rate-limit/dist/index.cjs +6 -4
  14. package/node_modules/express-rate-limit/dist/index.mjs +6 -4
  15. package/node_modules/express-rate-limit/package.json +1 -1
  16. package/node_modules/jose/dist/webapi/jwks/remote.js +2 -2
  17. package/node_modules/jose/dist/webapi/jwt/encrypt.js +5 -8
  18. package/node_modules/jose/dist/webapi/lib/jwe_decrypt.js +1 -1
  19. package/node_modules/jose/dist/webapi/lib/jwe_encrypt.js +2 -2
  20. package/node_modules/jose/dist/webapi/lib/jwt_claims_set.js +1 -1
  21. package/node_modules/jose/dist/webapi/lib/key.js +2 -0
  22. package/node_modules/jose/package.json +1 -1
  23. package/node_modules/object-inspect/CHANGELOG.md +31 -0
  24. package/node_modules/object-inspect/index.js +326 -24
  25. package/node_modules/object-inspect/package.json +22 -13
  26. package/node_modules/object-inspect/readme.markdown +4 -1
  27. package/node_modules/object-inspect/stringWidth.js +68 -0
  28. package/node_modules/object-inspect/stringWidthRanges.js +38 -0
  29. package/package.json +1 -1
  30. package/node_modules/object-inspect/.eslintrc +0 -53
  31. package/node_modules/object-inspect/.nycrc +0 -13
  32. package/node_modules/object-inspect/example/all.js +0 -23
  33. package/node_modules/object-inspect/example/circular.js +0 -6
  34. package/node_modules/object-inspect/example/fn.js +0 -5
  35. package/node_modules/object-inspect/example/inspect.js +0 -10
  36. package/node_modules/object-inspect/test/bigint.js +0 -58
  37. package/node_modules/object-inspect/test/browser/dom.js +0 -15
  38. package/node_modules/object-inspect/test/circular.js +0 -16
  39. package/node_modules/object-inspect/test/deep.js +0 -12
  40. package/node_modules/object-inspect/test/element.js +0 -53
  41. package/node_modules/object-inspect/test/err.js +0 -48
  42. package/node_modules/object-inspect/test/fakes.js +0 -29
  43. package/node_modules/object-inspect/test/fn.js +0 -76
  44. package/node_modules/object-inspect/test/global.js +0 -17
  45. package/node_modules/object-inspect/test/has.js +0 -15
  46. package/node_modules/object-inspect/test/holes.js +0 -15
  47. package/node_modules/object-inspect/test/indent-option.js +0 -271
  48. package/node_modules/object-inspect/test/inspect.js +0 -139
  49. package/node_modules/object-inspect/test/lowbyte.js +0 -12
  50. package/node_modules/object-inspect/test/number.js +0 -58
  51. package/node_modules/object-inspect/test/quoteStyle.js +0 -26
  52. package/node_modules/object-inspect/test/toStringTag.js +0 -40
  53. package/node_modules/object-inspect/test/undef.js +0 -12
  54. package/node_modules/object-inspect/test/values.js +0 -261
  55. package/node_modules/object-inspect/test-core-js.js +0 -26
@@ -0,0 +1,68 @@
1
+ var $charCodeAt = String.prototype.charCodeAt;
2
+ var $indexOf = String.prototype.indexOf;
3
+ var $normalize = String.prototype.normalize;
4
+ var $slice = String.prototype.slice;
5
+ var $split = String.prototype.split;
6
+ var $floor = Math.floor;
7
+ var $parseInt = parseInt;
8
+
9
+ var ranges = require('./stringWidthRanges');
10
+
11
+ var starts = [];
12
+ var ends = [];
13
+ var widths = [];
14
+ var tokens = $split.call(ranges, ',');
15
+ var previousEnd = -1;
16
+ for (var t = 0; t < tokens.length; t++) {
17
+ var dot = $indexOf.call(tokens[t], '.');
18
+ starts[t] = previousEnd + 1 + $parseInt($slice.call(tokens[t], 1, dot), 36);
19
+ previousEnd = starts[t] + $parseInt($slice.call(tokens[t], dot + 1), 36);
20
+ ends[t] = previousEnd;
21
+ widths[t] = Number($slice.call(tokens[t], 0, 1));
22
+ }
23
+
24
+ function codePointWidth(code) {
25
+ var low = 0;
26
+ var high = starts.length - 1;
27
+ while (low <= high) {
28
+ var mid = $floor((low + high) / 2);
29
+ if (code < starts[mid]) {
30
+ high = mid - 1;
31
+ } else if (code > ends[mid]) {
32
+ low = mid + 1;
33
+ } else {
34
+ return widths[mid];
35
+ }
36
+ }
37
+ return 1;
38
+ }
39
+
40
+ function unicodeWidth(str) {
41
+ var width = 0;
42
+ for (var i = 0; i < str.length; i++) {
43
+ var code = $charCodeAt.call(str, i);
44
+ if (code >= 0xD800 && code <= 0xDBFF && i + 1 < str.length) {
45
+ var next = $charCodeAt.call(str, i + 1);
46
+ if (next >= 0xDC00 && next <= 0xDFFF) {
47
+ code = ((code - 0xD800) * 0x400) + (next - 0xDC00) + 0x10000;
48
+ i += 1;
49
+ }
50
+ }
51
+ width += codePointWidth(code);
52
+ }
53
+ return width;
54
+ }
55
+
56
+ // like node, only the part of the string after its first non-ASCII character is NFC-normalized and looked up
57
+ module.exports = function getStringWidth(str) {
58
+ var width = 0;
59
+ for (var i = 0; i < str.length; i++) {
60
+ var code = $charCodeAt.call(str, i);
61
+ if (code >= 127) {
62
+ var rest = $slice.call(str, i);
63
+ return width + unicodeWidth($normalize ? $normalize.call(rest, 'NFC') : rest);
64
+ }
65
+ width += code >= 32 ? 1 : 0;
66
+ }
67
+ return width;
68
+ };
@@ -0,0 +1,38 @@
1
+ /*
2
+ * generated by `npm run generate:string-width`; do not edit.
3
+ * display widths of code points, as computed by node's ICU-based `getStringWidth`, for Unicode 17.0.
4
+ * every code point not in a range has width 1. each comma-separated range is: its width, then (in base 36) the gap since the previous range ended, a dot, and its length minus 1.
5
+ */
6
+
7
+ var $join = Array.prototype.join;
8
+
9
+ module.exports = $join.call([
10
+ '00.v,02n.w,0gw.33,07n.6,07b.18,01.0,01.1,01.1,01.0,01k.5,0a.a,01.0,01a.k,0g.0,02t.7,01.5,02.1,01.3,',
11
+ '0x.0,01.0,0u.q,02j.a,01m.8,09.0,0o.3,01.8,01.2,01.4,017.2,01g.1,05.8,016.1k,01j.0,01.0,04.7,04.0,',
12
+ '03.6,0a.1,0t.0,01m.0,04.3,08.0,0k.1,0q.0,02.1,01l.0,04.1,04.1,02.2,03.0,0u.1,03.0,0b.1,01l.0,04.4,',
13
+ '01.1,04.0,0k.1,0m.5,01.0,01m.0,02.0,01.3,08.0,07.1,0b.1,0u.0,01p.0,0c.0,01e.0,03.0,01j.0,01.2,05.2,',
14
+ '01.3,07.1,0b.1,0t.0,01m.0,02.0,06.0,05.1,0k.1,0s.1,01l.1,04.3,08.0,0k.1,0t.0,020.0,07.2,01.0,02i.0,',
15
+ '02.6,0c.7,02q.0,02.8,0b.6,021.1,0r.0,01.0,01.0,01j.d,01.4,01.1,05.a,01.z,09.0,02u.3,01.5,01.1,02.1,',
16
+ '0p.1,04.2,0g.3,0d.0,02.1,06.0,0f.0,22q.2n,0e5.2,0qa.2,0t.1,0u.1,0u.1,01s.1,01.6,08.0,02.a,09.0,',
17
+ '019.4,039.1,0y.0,03a.2,04.1,09.0,06.2,063.1,02.0,01m.0,01.6,01.0,01.0,02.7,06.9,02.0,01c.19,02.b,',
18
+ '0k.3,01c.0,01.4,01.0,05.0,014.8,0c.1,0w.3,02.1,01.2,01k.0,01.1,03.0,01.2,01m.7,02.1,048.2,01.c,01.6,',
19
+ '04.0,06.0,03.1,05i.1r,0ej.4,0q.4,01d.4,01.9,02o.w,2fd.1,2d.1,25a.3,23.0,22.0,2eh.1,2l.1,2q.7,2g.b,',
20
+ '217.0,2a.5,23.0,2d.0,28.1,2h.1,25.1,28.0,25.0,2l.0,27.1,21.0,24.0,22.0,27.0,24.1,2s.0,2z.0,21.0,',
21
+ '24.2,21.0,21p.2,2o.0,2e.0,2nv.1,21f.0,24.0,0bd.2,03x.0,02o.v,23k.p,21.2g,2c.5x,2q.26,22.2d,22.2u,',
22
+ '25.16,21.2l,21.2d,29.1b,21.13,28.mkc,23.1i,0bs.3,01.9,0w.1,028.1,07k.0,03.0,04.0,0p.1,05.0,047.1,',
23
+ '0q.h,0d.0,012.7,0p.a,2e.s,03.2,01c.0,02.3,02.1,013.0,01v.5,02.1,02.1,0c.0,08.0,01b.0,01f.0,01.2,',
24
+ '02.1,05.1,01.0,016.1,08.0,06m.0,02.0,04.0,2i.8mb,26l8.e7,0u.0,0kh.f,20.9,06.f,20.y,21.i,21.3,043.0,',
25
+ '21.2n,23j.6,0i.2,0e9.0,06a.0,045.4,01ae.2,01.1,05.3,014.2,04.0,04l.1,0fx.3,01t.4,08t.1,025.5,01y.a,',
26
+ '01d.3,03f.0,01i.e,015.0,02.1,0a.2,01d.3,02.1,02.0,04.0,0a.0,01e.2,010.4,01.7,01q.0,0c.1,01g.8,0a.3,',
27
+ '02.0,02n.2,02.0,01.1,06.0,02.0,04d.0,03.7,0l.1,01l.1,03.0,011.6,03.4,01y.5,0d.0,01.0,01.0,0e.1,',
28
+ '02d.7,02.2,01.0,0n.0,02c.5,01.0,04.1,01.1,06m.3,06.1,01.1,0r.1,02d.7,02.0,01.1,02y.0,01.0,02.5,01.0,',
29
+ '02t.0,01.0,02.3,01.4,077.8,01.1,074.1,01.0,04.0,040.3,02.1,04.0,0w.9,014.5,02.3,08.0,09.5,02.2,',
30
+ '01a.c,01.1,05i.0,01.2,01.0,05l.6,01.5,01.0,02a.l,02.6,01.1,01.1,03e.5,03.0,01.1,01.6,01.0,020.1,',
31
+ '03.0,01.0,09n.1,0b.1,01g.4,05.0,01.0,0n.0,0445.g,06.e,08ug.b,03.2,01xc.4,01n.6,0t4.0,01r.3,225.4,',
32
+ '2b.6,29.5p1,215.v,22p.36,26pp.3,21.6,21.1,21.82,2f.0,2t.2,22.0,2e.3,28.az,01wh.1,01.3,03mk.19,02.m,',
33
+ '2ev.1,30.4,02.2,09.f,02.6,0u.3,2d.1,30.3,03l.2,257.2e,29.m,01ah.1i,04.1d,08.0,0e.0,0m.4,01.e,011s.6,',
34
+ '01.g,02.6,01.1,01.4,02s.0,04g.6,0af.0,01p.3,0e4.3,072.1,06r.0,02.0,07.1,05.0,0d6.6,031.6,21bt.0,',
35
+ '25m.0,25a.0,22.9,223.s,2d.17,24.8,27.1,2e.5,24a.w,2c.8,21.1x,21.l,2c.16,24.4,2c.g,23.0,23.1y,21.0,',
36
+ '21.56,22.1q,2d.3,21.n,2i.0,2q.1,2d.0,22e.2c,21c.1x,26.0,23.2,22.3,23.3,2b.1,27.8,26b.b,24.0,27v.1a,',
37
+ '21.9,21.54,234.c,23.a,23.1k,21.0,24.f,22.b,24.9,2zr.1ekd,22.1ekd,0e1oj.0,0u.2n,03k.6n'
38
+ ], '');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-dent-agent",
3
- "version": "0.2.2",
3
+ "version": "0.2.4",
4
4
  "description": "A generic coding agent as a pi extension: Bash, Task, Agent, Fleet, Script, Search, Markdown and more tools, with billing and terms extensions bundled",
5
5
  "keywords": [
6
6
  "coding-agent",
@@ -1,53 +0,0 @@
1
- {
2
- "root": true,
3
- "extends": "@ljharb",
4
- "rules": {
5
- "complexity": 0,
6
- "func-style": [2, "declaration"],
7
- "indent": [2, 4],
8
- "max-lines": 1,
9
- "max-lines-per-function": 1,
10
- "max-params": [2, 4],
11
- "max-statements": 0,
12
- "max-statements-per-line": [2, { "max": 2 }],
13
- "no-magic-numbers": 0,
14
- "no-param-reassign": 1,
15
- "strict": 0, // TODO
16
- },
17
- "overrides": [
18
- {
19
- "files": ["test/**", "test-*", "example/**"],
20
- "extends": "@ljharb/eslint-config/tests",
21
- "rules": {
22
- "id-length": 0,
23
- },
24
- },
25
- {
26
- "files": ["example/**"],
27
- "rules": {
28
- "no-console": 0,
29
- },
30
- },
31
- {
32
- "files": ["test/browser/**"],
33
- "env": {
34
- "browser": true,
35
- },
36
- },
37
- {
38
- "files": ["test/bigint*"],
39
- "rules": {
40
- "new-cap": [2, { "capIsNewExceptions": ["BigInt"] }],
41
- },
42
- },
43
- {
44
- "files": "index.js",
45
- "globals": {
46
- "HTMLElement": false,
47
- },
48
- "rules": {
49
- "no-use-before-define": 1,
50
- },
51
- },
52
- ],
53
- }
@@ -1,13 +0,0 @@
1
- {
2
- "all": true,
3
- "check-coverage": false,
4
- "instrumentation": false,
5
- "sourceMap": false,
6
- "reporter": ["text-summary", "text", "html", "json"],
7
- "exclude": [
8
- "coverage",
9
- "example",
10
- "test",
11
- "test-core-js.js"
12
- ]
13
- }
@@ -1,23 +0,0 @@
1
- 'use strict';
2
-
3
- var inspect = require('../');
4
- var Buffer = require('safer-buffer').Buffer;
5
-
6
- var holes = ['a', 'b'];
7
- holes[4] = 'e';
8
- holes[6] = 'g';
9
-
10
- var obj = {
11
- a: 1,
12
- b: [3, 4, undefined, null],
13
- c: undefined,
14
- d: null,
15
- e: {
16
- regex: /^x/i,
17
- buf: Buffer.from('abc'),
18
- holes: holes
19
- },
20
- now: new Date()
21
- };
22
- obj.self = obj;
23
- console.log(inspect(obj));
@@ -1,6 +0,0 @@
1
- 'use strict';
2
-
3
- var inspect = require('../');
4
- var obj = { a: 1, b: [3, 4] };
5
- obj.c = obj;
6
- console.log(inspect(obj));
@@ -1,5 +0,0 @@
1
- 'use strict';
2
-
3
- var inspect = require('../');
4
- var obj = [1, 2, function f(n) { return n + 5; }, 4];
5
- console.log(inspect(obj));
@@ -1,10 +0,0 @@
1
- 'use strict';
2
-
3
- /* eslint-env browser */
4
- var inspect = require('../');
5
-
6
- var d = document.createElement('div');
7
- d.setAttribute('id', 'beep');
8
- d.innerHTML = '<b>wooo</b><i>iiiii</i>';
9
-
10
- console.log(inspect([d, { a: 3, b: 4, c: [5, 6, [7, [8, [9]]]] }]));
@@ -1,58 +0,0 @@
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
- });
@@ -1,15 +0,0 @@
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
- });
@@ -1,16 +0,0 @@
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
- });
@@ -1,12 +0,0 @@
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
- });
@@ -1,53 +0,0 @@
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
- });
@@ -1,48 +0,0 @@
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
- });
@@ -1,29 +0,0 @@
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
- });
@@ -1,76 +0,0 @@
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
- });
@@ -1,17 +0,0 @@
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
- });
@@ -1,15 +0,0 @@
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
- });
@@ -1,15 +0,0 @@
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
- });