@tstdl/base 0.90.49 → 0.90.51

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 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",
@@ -1,2 +1,3 @@
1
+ import type { WrapLogOptions } from '../function/log.js';
1
2
  import type { Decorator } from '../reflection/types.js';
2
- export declare function Log(): Decorator<'class' | 'method'>;
3
+ export declare function Log(options?: WrapLogOptions): Decorator<'class' | 'method'>;
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], 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], 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.49",
3
+ "version": "0.90.51",
4
4
  "author": "Patrick Hein",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -70,6 +70,7 @@
70
70
  "./promise": "./promise/index.js",
71
71
  "./queue": "./queue/index.js",
72
72
  "./queue/mongo": "./queue/mongo/index.js",
73
+ "./random": "./random/index.js",
73
74
  "./reflection": "./reflection/index.js",
74
75
  "./rpc": "./rpc/index.js",
75
76
  "./rpc/endpoints": "./rpc/endpoints/index.js",
@@ -108,19 +109,19 @@
108
109
  "luxon": "^3.4",
109
110
  "reflect-metadata": "^0.2",
110
111
  "rxjs": "^7.8",
111
- "type-fest": "4.9"
112
+ "type-fest": "4.10"
112
113
  },
113
114
  "devDependencies": {
114
115
  "@mxssfd/typedoc-theme": "1.1",
115
116
  "@types/chroma-js": "2.4",
116
117
  "@types/koa__router": "12.0",
117
- "@types/luxon": "3.3",
118
+ "@types/luxon": "3.4",
118
119
  "@types/minio": "7.1",
119
120
  "@types/mjml": "4.7",
120
121
  "@types/node": "20",
121
122
  "@types/nodemailer": "6.4",
122
- "@typescript-eslint/eslint-plugin": "6.16",
123
- "@typescript-eslint/parser": "6.16",
123
+ "@typescript-eslint/eslint-plugin": "6.19",
124
+ "@typescript-eslint/parser": "6.19",
124
125
  "concurrently": "8.2",
125
126
  "esbuild": "0.19",
126
127
  "eslint": "8.56",
@@ -128,7 +129,7 @@
128
129
  "eslint-plugin-import": "2.29",
129
130
  "tsc-alias": "1.8",
130
131
  "typedoc": "0.25",
131
- "typedoc-plugin-missing-exports": "2.1",
132
+ "typedoc-plugin-missing-exports": "2.2",
132
133
  "typescript": "5.3"
133
134
  },
134
135
  "peerDependencies": {
@@ -146,11 +147,11 @@
146
147
  "mjml": "^4.14",
147
148
  "mongodb": "^6.3",
148
149
  "nodemailer": "^6.9",
149
- "playwright": "^1.40",
150
+ "playwright": "^1.41",
150
151
  "preact": "^10.19",
151
152
  "preact-render-to-string": "^6.3",
152
- "undici": "^6.2",
153
- "urlpattern-polyfill": "^9.0"
153
+ "undici": "^6.4",
154
+ "urlpattern-polyfill": "^10.0"
154
155
  },
155
156
  "peerDependenciesMeta": {
156
157
  "@tstdl/angular": {
@@ -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