@tstdl/base 0.90.57 → 0.90.59

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.
Files changed (76) hide show
  1. package/.eslintrc.json +136 -116
  2. package/json-path/json-path.d.ts +11 -9
  3. package/json-path/json-path.js +9 -6
  4. package/jsx/render-to-string.d.ts +2 -0
  5. package/jsx/render-to-string.js +9 -3
  6. package/package.json +9 -9
  7. package/queue/mongo/queue.provider.d.ts +2 -4
  8. package/random/series.d.ts +1 -1
  9. package/schema/constraints/maximum.d.ts +1 -1
  10. package/schema/constraints/minimum-date.d.ts +1 -1
  11. package/schema/constraints/minimum.d.ts +1 -1
  12. package/schema/constraints/pattern.d.ts +1 -1
  13. package/schema/types/types.d.ts +2 -2
  14. package/search-index/elastic/query-builder/boolean-query-builder.d.ts +1 -4
  15. package/search-index/elastic/query-builder/boolean-query-builder.js +23 -23
  16. package/templates/renderers/jsx.template-renderer.d.ts +1 -1
  17. package/templates/renderers/jsx.template-renderer.js +3 -3
  18. package/theme/theme-service.d.ts +1 -1
  19. package/theme/theme-service.js +3 -2
  20. package/types.d.ts +26 -12
  21. package/utils/async-iterable-helpers/to-async-iterator.js +2 -2
  22. package/utils/async-iterator-iterable-iterator.js +3 -3
  23. package/utils/base64.js +1 -1
  24. package/utils/cryptography.d.ts +13 -13
  25. package/utils/cryptography.js +12 -12
  26. package/utils/date-time.js +1 -1
  27. package/utils/encoding.d.ts +6 -6
  28. package/utils/encoding.js +6 -6
  29. package/utils/enum.js +9 -15
  30. package/utils/equals.js +3 -2
  31. package/utils/format-error.d.ts +5 -5
  32. package/utils/format.js +7 -6
  33. package/utils/helpers.d.ts +9 -9
  34. package/utils/helpers.js +3 -3
  35. package/utils/object/decycle.d.ts +2 -2
  36. package/utils/object/decycle.js +8 -8
  37. package/utils/object/dereference.d.ts +4 -4
  38. package/utils/object/dereference.js +4 -4
  39. package/utils/object/forward-ref.js +2 -2
  40. package/utils/object/lazy-property.d.ts +9 -9
  41. package/utils/object/lazy-property.js +4 -3
  42. package/utils/object/merge.d.ts +1 -1
  43. package/utils/object/merge.js +3 -3
  44. package/utils/object/object.d.ts +2 -2
  45. package/utils/object/object.js +2 -2
  46. package/utils/object/property-name.d.ts +15 -15
  47. package/utils/object/property-name.js +12 -12
  48. package/utils/patch-worker.d.ts +3 -3
  49. package/utils/patterns.d.ts +2 -2
  50. package/utils/patterns.js +3 -3
  51. package/utils/periodic-reporter.d.ts +1 -1
  52. package/utils/periodic-sampler.d.ts +1 -1
  53. package/utils/periodic-sampler.js +7 -5
  54. package/utils/random.d.ts +2 -2
  55. package/utils/random.js +2 -2
  56. package/utils/reactive-value-to-signal.d.ts +1 -1
  57. package/utils/reactive-value-to-signal.js +1 -1
  58. package/utils/repl.js +1 -0
  59. package/utils/singleton.d.ts +5 -4
  60. package/utils/singleton.js +3 -3
  61. package/utils/stream/finalize-stream.d.ts +5 -5
  62. package/utils/stream/readable-stream-adapter.d.ts +1 -1
  63. package/utils/stream/readable-stream-adapter.js +2 -2
  64. package/utils/stream/readable-stream-from-promise.d.ts +1 -1
  65. package/utils/stream/slice.js +1 -1
  66. package/utils/stream/to-bytes-stream.js +4 -4
  67. package/utils/timing.d.ts +5 -5
  68. package/utils/timing.js +4 -4
  69. package/utils/type-guards.js +1 -1
  70. package/utils/type-of.d.ts +3 -2
  71. package/utils/type-of.js +1 -1
  72. package/utils/units.js +3 -2
  73. package/utils/url-builder.js +3 -3
  74. package/utils/value-or-provider.js +1 -1
  75. package/utils/z-base32.js +1 -3
  76. package/web-types.d.ts +1 -1
