@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
@@ -5,7 +5,7 @@ export function reactiveValueToSignal(source, options) {
5
5
  return source;
6
6
  }
7
7
  if (isObservable(source)) {
8
- return toSignal(source, options);
8
+ return toSignal(source, options); // eslint-disable-line @typescript-eslint/no-unsafe-argument
9
9
  }
10
10
  return computed(() => source);
11
11
  }
package/utils/repl.js CHANGED
@@ -1,3 +1,4 @@
1
+ /* eslint-disable import/no-nodejs-modules */
1
2
  import { dynamicImport } from '../import.js';
2
3
  import { objectEntries } from './object/object.js';
3
4
  import { isDefined } from './type-guards.js';
@@ -1,6 +1,7 @@
1
+ import type { ObjectLiteral } from '../types.js';
1
2
  export type Builder<T> = () => T;
2
3
  export type AsyncBuilder<T> = () => Promise<T>;
3
- export declare function singleton<T>(type: any, builder: Builder<T>): T;
4
- export declare function singleton<T>(type: any, builder: AsyncBuilder<T>): Promise<T>;
5
- export declare function singleton<T>(scope: any, type: any, builder: Builder<T>): T;
6
- export declare function singleton<T>(scope: any, type: any, builder: AsyncBuilder<T>): Promise<T>;
4
+ export declare function singleton<T>(type: ObjectLiteral, builder: Builder<T>): T;
5
+ export declare function singleton<T>(type: ObjectLiteral, builder: AsyncBuilder<T>): Promise<T>;
6
+ export declare function singleton<T>(scope: ObjectLiteral, type: ObjectLiteral, builder: Builder<T>): T;
7
+ export declare function singleton<T>(scope: ObjectLiteral, type: ObjectLiteral, builder: AsyncBuilder<T>): Promise<T>;
@@ -2,9 +2,9 @@ import { FactoryMap } from './factory-map.js';
2
2
  const globalScope = Symbol('global singleton scope');
3
3
  const scopes = new FactoryMap(() => new Map());
