@jsenv/humanize 1.6.0 → 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.
- package/dist/browser/jsenv_humanize_browser.js +539 -482
- package/dist/browser/jsenv_humanize_browser.js.map +76 -0
- package/dist/node/jsenv_humanize_node.js +36 -37
- package/dist/node/jsenv_humanize_node.js.map +97 -0
- package/dist/node/jsenv_humanize_node_modules.js +23 -15
- package/dist/node/jsenv_humanize_node_modules.js.map +21 -0
- package/package.json +18 -19
- package/src/_tests/byte/file_size.test.js +0 -18
- package/src/_tests/byte/memory.test.js +0 -11
- package/src/_tests/content_frame/content_frame.test.js +0 -155
- package/src/_tests/content_frame/snapshots/10_line_and_column_are_zero.txt +0 -2
- package/src/_tests/content_frame/snapshots/11_line_is_last.txt +0 -3
- package/src/_tests/content_frame/snapshots/1_basic.txt +0 -4
- package/src/_tests/content_frame/snapshots/2_basic_2.txt +0 -6
- package/src/_tests/content_frame/snapshots/3_empty_last_line.txt +0 -7
- package/src/_tests/content_frame/snapshots/4_no_column.txt +0 -3
- package/src/_tests/content_frame/snapshots/5_line_1_and_2_digits.txt +0 -3
- package/src/_tests/content_frame/snapshots/6_line_too_long_column_undefined.txt +0 -3
- package/src/_tests/content_frame/snapshots/7_line_too_long_column_near_start.txt +0 -4
- package/src/_tests/content_frame/snapshots/8_line_too_long_column_near_middle.txt +0 -4
- package/src/_tests/content_frame/snapshots/9_line_too_long_column_near_end.txt +0 -4
- package/src/_tests/js_value/_inspect.test.html +0 -22
- package/src/_tests/js_value/array.test.js +0 -72
- package/src/_tests/js_value/biginit.test.js +0 -35
- package/src/_tests/js_value/boolean.test.js +0 -45
- package/src/_tests/js_value/date.test.js +0 -15
- package/src/_tests/js_value/error.test.js +0 -33
- package/src/_tests/js_value/function.test.js +0 -51
- package/src/_tests/js_value/instance.test.js +0 -12
- package/src/_tests/js_value/null.test.js +0 -6
- package/src/_tests/js_value/number.test.js +0 -182
- package/src/_tests/js_value/object.test.js +0 -173
- package/src/_tests/js_value/regexp.test.js +0 -15
- package/src/_tests/js_value/string.test.js +0 -106
- package/src/_tests/js_value/symbol.test.js +0 -20
- package/src/_tests/js_value/undefined.test.js +0 -6
- package/src/_tests/log/log_long.test_manual.mjs +0 -39
- package/src/_tests/log/log_modified.test_manual.mjs +0 -7
- package/src/_tests/log/logger.test.mjs +0 -90
- package/src/_tests/log/spinner.duration.test_manual.mjs +0 -25
- package/src/_tests/log/spinner.test.mjs +0 -33
- package/src/_tests/log/spinner.test_manual.mjs +0 -15
- package/src/_tests/percentage/percentage_distribution.test.mjs +0 -89
- package/src/_tests/time/decimals.test.js +0 -119
- package/src/_tests/time/duration.test.js +0 -20
- package/src/_tests/time/ellapsed.test.js +0 -10
- package/src/ansi/ansi_browser.js +0 -3
- package/src/ansi/ansi_node.js +0 -13
- package/src/ansi/ansi_runtime_agnostic.js +0 -107
- package/src/byte/byte.js +0 -44
- package/src/content_frame/content_frame.js +0 -157
- package/src/error/error_to_html.js +0 -22
- package/src/error/error_to_markdown.js +0 -14
- package/src/error/format_error.js +0 -53
- package/src/js_value/array.js +0 -58
- package/src/js_value/bigint.js +0 -3
- package/src/js_value/bigint_object.js +0 -5
- package/src/js_value/boolean.js +0 -1
- package/src/js_value/boolean_object.js +0 -12
- package/src/js_value/constructor.js +0 -10
- package/src/js_value/date.js +0 -8
- package/src/js_value/error.js +0 -34
- package/src/js_value/function.js +0 -20
- package/src/js_value/humanize.js +0 -142
- package/src/js_value/null.js +0 -1
- package/src/js_value/number.js +0 -101
- package/src/js_value/number_object.js +0 -9
- package/src/js_value/object.js +0 -78
- package/src/js_value/regexp.js +0 -1
- package/src/js_value/string.js +0 -141
- package/src/js_value/string_object.js +0 -10
- package/src/js_value/symbol.js +0 -24
- package/src/js_value/undefined.js +0 -1
- package/src/log/LOG_LEVELS.js +0 -9
- package/src/log/call_orderer.js +0 -39
- package/src/log/detailed_message.js +0 -29
- package/src/log/details.js +0 -26
- package/src/log/dynamic_log.js +0 -186
- package/src/log/logger.js +0 -85
- package/src/log/section.js +0 -50
- package/src/log/spinner.js +0 -72
- package/src/log/task_log.js +0 -49
- package/src/main_browser.js +0 -13
- package/src/main_node.js +0 -25
- package/src/percentage/distribute_percentages.js +0 -53
- package/src/time/time.js +0 -151
- package/src/unicode/unicode_browser.js +0 -7
- package/src/unicode/unicode_node.js +0 -8
- package/src/unicode/unicode_runtime_agnostic.js +0 -56
- package/src/utils/decimals.js +0 -95
- package/src/utils/indentation.js +0 -38
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import isUnicodeSupported from "is-unicode-supported";
|
|
2
|
-
import { ANSI } from "../ansi/ansi_node.js";
|
|
3
|
-
import { createUnicode } from "./unicode_runtime_agnostic.js";
|
|
4
|
-
|
|
5
|
-
export const UNICODE = createUnicode({
|
|
6
|
-
supported: process.env.FORCE_UNICODE === "1" || isUnicodeSupported(),
|
|
7
|
-
ANSI,
|
|
8
|
-
});
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
// see also https://github.com/sindresorhus/figures
|
|
2
|
-
|
|
3
|
-
export const createUnicode = ({ supported, ANSI }) => {
|
|
4
|
-
const UNICODE = {
|
|
5
|
-
supported,
|
|
6
|
-
get COMMAND_RAW() {
|
|
7
|
-
return UNICODE.supported ? `❯` : `>`;
|
|
8
|
-
},
|
|
9
|
-
get OK_RAW() {
|
|
10
|
-
return UNICODE.supported ? `✔` : `√`;
|
|
11
|
-
},
|
|
12
|
-
get FAILURE_RAW() {
|
|
13
|
-
return UNICODE.supported ? `✖` : `×`;
|
|
14
|
-
},
|
|
15
|
-
get DEBUG_RAW() {
|
|
16
|
-
return UNICODE.supported ? `◆` : `♦`;
|
|
17
|
-
},
|
|
18
|
-
get INFO_RAW() {
|
|
19
|
-
return UNICODE.supported ? `ℹ` : `i`;
|
|
20
|
-
},
|
|
21
|
-
get WARNING_RAW() {
|
|
22
|
-
return UNICODE.supported ? `⚠` : `‼`;
|
|
23
|
-
},
|
|
24
|
-
get CIRCLE_CROSS_RAW() {
|
|
25
|
-
return UNICODE.supported ? `ⓧ` : `(×)`;
|
|
26
|
-
},
|
|
27
|
-
get CIRCLE_DOTTED_RAW() {
|
|
28
|
-
return UNICODE.supported ? `◌` : `*`;
|
|
29
|
-
},
|
|
30
|
-
get COMMAND() {
|
|
31
|
-
return ANSI.color(UNICODE.COMMAND_RAW, ANSI.GREY); // ANSI_MAGENTA)
|
|
32
|
-
},
|
|
33
|
-
get OK() {
|
|
34
|
-
return ANSI.color(UNICODE.OK_RAW, ANSI.GREEN);
|
|
35
|
-
},
|
|
36
|
-
get FAILURE() {
|
|
37
|
-
return ANSI.color(UNICODE.FAILURE_RAW, ANSI.RED);
|
|
38
|
-
},
|
|
39
|
-
get DEBUG() {
|
|
40
|
-
return ANSI.color(UNICODE.DEBUG_RAW, ANSI.GREY);
|
|
41
|
-
},
|
|
42
|
-
get INFO() {
|
|
43
|
-
return ANSI.color(UNICODE.INFO_RAW, ANSI.BLUE);
|
|
44
|
-
},
|
|
45
|
-
get WARNING() {
|
|
46
|
-
return ANSI.color(UNICODE.WARNING_RAW, ANSI.YELLOW);
|
|
47
|
-
},
|
|
48
|
-
get CIRCLE_CROSS() {
|
|
49
|
-
return ANSI.color(UNICODE.CIRCLE_CROSS_RAW, ANSI.RED);
|
|
50
|
-
},
|
|
51
|
-
get ELLIPSIS() {
|
|
52
|
-
return UNICODE.supported ? `…` : `...`;
|
|
53
|
-
},
|
|
54
|
-
};
|
|
55
|
-
return UNICODE;
|
|
56
|
-
};
|
package/src/utils/decimals.js
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
export const getPrecision = (number) => {
|
|
2
|
-
if (Math.floor(number) === number) return 0;
|
|
3
|
-
const [, decimals] = number.toString().split(".");
|
|
4
|
-
return decimals.length || 0;
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
export const setRoundedPrecision = (
|
|
8
|
-
number,
|
|
9
|
-
{ decimals = 1, decimalsWhenSmall = decimals } = {},
|
|
10
|
-
) => {
|
|
11
|
-
return setDecimalsPrecision(number, {
|
|
12
|
-
decimals,
|
|
13
|
-
decimalsWhenSmall,
|
|
14
|
-
transform: Math.round,
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export const setFlooredPrecision = (
|
|
19
|
-
number,
|
|
20
|
-
{ decimals = 1, decimalsWhenSmall = decimals } = {},
|
|
21
|
-
) => {
|
|
22
|
-
return setDecimalsPrecision(number, {
|
|
23
|
-
decimals,
|
|
24
|
-
decimalsWhenSmall,
|
|
25
|
-
transform: Math.floor,
|
|
26
|
-
});
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export const setCeiledPrecision = (
|
|
30
|
-
number,
|
|
31
|
-
{ decimals = 1, decimalsWhenSmall = decimals } = {},
|
|
32
|
-
) => {
|
|
33
|
-
return setDecimalsPrecision(number, {
|
|
34
|
-
decimals,
|
|
35
|
-
decimalsWhenSmall,
|
|
36
|
-
transform: Math.ceil,
|
|
37
|
-
});
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export const setPrecision = (
|
|
41
|
-
number,
|
|
42
|
-
{ decimals = 1, decimalsWhenSmall = decimals } = {},
|
|
43
|
-
) => {
|
|
44
|
-
return setDecimalsPrecision(number, {
|
|
45
|
-
decimals,
|
|
46
|
-
decimalsWhenSmall,
|
|
47
|
-
transform: parseInt,
|
|
48
|
-
});
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
const setDecimalsPrecision = (
|
|
52
|
-
number,
|
|
53
|
-
{
|
|
54
|
-
transform,
|
|
55
|
-
decimals, // max decimals for number in [-Infinity, -1[]1, Infinity]
|
|
56
|
-
decimalsWhenSmall, // max decimals for number in [-1,1]
|
|
57
|
-
} = {},
|
|
58
|
-
) => {
|
|
59
|
-
if (number === 0) {
|
|
60
|
-
return 0;
|
|
61
|
-
}
|
|
62
|
-
let numberCandidate = Math.abs(number);
|
|
63
|
-
if (numberCandidate < 1) {
|
|
64
|
-
const integerGoal = Math.pow(10, decimalsWhenSmall - 1);
|
|
65
|
-
let i = 1;
|
|
66
|
-
while (numberCandidate < integerGoal) {
|
|
67
|
-
numberCandidate *= 10;
|
|
68
|
-
i *= 10;
|
|
69
|
-
}
|
|
70
|
-
const asInteger = transform(numberCandidate);
|
|
71
|
-
const asFloat = asInteger / i;
|
|
72
|
-
return number < 0 ? -asFloat : asFloat;
|
|
73
|
-
}
|
|
74
|
-
const coef = Math.pow(10, decimals);
|
|
75
|
-
const numberMultiplied = (number + Number.EPSILON) * coef;
|
|
76
|
-
const asInteger = transform(numberMultiplied);
|
|
77
|
-
const asFloat = asInteger / coef;
|
|
78
|
-
return number < 0 ? -asFloat : asFloat;
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
// https://www.codingem.com/javascript-how-to-limit-decimal-places/
|
|
82
|
-
// export const roundNumber = (number, maxDecimals) => {
|
|
83
|
-
// const decimalsExp = Math.pow(10, maxDecimals)
|
|
84
|
-
// const numberRoundInt = Math.round(decimalsExp * (number + Number.EPSILON))
|
|
85
|
-
// const numberRoundFloat = numberRoundInt / decimalsExp
|
|
86
|
-
// return numberRoundFloat
|
|
87
|
-
// }
|
|
88
|
-
|
|
89
|
-
// export const setPrecision = (number, precision) => {
|
|
90
|
-
// if (Math.floor(number) === number) return number
|
|
91
|
-
// const [int, decimals] = number.toString().split(".")
|
|
92
|
-
// if (precision <= 0) return int
|
|
93
|
-
// const numberTruncated = `${int}.${decimals.slice(0, precision)}`
|
|
94
|
-
// return numberTruncated
|
|
95
|
-
// }
|
package/src/utils/indentation.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
export const preNewLineAndIndentation = (
|
|
2
|
-
value,
|
|
3
|
-
{ depth, indentUsingTab, indentSize },
|
|
4
|
-
) => {
|
|
5
|
-
return `${newLineAndIndent({
|
|
6
|
-
count: depth + 1,
|
|
7
|
-
useTabs: indentUsingTab,
|
|
8
|
-
size: indentSize,
|
|
9
|
-
})}${value}`;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
const postNewLineAndIndentation = ({ depth, indentUsingTab, indentSize }) => {
|
|
13
|
-
return newLineAndIndent({
|
|
14
|
-
count: depth,
|
|
15
|
-
useTabs: indentUsingTab,
|
|
16
|
-
size: indentSize,
|
|
17
|
-
});
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const newLineAndIndent = ({ count, useTabs, size }) => {
|
|
21
|
-
if (useTabs) {
|
|
22
|
-
// eslint-disable-next-line prefer-template
|
|
23
|
-
return "\n" + "\t".repeat(count);
|
|
24
|
-
}
|
|
25
|
-
// eslint-disable-next-line prefer-template
|
|
26
|
-
return "\n" + " ".repeat(count * size);
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export const wrapNewLineAndIndentation = (
|
|
30
|
-
value,
|
|
31
|
-
{ depth, indentUsingTab, indentSize },
|
|
32
|
-
) => {
|
|
33
|
-
return `${preNewLineAndIndentation(value, {
|
|
34
|
-
depth,
|
|
35
|
-
indentUsingTab,
|
|
36
|
-
indentSize,
|
|
37
|
-
})}${postNewLineAndIndentation({ depth, indentUsingTab, indentSize })}`;
|
|
38
|
-
};
|