package/utils/format.js CHANGED
@@ -1,22 +1,23 @@
1
+ import { kibibyte, kilobyte, microsecondsPerMillisecond, millisecondsPerSecond, nanosecondsPerMillisecond } from './units.js';
1
2
  const siByteSizes = ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
2
3
  const iecByteSizes = ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'];
3
4
  export function formatDuration(milliseconds, precision) {
4
5
  let value;
5
6
  let suffix;
6
- if (milliseconds >= (10 ** 3)) {
7
- value = milliseconds / (10 ** 3);
7
+ if (milliseconds >= millisecondsPerSecond) {
8
+ value = milliseconds / millisecondsPerSecond;
8
9
  suffix = 's';
9
10
  }
10
11
  else if (milliseconds >= 1) {
11
12
  value = milliseconds;
12
13
  suffix = 'ms';
13
14
  }
14
- else if (milliseconds >= 1 / (10 ** 3)) {
15
- value = milliseconds * (10 ** 3);
15
+ else if (milliseconds >= 1 / microsecondsPerMillisecond) {
16
+ value = milliseconds * microsecondsPerMillisecond;
16
17
  suffix = 'us';
17
18
  }
18
19
  else {
19
- value = milliseconds * (10 ** 6);
20
+ value = milliseconds * nanosecondsPerMillisecond;
20
21
  suffix = 'ns';
21
22
  }
22
23
  const trimmed = parseFloat(value.toFixed(precision));
@@ -25,7 +26,7 @@ export function formatDuration(milliseconds, precision) {
25
26
  }
26
27
  export function formatBytes(bytes, { decimals = 2, unit = 'IEC' } = {}) {
27
28
  const iec = unit == 'IEC';
28
- const base = iec ? 1024 : 1000;
29
+ const base = iec ? kibibyte : kilobyte;
29
30
  const exponent = Math.floor(Math.log(bytes) / Math.log(base));
30
31
  const prefix = (iec ? iecByteSizes : siByteSizes)[exponent];
31
32
  const result = (bytes / (base ** exponent));
@@ -1,6 +1,6 @@
1
1
  import type { DeepArray, Record } from '../types.js';
2
2
  /**
3
- * create an structured clone of an value using Notification if available, otherwise history state (may alters history)
3
+ * Create an structured clone of an value using Notification if available, otherwise history state (may alters history)
4
4
  *
5
5
  * may not work in every environment!
6
6
  * @param value value to clone
@@ -8,7 +8,7 @@ import type { DeepArray, Record } from '../types.js';
8
8
  */
9
9
  export declare function structuredClone<T>(value: T): T;
10
10
  /**
11
- * create an structured clone of an value using a MessageChannel
11
+ * Create an structured clone of an value using a MessageChannel
12
12
  *
13
13
  * should work in all environments
14
14
  * @param value value to clone
@@ -27,39 +27,39 @@ export declare function parseFirstAndFamilyName(name: string): {
27
27
  };
28
28
  export type NormalizeTextOptions = {
29
29
  /**
30
- * remove leading and trailing whitespace
30
+ * Remove leading and trailing whitespace
31
31
  */
32
32
  trim?: boolean;
33
33
  /**
34
- * lowercase all characters
34
+ * Lowercase all characters
35
35
  */
36
36
  lowercase?: boolean;
37
37
  /**
38
- * remove multiple consecutive whitespace characters
38
+ * Remove multiple consecutive whitespace characters
39
39
  */
40
40
  multipleWhitespace?: boolean;
41
41
  /**
42
- * remove diacritics (è -> e)
42
+ * Remove diacritics (è -> e)
43
43
  *
44
44
  * applies unicode NFD normalization and removes diacritics
45
45
  * @see unicode option
46
46
  */
47
47
  diacritics?: boolean;
48
48
  /**
49
- * replace ligatures with their consecutive characters (æ -> ae)
49
+ * Replace ligatures with their consecutive characters (æ -> ae)
50
50
  *
51
51
  * applies unicode NFKC normalization
52
52
  * @see unicode option
53
53
  */
54
54
  ligatures?: boolean;
55
55
  /**
56
- * unicode normalization
56
+ * Unicode normalization
57
57
  * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize
58
58
  */
59
59
  unicode?: 'NFC' | 'NFD' | 'NFKC' | 'NFKD';
60
60
  };
61
61
  /**
62
- * trims, lowercases, replaces multi-character whitespace with a single space and unicode normalization
62
+ * Trims, lowercases, replaces multi-character whitespace with a single space and unicode normalization
63
63
  * @param text text to normalize
64
64
  * @param options specify what to normalize. Defaults to all except unicode
65
65
  * @returns normalized text
package/utils/helpers.js CHANGED
@@ -4,7 +4,7 @@ import { DetailsError } from '../errors/details.error.js';
4
4
  import { decycle } from './object/decycle.js';
5
5
  import { isDefined } from './type-guards.js';
6
6
  /**
7
- * create an structured clone of an value using Notification if available, otherwise history state (may alters history)
7
+ * Create an structured clone of an value using Notification if available, otherwise history state (may alters history)
8
8
  *
9
9
  * may not work in every environment!
10
10
  * @param value value to clone
@@ -21,7 +21,7 @@ export function structuredClone(value) {
21
21
  return copy;
22
22
  }
23
23
  /**
24
- * create an structured clone of an value using a MessageChannel
24
+ * Create an structured clone of an value using a MessageChannel
25
25
  *
26
26
  * should work in all environments
27
27
  * @param value value to clone
@@ -70,7 +70,7 @@ export function parseFirstAndFamilyName(name) {
70
70
  };
71
71
  }
72
72
  /**
73
- * trims, lowercases, replaces multi-character whitespace with a single space and unicode normalization
73
+ * Trims, lowercases, replaces multi-character whitespace with a single space and unicode normalization
74
74
  * @param text text to normalize
75
75
  * @param options specify what to normalize. Defaults to all except unicode
76
76
  * @returns normalized text
@@ -3,13 +3,13 @@ export type Decycled<T> = {
3
3
  __type: T;
4
4
  } & Record<string>;
5
5
  /**
6
- * replaces cycles (circular references) in objects with JSONPath
6
+ * Replaces cycles (circular references) in objects with JSONPath
7
7
  * @param value object to decycle
8
8
  * @param replacer replace values. Like JSON.stringify(value, *replacer*)
9
9
  */
10
10
  export declare function decycle<T>(value: T, replacer?: (value: any) => any): Decycled<T>;
11
11
  /**
12
- * replaces JSONPath in objects with their reference
12
+ * Replaces JSONPath in objects with their reference
13
13
  * @param value object to recycle
14
14
  */
15
15
  export declare function recycle<T = any>(value: Decycled<T>, clone?: boolean): T;
@@ -6,7 +6,7 @@ import { hasOwnProperty, mapObjectValues, objectKeys } from './object.js';
6
6
  export function decycle(_value, replacer) {
7
7
  const mapping = new Map();
8
8
  const replacerFn = isDefined(replacer) ? replacer : (value) => value;
9
- function _decycle(__value, path) {
9
+ function decycleInternal(__value, path) {
10
10
  const value = replacerFn(__value);
11
11
  if (isPrimitive(value) || isRegExp(value) || isDate(value) || isFunction(value)) {
12
12
  return value;
@@ -17,11 +17,11 @@ export function decycle(_value, replacer) {
17
17
  }
18
18
  mapping.set(value, path);
19
19
  if (isArray(value)) {
20
- return value.map((item, index) => _decycle(item, path.add(index)));
20
+ return value.map((item, index) => decycleInternal(item, path.add(index)));
21
21
  }
22
- return mapObjectValues(value, (item, key) => _decycle(item, path.add(key)));
22
+ return mapObjectValues(value, (item, key) => decycleInternal(item, path.add(key)));
23
23
  }
24
- return _decycle(_value, JsonPath.ROOT);
24
+ return decycleInternal(_value, JsonPath.ROOT);
25
25
  }
26
26
  export function recycle(_value, _clone = true) {
27
27
  const value = _clone ? clone(_value, true) : _value;
@@ -35,7 +35,7 @@ export function recycle(_value, _clone = true) {
35
35
  }
36
36
  return undefined;
37
37
  }
38
- function _recycle(node) {
38
+ function recycleInternal(node) {
39
39
  if (isWritableArray(node)) {
40
40
  for (let i = 0; i < node.length; i++) {
41
41
  const ref = getRef(node[i]);
@@ -43,7 +43,7 @@ export function recycle(_value, _clone = true) {
43
43
  node[i] = deref(value, ref);
44
44
  }
45
45
  else {
46
- _recycle(node[i]);
46
+ recycleInternal(node[i]);
47
47
  }
48
48
  }
49
49
  }
@@ -54,11 +54,11 @@ export function recycle(_value, _clone = true) {
54
54
  node[key] = deref(value, ref);
55
55
  }
56
56
  else {
57
- _recycle(node[key]);
57
+ recycleInternal(node[key]);
58
58
  }
59
59
  }
60
60
  }
61
61
  }
62
- _recycle(value);
62
+ recycleInternal(value);
63
63
  return value;
64
64
  }
@@ -1,14 +1,14 @@
1
- import type { JsonPathInput } from '../../json-path/index.js';
1
+ import { type JsonPathInput } from '../../json-path/index.js';
2
2
  export type CompiledDereferencer = (object: object) => unknown;
3
3
  /**
4
- * compiles a dereferencer for a specific reference
4
+ * Compiles a dereferencer for a specific reference
5
5
  * @param object object to dereference
6
6
  * @param reference path to property in dot notation or {@link JsonPath}
7
7
  * @returns referenced value
8
8
  */
9
9
  export declare function compileDereferencer(reference: JsonPathInput): (object: object) => unknown;
10
10
  /**
11
- * dereference a reference
11
+ * Dereference a reference
12
12
  *
13
13
  * @description useful if you dereference a reference a few times at most
14
14
  *
@@ -19,7 +19,7 @@ export declare function compileDereferencer(reference: JsonPathInput): (object:
19
19
  */
20
20
  export declare function dereference(object: object, reference: JsonPathInput): unknown;
21
21
  /**
22
- * cached version of {@link dereference}. It caches the internally used dereferencer, but it does *not* cache the referenced value
22
+ * Cached version of {@link dereference}. It caches the internally used dereferencer, but it does *not* cache the referenced value
23
23
  *
24
24
  * @description
25
25
  * useful if you dereference multiple references, each multiple times
@@ -1,13 +1,13 @@
1
1
  import { JsonPath } from '../../json-path/index.js';
2
2
  import { memoizeSingle } from '../function/memoize.js';
3
3
  /**
4
- * compiles a dereferencer for a specific reference
4
+ * Compiles a dereferencer for a specific reference
5
5
  * @param object object to dereference
6
6
  * @param reference path to property in dot notation or {@link JsonPath}
7
7
  * @returns referenced value
8
8
  */
9
9
  export function compileDereferencer(reference) {
10
- const nodes = new JsonPath(reference).nodes;
10
+ const nodes = JsonPath.from(reference).nodes;
11
11
  function dereferencer(object) {
12
12
  let target = object;
13
13
  for (let i = 0; i < nodes.length; i++) { // eslint-disable-line @typescript-eslint/prefer-for-of
@@ -18,7 +18,7 @@ export function compileDereferencer(reference) {
18
18
  return dereferencer;
19
19
  }
20
20
  /**
21
- * dereference a reference
21
+ * Dereference a reference
22
22
  *
23
23
  * @description useful if you dereference a reference a few times at most
24
24
  *
@@ -31,7 +31,7 @@ export function dereference(object, reference) {
31
31
  return compileDereferencer(reference)(object);
32
32
  }
33
33
  /**
34
- * cached version of {@link dereference}. It caches the internally used dereferencer, but it does *not* cache the referenced value
34
+ * Cached version of {@link dereference}. It caches the internally used dereferencer, but it does *not* cache the referenced value
35
35
  *
36
36
  * @description
37
37
  * useful if you dereference multiple references, each multiple times
@@ -54,9 +54,9 @@ function getForwardRefProxy(context) {
54
54
  }
55
55
  function getContext(options) {
56
56
  const reference = isDefined(options?.reference)
57
- ? { value: options?.reference }
57
+ ? { value: options.reference }
58
58
  : isDefined(options?.initializer)
59
- ? { initializer: options?.initializer }
59
+ ? { initializer: options.initializer }
60
60
  : { value: undefined };
61
61
  return lazyObject({
62
62
  reference
@@ -1,34 +1,34 @@
1
- import type { IfUnknown } from '../../types.js';
1
+ import type { AnyFunction, IfUnknown } from '../../types.js';
2
2
  declare const lazyObjectValueSymbol: unique symbol;
3
3
  export type LazyPropertyInitializer<T, K extends keyof T> = (this: T, key: K) => T[K];
4
4
  export type LazyPropertyObjectDefinition<T extends object, P extends keyof T> = LazyPropertyDescriptor & {
5
- /** define property with existing value */
5
+ /** Define property with existing value */
6
6
  value?: T[P];
7
- /** define property with getter */
7
+ /** Define property with getter */
8
8
  get?: (this: T) => T[P];
9
- /** define property with setter */
9
+ /** Define property with setter */
10
10
  set?: (this: T, value: T[P]) => void;
11
- /** lazily define property with initializer */
11
+ /** Lazily define property with initializer */
12
12
  initializer?: LazyPropertyInitializer<T, P>;
13
13
  };
14
14
  export type LazyObjectValue<T> = {
15
15
  [lazyObjectValueSymbol]: typeof lazyObjectValueSymbol;
16
16
  value: T;
17
17
  };
18
- export type LazyInitializerItem<T extends object, P extends keyof T> = Exclude<IfUnknown<T[P], never, T[P]>, Function | object> | LazyPropertyInitializer<T, P> | LazyPropertyObjectDefinition<T, P> | LazyObjectValue<T[P]>;
18
+ export type LazyInitializerItem<T extends object, P extends keyof T> = Exclude<IfUnknown<T[P], never, T[P]>, AnyFunction | object> | LazyPropertyInitializer<T, P> | LazyPropertyObjectDefinition<T, P> | LazyObjectValue<T[P]>;
19
19
  export type LazyPropertyDescriptor = {
20
20
  /**
21
- * true if the type of this property descriptor may be changed and if the property may be deleted from the corresponding object
21
+ * True if the type of this property descriptor may be changed and if the property may be deleted from the corresponding object
22
22
  * @default true
23
23
  */
24
24
  configurable?: boolean;
25
25
  /**
26
- * true if and only if this property shows up during enumeration of the properties on the corresponding object
26
+ * True if and only if this property shows up during enumeration of the properties on the corresponding object
27
27
  * @default true
28
28
  */
29
29
  enumerable?: boolean;
30
30
  /**
31
- * true if the value associated with the property may be changed with an assignment operator
31
+ * True if the value associated with the property may be changed with an assignment operator
32
32
  * @default true
33
33
  */
34
34
  writable?: boolean;
@@ -23,14 +23,15 @@ export function lazyProperty(object, propertyKey, initializer, descriptor = {})
23
23
  }
24
24
  return _value;
25
25
  },
26
- set: !writable ? undefined
27
- : function set(value) {
26
+ set: writable
27
+ ? function set(value) {
28
28
  if (configurable) {
29
29
  Object.defineProperty(object, propertyKey, { configurable, enumerable, writable, value });
30
30
  }
31
31
  _value = value;
32
32
  initialized = true;
33
- },
33
+ }
34
+ : undefined,
34
35
  enumerable,
35
36
  configurable
36
37
  });
@@ -1,6 +1,6 @@
1
1
  export type MergeObjectsOptions = {
2
2
  /**
3
- * whether to merge arrays or ensure they are equal
3
+ * Whether to merge arrays or ensure they are equal
4
4
  * @default 'merge'
5
5
  */
6
6
  array?: 'merge' | 'merge-unique' | 'equals' | 'equals-sorted';
@@ -3,9 +3,9 @@ import { arrayEquals } from '../equals.js';
3
3
  import { isArray, isPrimitive, isUndefined } from '../type-guards.js';
4
4
  import { hasOwnProperty, objectEntries } from './object.js';
5
5
  export function mergeObjects(objects, options = {}) {
6
- return objects.reduce((merged, object) => _mergeObjects(merged, object, options), {});
6
+ return objects.reduce((merged, object) => mergeObjectsInternal(merged, object, options), {});
7
7
  }
8
- function _mergeObjects(a, b, options, path = '$') {
8
+ function mergeObjectsInternal(a, b, options, path = '$') {
9
9
  const merged = { ...a };
10
10
  const bEntries = objectEntries(b);
11
11
  for (const [key, valueB] of bEntries) {
@@ -36,7 +36,7 @@ function mergeValues(a, b, options, path) {
36
36
  }
37
37
  return mergeArray(a, b, options, path); // eslint-disable-line @typescript-eslint/no-unsafe-return
38
38
  }
39
- return _mergeObjects(a, b, options, path);
39
+ return mergeObjectsInternal(a, b, options, path);
40
40
  }
41
41
  function mergeArray(a, b, options, path) {
42
42
  if (options.array == 'merge' || isUndefined(options.array)) {
@@ -2,11 +2,11 @@ import type { FromEntries, ObjectLiteral, PickBy, Record, SimplifyObject } from
2
2
  import type { IsEqual } from 'type-fest';
3
3
  export declare function hasOwnProperty<T extends Record>(obj: T, key: keyof T): boolean;
4
4
  /**
5
- * returns object entries including those with symbols keys (which Object.entries does not)
5
+ * Returns object entries including those with symbols keys (which Object.entries does not)
6
6
  */
7
7
  export declare function objectEntries<T extends ObjectLiteral>(object: T): [keyof T, T[keyof T]][];
8
8
  /**
9
- * returns object keys including symbols (which Object.keys does not)
9
+ * Returns object keys including symbols (which Object.keys does not)
10
10
  */
11
11
  export declare function objectKeys<T extends ObjectLiteral>(object: T): (keyof T)[];
12
12
  export declare function objectValues<T extends ObjectLiteral>(object: T): (T[keyof T])[];
@@ -6,14 +6,14 @@ export function hasOwnProperty(obj, key) {
6
6
  return Object.hasOwn(obj, key);
7
7
  }
8
8
  /**
9
- * returns object entries including those with symbols keys (which Object.entries does not)
9
+ * Returns object entries including those with symbols keys (which Object.entries does not)
10
10
  */
11
11
  export function objectEntries(object) {
12
12
  const keys = objectKeys(object);
13
13
  return keys.map((key) => [key, object[key]]);
14
14
  }
15
15
  /**
16
- * returns object keys including symbols (which Object.keys does not)
16
+ * Returns object keys including symbols (which Object.keys does not)
17
17
  */
18
18
  export function objectKeys(object) {
19
19
  return Reflect.ownKeys(object).filter((key) => key != '__proto__');
@@ -8,26 +8,26 @@ export type PropertyNameProxy<T extends Record> = {
8
8
  [P in keyof DeepNonNullable<T>]: PropertyNameProxyChild<T[P]>;
9
9
  };
10
10
  export type PropertyNameProxyChild<T> = (T extends Record ? (PropertyNameProxy<T> & PropertyName) : (PropertyName)) & {
11
- [cast]: <U extends T>() => PropertyNameProxyChild<U>;
11
+ [cast]<U extends T>(): PropertyNameProxyChild<U>;
12
12
  };
13
13
  export type PropertyNameOfExpressionObject<T> = {
14
14
  [P in keyof T]: PropertyNameOfExpressionObject<DeepNonNullable<T>[P]> & {
15
- [cast]: <U extends T[P]>() => PropertyNameOfExpressionObject<DeepNonNullable<U>>;
15
+ [cast]<U extends T[P]>(): PropertyNameOfExpressionObject<DeepNonNullable<U>>;
16
16
  };
17
17
  };
18
18
  export type FlatPropertyNameOfExpressionObject<T> = {
19
19
  [P in keyof DeepFlatten<T>]: FlatPropertyNameOfExpressionObject<DeepFlatten<DeepNonNullable<T>>[P]> & {
20
- [cast]: <U extends DeepFlatten<T>[P]>() => FlatPropertyNameOfExpressionObject<DeepNonNullable<U>>;
20
+ [cast]<U extends DeepFlatten<T>[P]>(): FlatPropertyNameOfExpressionObject<DeepNonNullable<U>>;
21
21
  };
22
22
  };
23
23
  export declare function getPropertyName(name: string): PropertyName;
24
24
  export declare function isPropertyName(value: any): value is PropertyName;
25
25
  /**
26
- * get the path to a property
26
+ * Get the path to a property
27
27
  *
28
- * @param options.deep whether to return the whole path to the property or just the last property
29
- * @param options.flat ignore array accesses (properties consiting only of numbers)
30
- * @param options.prefix name prefix
28
+ * @param options.deep Whether to return the whole path to the property or just the last property
29
+ * @param options.flat Ignore array accesses (properties consiting only of numbers)
30
+ * @param options.prefix Name prefix
31
31
  *
32
32
  * @example
33
33
  * import { getPropertyNameProxy, propertyName } from '@tstdl/base/utils/object.js';
@@ -42,19 +42,19 @@ export declare function getPropertyNameProxy<T extends Record = Record>(options?
42
42
  prefix?: string;
43
43
  }): PropertyNameProxy<T>;
44
44
  /**
45
- * get the path to a property
46
- * @param expression property selection expression
47
- * @param options.deep whether to return the whole path to the property or just the last property
48
- * @returns property name
45
+ * Get the path to a property
46
+ * @param expression Property selection expression
47
+ * @param options.deep Whether to return the whole path to the property or just the last property
48
+ * @returns Property name
49
49
  */
50
50
  export declare function propertyNameOf<T extends Record = Record>(expression: (instance: PropertyNameOfExpressionObject<T>) => any, options?: {
51
51
  deep?: boolean;
52
52
  }): string;
53
53
  /**
54
- * get the flat path to a property (flat = ignore array accesses (properties only consisting of numbers))
55
- * @param expression property selection expression
56
- * @param options.deep whether to return the whole path to the property or just the last property
57
- * @returns property name
54
+ * Get the flat path to a property (flat = ignore array accesses (properties only consisting of numbers))
55
+ * @param expression Property selection expression
56
+ * @param options.deep Whether to return the whole path to the property or just the last property
57
+ * @returns Property name
58
58
  */
59
59
  export declare function flatPropertyNameOf<T extends Record = Record>(expression: (instance: FlatPropertyNameOfExpressionObject<T>) => any, options?: {
60
60
  deep?: boolean;
@@ -9,11 +9,11 @@ export function isPropertyName(value) {
9
9
  }
10
10
  const propertyNameProxy = Symbol('PropertyNameProxy');
11
11
  /**
12
- * get the path to a property
12
+ * Get the path to a property
13
13
  *
14
- * @param options.deep whether to return the whole path to the property or just the last property
15
- * @param options.flat ignore array accesses (properties consiting only of numbers)
16
- * @param options.prefix name prefix
14
+ * @param options.deep Whether to return the whole path to the property or just the last property
15
+ * @param options.flat Ignore array accesses (properties consiting only of numbers)
16
+ * @param options.prefix Name prefix
17
17
  *
18
18
  * @example
19
19
  * import { getPropertyNameProxy, propertyName } from '@tstdl/base/utils/object.js';
@@ -53,20 +53,20 @@ export function getPropertyNameProxy(options = {}) {
53
53
  return proxy;
54
54
  }
55
55
  /**
56
- * get the path to a property
57
- * @param expression property selection expression
58
- * @param options.deep whether to return the whole path to the property or just the last property
59
- * @returns property name
56
+ * Get the path to a property
57
+ * @param expression Property selection expression
58
+ * @param options.deep Whether to return the whole path to the property or just the last property
59
+ * @returns Property name
60
60
  */
61
61
  export function propertyNameOf(expression, options = {}) {
62
62
  const name = expression(getPropertyNameProxy({ deep: options.deep, flat: false }))?.[propertyName];
63
63
  return assertStringPass(name, 'invalid expression');
64
64
  }
65
65
  /**
66
- * get the flat path to a property (flat = ignore array accesses (properties only consisting of numbers))
67
- * @param expression property selection expression
68
- * @param options.deep whether to return the whole path to the property or just the last property
69
- * @returns property name
66
+ * Get the flat path to a property (flat = ignore array accesses (properties only consisting of numbers))
67
+ * @param expression Property selection expression
68
+ * @param options.deep Whether to return the whole path to the property or just the last property
69
+ * @returns Property name
70
70
  */
71
71
  export function flatPropertyNameOf(expression, options = {}) {
72
72
  const name = expression(getPropertyNameProxy({ deep: options.deep, flat: true }))?.[propertyName];
@@ -1,12 +1,12 @@
1
- import type { Observable } from 'rxjs';
1
+ import { type Observable } from 'rxjs';
2
2
  import type { Record, StringMap } from '../types.js';
3
3
  export type PatchWorkerOptions<T extends StringMap> = {
4
4
  debounceTime?: number;
5
5
  retryDelay?: number;
6
6
  handleOn?: Observable<any>;
7
7
  completeOn?: Observable<any>;
8
- handler: (patch: Partial<T>) => void | Promise<void>;
9
- errorHandler?: (error: Error) => void | Promise<void>;
8
+ handler(patch: Partial<T>): void | Promise<void>;
9
+ errorHandler?(error: Error): void | Promise<void>;
10
10
  };
11
11
  export declare class PatchWorker<T extends Record> {
12
12
  private readonly patchAddedSubject;
@@ -1,5 +1,5 @@
1
- /** pattern matching valid JavaScript number literals including binary, octal and hexadecimal format but *not* Infinity and NaN */
1
+ /** Pattern matching valid JavaScript number literals including binary, octal and hexadecimal format but *not* Infinity and NaN */
2
2
  export declare const numberPattern: RegExp;
3
- /** pattern matching valid email addresses */
3
+ /** Pattern matching valid email addresses */
4
4
  export declare const mailPattern: RegExp;
5
5
  export declare function isEmail(value: string): boolean;
package/utils/patterns.js CHANGED
@@ -1,7 +1,7 @@
1
- /** pattern matching valid JavaScript number literals including binary, octal and hexadecimal format but *not* Infinity and NaN */
1
+ /** Pattern matching valid JavaScript number literals including binary, octal and hexadecimal format but *not* Infinity and NaN */
2
2
  export const numberPattern = /^[+-]?(?:\d*\.?\d+|\d+\.?\d*|0[bB][01]+|0[xX][\da-fA-F]+|0[oO][0-7]+)$/u;
3
- /** pattern matching valid email addresses */
4
- // eslint-disable-next-line no-control-regex
3
+ /** Pattern matching valid email addresses */
4
+ // eslint-disable-next-line no-control-regex, prefer-named-capture-group
5
5
  export const mailPattern = /^(?:[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-zA-Z0-9-]*[a-zA-Z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])$/u;
6
6
  export function isEmail(value) {
7
7
  return mailPattern.test(value);
@@ -1,4 +1,4 @@
1
- import type { Observable } from 'rxjs';
1
+ import { type Observable } from 'rxjs';
2
2
  export declare class PeriodicReporter {
3
3
  private readonly reportSubject;
4
4
  private readonly interval;
@@ -1,4 +1,4 @@
1
- import type { Observable } from 'rxjs';
1
+ import { type Observable } from 'rxjs';
2
2
  export declare enum AggregationMode {
3
3
  Minimum = 0,
4
4
  Maximum = 1,
@@ -1,5 +1,4 @@
1
- import { Subject } from 'rxjs';
2
- import { bufferCount, filter, map } from 'rxjs';
1
+ import { Subject, bufferCount, filter, map } from 'rxjs';
3
2
  import { compareByValue } from './comparison.js';
4
3
  import { average } from './math.js';
5
4
  import { timeout } from './timing.js';
@@ -55,18 +54,21 @@ function aggregate(aggregation, values) {
55
54
  return Math.max(...values);
56
55
  case AggregationMode.Mean:
57
56
  return average(values);
58
- case AggregationMode.Median:
57
+ case AggregationMode.Median: {
59
58
  values.sort(compareByValue);
60
59
  const median = Math.floor(values.length / 2);
61
60
  return values[median];
62
- case AggregationMode.FirstQuartile:
61
+ }
62
+ case AggregationMode.FirstQuartile: {
63
63
  values.sort(compareByValue);
64
64
  const firstQuartile = Math.floor(values.length / 4 * 1);
65
65
  return values[firstQuartile];
66
- case AggregationMode.ThirdQuartile:
66
+ }
67
+ case AggregationMode.ThirdQuartile: {
67
68
  values.sort(compareByValue);
68
69
  const thirdQuartile = Math.floor(values.length / 4 * 3);
69
70
  return values[thirdQuartile];
71
+ }
70
72
  default:
71
73
  throw new Error(`aggregation mode ${aggregation} not implemented`);
72
74
  }
package/utils/random.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * generate cryptographically secure random bytes
2
+ * Generate cryptographically secure random bytes
3
3
  *
4
4
  * if allowUnsafe is true a view on the underlying pool is returned. This can be dangerous as the underlying
5
5
  * pool can be read and modified by other callers of {@link getRandomBytes} but improves performance as
@@ -9,7 +9,7 @@
9
9
  */
10
10
  export declare function getRandomBytes(count: number, allowUnsafe?: boolean): Uint8Array;
11
11
  /**
12
- * generate a cryptographically secure random string (in terms of source of randomness).
12
+ * Generate a cryptographically secure random string (in terms of source of randomness).
13
13
  * @param length length of string
14
14
  * @param alphabet alphabet to choose characters from. Defaults to {@link Alphabet.LowerUpperCaseNumbers}
15
15
  */
package/utils/random.js CHANGED
@@ -4,7 +4,7 @@ const bufferBypassThreshold = (bufferSize / 2) + 1;
4
4
  let randomBytesBuffer = new Uint8Array();
5
5
  let randomBytesBufferIndex = 0;
6
6
  /**
7
- * generate cryptographically secure random bytes
7
+ * Generate cryptographically secure random bytes
8
8
  *
9
9
  * if allowUnsafe is true a view on the underlying pool is returned. This can be dangerous as the underlying
10
10
  * pool can be read and modified by other callers of {@link getRandomBytes} but improves performance as
@@ -26,7 +26,7 @@ export function getRandomBytes(count, allowUnsafe = false) {
26
26
  return bytes;
27
27
  }
28
28
  /**
29
- * generate a cryptographically secure random string (in terms of source of randomness).
29
+ * Generate a cryptographically secure random string (in terms of source of randomness).
30
30
  * @param length length of string
31
31
  * @param alphabet alphabet to choose characters from. Defaults to {@link Alphabet.LowerUpperCaseNumbers}
32
32
  */
@@ -1,4 +1,4 @@
1
- import type { Signal, ToSignalOptions } from '../signals/api.js';
1
+ import { type Signal, type ToSignalOptions } from '../signals/api.js';
2
2
  import type { ReactiveValue } from '../types.js';
3
3
  export type ReactiveValueToSignalOptions = ToSignalOptions;
4
4
  export declare function reactiveValueToSignal<T>(source: ReactiveValue<T>): Signal<T | undefined>;