@tstdl/base 0.90.49 → 0.90.50
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/.eslintrc.json +1 -1
- package/decorators/log.d.ts +2 -1
- package/decorators/log.js +4 -4
- package/function/log.d.ts +2 -1
- package/function/log.js +4 -1
- package/package.json +7 -7
- package/utils/function/throttle.js +0 -1
package/.eslintrc.json
CHANGED
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@typescript-eslint/brace-style": ["error", "stroustrup", { "allowSingleLine": true }],
|
|
29
29
|
"@typescript-eslint/class-methods-use-this": ["error", { "ignoreOverrideMethods": true, "ignoreClassesThatImplementAnInterface": true }],
|
|
30
30
|
"@typescript-eslint/consistent-type-definitions": "off",
|
|
31
|
-
"@typescript-eslint/explicit-function-return-type": ["error", { "allowExpressions": true }],
|
|
31
|
+
"@typescript-eslint/explicit-function-return-type": ["error", { "allowExpressions": true, "allowFunctionsWithoutTypeParameters": true }],
|
|
32
32
|
"@typescript-eslint/explicit-member-accessibility": ["error", { "accessibility": "no-public" }],
|
|
33
33
|
"@typescript-eslint/explicit-module-boundary-types": "off",
|
|
34
34
|
"@typescript-eslint/indent": "off",
|
package/decorators/log.d.ts
CHANGED
package/decorators/log.js
CHANGED
|
@@ -15,19 +15,19 @@ function setWrapped(constructor, property, isStatic) {
|
|
|
15
15
|
}
|
|
16
16
|
map.get(constructor).add(property);
|
|
17
17
|
}
|
|
18
|
-
export function Log() {
|
|
18
|
+
export function Log(options) {
|
|
19
19
|
return createDecorator({ class: true, method: true }, (data) => {
|
|
20
20
|
if (data.type == 'method') {
|
|
21
21
|
setWrapped(data.constructor, data.methodKey, data.static);
|
|
22
|
-
return { value: wrapLog(data.descriptor.value) };
|
|
22
|
+
return { value: wrapLog(data.descriptor.value, options) };
|
|
23
23
|
}
|
|
24
24
|
const staticProperties = objectKeys(data.constructor).filter((property) => (property != 'length') && (property != 'name') && (property != 'prototype') && isFunction(data.constructor[property]) && !isWrapped(data.constructor, property, true));
|
|
25
25
|
const instanceProperties = objectKeys(data.prototype).filter((property) => (property != 'constructor') && isFunction(data.prototype[property]) && !isWrapped(data.constructor, property, false));
|
|
26
26
|
for (const property of staticProperties) {
|
|
27
|
-
data.constructor[property] = wrapLog(data.constructor[property],
|
|
27
|
+
data.constructor[property] = wrapLog(data.constructor[property], options);
|
|
28
28
|
}
|
|
29
29
|
for (const property of instanceProperties) {
|
|
30
|
-
data.prototype[property] = wrapLog(data.prototype[property],
|
|
30
|
+
data.prototype[property] = wrapLog(data.prototype[property], options);
|
|
31
31
|
}
|
|
32
32
|
return undefined;
|
|
33
33
|
});
|
package/function/log.d.ts
CHANGED
|
@@ -2,5 +2,6 @@ import type { Logger } from '../logger/logger.js';
|
|
|
2
2
|
export type WrapLogOptions = {
|
|
3
3
|
fnName?: string;
|
|
4
4
|
logger?: Logger;
|
|
5
|
+
trace?: boolean;
|
|
5
6
|
};
|
|
6
|
-
export declare function wrapLog(fn: Function, { fnName, logger }?: WrapLogOptions): Function;
|
|
7
|
+
export declare function wrapLog(fn: Function, { fnName, logger, trace }?: WrapLogOptions): Function;
|
package/function/log.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/ban-types */
|
|
2
2
|
import { isArray, isPrimitive, isString } from '../utils/type-guards.js';
|
|
3
3
|
import { typeOf } from '../utils/type-of.js';
|
|
4
|
-
export function wrapLog(fn, { fnName = fn.name, logger } = {}) {
|
|
4
|
+
export function wrapLog(fn, { fnName = fn.name, logger, trace = false } = {}) {
|
|
5
5
|
const log = logger?.trace.bind(logger) ?? console.log.bind(console); // eslint-disable-line no-console
|
|
6
6
|
const wrapped = {
|
|
7
7
|
[fnName](...args) {
|
|
8
8
|
const argString = args.map((arg) => stringifyArg(arg)).join(', ');
|
|
9
9
|
log(`[call: ${fnName}(${argString})]`);
|
|
10
|
+
if (trace) {
|
|
11
|
+
console.trace();
|
|
12
|
+
}
|
|
10
13
|
return Reflect.apply(fn, this, args);
|
|
11
14
|
}
|
|
12
15
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tstdl/base",
|
|
3
|
-
"version": "0.90.
|
|
3
|
+
"version": "0.90.50",
|
|
4
4
|
"author": "Patrick Hein",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -114,13 +114,13 @@
|
|
|
114
114
|
"@mxssfd/typedoc-theme": "1.1",
|
|
115
115
|
"@types/chroma-js": "2.4",
|
|
116
116
|
"@types/koa__router": "12.0",
|
|
117
|
-
"@types/luxon": "3.
|
|
117
|
+
"@types/luxon": "3.4",
|
|
118
118
|
"@types/minio": "7.1",
|
|
119
119
|
"@types/mjml": "4.7",
|
|
120
120
|
"@types/node": "20",
|
|
121
121
|
"@types/nodemailer": "6.4",
|
|
122
|
-
"@typescript-eslint/eslint-plugin": "6.
|
|
123
|
-
"@typescript-eslint/parser": "6.
|
|
122
|
+
"@typescript-eslint/eslint-plugin": "6.19",
|
|
123
|
+
"@typescript-eslint/parser": "6.19",
|
|
124
124
|
"concurrently": "8.2",
|
|
125
125
|
"esbuild": "0.19",
|
|
126
126
|
"eslint": "8.56",
|
|
@@ -128,7 +128,7 @@
|
|
|
128
128
|
"eslint-plugin-import": "2.29",
|
|
129
129
|
"tsc-alias": "1.8",
|
|
130
130
|
"typedoc": "0.25",
|
|
131
|
-
"typedoc-plugin-missing-exports": "2.
|
|
131
|
+
"typedoc-plugin-missing-exports": "2.2",
|
|
132
132
|
"typescript": "5.3"
|
|
133
133
|
},
|
|
134
134
|
"peerDependencies": {
|
|
@@ -146,10 +146,10 @@
|
|
|
146
146
|
"mjml": "^4.14",
|
|
147
147
|
"mongodb": "^6.3",
|
|
148
148
|
"nodemailer": "^6.9",
|
|
149
|
-
"playwright": "^1.
|
|
149
|
+
"playwright": "^1.41",
|
|
150
150
|
"preact": "^10.19",
|
|
151
151
|
"preact-render-to-string": "^6.3",
|
|
152
|
-
"undici": "^6.
|
|
152
|
+
"undici": "^6.3",
|
|
153
153
|
"urlpattern-polyfill": "^9.0"
|
|
154
154
|
},
|
|
155
155
|
"peerDependenciesMeta": {
|
|
@@ -4,7 +4,6 @@ export function throttleFunction(func, interval, queue = false) {
|
|
|
4
4
|
let lastCall = 0;
|
|
5
5
|
let pending = false;
|
|
6
6
|
let nextArgs;
|
|
7
|
-
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
8
7
|
const throttled = (...args) => {
|
|
9
8
|
const nextAllowedCall = lastCall + interval;
|
|
10
9
|
const now = currentTimestamp(); // eslint-disable-line no-shadow
|