topkat-utils 1.1.13 → 1.2.1
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 +36 -0
- package/dist/index.js +58 -0
- package/dist/index.js.map +1 -0
- package/dist/src/array-utils.d.ts +56 -0
- package/dist/src/array-utils.js +160 -0
- package/dist/src/array-utils.js.map +1 -0
- package/dist/src/clean-stack-trace.d.ts +1 -0
- package/dist/src/clean-stack-trace.js +46 -0
- package/dist/src/clean-stack-trace.js.map +1 -0
- package/dist/src/config.d.ts +44 -0
- package/dist/src/config.js +66 -0
- package/dist/src/config.js.map +1 -0
- package/dist/src/date-utils.d.ts +100 -0
- package/dist/src/date-utils.js +407 -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 +29 -0
- package/dist/src/error-utils.js +202 -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 +12 -0
- package/dist/src/isset.js.map +1 -0
- package/dist/src/logger-utils.d.ts +76 -0
- package/dist/src/logger-utils.js +484 -0
- package/dist/src/logger-utils.js.map +1 -0
- package/dist/src/loop-utils.d.ts +40 -0
- package/dist/src/loop-utils.js +182 -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 +59 -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 +63 -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 +409 -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 +66 -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 +46 -0
- package/dist/src/private/error-handler.js.map +1 -0
- package/dist/src/private/types.d.ts +5 -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 +45 -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 +21 -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 +267 -0
- package/dist/src/string-utils.js.map +1 -0
- package/dist/src/tests-utils.d.ts +21 -0
- package/dist/src/tests-utils.js +80 -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 +146 -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 +157 -0
- package/dist/src/transaction-utils.js.map +1 -0
- package/dist/src/types.d.ts +5 -0
- package/dist/src/types.js +3 -0
- package/dist/src/types.js.map +1 -0
- package/dist/src/validation-utils.d.ts +80 -0
- package/dist/src/validation-utils.js +249 -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 +88 -0
- package/dist/src/wtf-utils.js.map +1 -0
- package/index.ts +1 -1
- package/package.json +1 -1
- package/src/clean-stack-trace.ts +40 -0
- package/src/config.ts +1 -1
- package/src/date-utils.ts +5 -5
- package/src/error-utils.ts +86 -44
- package/src/logger-utils.ts +2 -2
- package/src/loop-utils.ts +1 -1
- package/src/object-utils.ts +6 -6
- package/src/string-utils.ts +1 -1
- package/src/tests-utils.ts +2 -2
- package/src/timer-utils.ts +2 -2
- package/src/{private/types.ts → types.ts} +0 -0
- package/src/validation-utils.ts +8 -8
- package/src/private/error-handler.ts +0 -21
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __assign = (this && this.__assign) || function () {
|
|
18
|
+
__assign = Object.assign || function(t) {
|
|
19
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
+
s = arguments[i];
|
|
21
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
+
t[p] = s[p];
|
|
23
|
+
}
|
|
24
|
+
return t;
|
|
25
|
+
};
|
|
26
|
+
return __assign.apply(this, arguments);
|
|
27
|
+
};
|
|
28
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
29
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
30
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
31
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
32
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
33
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
34
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
38
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
39
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
40
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
41
|
+
function step(op) {
|
|
42
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
43
|
+
while (_) try {
|
|
44
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
45
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
46
|
+
switch (op[0]) {
|
|
47
|
+
case 0: case 1: t = op; break;
|
|
48
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
49
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
50
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
51
|
+
default:
|
|
52
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
53
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
54
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
55
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
56
|
+
if (t[2]) _.ops.pop();
|
|
57
|
+
_.trys.pop(); continue;
|
|
58
|
+
}
|
|
59
|
+
op = body.call(thisArg, _);
|
|
60
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
61
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
65
|
+
var t = {};
|
|
66
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
67
|
+
t[p] = s[p];
|
|
68
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
69
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
70
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
71
|
+
t[p[i]] = s[p[i]];
|
|
72
|
+
}
|
|
73
|
+
return t;
|
|
74
|
+
};
|
|
75
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
76
|
+
exports.DescriptiveError = exports.tryCatch = exports.err422IfNotSet = exports.errXXXIfNotSet = exports.err500IfEmptyOrNotSet = exports.errIfEmptyOrNotSet = exports.err500IfNotSet = exports.errIfNotSet = void 0;
|
|
77
|
+
//----------------------------------------
|
|
78
|
+
// ERROR UTILS
|
|
79
|
+
//----------------------------------------
|
|
80
|
+
var isset_1 = require("./isset");
|
|
81
|
+
var is_empty_1 = require("./is-empty");
|
|
82
|
+
var clean_stack_trace_1 = require("./clean-stack-trace");
|
|
83
|
+
var logger_utils_1 = require("./logger-utils");
|
|
84
|
+
function errIfNotSet(objOfVarNamesWithValues) { return errXXXIfNotSet(422, false, objOfVarNamesWithValues); }
|
|
85
|
+
exports.errIfNotSet = errIfNotSet;
|
|
86
|
+
function err500IfNotSet(objOfVarNamesWithValues) { return errXXXIfNotSet(500, false, objOfVarNamesWithValues); }
|
|
87
|
+
exports.err500IfNotSet = err500IfNotSet;
|
|
88
|
+
function errIfEmptyOrNotSet(objOfVarNamesWithValues) { return errXXXIfNotSet(422, true, objOfVarNamesWithValues); }
|
|
89
|
+
exports.errIfEmptyOrNotSet = errIfEmptyOrNotSet;
|
|
90
|
+
function err500IfEmptyOrNotSet(objOfVarNamesWithValues) { return errXXXIfNotSet(500, true, objOfVarNamesWithValues); }
|
|
91
|
+
exports.err500IfEmptyOrNotSet = err500IfEmptyOrNotSet;
|
|
92
|
+
function errXXXIfNotSet(errCode, checkEmpty, objOfVarNamesWithValues) {
|
|
93
|
+
var missingVars = [];
|
|
94
|
+
for (var prop in objOfVarNamesWithValues) {
|
|
95
|
+
if (!(0, isset_1.isset)(objOfVarNamesWithValues[prop]) || (checkEmpty && (0, is_empty_1.isEmpty)(objOfVarNamesWithValues[prop])))
|
|
96
|
+
missingVars.push(prop);
|
|
97
|
+
}
|
|
98
|
+
if (missingVars.length)
|
|
99
|
+
throw new DescriptiveError("requiredVariableEmptyOrNotSet", { code: errCode, origin: 'Validator', varNames: missingVars.join(', ') });
|
|
100
|
+
}
|
|
101
|
+
exports.errXXXIfNotSet = errXXXIfNotSet;
|
|
102
|
+
function err422IfNotSet(o) {
|
|
103
|
+
var m = [];
|
|
104
|
+
for (var p in o)
|
|
105
|
+
if (!(0, isset_1.isset)(o[p]))
|
|
106
|
+
m.push(p);
|
|
107
|
+
if (m.length)
|
|
108
|
+
throw new DescriptiveError("requiredVariableEmptyOrNotSet", { code: 422, origin: 'Validator', varNames: m.join(', ') });
|
|
109
|
+
}
|
|
110
|
+
exports.err422IfNotSet = err422IfNotSet;
|
|
111
|
+
function tryCatch(callback, onErr) {
|
|
112
|
+
if (onErr === void 0) { onErr = function () { }; }
|
|
113
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
114
|
+
var err_1;
|
|
115
|
+
return __generator(this, function (_a) {
|
|
116
|
+
switch (_a.label) {
|
|
117
|
+
case 0:
|
|
118
|
+
_a.trys.push([0, 2, , 4]);
|
|
119
|
+
return [4 /*yield*/, callback()];
|
|
120
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
121
|
+
case 2:
|
|
122
|
+
err_1 = _a.sent();
|
|
123
|
+
return [4 /*yield*/, onErr(err_1)];
|
|
124
|
+
case 3: return [2 /*return*/, _a.sent()];
|
|
125
|
+
case 4: return [2 /*return*/];
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
exports.tryCatch = tryCatch;
|
|
131
|
+
function extraInfosRendererDefault(extraInfos) {
|
|
132
|
+
logger_utils_1.C.error(false, '== EXTRA INFOS ==');
|
|
133
|
+
logger_utils_1.C.error(false, JSON.stringify(extraInfos, null, 2));
|
|
134
|
+
}
|
|
135
|
+
var DescriptiveError = /** @class */ (function (_super) {
|
|
136
|
+
__extends(DescriptiveError, _super);
|
|
137
|
+
function DescriptiveError(msg, options) {
|
|
138
|
+
if (options === void 0) { options = {}; }
|
|
139
|
+
var _this = _super.call(this, msg) || this;
|
|
140
|
+
delete options.errMsgId;
|
|
141
|
+
_this.msg = msg;
|
|
142
|
+
var _a = options.doNotWaitOneFrameForLog, doNotWaitOneFrameForLog = _a === void 0 ? false : _a, optionsClean = __rest(options, ["doNotWaitOneFrameForLog"]);
|
|
143
|
+
_this.options = optionsClean;
|
|
144
|
+
if (optionsClean.err)
|
|
145
|
+
optionsClean.err.hasBeenLogged = true;
|
|
146
|
+
_this.hasBeenLogged = false;
|
|
147
|
+
if (doNotWaitOneFrameForLog)
|
|
148
|
+
_this.log();
|
|
149
|
+
else
|
|
150
|
+
setTimeout(function () {
|
|
151
|
+
if (!_this.hasBeenLogged)
|
|
152
|
+
_this.log(); // wait one event loop to see if not catched
|
|
153
|
+
});
|
|
154
|
+
return _this;
|
|
155
|
+
}
|
|
156
|
+
DescriptiveError.prototype.log = function (doNotCountHasLogged) {
|
|
157
|
+
if (doNotCountHasLogged === void 0) { doNotCountHasLogged = false; }
|
|
158
|
+
if (!this.hasBeenLogged) {
|
|
159
|
+
var _a = this.options, err = _a.err, _b = _a.doNotThrow, doNotThrow = _b === void 0 ? false : _b, ressource = _a.ressource, _c = _a.extraInfosRenderer, extraInfosRenderer = _c === void 0 ? extraInfosRendererDefault : _c, _d = _a.notifyOnSlackChannel, notifyOnSlackChannel = _d === void 0 ? false : _d, originalMessage = _a.originalMessage, extraInfosRaw = __rest(_a, ["err", "doNotThrow", "ressource", "extraInfosRenderer", "notifyOnSlackChannel", "originalMessage"]);
|
|
160
|
+
var code = this.options.code;
|
|
161
|
+
var extraInfos = __assign(__assign({}, extraInfosRaw), (this.options.extraInfos || {}));
|
|
162
|
+
if (!(0, isset_1.isset)(extraInfos.value) && this.options.hasOwnProperty('value'))
|
|
163
|
+
extraInfos.value = 'undefined';
|
|
164
|
+
if (!(0, isset_1.isset)(extraInfos.gotValue) && this.options.hasOwnProperty('gotValue'))
|
|
165
|
+
extraInfos.gotValue = 'undefined';
|
|
166
|
+
if ((0, isset_1.isset)(ressource)) {
|
|
167
|
+
code = 404;
|
|
168
|
+
if (this.msg === '404')
|
|
169
|
+
this.msg = "Ressource ".concat(ressource, " not found");
|
|
170
|
+
extraInfos.ressource = ressource;
|
|
171
|
+
}
|
|
172
|
+
logger_utils_1.C.error(false, this.msg || this.message);
|
|
173
|
+
if (Object.keys(extraInfos).length > 0)
|
|
174
|
+
extraInfosRenderer(extraInfos);
|
|
175
|
+
if (err) {
|
|
176
|
+
logger_utils_1.C.error(false, '== ORIGINAL ERROR ==');
|
|
177
|
+
if (err.log) {
|
|
178
|
+
err.hasBeenLogged = false;
|
|
179
|
+
err.log();
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
logger_utils_1.C.error(err);
|
|
183
|
+
if (err.extraInfos)
|
|
184
|
+
logger_utils_1.C.error(false, err.extraInfos);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
logger_utils_1.C.error(false, logger_utils_1.C.dim((0, clean_stack_trace_1.cleanStackTrace)(extraInfosRaw.stack || this.stack)));
|
|
189
|
+
}
|
|
190
|
+
this.code = code || 500;
|
|
191
|
+
this.errorDescription = __assign({ msg: this.msg, code: code, ressource: ressource }, extraInfos);
|
|
192
|
+
}
|
|
193
|
+
if (!doNotCountHasLogged)
|
|
194
|
+
this.hasBeenLogged = true;
|
|
195
|
+
};
|
|
196
|
+
DescriptiveError.prototype.toString = function () {
|
|
197
|
+
return this.log(true);
|
|
198
|
+
};
|
|
199
|
+
return DescriptiveError;
|
|
200
|
+
}(Error));
|
|
201
|
+
exports.DescriptiveError = DescriptiveError;
|
|
202
|
+
//# sourceMappingURL=error-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-utils.js","sourceRoot":"","sources":["../../src/error-utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAA0C;AAC1C,cAAc;AACd,0CAA0C;AAC1C,iCAA+B;AAC/B,uCAAoC;AAEpC,yDAAqD;AACrD,+CAAkC;AAElC,SAAgB,WAAW,CAAC,uBAAuB,IAAI,OAAO,cAAc,CAAC,GAAG,EAAE,KAAK,EAAE,uBAAuB,CAAC,CAAA,CAAC,CAAC;AAAnH,kCAAmH;AAEnH,SAAgB,cAAc,CAAC,uBAAuB,IAAI,OAAO,cAAc,CAAC,GAAG,EAAE,KAAK,EAAE,uBAAuB,CAAC,CAAA,CAAC,CAAC;AAAtH,wCAAsH;AAEtH,SAAgB,kBAAkB,CAAC,uBAAuB,IAAI,OAAO,cAAc,CAAC,GAAG,EAAE,IAAI,EAAE,uBAAuB,CAAC,CAAA,CAAC,CAAC;AAAzH,gDAAyH;AAEzH,SAAgB,qBAAqB,CAAC,uBAAuB,IAAI,OAAO,cAAc,CAAC,GAAG,EAAE,IAAI,EAAE,uBAAuB,CAAC,CAAA,CAAC,CAAC;AAA5H,sDAA4H;AAE5H,SAAgB,cAAc,CAAC,OAAO,EAAE,UAAU,EAAE,uBAAuB;IACvE,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GAAG,CAAC,UAAU;wBAAE,gBAAC,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,UAAU,CAAC,CAAA;iBACrD;aACJ;iBAAM;gBACH,gBAAC,CAAC,KAAK,CAAC,KAAK,EAAE,gBAAC,CAAC,GAAG,CAAC,IAAA,mCAAe,EAAC,aAAa,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;aAC5E;YACD,IAAI,CAAC,IAAI,GAAG,IAAI,IAAI,GAAG,CAAA;YACvB,IAAI,CAAC,gBAAgB,cACjB,GAAG,EAAE,IAAI,CAAC,GAAG,EACb,IAAI,MAAA,EACJ,SAAS,WAAA,IACN,UAAU,CAChB,CAAA;SACJ;QACD,IAAI,CAAC,mBAAmB;YAAE,IAAI,CAAC,aAAa,GAAG,IAAI,CAAA;IACvD,CAAC;IACD,mCAAQ,GAAR;QACI,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IACzB,CAAC;IACL,uBAAC;AAAD,CAAC,AA9DD,CAAsC,KAAK,GA8D1C;AA9DY,4CAAgB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isEmpty(objOrArr: object | any[] | string | null | undefined): boolean;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isEmpty = void 0;
|
|
4
|
+
function isEmpty(objOrArr) {
|
|
5
|
+
if (Array.isArray(objOrArr) || typeof objOrArr === 'string')
|
|
6
|
+
return objOrArr.length === 0;
|
|
7
|
+
else if (typeof objOrArr == 'object' && objOrArr !== null && !(objOrArr instanceof Date))
|
|
8
|
+
return Object.keys(objOrArr).length === 0;
|
|
9
|
+
else
|
|
10
|
+
false;
|
|
11
|
+
}
|
|
12
|
+
exports.isEmpty = isEmpty;
|
|
13
|
+
//# sourceMappingURL=is-empty.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-empty.js","sourceRoot":"","sources":["../../src/is-empty.ts"],"names":[],"mappings":";;;AAAA,SAAgB,OAAO,CAAC,QAAoD;IACxE,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,OAAO,QAAQ,KAAK,QAAQ;QAAE,OAAO,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAA;SACpF,IAAI,OAAO,QAAQ,IAAI,QAAQ,IAAI,QAAQ,KAAK,IAAI,IAAI,CAAC,CAAC,QAAQ,YAAY,IAAI,CAAC;QAAE,OAAO,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM,KAAK,CAAC,CAAA;;QAC9H,KAAK,CAAA;AACd,CAAC;AAJD,0BAIC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isObject = void 0;
|
|
4
|
+
/** test if object but not array and not null (null is an object in Js) */
|
|
5
|
+
function isObject(o) { return o instanceof Object && [Object, Error].includes(o.constructor); }
|
|
6
|
+
exports.isObject = isObject;
|
|
7
|
+
//# sourceMappingURL=is-object.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-object.js","sourceRoot":"","sources":["../../src/is-object.ts"],"names":[],"mappings":";;;AACA,0EAA0E;AAC1E,SAAgB,QAAQ,CAAC,CAAM,IAAa,OAAO,CAAC,YAAY,MAAM,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,CAAA,CAAC,CAAC;AAAnH,4BAAmH"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isset(...elms: any[]): boolean;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isset = void 0;
|
|
4
|
+
function isset() {
|
|
5
|
+
var elms = [];
|
|
6
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
7
|
+
elms[_i] = arguments[_i];
|
|
8
|
+
}
|
|
9
|
+
return elms.every(function (elm) { return typeof elm !== 'undefined' && elm !== null; });
|
|
10
|
+
}
|
|
11
|
+
exports.isset = isset;
|
|
12
|
+
//# sourceMappingURL=isset.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isset.js","sourceRoot":"","sources":["../../src/isset.ts"],"names":[],"mappings":";;;AAAA,SAAgB,KAAK;IAAC,cAAO;SAAP,UAAO,EAAP,qBAAO,EAAP,IAAO;QAAP,yBAAO;;IACzB,OAAO,IAAI,CAAC,KAAK,CAAC,UAAA,GAAG,IAAI,OAAA,OAAO,GAAG,KAAK,WAAW,IAAI,GAAG,KAAK,IAAI,EAA1C,CAA0C,CAAC,CAAA;AACxE,CAAC;AAFD,sBAEC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { Color } from "./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;
|