topkat-utils 1.3.24 → 1.3.25
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/README.md +1 -1
- package/backend.ts +3 -4
- package/dist/backend.js +3 -4
- package/dist/backend.js.map +1 -1
- package/dist/src/array-utils.d.ts +1 -1
- package/dist/src/array-utils.js +2 -2
- package/dist/src/array-utils.js.map +1 -1
- package/dist/src/clean-stack-trace.js.map +1 -1
- package/dist/src/date-utils.d.ts +25 -20
- package/dist/src/date-utils.js +1 -0
- package/dist/src/date-utils.js.map +1 -1
- package/dist/src/env-utils.d.ts +1 -1
- package/dist/src/env-utils.js.map +1 -1
- package/dist/src/error-utils.d.ts +6 -6
- package/dist/src/error-utils.js.map +1 -1
- package/dist/src/isset.js.map +1 -1
- package/dist/src/logger-utils.d.ts +33 -30
- package/dist/src/logger-utils.js +10 -29
- package/dist/src/logger-utils.js.map +1 -1
- package/dist/src/loop-utils.d.ts +4 -4
- package/dist/src/loop-utils.js.map +1 -1
- package/dist/src/mongo-utils.js.map +1 -1
- package/dist/src/object-utils.d.ts +4 -4
- package/dist/src/object-utils.js +1 -1
- package/dist/src/object-utils.js.map +1 -1
- package/dist/src/regexp-utils.d.ts +1 -1
- package/dist/src/regexp-utils.js.map +1 -1
- package/dist/src/remove-circular-json-stringify.d.ts +1 -1
- package/dist/src/remove-circular-json-stringify.js.map +1 -1
- package/dist/src/string-utils.d.ts +4 -4
- package/dist/src/string-utils.js +1 -1
- package/dist/src/string-utils.js.map +1 -1
- package/dist/src/tests-utils.js.map +1 -1
- package/dist/src/timer-utils.d.ts +4 -4
- package/dist/src/timer-utils.js +1 -1
- package/dist/src/timer-utils.js.map +1 -1
- package/dist/src/transaction-utils.d.ts +3 -3
- package/dist/src/transaction-utils.js.map +1 -1
- package/dist/src/transaction-utils.spec.js +1 -1
- package/dist/src/transaction-utils.spec.js.map +1 -1
- package/dist/src/validation-utils.d.ts +3 -3
- package/dist/src/validation-utils.js +17 -16
- package/dist/src/validation-utils.js.map +1 -1
- package/dist/src/wtf-utils.d.ts +3 -3
- package/dist/src/wtf-utils.js +1 -1
- package/dist/src/wtf-utils.js.map +1 -1
- package/package.json +1 -1
- package/src/array-utils.ts +3 -3
- package/src/clean-stack-trace.ts +1 -1
- package/src/date-utils.ts +45 -41
- package/src/env-utils.ts +1 -1
- package/src/error-utils.ts +8 -8
- package/src/isset.ts +1 -1
- package/src/logger-utils.ts +40 -52
- package/src/loop-utils.ts +5 -5
- package/src/mongo-utils.ts +1 -1
- package/src/object-utils.ts +22 -22
- package/src/regexp-utils.ts +3 -3
- package/src/remove-circular-json-stringify.ts +2 -2
- package/src/string-utils.ts +3 -3
- package/src/tests-utils.ts +1 -1
- package/src/timer-utils.ts +4 -4
- package/src/transaction-utils.spec.ts +1 -1
- package/src/transaction-utils.ts +5 -5
- package/src/validation-utils.ts +28 -26
- package/src/wtf-utils.ts +6 -6
- package/tsconfig.json +1 -1
package/src/validation-utils.ts
CHANGED
|
@@ -11,17 +11,17 @@ import { removeCircularJSONstringify } from './remove-circular-json-stringify'
|
|
|
11
11
|
|
|
12
12
|
export type BaseTypes = 'objectId' | 'dateInt6' | 'dateInt' | 'dateInt8' | 'dateInt12' | 'time' | 'humanReadableTimestamp' | 'date' | 'dateObject' | 'array' | 'object' | 'buffer' | 'string' | 'function' | 'boolean' | 'number' | 'bigint' | 'year' | 'email' | 'any'
|
|
13
13
|
|
|
14
|
-
export function issetOr(...elms) { return elms.some(elm => typeof elm !== 'undefined' && elm !== null) }
|
|
14
|
+
export function issetOr(...elms: any[]) { return elms.some(elm => typeof elm !== 'undefined' && elm !== null) }
|
|
15
15
|
|
|
16
|
-
export function isEmptyOrNotSet(...elms) { return elms.some(elm => !isset(elm) || isEmpty(elm)) }
|
|
16
|
+
export function isEmptyOrNotSet(...elms: any[]) { return elms.some(elm => !isset(elm) || isEmpty(elm)) }
|
|
17
17
|
|
|
18
|
-
export function isDateObject(variable) { return variable instanceof Date }
|
|
18
|
+
export function isDateObject(variable: any[]) { return variable instanceof Date }
|
|
19
19
|
|
|
20
20
|
/** Check all values are set */
|
|
21
|
-
export function checkAllObjectValuesAreEmpty(o) { return Object.values(o).every(value => !isset(value)) }
|
|
21
|
+
export function checkAllObjectValuesAreEmpty(o: Record<string, any>) { return Object.values(o).every(value => !isset(value)) }
|
|
22
22
|
|
|
23
23
|
/** Throw an error in case data passed is not a valid ctx */
|
|
24
|
-
export function checkCtxIntegrity(ctx) {
|
|
24
|
+
export function checkCtxIntegrity(ctx: Record<string, any>) {
|
|
25
25
|
if (!isset(ctx) || !isset(ctx.user)) throw new DescriptiveError('ctxNotSet', { code: 500 })
|
|
26
26
|
}
|
|
27
27
|
|
|
@@ -102,7 +102,7 @@ export function isValid(...paramsToValidate: ValidatorObject[]) {
|
|
|
102
102
|
return errArray.length ? false : true
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
function parseValueForDisplay(value
|
|
105
|
+
function parseValueForDisplay(value?: any) {
|
|
106
106
|
try {
|
|
107
107
|
if (value === undefined) return 'undefined'
|
|
108
108
|
else if (value?.data?.data) return { ...value, data: 'Buffer' }
|
|
@@ -115,7 +115,7 @@ function parseValueForDisplay(value?) {
|
|
|
115
115
|
/** Default types + custom types
|
|
116
116
|
* 'objectId','dateInt6','dateInt','dateInt8','dateInt12','time','humanReadableTimestamp','date','array','object','buffer','string','function','boolean','number','bigint',
|
|
117
117
|
*/
|
|
118
|
-
export function isType(value, type: BaseTypes) { return isValid({ name: 'Is type check', value, type, emptyAllowed: true }) }
|
|
118
|
+
export function isType(value: any, type: BaseTypes) { return isValid({ name: 'Is type check', value, type, emptyAllowed: true }) }
|
|
119
119
|
|
|
120
120
|
export function validatorReturnErrArray(...paramsToValidate: ValidatorObject[]): [string?, object?] {
|
|
121
121
|
const paramsFormatted: ValidatorObject[] = []
|
|
@@ -127,7 +127,7 @@ export function validatorReturnErrArray(...paramsToValidate: ValidatorObject[]):
|
|
|
127
127
|
|
|
128
128
|
// parse => name: {myVar1: 'blah, myvar2: myvar2}
|
|
129
129
|
if (typeof param.name === 'object' && !Array.isArray(param.name))
|
|
130
|
-
Object.keys(param.name).forEach(name => paramsFormatted.push(Object.assign({}, param, { name: name, value: param?.name?.[name] })))
|
|
130
|
+
Object.keys(param.name).forEach(name => paramsFormatted.push(Object.assign({}, param, { name: name, value: param?.name?.[name as any] })))
|
|
131
131
|
else paramsFormatted.push(param)
|
|
132
132
|
})
|
|
133
133
|
|
|
@@ -138,7 +138,7 @@ export function validatorReturnErrArray(...paramsToValidate: ValidatorObject[]):
|
|
|
138
138
|
let optional = paramObj.optional || false
|
|
139
139
|
const emptyAllowed = optional || paramObj.emptyAllowed || false
|
|
140
140
|
if (paramObj.isset === false) paramObj.mustNotBeSet = true // ALIAS
|
|
141
|
-
const errMess = (msg, extraInfos = {}, errCode = 422): [string, object] => [msg, { code: errCode, origin: 'Generic validator', varName: name, varType: typeof value, gotValue: parseValueForDisplay(value), ...extraInfos }]
|
|
141
|
+
const errMess = (msg: string, extraInfos = {}, errCode = 422): [string, object] => [msg, { code: errCode, origin: 'Generic validator', varName: name, varType: typeof value, gotValue: parseValueForDisplay(value), ...extraInfos }]
|
|
142
142
|
|
|
143
143
|
// accept syntax { 'myVar.var2': myVar.var2, ... }
|
|
144
144
|
if (typeof name !== 'undefined' && !hasValue) {
|
|
@@ -167,7 +167,7 @@ export function validatorReturnErrArray(...paramsToValidate: ValidatorObject[]):
|
|
|
167
167
|
const areSomeTypeValid = types.some(type => {
|
|
168
168
|
if (type.endsWith('[]')) {
|
|
169
169
|
if (!Array.isArray(value)) errMess('wrongTypeForVar', { expectedType: 'array', gotType: typeof value })
|
|
170
|
-
type = type.replace('[]', '')
|
|
170
|
+
type = type.replace('[]', '') as typeof type
|
|
171
171
|
}
|
|
172
172
|
|
|
173
173
|
const allTypes: Array<BaseTypes> = [
|
|
@@ -197,26 +197,28 @@ export function validatorReturnErrArray(...paramsToValidate: ValidatorObject[]):
|
|
|
197
197
|
if (!allTypes.includes(type)) throw new DescriptiveError('typeDoNotExist', { code: 500, type })
|
|
198
198
|
|
|
199
199
|
const basicTypeCheck = {
|
|
200
|
-
objectId: val => /^[0-9a-fA-F-]{24,}$/.test(val), // "0c65940b-6b0c-4dd8-9c7a-7c5fe1ba907a"
|
|
201
|
-
dateInt6: val => isDateIntOrStringValid(parseInt(val + '01'), true, 8),
|
|
202
|
-
dateInt: val => isDateIntOrStringValid(val, true, 8),
|
|
203
|
-
dateInt8: val => isDateIntOrStringValid(val, true, 8),
|
|
204
|
-
dateInt12: val => isDateIntOrStringValid(val, true, 12),
|
|
205
|
-
time: val => /^\d\d:\d\d$/.test(val) && isTimeStringValid(val),
|
|
206
|
-
humanReadableTimestamp: val => (val + '').length === 17,
|
|
207
|
-
date: val => isDateIsoOrObjectValid(val, true),
|
|
208
|
-
dateObject: val => isDateIsoOrObjectValid(val, true),
|
|
209
|
-
array: val => Array.isArray(val),
|
|
210
|
-
object: val => !Array.isArray(val) && val !== null && typeof val === type,
|
|
211
|
-
buffer: val => Buffer.isBuffer(val),
|
|
212
|
-
year: val => /^\d\d\d\d$/.test(val),
|
|
213
|
-
email: val => /^[^\s@]+@([^\s@.,]+\.)+[^\s@.,]+$/.test(val),
|
|
200
|
+
objectId: (val: any) => /^[0-9a-fA-F-]{24,}$/.test(val), // "0c65940b-6b0c-4dd8-9c7a-7c5fe1ba907a"
|
|
201
|
+
dateInt6: (val: any) => isDateIntOrStringValid(parseInt(val + '01'), true, 8),
|
|
202
|
+
dateInt: (val: any) => isDateIntOrStringValid(val, true, 8),
|
|
203
|
+
dateInt8: (val: any) => isDateIntOrStringValid(val, true, 8),
|
|
204
|
+
dateInt12: (val: any) => isDateIntOrStringValid(val, true, 12),
|
|
205
|
+
time: (val: any) => /^\d\d:\d\d$/.test(val) && isTimeStringValid(val),
|
|
206
|
+
humanReadableTimestamp: (val: any) => (val + '').length === 17,
|
|
207
|
+
date: (val: any) => isDateIsoOrObjectValid(val, true),
|
|
208
|
+
dateObject: (val: any) => isDateIsoOrObjectValid(val, true),
|
|
209
|
+
array: (val: any) => Array.isArray(val),
|
|
210
|
+
object: (val: any) => !Array.isArray(val) && val !== null && typeof val === type,
|
|
211
|
+
buffer: (val: any) => Buffer.isBuffer(val),
|
|
212
|
+
year: (val: any) => /^\d\d\d\d$/.test(val),
|
|
213
|
+
email: (val: any) => /^[^\s@]+@([^\s@.,]+\.)+[^\s@.,]+$/.test(val),
|
|
214
214
|
any: () => true,
|
|
215
215
|
}
|
|
216
216
|
|
|
217
|
-
|
|
217
|
+
const typeTyped = type as keyof typeof basicTypeCheck
|
|
218
|
+
|
|
219
|
+
return typeof basicTypeCheck?.[typeTyped] !== 'undefined' && basicTypeCheck?.[typeTyped](value) ||
|
|
218
220
|
typeof value === type && type !== 'object' || // for string, number, boolean...
|
|
219
|
-
typeof configFn()?.customTypes?.[
|
|
221
|
+
typeof (configFn()?.customTypes as any)?.[typeTyped as any] !== 'undefined' && (configFn()?.customTypes as any)?.[typeTyped as any]?.test(value)
|
|
220
222
|
})
|
|
221
223
|
if (!areSomeTypeValid) return errMess(`wrongTypeForVar`, { expectedTypes: types.join(', '), gotType: Object.prototype.toString.call(value), gotValue: parseValueForDisplay(value) })
|
|
222
224
|
}
|
package/src/wtf-utils.ts
CHANGED
|
@@ -12,7 +12,7 @@ export function chineseProverb() {
|
|
|
12
12
|
return ['é ', 'àe', 'èa', 'ùt', 'çi'].reduce((s, e) => s.replace(new RegExp(e[0], 'g'), e[1]), str).split('$')[Math.floor(Math.random() * 11)]
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
export function randomEmoji(msg, length = 20) {
|
|
15
|
+
export function randomEmoji(msg: string, length = 20) {
|
|
16
16
|
const o = `\u0298\u203f\u0298§\u0ca0\u005f\u0ca0§\u0028\uff61\u25d5\u203f\u25d5\uff61\u0029§\uff08\u3000\uff9f\u0414\uff9f\uff09§\u0028\u256c\u0020\u0ca0\u76ca\u0ca0\u0029§\u0ca0\u203f\u0ca0§\u0028\u0020\u0361\u00b0\u0020\u035c\u0296\u0020\u0361\u00b0\u0029§\u0ca5\u005f\u0ca5§\u0ca5\ufe4f\u0ca5§\u2299\ufe4f\u2299§\u00b0\u203f\u203f\u00b0§\u0028\u00b4\uff65\u005f\uff65\u0060\u0029§\u0c20\u005f\u0c20§\u0028\u2299\u005f\u25ce\u0029§\u30df\u25cf\ufe4f\u2609\u30df§\u0028\u0ca5\u2323\u0ca5\u0029§\u0028\u0e51\u2022\u0301\u0020\u2083\u0020\u2022\u0300\u0e51\u0029§\u25d4\u005f\u25d4§\u2665\u203f\u2665§\u0028\u0020\u02d8\u0020\u00b3\u02d8\u0029\u2665§\u0028\u0020\u02c7\u0df4\u02c7\u0020\u0029§\u0028\u0482\u25e1\u005f\u25e1\u0029§\u2940\u002e\u2940§\u0028\u2a7e\ufe4f\u2a7d\u0029§\u0028\u0020\u0c20\u0020\u035f\u0296\u0020\u0c20\u0029§\u0028\u0020\u0361\u0ca0\u0020\u0296\u032f\u0020\u0361\u0ca0\u0029§\u0028\u0020\u0ca0\u0020\u0296\u032f\u0020\u0ca0\u0029§\u2668\u005f\u2668§\u0028\u002e\u005f\u002e\u0029§\ub208\u005f\ub208§\u0028\u25e0\ufe4f\u25e0\u0029§\u25d6\u1d54\u1d25\u1d54\u25d7\u0020\u266a\u0020\u266b§\u007b\u2022\u0303\u005f\u2022\u0303\u007d§\u0028\u1d54\u1d25\u1d54\u0029§\u0028\u053e\u2038\u0020\u053e\u0029§\u00af\u005c\u005f\u0028\u30c4\u0029\u005f\u002f\u00af§\u00af\u005c\u0028\u00b0\u005f\u006f\u0029\u002f\u00af§\u00af\u005c\u005f\u0028\u2299\ufe3f\u2299\u0029\u005f\u002f\u00af§\u0505\u0028\u2256\u203f\u2256\u0505\u0029§\u10da\u0028\uff40\u30fc\u00b4\u10da\u0029§\u261c\u0028\u2312\u25bd\u2312\u0029\u261e§\u30fd\u0028\u00b4\u25bd\u0060\u0029\u002f§\u30fd\u0028\u00b4\u30fc\uff40\u0029\u30ce§\u1559\u0028\u21c0\u2038\u21bc\u2036\u0029\u1557§\u1566\u0028\u00f2\u005f\u00f3\u02c7\u0029\u1564§\u2282\u0028\u25c9\u203f\u25c9\u0029\u3064§\u0071\u0028\u2742\u203f\u2742\u0029\u0070§\u00bf\u24e7\u005f\u24e7\ufb8c§\u0028\u2299\u002e\u2609\u0029§\u0449\uff08\uff9f\u0414\uff9f\u0449\uff09§\u0669\u0028\u0e4f\u005f\u0e4f\u0029\u06f6§\u0074\u0028\u002d\u005f\u002d\u0074\u0029§\u0028\u3065\uffe3\u0020\u00b3\uffe3\u0029\u3065§\u0028\u3065\uff61\u25d5\u203f\u203f\u25d5\uff61\u0029\u3065§\u201c\u30fd\u0028\u00b4\u25bd\uff40\u0029\u30ce\u201d§\u250c\u0028\u3186\u3268\u3186\u0029\u0283§\u0028\u2283\uff61\u2022\u0301\u203f\u2022\u0300\uff61\u0029\u2283§\u0028\u3063\u02d8\u06a1\u02d8\u03c2\u0029§\u0028\u0e07\u30c4\u0029\u0e27§\u30fe\u0028\u002d\u005f\u002d\u0020\u0029\u309e§\u266a\u266a\u0020\u30fd\u0028\u02c7\u2200\u02c7\u0020\u0029\u309e§\u30fe\u0028\u00b4\u3007\u0060\u0029\uff89\u266a\u266a\u266a§\u0028\u3063\u2580\u00af\u2580\u0029\u3064§\u0028\u00b4\u0436\uff40\u03c2\u0029§\u0028\u00b0\u0020\u035c\u0296\u0361\u00b0\u0029\u256d\u2229\u256e§\u062d\u0028\u2022\u0300\u0436\u2022\u0301\u0029\u0e07\u0020\u2020§\u007e\u0028\u005e\u002d\u005e\u0029\u007e§\u005c\u0028\u1d54\u1d55\u1d54\u0029\u002f§\u10da\u0028\u2022\u0301\u2022\u0301\u10da\u0029§\u0028\u0e07\u2019\u0300\u002d\u2018\u0301\u0029\u0e07§\u0028\u2022\u0300\u1d17\u2022\u0301\u0029\u0648\u0020\u0311\u0311§\u005b\u00ac\u00ba\u002d\u00b0\u005d\u00ac§\u0028\u261e\uff9f\u30ee\uff9f\u0029\u261e§\u00bb\u2310\u0028\u0ca0\u06fe\u0ca0\u0029\u00ac\u0020\u00bb\u2019§\u0028\u3063\u2022\u0301\uff61\u2022\u0301\u0029\u266a\u266c§\u01aa\u0028\u0693\u05f2\u0029\u200e\u01aa\u200b\u200b§\u0295\u2022\u1d25\u2022\u0294§\u0295\u1d54\u1d25\u1d54\u0294§\u0295\u0020\u2022\u0060\u1d25\u2022\u00b4\u0294§\u0295\u0020\u2022\u0301\u0608\u2022\u0300\u0020\u208e§\u0028\u0060\uff65\u03c9\uff65\u00b4\u0029§\u1d52\u1d25\u1d52§\u0056\u2022\u1d25\u2022\u0056§\u0e05\u005e\u2022\ufecc\u2022\u005e\u0e05§\u0028\u0020\u0c20\u0d60\u0c20\u0020\u0029\uff89§\u0295\u0298\u0305\u035c\u0298\u0305\u0294§\u062d\u02da\u0bf0\u02da\u3065§\u0028\u256f\u00b0\u25a1\u00b0\uff09\u256f\ufe35\u0020\u253b\u2501\u253b§\u252c\u2500\u252c\ufeff\u0020\u30ce\u0028\u0020\u309c\u002d\u309c\u30ce\u0029§\u252c\u2500\u252c\u20f0\u0361\u2007\u0028\u1d54\u1d55\u1d54\u035c\u2007\u0029§\u253b\u2501\u253b\u0020\ufe35\u30fd\u0028\u0060\u0414\u00b4\u0029\uff89\ufe35\ufeff\u0020\u253b\u2501\u253b§\u0028\u30ce\u0ca0\u0020\u2229\u0ca0\u0029\u30ce\u5f61\u0028\u0020\u005c\u006f\u00b0\u006f\u0029\u005c§\uff08\u0020\u005e\u005f\u005e\uff09\u006f\u81ea\u81ea\u006f\uff08\u005e\u005f\u005e\u0020\uff09§\u0f3c\u2235\u0f3d§\u0f3c\u2368\u0f3d§\u0f3c\u2362\u0f3d§\u0f3c\u2364\u0f3d§\u30fd\u0f3c\u0020\u0ca0\u76ca\u0ca0\u0020\u0f3d\uff89§\u4e41\u0028\u0020\u25d4\u0020\u0c6a\u25d4\u0029\u300c§\u0028\u2229\uff40\u002d\u00b4\u0029\u2283\u2501\u2606\uff9f\u002e\u002a\uff65\uff61\uff9f`.split('§')[Math.floor(Math.random() * 100)]
|
|
17
17
|
return o.padEnd(length, ' ') + (msg ? '< ' + msg : '')
|
|
18
18
|
}
|
|
@@ -22,7 +22,7 @@ type CompObject = { char: string, replacement: string }
|
|
|
22
22
|
/** STRING COMPRESSOR
|
|
23
23
|
* peut facilement être utilisé par uncomp directement (stock les metadonnées sur la comp)
|
|
24
24
|
*/
|
|
25
|
-
export function compAuto(str) {
|
|
25
|
+
export function compAuto(str: string) {
|
|
26
26
|
|
|
27
27
|
const oldStrLength = str.length
|
|
28
28
|
const utf8Chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ:;<=>%?@"#$&\'()*+,-./[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u007f€\u0081‚ƒ„…†‡ˆ‰Š‹ŒŽ\u008f‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐőŔŕŖŗŘřŚśŜŝŞşŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŹźŻżſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐƑƓƔƕƖƗƘƙƚƛƜƝƞƟ'.split('')
|
|
@@ -31,8 +31,8 @@ export function compAuto(str) {
|
|
|
31
31
|
const unusedChars = utf8Chars.filter(c => !str.includes(c))
|
|
32
32
|
const charMap: CompObject[] = []
|
|
33
33
|
|
|
34
|
-
const mostFreqStr = str2 => {
|
|
35
|
-
const o = {}
|
|
34
|
+
const mostFreqStr = (str2: string) => {
|
|
35
|
+
const o = {} as Record<string, any>
|
|
36
36
|
// recherche la meilleure optim selon le nb de char
|
|
37
37
|
for (let strLength = 2; strLength < 16; strLength++) {
|
|
38
38
|
for (let i = 0; isset(str2[i + strLength - 1]); i++) {
|
|
@@ -68,10 +68,10 @@ export function compAuto(str) {
|
|
|
68
68
|
return str
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
export function unComp(str) {
|
|
71
|
+
export function unComp(str: string) {
|
|
72
72
|
const charMap: CompObject[] = []
|
|
73
73
|
const map = str.split('§')
|
|
74
|
-
str = map.pop()
|
|
74
|
+
str = map.pop() as string
|
|
75
75
|
map.forEach(e => {
|
|
76
76
|
const char: string = e[0]
|
|
77
77
|
let replacement = e.substring(1, 999)
|