topkat-utils 1.0.60 → 1.1.2
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/CHANGELOG.md +4 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.js +56 -0
- package/dist/index.js.map +1 -0
- package/dist/src/array-utils.d.ts +56 -0
- package/dist/src/array-utils.js +138 -0
- package/dist/src/array-utils.js.map +1 -0
- package/dist/src/date-utils.d.ts +100 -0
- package/dist/src/date-utils.js +357 -0
- package/dist/src/date-utils.js.map +1 -0
- package/dist/src/env-utils.d.ts +8 -0
- package/dist/src/env-utils.js +38 -0
- package/dist/src/env-utils.js.map +1 -0
- package/dist/src/error-utils.d.ts +8 -0
- package/dist/src/error-utils.js +99 -0
- package/dist/src/error-utils.js.map +1 -0
- package/dist/src/is-empty.d.ts +1 -0
- package/dist/src/is-empty.js +13 -0
- package/dist/src/is-empty.js.map +1 -0
- package/dist/src/is-object.d.ts +2 -0
- package/dist/src/is-object.js +7 -0
- package/dist/src/is-object.js.map +1 -0
- package/dist/src/isset.d.ts +1 -0
- package/dist/src/isset.js +8 -0
- package/dist/src/isset.js.map +1 -0
- package/dist/src/logger-utils.d.ts +76 -0
- package/dist/src/logger-utils.js +355 -0
- package/dist/src/logger-utils.js.map +1 -0
- package/dist/src/loop-utils.d.ts +37 -0
- package/dist/src/loop-utils.js +105 -0
- package/dist/src/loop-utils.js.map +1 -0
- package/dist/src/math-utils.d.ts +23 -0
- package/dist/src/math-utils.js +43 -0
- package/dist/src/math-utils.js.map +1 -0
- package/dist/src/mongo-utils.d.ts +11 -0
- package/dist/src/mongo-utils.js +49 -0
- package/dist/src/mongo-utils.js.map +1 -0
- package/dist/src/object-utils.d.ts +96 -0
- package/dist/src/object-utils.js +369 -0
- package/dist/src/object-utils.js.map +1 -0
- package/dist/src/private/config.d.ts +44 -0
- package/dist/src/private/config.js +55 -0
- package/dist/src/private/config.js.map +1 -0
- package/dist/src/private/error-handler.d.ts +10 -0
- package/dist/src/private/error-handler.js +18 -0
- package/dist/src/private/error-handler.js.map +1 -0
- package/dist/src/private/types.d.ts +4 -0
- package/dist/src/private/types.js +3 -0
- package/dist/src/private/types.js.map +1 -0
- package/dist/src/regexp-utils.d.ts +12 -0
- package/dist/src/regexp-utils.js +44 -0
- package/dist/src/regexp-utils.js.map +1 -0
- package/dist/src/remove-circular-json-stringify.d.ts +1 -0
- package/dist/src/remove-circular-json-stringify.js +20 -0
- package/dist/src/remove-circular-json-stringify.js.map +1 -0
- package/dist/src/string-utils.d.ts +77 -0
- package/dist/src/string-utils.js +209 -0
- package/dist/src/string-utils.js.map +1 -0
- package/dist/src/tests-utils.js +77 -0
- package/dist/src/tests-utils.js.map +1 -0
- package/dist/src/timer-utils.d.ts +16 -0
- package/dist/src/timer-utils.js +79 -0
- package/dist/src/timer-utils.js.map +1 -0
- package/dist/src/transaction-utils.d.ts +14 -0
- package/dist/src/transaction-utils.js +87 -0
- package/dist/src/transaction-utils.js.map +1 -0
- package/dist/src/validation-utils.d.ts +89 -0
- package/dist/src/validation-utils.js +192 -0
- package/dist/src/validation-utils.js.map +1 -0
- package/dist/src/wtf-utils.d.ts +7 -0
- package/dist/src/wtf-utils.js +83 -0
- package/dist/src/wtf-utils.js.map +1 -0
- package/index.ts +38 -0
- package/package.json +2 -2
- package/src/array-utils.ts +128 -0
- package/src/date-utils.ts +377 -0
- package/src/env-utils.ts +29 -0
- package/src/error-utils.ts +77 -0
- package/src/is-empty.ts +5 -0
- package/src/is-object.ts +3 -0
- package/src/isset.ts +3 -0
- package/src/logger-utils.ts +349 -0
- package/src/loop-utils.ts +101 -0
- package/src/math-utils.ts +38 -0
- package/src/mongo-utils.ts +38 -0
- package/src/object-utils.ts +356 -0
- package/src/private/config.ts +85 -0
- package/src/private/error-handler.ts +21 -0
- package/src/private/types.ts +6 -0
- package/src/regexp-utils.ts +37 -0
- package/src/remove-circular-json-stringify.ts +17 -0
- package/src/string-utils.ts +212 -0
- package/src/tests-utils.ts +70 -0
- package/src/timer-utils.ts +58 -0
- package/src/transaction-utils.ts +63 -0
- package/src/validation-utils.ts +253 -0
- package/src/wtf-utils.ts +88 -0
- package/tsconfig.json +11 -4
- package/utils.d.ts +0 -694
- package/utils.js +0 -2227
- package/utils.js.map +0 -1
- package/utils.ts +0 -2304
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { Color } from "./private/types";
|
|
2
|
+
export declare const logger: any;
|
|
3
|
+
/**
|
|
4
|
+
// console colored output
|
|
5
|
+
// * console.log(C.green(C.dim('Hey bro !')))
|
|
6
|
+
// * or C.log() // will use padding and color defined by themes
|
|
7
|
+
// * or C.line('MY TITLE', 53)
|
|
8
|
+
// * or C.gradientize(myLongString)
|
|
9
|
+
*/
|
|
10
|
+
export declare const C: {
|
|
11
|
+
dim: (str: any) => string;
|
|
12
|
+
green: (str: any) => string;
|
|
13
|
+
red: (str: any) => string;
|
|
14
|
+
yellow: (str: any) => string;
|
|
15
|
+
grey: (str: any) => string;
|
|
16
|
+
magenta: (str: any) => string;
|
|
17
|
+
cyan: (str: any) => string;
|
|
18
|
+
blue: (str: any) => string;
|
|
19
|
+
primary: (str: any) => string;
|
|
20
|
+
reset: string;
|
|
21
|
+
output: (code: any, str?: string) => string;
|
|
22
|
+
rgb: (r: any, g?: number, b?: number) => string;
|
|
23
|
+
bg: (r?: any, g?: any, b?: any) => string;
|
|
24
|
+
/** Output a line of title */
|
|
25
|
+
line(title?: string, length?: number, clr?: Color, char?: string, paddingX?: number): void;
|
|
26
|
+
/** Eg: ['cell1', 'cell2', 'cell3'], [25, 15] will start cell2 at 25 and cell 3 at 25 + 15
|
|
27
|
+
* @param {Array} limits default divide the viewport
|
|
28
|
+
*/
|
|
29
|
+
cols(strings: any, limits?: any[], clr?: Color, paddingX?: number): void;
|
|
30
|
+
/** Console log alias */
|
|
31
|
+
log(...stringsCtxMayBeFirstParam: any[]): void;
|
|
32
|
+
logClr(str: any, clr?: Color, paddingX?: number): void;
|
|
33
|
+
info(...str: any[]): void;
|
|
34
|
+
success(...str: any[]): void;
|
|
35
|
+
/** First param **false** to avoid logging stack trace */
|
|
36
|
+
error: (...errors: any[]) => any;
|
|
37
|
+
/** First param **false** to avoid logging stack trace */
|
|
38
|
+
warning: (...str: any[]) => any;
|
|
39
|
+
customError: (color: any, ...str: any[]) => any;
|
|
40
|
+
customWarning: (color: any, ...str: any[]) => any;
|
|
41
|
+
applicationError: (color: any, ...str: any[]) => any;
|
|
42
|
+
warningLight: (color: any, ...str: any[]) => any;
|
|
43
|
+
dimStrSplit(...logs: any[]): string;
|
|
44
|
+
notifShow(): void;
|
|
45
|
+
/** Keep in memory the logs to show when needed with C.notifShow()
|
|
46
|
+
* Ex: C.notification('info', str); */
|
|
47
|
+
notification(type: any, ...messages: any[]): void;
|
|
48
|
+
notifications: any[];
|
|
49
|
+
/** Gratientize lines of text (separated by \n) */
|
|
50
|
+
gradientize(str?: string, rgb1?: Color, rgb2?: Color, bgRgb?: Color, paddingY?: number, paddingX?: number): void;
|
|
51
|
+
debugModeLog(title: any, ...string: any[]): void;
|
|
52
|
+
useTheme(): void;
|
|
53
|
+
};
|
|
54
|
+
export declare function logErrPrivate(type: any, color: Color, ...errors: any[]): any;
|
|
55
|
+
export declare function stringifyInstanceOfError(err: any, type?: string, color?: Color, level?: number): {
|
|
56
|
+
str: string;
|
|
57
|
+
stackTrace?: undefined;
|
|
58
|
+
} | {
|
|
59
|
+
str: string;
|
|
60
|
+
stackTrace: any;
|
|
61
|
+
};
|
|
62
|
+
export declare function stringifyExtraInfos(extraInfoOriginal: any, type: any, color: any, level?: number): {
|
|
63
|
+
str: string;
|
|
64
|
+
stackTrace?: undefined;
|
|
65
|
+
} | {
|
|
66
|
+
str: string;
|
|
67
|
+
stackTrace: any;
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Call this at each steps of your progress and change the step value
|
|
71
|
+
* @param {Number} step Number of "char" to output
|
|
72
|
+
* @param {String} char Default: '.'
|
|
73
|
+
* @param {String} msg String before char. Final output will be `${str}${char.repeat(step)}`
|
|
74
|
+
*/
|
|
75
|
+
export declare function cliProgressBar(step: any, char?: string, msg?: string): void;
|
|
76
|
+
export declare function dim(str?: string): string;
|
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.dim = exports.cliProgressBar = exports.stringifyExtraInfos = exports.stringifyInstanceOfError = exports.logErrPrivate = exports.C = exports.logger = void 0;
|
|
4
|
+
//----------------------------------------
|
|
5
|
+
// LOGGER
|
|
6
|
+
//----------------------------------------
|
|
7
|
+
const config_1 = require("./private/config");
|
|
8
|
+
const isset_1 = require("./isset");
|
|
9
|
+
const remove_circular_json_stringify_1 = require("./remove-circular-json-stringify");
|
|
10
|
+
const error_utils_1 = require("./error-utils");
|
|
11
|
+
exports.logger = {
|
|
12
|
+
log(str, type = 'log') {
|
|
13
|
+
const { preprocessLog } = (0, config_1.configFn)();
|
|
14
|
+
if (typeof preprocessLog === 'function')
|
|
15
|
+
str = preprocessLog(str) || str;
|
|
16
|
+
if ((0, isset_1.isset)(console[type]))
|
|
17
|
+
console[type](str);
|
|
18
|
+
else if (type === 'appError')
|
|
19
|
+
console.warn(str);
|
|
20
|
+
else
|
|
21
|
+
console.log(str);
|
|
22
|
+
exports.logger.raw.push(str + `\n`);
|
|
23
|
+
exports.logger.raw = exports.logger.raw.slice(exports.logger.raw.length - (0, config_1.configFn)().nbOfLogsToKeep, exports.logger.raw.length);
|
|
24
|
+
},
|
|
25
|
+
/**
|
|
26
|
+
* @param {String[]|String} inputLogs
|
|
27
|
+
*/
|
|
28
|
+
toHtml(inputLogs = [...exports.logger.raw]) {
|
|
29
|
+
if (!Array.isArray(inputLogs))
|
|
30
|
+
inputLogs = [inputLogs];
|
|
31
|
+
const code2css = {
|
|
32
|
+
2: `opacity:.5`,
|
|
33
|
+
32: `color:#679933`,
|
|
34
|
+
31: `color:#A8383B`,
|
|
35
|
+
33: `color:#D7941C`,
|
|
36
|
+
35: `color:#C21949`,
|
|
37
|
+
36: `color:#128C6D`,
|
|
38
|
+
34: `color:#1B568B`, // blue
|
|
39
|
+
};
|
|
40
|
+
let htmlLogs = '';
|
|
41
|
+
inputLogs.join('<br/>').split('\x1b[').forEach((bit, i) => {
|
|
42
|
+
// the first doesn't have a preceding (may be undef)
|
|
43
|
+
if (bit) {
|
|
44
|
+
if (i !== 0) {
|
|
45
|
+
const [, code, R, G, B, content] = bit.match(/(^\d\d?)(?:;|m)(?:\d;(\d+);(\d+);(\d+)m)?(.*$)/) || [];
|
|
46
|
+
if (content) {
|
|
47
|
+
const style = !(0, isset_1.isset)(R) ? (0, isset_1.isset)(code) ? code2css[code] : undefined : `color:rgb(${R},${G},${B})`;
|
|
48
|
+
htmlLogs += (0, isset_1.isset)(style) ? `<span style='${style}'>${content.replace(/\n/g, '<br>')}</span>` : content.replace(/\n/g, '<br>');
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
else
|
|
52
|
+
htmlLogs += bit.replace(/\n/g, '<br>');
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
return `<div style='color:#ccc'>${htmlLogs}<br></div>`;
|
|
56
|
+
},
|
|
57
|
+
toText(inputLogs = [...exports.logger.raw]) {
|
|
58
|
+
const str = Array.isArray(inputLogs) ? inputLogs.join('\n') : inputLogs;
|
|
59
|
+
return str.replace(/\x1b\[.*?m/g, '');
|
|
60
|
+
},
|
|
61
|
+
raw: [],
|
|
62
|
+
json: [],
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
// console colored output
|
|
66
|
+
// * console.log(C.green(C.dim('Hey bro !')))
|
|
67
|
+
// * or C.log() // will use padding and color defined by themes
|
|
68
|
+
// * or C.line('MY TITLE', 53)
|
|
69
|
+
// * or C.gradientize(myLongString)
|
|
70
|
+
*/
|
|
71
|
+
exports.C = {
|
|
72
|
+
dim: str => exports.C.output(2, str),
|
|
73
|
+
green: str => exports.C.output(32, str),
|
|
74
|
+
red: str => exports.C.output(31, str),
|
|
75
|
+
yellow: str => exports.C.output(33, str),
|
|
76
|
+
grey: str => exports.C.output(2, str),
|
|
77
|
+
magenta: str => exports.C.output(35, str),
|
|
78
|
+
cyan: str => exports.C.output(36, str),
|
|
79
|
+
blue: str => exports.C.output(34, str),
|
|
80
|
+
primary: str => {
|
|
81
|
+
const primary = (0, config_1.configFn)().terminal.theme.primary;
|
|
82
|
+
return exports.C.rgb(...primary) + str + exports.C.reset;
|
|
83
|
+
},
|
|
84
|
+
reset: '\x1b[0m',
|
|
85
|
+
output: (code, str = '') => (0, config_1.configFn)().terminal.noColor ? str : `\x1b[${code}m${str.toString().split('\n').join('\x1b[0m\n\x1b[2m')}\x1b[0m`,
|
|
86
|
+
// true RGB colors B-*
|
|
87
|
+
rgb: (r, g = 0, b = 0) => (0, config_1.configFn)().terminal.noColor || !(0, isset_1.isset)(r, g, b) ? '' : `\x1b[38;2;${r};${g};${b}m`,
|
|
88
|
+
bg: (r, g, b) => (0, config_1.configFn)().terminal.noColor || !(0, isset_1.isset)(r, g, b) ? '' : `${'\x1b['}48;2;${r};${g};${b}m`,
|
|
89
|
+
/** Output a line of title */
|
|
90
|
+
line(title = '', length = (0, config_1.configFn)().terminal.theme.pageWidth, clr = (0, config_1.configFn)().terminal.theme.primary, char = '=', paddingX = (0, config_1.configFn)().terminal.theme.paddingX) {
|
|
91
|
+
const padX = ' '.repeat(paddingX);
|
|
92
|
+
this.log('\u00A0\n' + padX + this.rgb(...clr) + (title + ' ').padEnd(length, char) + this.reset + padX + '\u00A0\n');
|
|
93
|
+
},
|
|
94
|
+
/** Eg: ['cell1', 'cell2', 'cell3'], [25, 15] will start cell2 at 25 and cell 3 at 25 + 15
|
|
95
|
+
* @param {Array} limits default divide the viewport
|
|
96
|
+
*/
|
|
97
|
+
cols(strings, limits = [], clr = (0, config_1.configFn)().terminal.theme.fontColor, paddingX = (0, config_1.configFn)().terminal.theme.paddingX) {
|
|
98
|
+
if (!limits.length) {
|
|
99
|
+
const colWidth = Math.round((0, config_1.configFn)().terminal.theme.pageWidth / strings.length);
|
|
100
|
+
limits = Array(strings.length - 1).fill(2).map((itm, i) => colWidth * i + 1);
|
|
101
|
+
}
|
|
102
|
+
const str = strings.reduce((glob, str = '', i) => {
|
|
103
|
+
const realCharLength = str.toString().replace(/\x1b\[.*?m/, '').length;
|
|
104
|
+
const charLength = str.toString().length;
|
|
105
|
+
const realLimit = limits[i] + charLength - realCharLength;
|
|
106
|
+
return glob + str.toString().substring(0, realLimit || 999).padEnd(realLimit || 0, ' ');
|
|
107
|
+
}, '');
|
|
108
|
+
this.logClr(str, clr, paddingX);
|
|
109
|
+
},
|
|
110
|
+
/** Console log alias */
|
|
111
|
+
log(...stringsCtxMayBeFirstParam) {
|
|
112
|
+
stringsCtxMayBeFirstParam.forEach(str => this.logClr(str, undefined, undefined));
|
|
113
|
+
},
|
|
114
|
+
logClr(str, clr = (0, config_1.configFn)().terminal.theme.fontColor, paddingX = (0, config_1.configFn)().terminal.theme.paddingX) {
|
|
115
|
+
if (!(0, isset_1.isset)(str))
|
|
116
|
+
return;
|
|
117
|
+
const padX = ' '.repeat(paddingX);
|
|
118
|
+
str = padX + ((0, isset_1.isset)(clr) ? this.rgb(...clr) : '') + str.toString().replace(/\n/g, '\n' + padX + ((0, isset_1.isset)(clr) ? this.rgb(...clr) : ''));
|
|
119
|
+
exports.logger.log(str + this.reset, 'log');
|
|
120
|
+
},
|
|
121
|
+
info(...str) {
|
|
122
|
+
str.forEach((s, i) => {
|
|
123
|
+
if (i === 0)
|
|
124
|
+
this.logClr('ⓘ ' + s, (0, config_1.configFn)().terminal.theme.primary);
|
|
125
|
+
else
|
|
126
|
+
this.log(this.dimStrSplit(s));
|
|
127
|
+
});
|
|
128
|
+
this.log(' ');
|
|
129
|
+
},
|
|
130
|
+
success(...str) {
|
|
131
|
+
str.forEach((s, i) => {
|
|
132
|
+
if (i === 0)
|
|
133
|
+
this.log(this.green('✓ ' + s));
|
|
134
|
+
else
|
|
135
|
+
this.log(this.dimStrSplit(s));
|
|
136
|
+
});
|
|
137
|
+
},
|
|
138
|
+
/** First param **false** to avoid logging stack trace */
|
|
139
|
+
error: (...errors) => logErrPrivate('error', [255, 0, 0], ...errors),
|
|
140
|
+
/** First param **false** to avoid logging stack trace */
|
|
141
|
+
warning: (...str) => logErrPrivate('warn', [255, 122, 0], ...str),
|
|
142
|
+
customError: (color, ...str) => logErrPrivate('error', color, ...str),
|
|
143
|
+
customWarning: (color, ...str) => logErrPrivate('warn', color, ...str),
|
|
144
|
+
applicationError: (color, ...str) => logErrPrivate('appError', color, ...str),
|
|
145
|
+
warningLight: (color, ...str) => logErrPrivate('warn', [196, 120, 52], ...str),
|
|
146
|
+
dimStrSplit(...logs) {
|
|
147
|
+
let logsStr = [];
|
|
148
|
+
logs.filter(isset_1.isset).forEach(log => log.toString().split('\n').forEach(line => line && logsStr.push(this.dim(` ${line}`))));
|
|
149
|
+
return logsStr.join('\n');
|
|
150
|
+
},
|
|
151
|
+
notifShow() {
|
|
152
|
+
console.log('\n\u00A0');
|
|
153
|
+
this.notifications.forEach(fn => fn());
|
|
154
|
+
this.notifications = [];
|
|
155
|
+
console.log('\n\u00A0');
|
|
156
|
+
},
|
|
157
|
+
/** Keep in memory the logs to show when needed with C.notifShow()
|
|
158
|
+
* Ex: C.notification('info', str); */
|
|
159
|
+
notification(type, ...messages) {
|
|
160
|
+
this.notifications.push(() => {
|
|
161
|
+
if ((0, isset_1.isset)(this[type])) {
|
|
162
|
+
this[type](...messages);
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
this.warning('Wrong param for C.notification');
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
},
|
|
169
|
+
notifications: [],
|
|
170
|
+
/** Gratientize lines of text (separated by \n) */
|
|
171
|
+
gradientize(str = '', rgb1 = (0, config_1.configFn)().terminal.theme.shade1, rgb2 = (0, config_1.configFn)().terminal.theme.shade2, bgRgb = (0, config_1.configFn)().terminal.theme.bgColor, paddingY = (0, config_1.configFn)().terminal.theme.paddingY, paddingX = (0, config_1.configFn)().terminal.theme.paddingX) {
|
|
172
|
+
const lines = str.split('\n');
|
|
173
|
+
const largestLine = lines.reduce((sum, line) => sum < line.length ? line.length : sum, 0);
|
|
174
|
+
const rgbParts = rgb1.map((val, i) => (val - rgb2[i]) / (lines.length));
|
|
175
|
+
const bg = bgRgb ? this.bg(bgRgb[0], bgRgb[1], bgRgb[2]) : '';
|
|
176
|
+
const padX = ' '.repeat(paddingX);
|
|
177
|
+
const padLine = bg + padX + ' '.padEnd(largestLine, ' ') + padX + '\x1b[0m\n';
|
|
178
|
+
console.log(padLine.repeat(paddingY) +
|
|
179
|
+
lines.reduce((s, line, i) => {
|
|
180
|
+
return s + bg + padX + this.rgb(...rgb1.map((val, i2) => Math.round(val - i * rgbParts[i2]))) + line.padEnd(largestLine, ' ') + padX + '\x1b[0m\n';
|
|
181
|
+
}, '') +
|
|
182
|
+
padLine.repeat(paddingY));
|
|
183
|
+
},
|
|
184
|
+
debugModeLog(title, ...string) {
|
|
185
|
+
this.logClr('🐞 ' + title, (0, config_1.configFn)().terminal.theme.debugModeColor, 0);
|
|
186
|
+
this.log(this.dimStrSplit(...string));
|
|
187
|
+
},
|
|
188
|
+
// DEPRECATED
|
|
189
|
+
useTheme() { },
|
|
190
|
+
};
|
|
191
|
+
function logErrPrivate(type, color, ...errors) {
|
|
192
|
+
const { isProd } = (0, config_1.configFn)();
|
|
193
|
+
if (errors.length === 1 && typeof errors[0].log === 'function')
|
|
194
|
+
return errors[0].log();
|
|
195
|
+
let stackTrace = (new Error('')).stack || '';
|
|
196
|
+
const displayStack = errors[0] === false ? errors.shift() : true;
|
|
197
|
+
const symbol = type === 'error' ? '✘ ' : '⚠ ';
|
|
198
|
+
if (errors.length > 1 && !(0, isset_1.isset)(errors[0]))
|
|
199
|
+
errors.shift();
|
|
200
|
+
const getStringFromErr = (err, i) => {
|
|
201
|
+
if (!(0, isset_1.isset)(err))
|
|
202
|
+
return '';
|
|
203
|
+
else if (typeof err === 'string') {
|
|
204
|
+
if (i === 0)
|
|
205
|
+
return exports.C.rgb(...color) + symbol + err + exports.C.reset;
|
|
206
|
+
else
|
|
207
|
+
return err.split('\n').map(val => exports.C.dim(val)).join('\n');
|
|
208
|
+
}
|
|
209
|
+
else if (err instanceof Error) {
|
|
210
|
+
const { str, stackTrace: stkTrc } = stringifyInstanceOfError(err, type, color);
|
|
211
|
+
if (stkTrc)
|
|
212
|
+
stackTrace = stkTrc;
|
|
213
|
+
return str;
|
|
214
|
+
}
|
|
215
|
+
else if (typeof err === 'object') {
|
|
216
|
+
let msg = '';
|
|
217
|
+
msg += (0, remove_circular_json_stringify_1.removeCircularJSONstringify)(err, 2).split('\n').map(val => exports.C.dim(val)).join('\n') + '\n';
|
|
218
|
+
const { str, stackTrace: stkTrc } = stringifyExtraInfos(err.extraInfo || err, type, color);
|
|
219
|
+
if (stkTrc)
|
|
220
|
+
stackTrace = stkTrc;
|
|
221
|
+
msg += str;
|
|
222
|
+
return msg;
|
|
223
|
+
}
|
|
224
|
+
else
|
|
225
|
+
return '';
|
|
226
|
+
};
|
|
227
|
+
if (errors.length && errors[0]) {
|
|
228
|
+
const messages = errors.map((e, i) => {
|
|
229
|
+
if (typeof e.log === 'function') {
|
|
230
|
+
e.log();
|
|
231
|
+
return '';
|
|
232
|
+
}
|
|
233
|
+
else
|
|
234
|
+
return getStringFromErr(e, i);
|
|
235
|
+
});
|
|
236
|
+
// Stack
|
|
237
|
+
if (displayStack) {
|
|
238
|
+
messages.push(isProd ? stackTrace : (0, error_utils_1.cleanStackTrace)(stackTrace) + '\n');
|
|
239
|
+
}
|
|
240
|
+
exports.logger.log(messages.join(''), type);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
exports.logErrPrivate = logErrPrivate;
|
|
244
|
+
function stringifyInstanceOfError(err, type = 'error', color = [255, 0, 0], level = 0) {
|
|
245
|
+
if (level > 5)
|
|
246
|
+
return { str: '' };
|
|
247
|
+
let str = '';
|
|
248
|
+
let stackTrace;
|
|
249
|
+
const symbol = type === 'error' ? '✘ ' : '⚠ ';
|
|
250
|
+
const title = err.msg || err.message || err.id || (err.stack ? err.stack.split('\n')[0] : 'Error');
|
|
251
|
+
// Err mess
|
|
252
|
+
str += exports.C.rgb(...color) + symbol + title + exports.C.reset + '\n';
|
|
253
|
+
if (err.stack)
|
|
254
|
+
stackTrace = err.stack; // more relevant
|
|
255
|
+
// ExtraInfos
|
|
256
|
+
if ((0, isset_1.isset)(err.extraInfo)) {
|
|
257
|
+
const { str: str2, stackTrace: stkTrc } = stringifyExtraInfos(err.extraInfo, type, color, level++);
|
|
258
|
+
if (stkTrc)
|
|
259
|
+
stackTrace = stkTrc;
|
|
260
|
+
str += str2;
|
|
261
|
+
}
|
|
262
|
+
return { str, stackTrace };
|
|
263
|
+
}
|
|
264
|
+
exports.stringifyInstanceOfError = stringifyInstanceOfError;
|
|
265
|
+
function stringifyExtraInfos(extraInfoOriginal, type, color, level = 0) {
|
|
266
|
+
let stackTrace;
|
|
267
|
+
const originalError = [exports.C.dim(`ORIGINAL ERROR ${'-'.repeat(39)}\n`)];
|
|
268
|
+
if (extraInfoOriginal instanceof Error) { // case where error is passed directly to extraInfos
|
|
269
|
+
return stringifyInstanceOfError(extraInfoOriginal, type, color);
|
|
270
|
+
}
|
|
271
|
+
else {
|
|
272
|
+
const extraInfo = Object.assign({}, extraInfoOriginal);
|
|
273
|
+
const extraInfos = [exports.C.dim(`EXTRA INFOS ${'-'.repeat(41)}\n`)];
|
|
274
|
+
if (typeof extraInfo === 'object' && Object.keys(extraInfo).length) {
|
|
275
|
+
for (const itemName in extraInfo) {
|
|
276
|
+
if (extraInfo[itemName] instanceof Error) {
|
|
277
|
+
const { str, stackTrace: stkTrc } = stringifyInstanceOfError(extraInfo[itemName], type, color, level++);
|
|
278
|
+
originalError.push(str);
|
|
279
|
+
stackTrace = stkTrc;
|
|
280
|
+
delete extraInfo[itemName];
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
if (Object.keys(extraInfo).length) {
|
|
285
|
+
extraInfos.push((0, remove_circular_json_stringify_1.removeCircularJSONstringify)(extraInfo, 2)
|
|
286
|
+
.replace(/(?:^\s*{(?:\n {2})?|}\s*$)/g, '')
|
|
287
|
+
.replace(/\n {2}/g, '\n')
|
|
288
|
+
.split('\n')
|
|
289
|
+
.map(val => exports.C.dim(val)).join('\n') + '\n');
|
|
290
|
+
}
|
|
291
|
+
return {
|
|
292
|
+
str: (extraInfos.length > 1 ? extraInfos.join('') : '') + (originalError.length > 1 ? originalError.join('') + '\n' : ''),
|
|
293
|
+
stackTrace
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
exports.stringifyExtraInfos = stringifyExtraInfos;
|
|
298
|
+
/**
|
|
299
|
+
* Call this at each steps of your progress and change the step value
|
|
300
|
+
* @param {Number} step Number of "char" to output
|
|
301
|
+
* @param {String} char Default: '.'
|
|
302
|
+
* @param {String} msg String before char. Final output will be `${str}${char.repeat(step)}`
|
|
303
|
+
*/
|
|
304
|
+
function cliProgressBar(step, char = '.', msg = `\x1b[2mⓘ Waiting response`) {
|
|
305
|
+
if ((0, isset_1.isset)(process) && (0, isset_1.isset)(process.stdout) && (0, isset_1.isset)(process.stdout.clearLine)) {
|
|
306
|
+
process.stdout.clearLine(0);
|
|
307
|
+
process.stdout.cursorTo(0);
|
|
308
|
+
process.stdout.write(`${msg}${char.repeat(step)}\x1b[0m`); // \x1b[0m == reset color
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
exports.cliProgressBar = cliProgressBar;
|
|
312
|
+
/** This allow an intuitive inline loading spinner with a check mark when loading as finished or a red cross for errors */
|
|
313
|
+
class cliLoadingSpinner {
|
|
314
|
+
constructor(type = 'dots', activeProcess = process) {
|
|
315
|
+
const anims = {
|
|
316
|
+
arrow: {
|
|
317
|
+
interval: 120,
|
|
318
|
+
frames: ['▹▹▹▹▹', '▸▹▹▹▹', '▹▸▹▹▹', '▹▹▸▹▹', '▹▹▹▸▹', '▹▹▹▹▸']
|
|
319
|
+
},
|
|
320
|
+
dots: {
|
|
321
|
+
interval: 80,
|
|
322
|
+
frames: ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏']
|
|
323
|
+
}
|
|
324
|
+
};
|
|
325
|
+
this.frameRate = anims[type].interval;
|
|
326
|
+
this.animFrames = anims[type].frames;
|
|
327
|
+
this.activeProcess = activeProcess;
|
|
328
|
+
}
|
|
329
|
+
start(msg) {
|
|
330
|
+
this.frameNb = 0;
|
|
331
|
+
this.progressMessage = msg;
|
|
332
|
+
this.interval = setInterval(() => {
|
|
333
|
+
this.activeProcess.stdout.clearLine();
|
|
334
|
+
this.activeProcess.stdout.cursorTo(0);
|
|
335
|
+
const symbol = this.animFrames[this.frameNb++ % this.animFrames.length];
|
|
336
|
+
this.activeProcess.stdout.write(exports.C.primary(symbol) + ' ' + this.progressMessage);
|
|
337
|
+
}, this.frameRate);
|
|
338
|
+
}
|
|
339
|
+
end(error = false) {
|
|
340
|
+
clearInterval(this.interval);
|
|
341
|
+
this.activeProcess.stdout.clearLine();
|
|
342
|
+
this.activeProcess.stdout.cursorTo(0);
|
|
343
|
+
this.activeProcess.stdout.write(error ? exports.C.red('✘ ' + this.progressMessage + '\n\n')
|
|
344
|
+
: '\x1b[32m✓ ' + this.progressMessage + '\n\n');
|
|
345
|
+
this.progressMessage = '';
|
|
346
|
+
}
|
|
347
|
+
error() {
|
|
348
|
+
return this.end(true);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
function dim(str = '') {
|
|
352
|
+
return (0, config_1.configFn)().terminal.noColor ? str : `\x1b[2m${str.toString().split('\n').join('\x1b[0m\n\x1b[2m')}\x1b[0m`;
|
|
353
|
+
}
|
|
354
|
+
exports.dim = dim;
|
|
355
|
+
//# sourceMappingURL=logger-utils.js.map
|
|
@@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G,IAAI,CAAC,eAAe,CAAC,CAAA;QACnF,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,CAAA;IACtB,CAAC;IACD,GAAG,CAAC,KAAK,GAAG,KAAK;QACb,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QAC5B,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,SAAS,EAAE,CAAA;QACrC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAA;QACrC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,KAAK,CAC3B,KAAK,CAAC,CAAC,CAAC,SAAC,CAAC,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,eAAe,GAAG,MAAM,CAAC;YAC/C,CAAC,CAAC,YAAY,GAAG,IAAI,CAAC,eAAe,GAAG,MAAM,CAAC,CAAA;QACvD,IAAI,CAAC,eAAe,GAAG,EAAE,CAAA;IAC7B,CAAC;IACD,KAAK;QACD,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IACzB,CAAC;CACJ;AAGD,SAAgB,GAAG,CAAC,GAAG,GAAG,EAAE;IACxB,OAAO,IAAA,iBAAQ,GAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,UAAU,GAAG,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,kBAAkB,CAAC,SAAS,CAAA;AACrH,CAAC;AAFD,kBAEC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ObjectGeneric } from "./private/types";
|
|
2
|
+
export declare function forI<T extends any[] | any>(nbIterations: number, callback: (number: number, previousValue: any, arrayOfPreviousValues: any[]) => T): T[];
|
|
3
|
+
export declare function forIasync<T extends any[] | any>(nbIterations: number, callback: (number: any) => T): Promise<T[]>;
|
|
4
|
+
export declare type RecursiveCallback = (item: any, addr: string, lastElementKey: string | number, parent: ObjectGeneric | any[]) => false | any;
|
|
5
|
+
/**
|
|
6
|
+
* @param {any} item the first array or object or whatever you want to recursively browse
|
|
7
|
+
* @param {function} callback the callback you want to apply on items including the main one
|
|
8
|
+
* * this callback has 2 arguments: (item, address) =>
|
|
9
|
+
* * `item` => the actual item
|
|
10
|
+
* * `addr` => the address of the item, not including root (Eg: subItem1.sub2.[3].[2]) array indexes are juste written as numbers
|
|
11
|
+
* * `lastElementKey` => the key of last item. May be a number if last item is an array
|
|
12
|
+
* * `parent` => reference the parent object as this is the only way of reassigning a value for the item. Eg: parent[lastElementKey] = myNewItem
|
|
13
|
+
* * **NOTE** => if a key of an item contains dots, they will be replaced by '%' in `addr`
|
|
14
|
+
* * **NOTE2** => if false is returned by the callback it will stop all other iterations (but not in an array)
|
|
15
|
+
* @param {string} addr$ optional, the base address for the callback function
|
|
16
|
+
* @param lastElementKey technical field
|
|
17
|
+
* NOTE: will remove circular references
|
|
18
|
+
* /!\ check return values
|
|
19
|
+
*/
|
|
20
|
+
export declare function recursiveGenericFunction(item: ObjectGeneric | any[], callback: RecursiveCallback, addr$?: string, lastElementKey?: string | number, parent?: any, techFieldToAvoidCircularDependency?: any[]): Promise<any[] | ObjectGeneric>;
|
|
21
|
+
/**
|
|
22
|
+
* @param {any} item the first array or object or whatever you want to recursively browse
|
|
23
|
+
* @param {function} callback the callback you want to apply on items including the main one
|
|
24
|
+
* * this callback has 2 arguments: (item, address) =>
|
|
25
|
+
* * `item` => the actual item
|
|
26
|
+
* * `addr` => the address of the item, not including root (Eg: subItem1.sub2.[3].[2]) array indexes are juste written as numbers
|
|
27
|
+
* * `lastElementKey` => the key of last item. May be a number if last item is an array
|
|
28
|
+
* * `parent` => reference the parent object as this is the only way of reassigning a value for the item. Eg: parent[lastElementKey] = myNewItem
|
|
29
|
+
* * **NOTE** => if a key of an item contains dots, they will be replaced by '%' in `addr`
|
|
30
|
+
* * **NOTE2** => if false is returned by the callback it will stop all other iterations (but not in an array)
|
|
31
|
+
* * **NOTE3** => to reassign a key use => parent[lastElementKey] = myNewItem
|
|
32
|
+
* @param {string} addr$ optional, the base address for the callback function
|
|
33
|
+
* @param lastElementKey technical field
|
|
34
|
+
* NOTE: will remove circular references
|
|
35
|
+
* /!\ check return values
|
|
36
|
+
*/
|
|
37
|
+
export declare function recursiveGenericFunctionSync(item: ObjectGeneric | any[], callback: RecursiveCallback, addr$?: string, lastElementKey?: string | number, parent?: any, techFieldToAvoidCircularDependency?: any[]): any[] | ObjectGeneric;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.recursiveGenericFunctionSync = exports.recursiveGenericFunction = exports.forIasync = exports.forI = void 0;
|
|
13
|
+
const error_utils_1 = require("./error-utils");
|
|
14
|
+
const is_object_1 = require("./is-object");
|
|
15
|
+
function forI(nbIterations, callback) {
|
|
16
|
+
const results = [];
|
|
17
|
+
for (let i = 0; i < nbIterations; i++) {
|
|
18
|
+
const prevValue = results[results.length - 1];
|
|
19
|
+
results.push(callback(i, prevValue, results));
|
|
20
|
+
}
|
|
21
|
+
return results;
|
|
22
|
+
}
|
|
23
|
+
exports.forI = forI;
|
|
24
|
+
function forIasync(nbIterations, callback) {
|
|
25
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
const results = [];
|
|
27
|
+
for (let i = 0; i < nbIterations; i++) {
|
|
28
|
+
results.push(yield callback(i));
|
|
29
|
+
}
|
|
30
|
+
return results;
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
exports.forIasync = forIasync;
|
|
34
|
+
/**
|
|
35
|
+
* @param {any} item the first array or object or whatever you want to recursively browse
|
|
36
|
+
* @param {function} callback the callback you want to apply on items including the main one
|
|
37
|
+
* * this callback has 2 arguments: (item, address) =>
|
|
38
|
+
* * `item` => the actual item
|
|
39
|
+
* * `addr` => the address of the item, not including root (Eg: subItem1.sub2.[3].[2]) array indexes are juste written as numbers
|
|
40
|
+
* * `lastElementKey` => the key of last item. May be a number if last item is an array
|
|
41
|
+
* * `parent` => reference the parent object as this is the only way of reassigning a value for the item. Eg: parent[lastElementKey] = myNewItem
|
|
42
|
+
* * **NOTE** => if a key of an item contains dots, they will be replaced by '%' in `addr`
|
|
43
|
+
* * **NOTE2** => if false is returned by the callback it will stop all other iterations (but not in an array)
|
|
44
|
+
* @param {string} addr$ optional, the base address for the callback function
|
|
45
|
+
* @param lastElementKey technical field
|
|
46
|
+
* NOTE: will remove circular references
|
|
47
|
+
* /!\ check return values
|
|
48
|
+
*/
|
|
49
|
+
function recursiveGenericFunction(item, callback, addr$ = '', lastElementKey = '', parent, techFieldToAvoidCircularDependency = []) {
|
|
50
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
(0, error_utils_1.err500IfNotSet)({ callback });
|
|
52
|
+
if (!techFieldToAvoidCircularDependency.includes(item)) {
|
|
53
|
+
const result = addr$ === '' ? true : yield callback(item, addr$, lastElementKey, parent);
|
|
54
|
+
if (result !== false) {
|
|
55
|
+
const addr = addr$ ? addr$ + '.' : '';
|
|
56
|
+
if (Array.isArray(item)) {
|
|
57
|
+
techFieldToAvoidCircularDependency.push(item);
|
|
58
|
+
yield Promise.all(item.map((e, i) => recursiveGenericFunction(e, callback, addr + '[' + i + ']', i, item, techFieldToAvoidCircularDependency)));
|
|
59
|
+
}
|
|
60
|
+
else if ((0, is_object_1.isObject)(item)) {
|
|
61
|
+
techFieldToAvoidCircularDependency.push(item);
|
|
62
|
+
yield Promise.all(Object.entries(item).map(([key, val]) => recursiveGenericFunction(val, callback, addr + key.replace(/\./g, '%'), key, item, techFieldToAvoidCircularDependency)));
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return item;
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
exports.recursiveGenericFunction = recursiveGenericFunction;
|
|
70
|
+
/**
|
|
71
|
+
* @param {any} item the first array or object or whatever you want to recursively browse
|
|
72
|
+
* @param {function} callback the callback you want to apply on items including the main one
|
|
73
|
+
* * this callback has 2 arguments: (item, address) =>
|
|
74
|
+
* * `item` => the actual item
|
|
75
|
+
* * `addr` => the address of the item, not including root (Eg: subItem1.sub2.[3].[2]) array indexes are juste written as numbers
|
|
76
|
+
* * `lastElementKey` => the key of last item. May be a number if last item is an array
|
|
77
|
+
* * `parent` => reference the parent object as this is the only way of reassigning a value for the item. Eg: parent[lastElementKey] = myNewItem
|
|
78
|
+
* * **NOTE** => if a key of an item contains dots, they will be replaced by '%' in `addr`
|
|
79
|
+
* * **NOTE2** => if false is returned by the callback it will stop all other iterations (but not in an array)
|
|
80
|
+
* * **NOTE3** => to reassign a key use => parent[lastElementKey] = myNewItem
|
|
81
|
+
* @param {string} addr$ optional, the base address for the callback function
|
|
82
|
+
* @param lastElementKey technical field
|
|
83
|
+
* NOTE: will remove circular references
|
|
84
|
+
* /!\ check return values
|
|
85
|
+
*/
|
|
86
|
+
function recursiveGenericFunctionSync(item, callback, addr$ = '', lastElementKey = '', parent, techFieldToAvoidCircularDependency = []) {
|
|
87
|
+
(0, error_utils_1.err500IfNotSet)({ callback });
|
|
88
|
+
if (!techFieldToAvoidCircularDependency.includes(item)) {
|
|
89
|
+
const result = addr$ === '' ? true : callback(item, addr$, lastElementKey, parent);
|
|
90
|
+
if (result !== false) {
|
|
91
|
+
const addr = addr$ ? addr$ + '.' : '';
|
|
92
|
+
if (Array.isArray(item)) {
|
|
93
|
+
techFieldToAvoidCircularDependency.push(item); // do not up one level
|
|
94
|
+
item.forEach((e, i) => recursiveGenericFunctionSync(e, callback, addr + '[' + i + ']', i, item, techFieldToAvoidCircularDependency));
|
|
95
|
+
}
|
|
96
|
+
else if ((0, is_object_1.isObject)(item)) {
|
|
97
|
+
techFieldToAvoidCircularDependency.push(item);
|
|
98
|
+
Object.entries(item).forEach(([key, val]) => recursiveGenericFunctionSync(val, callback, addr + key.replace(/\./g, '%'), key, item, techFieldToAvoidCircularDependency));
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return item;
|
|
103
|
+
}
|
|
104
|
+
exports.recursiveGenericFunctionSync = recursiveGenericFunctionSync;
|
|
105
|
+
//# sourceMappingURL=loop-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loop-utils.js","sourceRoot":"","sources":["../../src/loop-utils.ts"],"names":[],"mappings":";;;;;;;;;;;;AAIA,+CAA8C;AAC9C,2CAAsC;AAEtC,SAAgB,IAAI,CAAwB,YAAoB,EAAE,QAA4E;IAC1I,MAAM,OAAO,GAAG,EAAE,CAAA;IAClB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,YAAY,EAAE,CAAC,EAAE,EAAE;QACnC,MAAM,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;QAC7C,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC,CAAA;KAChD;IACD,OAAO,OAAO,CAAA;AAClB,CAAC;AAPD,oBAOC;AAED,SAAsB,SAAS,CAAwB,YAAoB,EAAE,QAAuB;;QAChG,MAAM,OAAO,GAAG,EAAE,CAAA;QAClB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAA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AC,CAAC,CAAA;aACvI;iBAAM,IAAI,IAAA,oBAAQ,EAAC,IAAI,CAAC,EAAE;gBACvB,kCAAkC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;gBAC7C,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,4BAA4B,CAAC,GAAG,EAAE,QAAQ,EAAE,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,kCAAkC,CAAC,CAAC,CAAA;aAC3K;SACJ;KACJ;IACD,OAAO,IAAI,CAAA;AACf,CAAC;AAlBD,oEAkBC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** Round with custom number of decimals (default:0) */
|
|
2
|
+
export declare function round(number: number | string, decimals?: number): number;
|
|
3
|
+
/** Round with custom number of decimals (default:2) */
|
|
4
|
+
export declare function round2(number: number | string, decimals?: number): number;
|
|
5
|
+
/** Is number between two numbers (including those numbers) */
|
|
6
|
+
export declare function isBetween(number: number, min: number, max: number, inclusive?: boolean): boolean;
|
|
7
|
+
/** Random number between two values with 0 decimals by default */
|
|
8
|
+
export declare function random(nb1: number, nb2: number, nbOfDecimals?: number): number;
|
|
9
|
+
/** Sum all values of an array, all values MUST be numbers */
|
|
10
|
+
export declare function sumArray(array: number[]): number;
|
|
11
|
+
/** Moyenne / average between array of values
|
|
12
|
+
* @param {Number} round number of decimals to keep. Default:2
|
|
13
|
+
*/
|
|
14
|
+
export declare function moyenne(array: number[], nbOfDecimals?: number): number;
|
|
15
|
+
/** length default 2, shortcut for 1 to 01 */
|
|
16
|
+
export declare function pad(numberOrStr: number | string, length?: number): string;
|
|
17
|
+
/** return the number or the closest number of the range
|
|
18
|
+
* * nb min max => returns
|
|
19
|
+
* * 7 5 10 => 7 // in the range
|
|
20
|
+
* * 2 5 10 => 5 // below the min value
|
|
21
|
+
* * 99 5 10 => 10// above the max value
|
|
22
|
+
*/
|
|
23
|
+
export declare function minMax(nb: number, min: number, max: number): number;
|