@jsenv/humanize 1.5.2 → 1.7.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.
Files changed (90) hide show
  1. package/dist/browser/jsenv_humanize_browser.js +539 -482
  2. package/dist/browser/jsenv_humanize_browser.js.map +76 -0
  3. package/dist/node/jsenv_humanize_node.js +58 -7
  4. package/dist/node/jsenv_humanize_node.js.map +97 -0
  5. package/dist/node/jsenv_humanize_node_modules.js +23 -15
  6. package/dist/node/jsenv_humanize_node_modules.js.map +21 -0
  7. package/package.json +20 -17
  8. package/src/_tests/byte/file_size.test.js +0 -18
  9. package/src/_tests/byte/memory.test.js +0 -11
  10. package/src/_tests/content_frame/content_frame.test.js +0 -156
  11. package/src/_tests/content_frame/snapshots/10_line_and_column_are_zero.txt +0 -2
  12. package/src/_tests/content_frame/snapshots/11_line_is_last.txt +0 -3
  13. package/src/_tests/content_frame/snapshots/1_basic.txt +0 -4
  14. package/src/_tests/content_frame/snapshots/2_basic_2.txt +0 -6
  15. package/src/_tests/content_frame/snapshots/3_empty_last_line.txt +0 -7
  16. package/src/_tests/content_frame/snapshots/4_no_column.txt +0 -3
  17. package/src/_tests/content_frame/snapshots/5_line_1_and_2_digits.txt +0 -3
  18. package/src/_tests/content_frame/snapshots/6_line_too_long_column_undefined.txt +0 -3
  19. package/src/_tests/content_frame/snapshots/7_line_too_long_column_near_start.txt +0 -4
  20. package/src/_tests/content_frame/snapshots/8_line_too_long_column_near_middle.txt +0 -4
  21. package/src/_tests/content_frame/snapshots/9_line_too_long_column_near_end.txt +0 -4
  22. package/src/_tests/js_value/_inspect.test.html +0 -22
  23. package/src/_tests/js_value/array.test.js +0 -72
  24. package/src/_tests/js_value/biginit.test.js +0 -35
  25. package/src/_tests/js_value/boolean.test.js +0 -45
  26. package/src/_tests/js_value/date.test.js +0 -15
  27. package/src/_tests/js_value/error.test.js +0 -33
  28. package/src/_tests/js_value/function.test.js +0 -51
  29. package/src/_tests/js_value/instance.test.js +0 -12
  30. package/src/_tests/js_value/null.test.js +0 -6
  31. package/src/_tests/js_value/number.test.js +0 -182
  32. package/src/_tests/js_value/object.test.js +0 -173
  33. package/src/_tests/js_value/regexp.test.js +0 -15
  34. package/src/_tests/js_value/string.test.js +0 -106
  35. package/src/_tests/js_value/symbol.test.js +0 -20
  36. package/src/_tests/js_value/undefined.test.js +0 -6
  37. package/src/_tests/log/log_long.test_manual.mjs +0 -39
  38. package/src/_tests/log/log_modified.test_manual.mjs +0 -7
  39. package/src/_tests/log/logger.test.mjs +0 -90
  40. package/src/_tests/log/spinner.duration.test_manual.mjs +0 -25
  41. package/src/_tests/log/spinner.test.mjs +0 -33
  42. package/src/_tests/log/spinner.test_manual.mjs +0 -15
  43. package/src/_tests/percentage/percentage_distribution.test.mjs +0 -89
  44. package/src/_tests/time/decimals.test.js +0 -119
  45. package/src/_tests/time/duration.test.js +0 -20
  46. package/src/_tests/time/ellapsed.test.js +0 -10
  47. package/src/ansi/ansi_browser.js +0 -3
  48. package/src/ansi/ansi_node.js +0 -13
  49. package/src/ansi/ansi_runtime_agnostic.js +0 -107
  50. package/src/byte/byte.js +0 -44
  51. package/src/content_frame/content_frame.js +0 -157
  52. package/src/error/error_to_html.js +0 -22
  53. package/src/error/error_to_markdown.js +0 -14
  54. package/src/js_value/array.js +0 -58
  55. package/src/js_value/bigint.js +0 -3
  56. package/src/js_value/bigint_object.js +0 -5
  57. package/src/js_value/boolean.js +0 -1
  58. package/src/js_value/boolean_object.js +0 -12
  59. package/src/js_value/constructor.js +0 -10
  60. package/src/js_value/date.js +0 -8
  61. package/src/js_value/error.js +0 -34
  62. package/src/js_value/function.js +0 -20
  63. package/src/js_value/humanize.js +0 -142
  64. package/src/js_value/null.js +0 -1
  65. package/src/js_value/number.js +0 -101
  66. package/src/js_value/number_object.js +0 -9
  67. package/src/js_value/object.js +0 -78
  68. package/src/js_value/regexp.js +0 -1
  69. package/src/js_value/string.js +0 -141
  70. package/src/js_value/string_object.js +0 -10
  71. package/src/js_value/symbol.js +0 -24
  72. package/src/js_value/undefined.js +0 -1
  73. package/src/log/LOG_LEVELS.js +0 -9
  74. package/src/log/call_orderer.js +0 -39
  75. package/src/log/detailed_message.js +0 -29
  76. package/src/log/details.js +0 -26
  77. package/src/log/dynamic_log.js +0 -186
  78. package/src/log/logger.js +0 -85
  79. package/src/log/section.js +0 -50
  80. package/src/log/spinner.js +0 -72
  81. package/src/log/task_log.js +0 -49
  82. package/src/main_browser.js +0 -13
  83. package/src/main_node.js +0 -24
  84. package/src/percentage/distribute_percentages.js +0 -53
  85. package/src/time/time.js +0 -151
  86. package/src/unicode/unicode_browser.js +0 -7
  87. package/src/unicode/unicode_node.js +0 -8
  88. package/src/unicode/unicode_runtime_agnostic.js +0 -56
  89. package/src/utils/decimals.js +0 -95
  90. package/src/utils/indentation.js +0 -38
