@tstdl/base 0.90.48 → 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 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.48",
3
+ "version": "0.90.50",
4
4
  "author": "Patrick Hein",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -108,27 +108,27 @@
108
108
  "luxon": "^3.4",
109
109
  "reflect-metadata": "^0.2",
110
110
  "rxjs": "^7.8",
111
- "type-fest": "4.7"
111
+ "type-fest": "4.9"
112
112
  },
113
113
  "devDependencies": {
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.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.14",
123
- "@typescript-eslint/parser": "6.14",
122
+ "@typescript-eslint/eslint-plugin": "6.19",
123
+ "@typescript-eslint/parser": "6.19",
124
124
  "concurrently": "8.2",
125
125
  "esbuild": "0.19",
126
- "eslint": "8.55",
126
+ "eslint": "8.56",
127
127
  "eslint-import-resolver-typescript": "3.6",
128
128
  "eslint-plugin-import": "2.29",
129
129
  "tsc-alias": "1.8",
130
130
  "typedoc": "0.25",
131
- "typedoc-plugin-missing-exports": "2.1",
131
+ "typedoc-plugin-missing-exports": "2.2",
132
132
  "typescript": "5.3"
133
133
  },
134
134
  "peerDependencies": {
@@ -141,15 +141,15 @@
141
141
  "@zxcvbn-ts/language-en": "^3.0",
142
142
  "chroma-js": "^2.4",
143
143
  "handlebars": "^4.7",
144
- "koa": "^2.14",
144
+ "koa": "^2.15",
145
145
  "minio": "^7.1",
146
146
  "mjml": "^4.14",
147
147
  "mongodb": "^6.3",
148
148
  "nodemailer": "^6.9",
149
- "playwright": "^1.40",
149
+ "playwright": "^1.41",
150
150
  "preact": "^10.19",
151
151
  "preact-render-to-string": "^6.3",
152
- "undici": "^6.0",
152
+ "undici": "^6.3",
153
153
  "urlpattern-polyfill": "^9.0"
154
154
  },
155
155
  "peerDependenciesMeta": {
package/types.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { Observable } from 'rxjs';
2
- import type { Except } from 'type-fest';
2
+ import type { CamelCase, Except } from 'type-fest';
3
3
  import type { Signal } from './signals/api.js';
4
4
  export type ObjectLiteral = {};
5
5
  export type PrimitiveTypeMap = {
@@ -193,4 +193,5 @@ export type TypeFromPath<T extends Record, Path extends Paths<T> | string> = {
193
193
  }[Path];
194
194
  export type ConstructorParameterDecorator = (target: Object, propertyKey: undefined, parameterIndex: number) => void;
195
195
  export type ReactiveValue<T> = T | Signal<T> | Observable<T>;
196
+ export type PascalCase<Value> = CamelCase<Value> extends string ? Capitalize<CamelCase<Value>> : CamelCase<Value>;
196
197
  export {};
@@ -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
@@ -1,5 +1,4 @@
1
- import type { AbstractConstructor, JsonPrimitive, Primitive, TypedArray } from '../types.js';
2
- import type { PascalCase } from 'type-fest';
1
+ import type { AbstractConstructor, JsonPrimitive, PascalCase, Primitive, TypedArray } from '../types.js';
3
2
  export type AssertionMessage = string | (() => string);
4
3
  export type IsFunction<T> = <U extends T = T>(value: any) => value is U;
5
4
  export type IsNotFunction<T> = <V>(value: V) => value is Exclude<V, T>;