4
4
  export function singleton(scopeOrType, typeOrBuilder, _builder) {
5
- const builder = _builder != undefined ? _builder : typeOrBuilder;
6
- const scope = _builder != undefined ? scopeOrType : globalScope;
7
- const type = _builder != undefined ? typeOrBuilder : scopeOrType;
5
+ const builder = _builder ?? typeOrBuilder;
6
+ const scope = _builder == undefined ? globalScope : scopeOrType;
7
+ const type = _builder == undefined ? scopeOrType : typeOrBuilder;
8
8
  const instances = scopes.get(scope);
9
9
  if (!instances.has(type)) {
10
10
  const instanceOrPromise = builder();
@@ -13,10 +13,10 @@ export type ReadableStreamFinalizeEvent = {
13
13
  export type StreamFinalizerHandler = (event: ReadableStreamFinalizeEvent) => void | Promise<void>;
14
14
  export type FinalizeStreamHandlers = {
15
15
  finalizer?: StreamFinalizerHandler;
16
- beforeDone?: () => void | Promise<void>;
17
- done?: () => void | Promise<void>;
18
- error?: (error: Error) => void | Promise<void>;
19
- beforeCancel?: (reason: any) => void | Promise<void>;
20
- cancel?: (reason: any) => void | Promise<void>;
16
+ beforeDone?(): void | Promise<void>;
17
+ done?(): void | Promise<void>;
18
+ error?(error: Error): void | Promise<void>;
19
+ beforeCancel?(reason: any): void | Promise<void>;
20
+ cancel?(reason: any): void | Promise<void>;
21
21
  };
22
22
  export declare function finalizeStream<T>(stream: ReadableStream<T>, finalizerOrHandlers: StreamFinalizerHandler | FinalizeStreamHandlers): ReadableStream<T>;
@@ -1,5 +1,5 @@
1
1
  import type { AnyIterable } from '../any-iterable-iterator.js';
2
- export declare function getReadableStreamIterable<T>(stream: ReadableStream<T>, options?: {
2
+ export declare function getReadableStreamIterable<T>(stream: ReadableStream<T>, { close }?: {
3
3
  close?: boolean;
4
4
  }): AsyncIterable<T>;
5
5
  export declare function getReadableStreamFromIterable<T>(iterable: AnyIterable<T>): ReadableStream<T>;
@@ -1,5 +1,5 @@
1
1
  import { isAsyncIterable } from '../async-iterable-helpers/is-async-iterable.js';
2
- export async function* getReadableStreamIterable(stream, options = {}) {
2
+ export async function* getReadableStreamIterable(stream, { close = true } = {}) {
3
3
  const reader = stream.getReader();
4
4
  try {
5
5
  while (true) {
@@ -11,7 +11,7 @@ export async function* getReadableStreamIterable(stream, options = {}) {
11
11
  }
12
12
  }
13
13
  finally {
14
- if (options.close != false) {
14
+ if (close) {
15
15
  await reader.cancel();
16
16
  }
17
17
  else {
@@ -1,2 +1,2 @@
1
- import type { ValueOrProvider } from '../value-or-provider.js';
1
+ import { type ValueOrProvider } from '../value-or-provider.js';
2
2
  export declare function readableStreamFromPromise<T>(promiseOrProvider: ValueOrProvider<Promise<ReadableStream<T>>>): ReadableStream<T>;
@@ -39,7 +39,7 @@ export function sliceStream(stream, offset, length, type = 'bytes') {
39
39
  let offsetBuffer = new ArrayBuffer(mebibyte);
40
40
  return new ReadableStream({
41
41
  type: 'bytes',
42
- autoAllocateChunkSize: 100 * kibibyte,
42
+ autoAllocateChunkSize: 100 * kibibyte, // eslint-disable-line @typescript-eslint/no-magic-numbers
43
43
  async pull(controller) {
44
44
  while (bytesRead < offset) {
45
45
  const readResult = await byobReader.read(new Uint8Array(offsetBuffer, 0, Math.min(offsetBuffer.byteLength, offset - bytesRead)));
@@ -1,11 +1,11 @@
1
1
  import { isNotNull, isNull } from '../type-guards.js';
2
2
  import { kibibyte } from '../units.js';
3
3
  export function toBytesStream(stream, options) {
4
- try { // try to use byob mode from source
4
+ try { // Try to use byob mode from source
5
5
  let byobReader;
6
6
  return new ReadableStream({
7
7
  type: 'bytes',
8
- autoAllocateChunkSize: 100 * kibibyte,
8
+ autoAllocateChunkSize: 100 * kibibyte, // eslint-disable-line @typescript-eslint/no-magic-numbers
9
9
  start() {
10
10
  byobReader = stream.getReader({ mode: 'byob' });
11
11
  },
@@ -26,7 +26,7 @@ export function toBytesStream(stream, options) {
26
26
  }
27
27
  });
28
28
  }
29
- catch { /* ignore */ }
29
+ catch { /* Ignore */ }
30
30
  let reader;
31
31
  let buffer = null;
32
32
  return new ReadableStream({
@@ -38,7 +38,7 @@ export function toBytesStream(stream, options) {
38
38
  const isByobRequest = isNotNull(controller.byobRequest);
39
39
  const bufferIsEmpty = isNull(buffer) || (buffer.byteLength == 0);
40
40
  if (!isByobRequest && !bufferIsEmpty) {
41
- // we stil have data left in buffer from previous pull which was byob
41
+ // We still have data left in buffer from previous pull which was byob
42
42
  controller.enqueue(buffer);
43
43
  buffer = null;
44
44
  return;
package/utils/timing.d.ts CHANGED
@@ -1,14 +1,14 @@
1
1
  import type { CancellationSignal } from '../cancellation/token.js';
2
- import type { ValueOrProvider } from './value-or-provider.js';
3
- /** timeout for specified duration */
2
+ import { type ValueOrProvider } from './value-or-provider.js';
3
+ /** Timeout for specified duration */
4
4
  export declare function timeout(milliseconds?: number, options?: {
5
5
  abortSignal?: AbortSignal;
6
6
  }): Promise<void>;
7
- /** timeout until specified time */
7
+ /** Timeout until specified time */
8
8
  export declare function timeoutUntil(timestamp: number | Date): Promise<void>;
9
- /** timeout for specified duration */
9
+ /** Timeout for specified duration */
10
10
  export declare function cancelableTimeout(milliseconds: number, cancelSignal: CancellationSignal): Promise<boolean>;
11
- /** timeout until specified time */
11
+ /** Timeout until specified time */
12
12
  export declare function cancelableTimeoutUntil(timestamp: number | Date, cancelSignal: CancellationSignal): Promise<boolean>;
13
13
  export declare function withTimeout<T>(milliseconds: number, promiseOrProvider: ValueOrProvider<Promise<T>>, options?: {
14
14
  errorMessage?: string;
package/utils/timing.js CHANGED
@@ -2,7 +2,7 @@ import { firstValueFrom, map, race, timer } from 'rxjs';
2
2
  import { TimeoutError } from '../errors/timeout.error.js';
3
3
  import { _throw } from './throw.js';
4
4
  import { resolveValueOrProvider } from './value-or-provider.js';
5
- /** timeout for specified duration */
5
+ /** Timeout for specified duration */
6
6
  export async function timeout(milliseconds = 0, options) {
7
7
  return new Promise((resolve) => {
8
8
  const abortListener = () => clearTimeout(timeoutRef);
@@ -13,19 +13,19 @@ export async function timeout(milliseconds = 0, options) {
13
13
  options?.abortSignal?.addEventListener('abort', abortListener);
14
14
  });
15
15
  }
16
- /** timeout until specified time */
16
+ /** Timeout until specified time */
17
17
  export async function timeoutUntil(timestamp) {
18
18
  const left = timestamp.valueOf() - Date.now();
19
19
  return timeout(left);
20
20
  }
21
- /** timeout for specified duration */
21
+ /** Timeout for specified duration */
22
22
  export async function cancelableTimeout(milliseconds, cancelSignal) {
23
23
  return firstValueFrom(race([
24
24
  timer(milliseconds).pipe(map(() => false)), // eslint-disable-line @typescript-eslint/no-unsafe-argument
25
25
  cancelSignal.set$.pipe(map(() => true)) // eslint-disable-line @typescript-eslint/no-unsafe-argument
26
26
  ]));
27
27
  }
28
- /** timeout until specified time */
28
+ /** Timeout until specified time */
29
29
  export async function cancelableTimeoutUntil(timestamp, cancelSignal) {
30
30
  const left = timestamp.valueOf() - Date.now();
31
31
  return cancelableTimeout(left, cancelSignal);
@@ -1,4 +1,4 @@
1
- /* eslint-disable @typescript-eslint/ban-types, @typescript-eslint/restrict-template-expressions, max-statements-per-line, no-eq-null */
1
+ /* eslint-disable max-lines, @typescript-eslint/ban-types, @typescript-eslint/no-invalid-void-type, @typescript-eslint/restrict-template-expressions, max-statements-per-line, no-eq-null */
2
2
  import { supportsBlob, supportsReadableStream } from '../supports.js';
3
3
  import { AssertionError } from '../errors/assertion.error.js';
4
4
  export function assert(condition, message = 'assertion failed') {
@@ -1,5 +1,6 @@
1
+ export type TypeOfTypes = 'string' | 'number' | 'bigint' | 'boolean' | 'symbol' | 'undefined' | 'object' | 'null' | `[class ${string}]` | `[function ${string}]` | `[instanceof ${string}]`;
1
2
  /**
2
- * get the type of value. Returns 'null' instead of 'object' for null, tries to distinguish between function and class and to get their names
3
+ * Get the type of value. Returns 'null' instead of 'object' for null, tries to distinguish between function and class and to get their names
3
4
  * @param value value to get type of
4
5
  */
5
- export declare function typeOf(value: any): 'string' | 'number' | 'bigint' | 'boolean' | 'symbol' | 'undefined' | 'object' | 'null' | `[class ${string}]` | `[function ${string}]` | `[instanceof ${string}]`;
6
+ export declare function typeOf(value: unknown): TypeOfTypes;
package/utils/type-of.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /* eslint-disable @typescript-eslint/ban-types */
2
2
  import { isNull } from './type-guards.js';
3
3
  /**
4
- * get the type of value. Returns 'null' instead of 'object' for null, tries to distinguish between function and class and to get their names
4
+ * Get the type of value. Returns 'null' instead of 'object' for null, tries to distinguish between function and class and to get their names
5
5
  * @param value value to get type of
6
6
  */
7
7
  export function typeOf(value) {
package/utils/units.js CHANGED
@@ -1,4 +1,5 @@
1
- /* data sizes */
1
+ /* eslint-disable @typescript-eslint/no-magic-numbers */
2
+ /* Data sizes */
2
3
  export const kilobyte = 1000;
3
4
  export const megabyte = 1000 * kilobyte;
4
5
  export const gigabyte = 1000 * megabyte;
@@ -15,7 +16,7 @@ export const pebibyte = 1024 * tebibyte;
15
16
  export const exbibyte = 1024 * pebibyte;
16
17
  export const zebibyte = 1024 * exbibyte;
17
18
  export const yobibyte = 1024 * zebibyte;
18
- /* durations */
19
+ /* Durations */
19
20
  export const nanosecondsPerMicrosecond = 1000;
20
21
  export const nanosecondsPerMillisecond = 1000 * nanosecondsPerMicrosecond;
21
22
  export const nanosecondsPerSecond = 1000 * nanosecondsPerMillisecond;
@@ -6,9 +6,8 @@ var UrlBuilderPartType;
6
6
  UrlBuilderPartType[UrlBuilderPartType["Literal"] = 0] = "Literal";
7
7
  UrlBuilderPartType[UrlBuilderPartType["Parameter"] = 1] = "Parameter";
8
8
  })(UrlBuilderPartType || (UrlBuilderPartType = {}));
9
- const urlParseRegex = /([^:]+|:\/+)|:([\w-]+)/ug;
9
+ const urlParseRegex = /(?<literal>[^:]+|:\/+)|:(?<parameter>[\w-]+)/ug;
10
10
  const isFullUrlRegex = /^\w+:\/\//u;
11
- // eslint-disable-next-line max-lines-per-function
12
11
  export function compileUrlBuilder(url) {
13
12
  const parts = [];
14
13
  const isFullUrl = isFullUrlRegex.test(url);
@@ -19,7 +18,8 @@ export function compileUrlBuilder(url) {
19
18
  parseUrl = url.slice(origin.length);
20
19
  }
21
20
  const matches = parseUrl.matchAll(urlParseRegex);
22
- for (const [, literal, parameter] of matches) {
21
+ for (const { groups } of matches) {
22
+ const { literal, parameter } = groups;
23
23
  if (isDefined(literal)) {
24
24
  parts.push({ type: UrlBuilderPartType.Literal, value: literal });
25
25
  }
@@ -18,5 +18,5 @@ export function cacheAsyncValueOrProvider(provider) {
18
18
  void valuePromise.then((resolvedValue) => (getValue = () => resolvedValue));
19
19
  return valuePromise;
20
20
  };
21
- return () => getValue(); // eslint-disable-line @typescript-eslint/promise-function-async
21
+ return async () => getValue();
22
22
  }
package/utils/z-base32.js CHANGED
@@ -1,9 +1,8 @@
1
- /* eslint-disable no-bitwise, @typescript-eslint/no-magic-numbers */
1
+ /* eslint-disable @typescript-eslint/no-magic-numbers */
2
2
  import { Alphabet } from './alphabet.js';
3
3
  import { toUint8Array } from './binary.js';
4
4
  const alphabet = Alphabet.ZBase32;
5
5
  const charValueMap = new Map(alphabet.split('').map((char, index) => [char, index]));
6
- // eslint-disable-next-line max-statements
7
6
  export function zBase32Encode(buffer) {
8
7
  const byteView = toUint8Array(buffer);
9
8
  let result = '';
@@ -23,7 +22,6 @@ export function zBase32Encode(buffer) {
23
22
  }
24
23
  return result;
25
24
  }
26
- // eslint-disable-next-line max-statements
27
25
  export function zBase32Decode(input) {
28
26
  const bytes = new Uint8Array((input.length * 5 / 8) | 0);
29
27
  let bits = 0;
package/web-types.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export type InputType = 'checkbox' | 'color' | 'date' | 'datetime-local' | 'email' | 'file' | 'image' | 'month' | 'number' | 'password' | 'radio' | 'range' | 'search' | 'tel' | 'text' | 'time' | 'url' | 'week';
2
- export type InputMode = 'none' | 'text' | 'decimal' | 'numeric' | 'tel' | 'search' | 'email' | 'url';
2
+ export type InputMode = 'decimal' | 'email' | 'none' | 'numeric' | 'search' | 'tel' | 'text' | 'url';
3
3
  export type InputAutocomplete = 'off' | 'on' | 'name' | 'honorific-prefix' | 'given-name' | 'additional-name' | 'family-name' | 'honorific-suffix' | 'nickname' | 'email' | 'username' | 'new-password' | 'current-password' | 'one-time-code' | 'organization-title' | 'organization' | 'street-address' | 'address-line1' | 'address-line2' | 'address-line3' | 'address-level4' | 'address-level3' | 'address-level2' | 'address-level1' | 'country' | 'country-name' | 'postal-code' | 'cc-name' | 'cc-given-name' | 'cc-additional-name' | 'cc-family-name' | 'cc-number' | 'cc-exp' | 'cc-exp-month' | 'cc-exp-year' | 'cc-csc' | 'cc-type' | 'transaction-currency' | 'transaction-amount' | 'language' | 'bday' | 'bday-day' | 'bday-month' | 'bday-year' | 'sex' | 'tel' | 'tel-country-code' | 'tel-national' | 'tel-area-code' | 'tel-local' | 'tel-extension' | 'impp' | 'url' | 'photo';
4
4
  export type InputAttributes = {
5
5
  accept?: string;