@@ -1,6 +0,0 @@
1
- 1 | const a = false;
2
- 2 | const b = true;
3
- 3 | const c = true;
4
- ^
5
- 4 | const d = true;
6
- 5 | const e = false;
@@ -1,7 +0,0 @@
1
- 1 | const a = false;
2
- 2 | const b = true;
3
- 3 | const c = true;
4
- ^
5
- 4 | const d = true;
6
- 5 | const e = false;
7
- 6 |
@@ -1,3 +0,0 @@
1
- 2 | const b = true;
2
- > 3 | const c = true;
3
- 4 | const d = true;
@@ -1,3 +0,0 @@
1
- 9 | const i = true;
2
- > 10 | const j = true;
3
- 11 | const k = true;
@@ -1,3 +0,0 @@
1
- 2 | const b = true;
2
- > 3 | const thisVari…
3
- 4 | const d = true;
@@ -1,4 +0,0 @@
1
- 2 | const b = true;
2
- 3 | const thisVari…
3
- ^
4
- 4 | const d = true;
@@ -1,4 +0,0 @@
1
- 2 |
2
- 3 | …ableNameisQu…
3
- ^
4
- 4 |
@@ -1,4 +0,0 @@
1
- 2 |
2
- 3 | …eLong = true;
3
- ^
4
- 4 |
@@ -1,22 +0,0 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <title>Inspect tests</title>
5
- <meta charset="utf-8" />
6
- <link rel="icon" href="data:," />
7
- </head>
8
-
9
- <body>
10
- <script type="module" src="./array.test.js"></script>
11
- <script type="module" src="./boolean.test.js"></script>
12
- <script type="module" src="./date.test.js"></script>
13
- <script type="module" src="./error.test.js"></script>
14
- <script type="module" src="./function.test.js"></script>
15
- <script type="module" src="./instance.test.js"></script>
16
- <script type="module" src="./null.test.js"></script>
17
- <script type="module" src="./number.test.js"></script>
18
- <script type="module" src="./regexp.test.js"></script>
19
- <script type="module" src="./symbol.test.js"></script>
20
- <script type="module" src="./undefined.test.js"></script>
21
- </body>
22
- </html>
@@ -1,72 +0,0 @@
1
- import { assert } from "@jsenv/assert";
2
- import { humanize } from "@jsenv/humanize";
3
-
4
- {
5
- const actual = humanize([]);
6
- const expect = `[]`;
7
- assert({ actual, expect });
8
- }
9
-
10
- {
11
- const actual = humanize([[]]);
12
- const expect = `[
13
- []
14
- ]`;
15
- assert({ actual, expect });
16
- }
17
-
18
- {
19
- const actual = humanize(Array(3));
20
- // prettier-ignore
21
- const expect = `[
22
- ,
23
- ,
24
- ${" "}
25
- ]`
26
- assert({ actual, expect });
27
- }
28
-
29
- {
30
- const actual = humanize([Symbol()]);
31
- const expect = `[
32
- Symbol()
33
- ]`;
34
- assert({ actual, expect });
35
- }
36
-
37
- {
38
- // eslint-disable-next-line no-array-constructor
39
- const newArray = new Array("foo", 1);
40
-
41
- {
42
- const actual = humanize(newArray);
43
- const expect = `[
44
- "foo",
45
- 1
46
- ]`;
47
- assert({
48
- actual,
49
- expect,
50
- });
51
- }
52
-
53
- {
54
- const actual = humanize(newArray);
55
- const expect = `[
56
- "foo",
57
- 1
58
- ]`;
59
- assert({ actual, expect });
60
- }
61
- }
62
-
63
- {
64
- const circularArray = [0];
65
- circularArray.push(circularArray);
66
- const actual = humanize(circularArray);
67
- const expect = `[
68
- 0,
69
- Symbol.for('circular')
70
- ]`;
71
- assert({ actual, expect });
72
- }
@@ -1,35 +0,0 @@
1
- import { assert } from "@jsenv/assert";
2
- import { humanize } from "@jsenv/humanize";
3
-
4
- {
5
- const value = BigInt(1);
6
- const actual = humanize(value);
7
- const expect = "1n";
8
- assert({ actual, expect });
9
- }
10
-
11
- {
12
- const value = 2n;
13
- const actual = humanize(value);
14
- const expect = "2n";
15
- assert({ actual, expect });
16
- }
17
-
18
- {
19
- const value = Object(BigInt(1));
20
- const actual = humanize(value);
21
- const expect = "BigInt(1n)";
22
- assert({ actual, expect });
23
- }
24
-
25
- {
26
- const actual = humanize(1234567n);
27
- const expect = "1234567n";
28
- assert({ actual, expect });
29
- }
30
-
31
- {
32
- const actual = humanize(19223n);
33
- const expect = "19223n";
34
- assert({ actual, expect });
35
- }
@@ -1,45 +0,0 @@
1
- import { assert } from "@jsenv/assert";
2
- import { humanize } from "@jsenv/humanize";
3
-
4
- {
5
- const actual = humanize(true);
6
- const expect = "true";
7
- assert({ actual, expect });
8
- }
9
-
10
- {
11
- const actual = humanize(false);
12
- const expect = "false";
13
- assert({ actual, expect });
14
- }
15
-
16
- /* eslint-disable no-new-wrappers */
17
- {
18
- const actual = humanize(new Boolean(true));
19
- const expect = "Boolean(true)";
20
- assert({ actual, expect });
21
- }
22
-
23
- {
24
- const actual = humanize(new Boolean(true), { parenthesis: true });
25
- const expect = "(Boolean(true))";
26
- assert({ actual, expect });
27
- }
28
-
29
- {
30
- const actual = humanize(new Boolean(true), { useNew: true });
31
- const expect = "new Boolean(true)";
32
- assert({ actual, expect });
33
- }
34
-
35
- {
36
- const actual = humanize(new Boolean(true), {
37
- parenthesis: true,
38
- useNew: true,
39
- });
40
- const expect = "new (Boolean(true))";
41
- assert({
42
- actual,
43
- expect,
44
- });
45
- }
@@ -1,15 +0,0 @@
1
- import { assert } from "@jsenv/assert";
2
- import { humanize } from "@jsenv/humanize";
3
-
4
- {
5
- const actual = humanize(new Date(10));
6
- const expect = `Date(10)`;
7
- assert({ actual, expect });
8
- }
9
-
10
- {
11
- const nowMs = Date.now();
12
- const actual = humanize(new Date(nowMs));
13
- const expect = `Date(${nowMs})`;
14
- assert({ actual, expect });
15
- }
@@ -1,33 +0,0 @@
1
- import { assert } from "@jsenv/assert";
2
- import { humanize } from "@jsenv/humanize";
3
-
4
- {
5
- const actual = humanize(new Error("here"));
6
- const expect = `Error("here")`;
7
- assert({ actual, expect });
8
- }
9
-
10
- {
11
- const actual = humanize(new RangeError("here"));
12
- const expect = `RangeError("here")`;
13
- assert({ actual, expect });
14
- }
15
-
16
- {
17
- const actualError = new Error("hello");
18
- Object.defineProperty(actualError, "bar", {
19
- enumerable: false,
20
- value: "bar",
21
- });
22
- const actual = humanize(actualError);
23
- const expect = `Error("hello")`;
24
- assert({ actual, expect });
25
- }
26
-
27
- {
28
- const error = new Error();
29
- error.name = "AssertionError";
30
- const actual = humanize(error);
31
- const expect = `Error("")`;
32
- assert({ actual, expect });
33
- }
@@ -1,51 +0,0 @@
1
- import { assert } from "@jsenv/assert";
2
- import { humanize } from "@jsenv/humanize";
3
-
4
- // const arrowFunctionSupported = (() => {}).prototype === null
5
-
6
- {
7
- const actual = humanize(function () {});
8
- const expect = `function () {/* hidden */}`;
9
- assert({ actual, expect });
10
- }
11
-
12
- {
13
- const actual = humanize(function () {}, { showFunctionBody: true });
14
- const expect = "function () {}";
15
- assert({ actual, expect });
16
- }
17
-
18
- {
19
- const value = function () {
20
- return true;
21
- };
22
- const actual = humanize(value, { showFunctionBody: true });
23
- const expect = value.toString();
24
- assert({ actual, expect });
25
- }
26
-
27
- function named(a) {
28
- return a;
29
- }
30
- {
31
- const actual = humanize(named);
32
- const expect = `function named() {/* hidden */}`;
33
- assert({ actual, expect });
34
- }
35
- {
36
- const actual = humanize(named, { showFunctionBody: true });
37
- const expect = named.toString();
38
- assert({ actual, expect });
39
- }
40
-
41
- {
42
- const nested = {
43
- // eslint-disable-next-line object-shorthand
44
- function: function () {},
45
- };
46
- const actual = humanize(nested);
47
- const expect = `{
48
- "function": function () {/* hidden */}
49
- }`;
50
- assert({ actual, expect });
51
- }
@@ -1,12 +0,0 @@
1
- import { assert } from "@jsenv/assert";
2
- import { humanize } from "@jsenv/humanize";
3
-
4
- const CustomConstructor = function () {
5
- this.foo = true;
6
- };
7
- const customInstance = new CustomConstructor();
8
- const actual = humanize(customInstance);
9
- const expect = `CustomConstructor({
10
- "foo": true
11
- })`;
12
- assert({ actual, expect });
@@ -1,6 +0,0 @@
1
- import { assert } from "@jsenv/assert";
2
- import { humanize } from "@jsenv/humanize";
3
-
4
- const actual = humanize(null);
5
- const expect = "null";
6
- assert({ actual, expect });
@@ -1,182 +0,0 @@
1
- // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/test/numeric-separators-style.mjs
2
-
3
- import { assert } from "@jsenv/assert";
4
- import { humanize } from "@jsenv/humanize";
5
-
6
- {
7
- const actual = humanize(0);
8
- const expect = "0";
9
- assert({ actual, expect });
10
- }
11
-
12
- {
13
- const actual = humanize(1);
14
- const expect = "1";
15
- assert({ actual, expect });
16
- }
17
-
18
- {
19
- const actual = humanize(-0);
20
- const expect = "-0";
21
- assert({ actual, expect });
22
- }
23
-
24
- {
25
- const actual = humanize(NaN);
26
- const expect = "NaN";
27
- assert({ actual, expect });
28
- }
29
-
30
- {
31
- const actual = humanize(Infinity);
32
- const expect = "Infinity";
33
- assert({ actual, expect });
34
- }
35
-
36
- {
37
- const actual = humanize(-Infinity);
38
- const expect = "-Infinity";
39
- assert({ actual, expect });
40
- }
41
-
42
- {
43
- // eslint-disable-next-line no-new-wrappers
44
- const actual = humanize(new Number(0));
45
- const expect = "Number(0)";
46
- assert({ actual, expect });
47
- }
48
-
49
- {
50
- // eslint-disable-next-line no-new-wrappers
51
- const actual = humanize(new Number(0), { parenthesis: true });
52
- const expect = "(Number(0))";
53
- assert({ actual, expect });
54
- }
55
-
56
- {
57
- // eslint-disable-next-line no-new-wrappers
58
- const actual = humanize(new Number(0), { useNew: true });
59
- const expect = "new Number(0)";
60
- assert({ actual, expect });
61
- }
62
-
63
- {
64
- // eslint-disable-next-line no-new-wrappers
65
- const actual = humanize(new Number(0), { parenthesis: true, useNew: true });
66
- const expect = "new (Number(0))";
67
- assert({ actual, expect });
68
- }
69
-
70
- // numeric separator - numbers
71
- {
72
- const actual = humanize(1235);
73
- const expect = "1235";
74
- assert({ actual, expect });
75
- }
76
-
77
- {
78
- const actual = humanize(67000);
79
- const expect = "67_000";
80
- assert({ actual, expect });
81
- }
82
-
83
- {
84
- const actual = humanize(149600000);
85
- const expect = "149_600_000";
86
- assert({ actual, expect });
87
- }
88
-
89
- {
90
- const actual = humanize(1_464_301);
91
- const expect = "1_464_301";
92
- assert({ actual, expect });
93
- }
94
-
95
- // decimal
96
- {
97
- const actual = humanize(1234.56);
98
- const expect = "1234.56";
99
- assert({ actual, expect });
100
- }
101
-
102
- {
103
- const actual = humanize(12345.67);
104
- const expect = "12_345.67";
105
- assert({ actual, expect });
106
- }
107
-
108
- {
109
- const actual = humanize(-0.120123);
110
- const expect = "-0.120123";
111
- assert({ actual, expect });
112
- }
113
-
114
- // negative
115
- {
116
- const actual = humanize(-1000001);
117
- const expect = "-1_000_001";
118
- assert({ actual, expect });
119
- }
120
-
121
- // exponential
122
- {
123
- const actual = humanize(-1.23456e105);
124
- const expect = "-1.23456e+105";
125
- assert({ actual, expect });
126
- }
127
-
128
- {
129
- const actual = humanize(-1200000e5);
130
- const expect = "-120_000_000_000";
131
- assert({ actual, expect });
132
- }
133
-
134
- {
135
- // prettier-ignore
136
- const actual = humanize(3.65432E12)
137
- const expect = "3_654_320_000_000";
138
- assert({ actual, expect });
139
- }
140
-
141
- // numeric separator - binary
142
- {
143
- const actual = humanize(0b10101010101010);
144
- const expect = "10_922";
145
- assert({ actual, expect });
146
- }
147
-
148
- {
149
- // prettier-ignore
150
- const actual = humanize(0B10101010101010)
151
- const expect = "10_922";
152
- assert({ actual, expect });
153
- }
154
-
155
- // numeric separator - hexadecimal
156
- {
157
- const actual = humanize(0xfabf00d);
158
- const expect = "262_926_349";
159
- assert({ actual, expect });
160
- }
161
-
162
- {
163
- // prettier-ignore
164
- const actual = humanize(0xABCDEF)
165
- // prettier-ignore
166
- const expect = "11_259_375"
167
- assert({ actual, expect });
168
- }
169
-
170
- // numeric separator - octal
171
- {
172
- const actual = humanize(0o010101010101);
173
- const expect = "1_090_785_345";
174
- assert({ actual, expect });
175
- }
176
-
177
- {
178
- // prettier-ignore
179
- const actual = humanize(0O010101010101)
180
- const expect = "1_090_785_345";
181
- assert({ actual, expect });
182
- }
@@ -1,173 +0,0 @@
1
- import { assert } from "@jsenv/assert";
2
- import { humanize } from "@jsenv/humanize";
3
-
4
- {
5
- const actual = humanize({});
6
- const expect = "{}";
7
- assert({ actual, expect });
8
- }
9
-
10
- {
11
- // eslint-disable-next-line no-new-object
12
- const actual = humanize(new Object({}));
13
- const expect = "{}";
14
- assert({ actual, expect });
15
- }
16
-
17
- {
18
- const actual = humanize({}, { objectConstructor: true });
19
- const expect = "Object({})";
20
- assert({ actual, expect });
21
- }
22
-
23
- {
24
- const actual = humanize(
25
- { foo: true },
26
- { objectConstructor: true, useNew: true },
27
- );
28
- const expect = `new Object({
29
- "foo": true
30
- })`;
31
- assert({
32
- actual,
33
- expect,
34
- });
35
- }
36
-
37
- {
38
- const actual = humanize({ 0: "foo" });
39
- const expect = `{
40
- 0: "foo"
41
- }`;
42
- assert({ actual, expect });
43
- }
44
-
45
- {
46
- const actual = humanize({ Infinity: "foo" });
47
- const expect = `{
48
- "Infinity": "foo"
49
- }`;
50
- assert({ actual, expect });
51
- }
52
-
53
- {
54
- const actual = humanize({ name: "dam" }, { quote: "'" });
55
- const expect = `{
56
- 'name': 'dam'
57
- }`;
58
- assert({ actual, expect });
59
- }
60
-
61
- {
62
- const actual = humanize(
63
- { foo: true, nested: { bar: true } },
64
- { parenthesis: true },
65
- );
66
- const expect = `({
67
- "foo": true,
68
- "nested": ({
69
- "bar": true
70
- })
71
- })`;
72
- assert({ actual, expect });
73
- }
74
-
75
- {
76
- const foo = { foo: true, bar: false };
77
-
78
- const actual = humanize(foo);
79
- const expect = `{
80
- "foo": true,
81
- "bar": false
82
- }`;
83
- assert({ actual, expect });
84
- }
85
-
86
- {
87
- const actual = humanize(
88
- Object.create({
89
- foo: true,
90
- }),
91
- );
92
- const expect = "{}";
93
- assert({ actual, expect });
94
- }
95
-
96
- {
97
- const nested = { foo: { name: "dam" } };
98
- const actual = humanize(nested);
99
- const expect = `{
100
- "foo": {
101
- "name": "dam"
102
- }
103
- }`;
104
- assert({ actual, expect });
105
- }
106
-
107
- {
108
- const circularObject = {
109
- foo: true,
110
- };
111
- circularObject.self = circularObject;
112
- const actual = humanize(circularObject);
113
- const expect = `{
114
- "foo": true,
115
- "self": Symbol.for('circular')
116
- }`;
117
- assert({ actual, expect });
118
- }
119
-
120
- {
121
- const nestedCircularObject = {
122
- foo: true,
123
- };
124
- nestedCircularObject.nested = {
125
- bar: true,
126
- parent: nestedCircularObject,
127
- };
128
- const actual = humanize(nestedCircularObject);
129
- const expect = `{
130
- "foo": true,
131
- "nested": {
132
- "bar": true,
133
- "parent": Symbol.for('circular')
134
- }
135
- }`;
136
- assert({ actual, expect });
137
- }
138
-
139
- {
140
- const actual = humanize(Object.create(null));
141
- const expect = "{}";
142
- assert({ actual, expect });
143
- }
144
-
145
- {
146
- const object = Object.create(null);
147
- object[Symbol.toStringTag] = "stuff";
148
- const actual = humanize(object);
149
- const expect = `{
150
- [Symbol("Symbol.toStringTag")]: "stuff"
151
- }`;
152
- assert({ actual, expect });
153
- }
154
-
155
- {
156
- const object = Object.create(null);
157
- object[Symbol.toStringTag] = "stuff";
158
- object.foo = true;
159
- const actual = humanize(object);
160
- const expect = `{
161
- "foo": true,
162
- [Symbol("Symbol.toStringTag")]: "stuff"
163
- }`;
164
- assert({ actual, expect });
165
- }
166
-
167
- {
168
- const actual = humanize({ [Symbol()]: true });
169
- const expect = `{
170
- [Symbol()]: true
171
- }`;
172
- assert({ actual, expect });
173
- }