@tstdl/base 0.93.72 → 0.93.74

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.
@@ -1,16 +1,18 @@
1
- export declare enum PdfFormat {
2
- Letter = "letter",
3
- Legal = "legal",
4
- Tabloid = "tabloid",
5
- Ledger = "ledger",
6
- A0 = "a0",
7
- A1 = "a1",
8
- A2 = "a2",
9
- A3 = "a3",
10
- A4 = "a4",
11
- A5 = "a5",
12
- A6 = "a6"
13
- }
1
+ import { type EnumType } from '../enumeration/enumeration.js';
2
+ export declare const PdfFormat: {
3
+ readonly Letter: "letter";
4
+ readonly Legal: "legal";
5
+ readonly Tabloid: "tabloid";
6
+ readonly Ledger: "ledger";
7
+ readonly A0: "a0";
8
+ readonly A1: "a1";
9
+ readonly A2: "a2";
10
+ readonly A3: "a3";
11
+ readonly A4: "a4";
12
+ readonly A5: "a5";
13
+ readonly A6: "a6";
14
+ };
15
+ export type PdfFormat = EnumType<typeof PdfFormat>;
14
16
  export declare class PdfMarginObject {
15
17
  top?: number | string;
16
18
  bottom?: number | string;
@@ -7,21 +7,21 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
7
7
  var __metadata = (this && this.__metadata) || function (k, v) {
8
8
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
9
  };
10
+ import { defineEnum } from '../enumeration/enumeration.js';
10
11
  import { Enumeration, Optional, Union } from '../schema/index.js';
11
- export var PdfFormat;
12
- (function (PdfFormat) {
13
- PdfFormat["Letter"] = "letter";
14
- PdfFormat["Legal"] = "legal";
15
- PdfFormat["Tabloid"] = "tabloid";
16
- PdfFormat["Ledger"] = "ledger";
17
- PdfFormat["A0"] = "a0";
18
- PdfFormat["A1"] = "a1";
19
- PdfFormat["A2"] = "a2";
20
- PdfFormat["A3"] = "a3";
21
- PdfFormat["A4"] = "a4";
22
- PdfFormat["A5"] = "a5";
23
- PdfFormat["A6"] = "a6";
24
- })(PdfFormat || (PdfFormat = {}));
12
+ export const PdfFormat = defineEnum('PdfFormat', {
13
+ Letter: 'letter',
14
+ Legal: 'legal',
15
+ Tabloid: 'tabloid',
16
+ Ledger: 'ledger',
17
+ A0: 'a0',
18
+ A1: 'a1',
19
+ A2: 'a2',
20
+ A3: 'a3',
21
+ A4: 'a4',
22
+ A5: 'a5',
23
+ A6: 'a6',
24
+ });
25
25
  export class PdfMarginObject {
26
26
  top;
27
27
  bottom;
@@ -4,7 +4,6 @@
4
4
  * @module Collections
5
5
  */
6
6
  export * from './collection.js';
7
- export * from './keyed-set.js';
8
7
  export * from './list.js';
9
8
  export * from './sorted-array-list.js';
10
9
  export * from './sorted-list.js';
@@ -4,7 +4,6 @@
4
4
  * @module Collections
5
5
  */
6
6
  export * from './collection.js';
7
- export * from './keyed-set.js';
8
7
  export * from './list.js';
9
8
  export * from './sorted-array-list.js';
10
9
  export * from './sorted-list.js';
@@ -1,19 +1,21 @@
1
+ import { type EnumType } from '../enumeration/enumeration.js';
1
2
  import type { TypedOmit, UndefinableJson } from '../types/index.js';
2
3
  import type { ErrorExtraInfo } from '../utils/format-error.js';
3
4
  import { CustomError } from '../errors/custom.error.js';
4
5
  import type { HttpClientRequest, HttpClientRequestObject, HttpClientResponse, HttpClientResponseObject } from './client/index.js';
5
- export declare enum HttpErrorReason {
6
- Unknown = "Unknown",
7
- Cancelled = "Cancelled",
8
- Network = "Network",
9
- InvalidRequest = "InvalidRequest",
10
- StatusCode = "StatusCode",
6
+ export declare const HttpErrorReason: {
7
+ readonly Unknown: "Unknown";
8
+ readonly Cancelled: "Cancelled";
9
+ readonly Network: "Network";
10
+ readonly InvalidRequest: "InvalidRequest";
11
+ readonly StatusCode: "StatusCode";
11
12
  /** Valid http response containing an error */
12
- ErrorResponse = "ErrorResponse",
13
+ readonly ErrorResponse: "ErrorResponse";
13
14
  /** Invalid http response */
14
- ResponseError = "ResponseError",
15
- Timeout = "Timeout"
16
- }
15
+ readonly ResponseError: "ResponseError";
16
+ readonly Timeout: "Timeout";
17
+ };
18
+ export type HttpErrorReason = EnumType<typeof HttpErrorReason>;
17
19
  export declare class HttpError extends CustomError implements ErrorExtraInfo {
18
20
  static readonly errorName = "HttpError";
19
21
  readonly reason: HttpErrorReason;
@@ -1,19 +1,19 @@
1
+ import { defineEnum } from '../enumeration/enumeration.js';
1
2
  import { propertyNameOf } from '../utils/object/property-name.js';
2
3
  import { isDefined, isNotString, isString } from '../utils/type-guards.js';
3
4
  import { CustomError } from '../errors/custom.error.js';
4
- export var HttpErrorReason;
5
- (function (HttpErrorReason) {
6
- HttpErrorReason["Unknown"] = "Unknown";
7
- HttpErrorReason["Cancelled"] = "Cancelled";
8
- HttpErrorReason["Network"] = "Network";
9
- HttpErrorReason["InvalidRequest"] = "InvalidRequest";
10
- HttpErrorReason["StatusCode"] = "StatusCode";
5
+ export const HttpErrorReason = defineEnum('HttpErrorReason', {
6
+ Unknown: 'Unknown',
7
+ Cancelled: 'Cancelled',
8
+ Network: 'Network',
9
+ InvalidRequest: 'InvalidRequest',
10
+ StatusCode: 'StatusCode',
11
11
  /** Valid http response containing an error */
12
- HttpErrorReason["ErrorResponse"] = "ErrorResponse";
12
+ ErrorResponse: 'ErrorResponse',
13
13
  /** Invalid http response */
14
- HttpErrorReason["ResponseError"] = "ResponseError";
15
- HttpErrorReason["Timeout"] = "Timeout";
16
- })(HttpErrorReason || (HttpErrorReason = {}));
14
+ ResponseError: 'ResponseError',
15
+ Timeout: 'Timeout',
16
+ });
17
17
  export class HttpError extends CustomError {
18
18
  static errorName = 'HttpError';
19
19
  reason;
@@ -1,26 +1,30 @@
1
- export declare enum ImageResizeMode {
2
- Fit = "fit",
3
- Fill = "fill"
4
- }
5
- export declare enum ImageFormat {
6
- Png = "png",
7
- Jpg = "jpg",
8
- Jpeg = "jpeg",
9
- Webp = "webp",
10
- Avif = "avif"
11
- }
12
- export declare enum ImageOrigin {
13
- Center = "center",
14
- Smart = "smart",
15
- Top = "top",
16
- Left = "left",
17
- Right = "right",
18
- Bottom = "bottom",
19
- TopLeft = "topleft",
20
- TopRight = "topright",
21
- BottomLeft = "bottomleft",
22
- BottomRight = "bottomright"
23
- }
1
+ import { type EnumType } from '../enumeration/enumeration.js';
2
+ export declare const ImageResizeMode: {
3
+ readonly Fit: "fit";
4
+ readonly Fill: "fill";
5
+ };
6
+ export type ImageResizeMode = EnumType<typeof ImageResizeMode>;
7
+ export declare const ImageFormat: {
8
+ readonly Png: "png";
9
+ readonly Jpg: "jpg";
10
+ readonly Jpeg: "jpeg";
11
+ readonly Webp: "webp";
12
+ readonly Avif: "avif";
13
+ };
14
+ export type ImageFormat = EnumType<typeof ImageFormat>;
15
+ export declare const ImageOrigin: {
16
+ readonly Center: "center";
17
+ readonly Smart: "smart";
18
+ readonly Top: "top";
19
+ readonly Left: "left";
20
+ readonly Right: "right";
21
+ readonly Bottom: "bottom";
22
+ readonly TopLeft: "topleft";
23
+ readonly TopRight: "topright";
24
+ readonly BottomLeft: "bottomleft";
25
+ readonly BottomRight: "bottomright";
26
+ };
27
+ export type ImageOrigin = EnumType<typeof ImageOrigin>;
24
28
  export declare class ImageOptions {
25
29
  resizeMode?: ImageResizeMode;
26
30
  width?: number;
@@ -7,33 +7,31 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
7
7
  var __metadata = (this && this.__metadata) || function (k, v) {
8
8
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
9
  };
10
+ import { defineEnum } from '../enumeration/enumeration.js';
10
11
  import { Enumeration, NumberProperty, Optional } from '../schema/index.js';
11
- export var ImageResizeMode;
12
- (function (ImageResizeMode) {
13
- ImageResizeMode["Fit"] = "fit";
14
- ImageResizeMode["Fill"] = "fill";
15
- })(ImageResizeMode || (ImageResizeMode = {}));
16
- export var ImageFormat;
17
- (function (ImageFormat) {
18
- ImageFormat["Png"] = "png";
19
- ImageFormat["Jpg"] = "jpg";
20
- ImageFormat["Jpeg"] = "jpeg";
21
- ImageFormat["Webp"] = "webp";
22
- ImageFormat["Avif"] = "avif";
23
- })(ImageFormat || (ImageFormat = {}));
24
- export var ImageOrigin;
25
- (function (ImageOrigin) {
26
- ImageOrigin["Center"] = "center";
27
- ImageOrigin["Smart"] = "smart";
28
- ImageOrigin["Top"] = "top";
29
- ImageOrigin["Left"] = "left";
30
- ImageOrigin["Right"] = "right";
31
- ImageOrigin["Bottom"] = "bottom";
32
- ImageOrigin["TopLeft"] = "topleft";
33
- ImageOrigin["TopRight"] = "topright";
34
- ImageOrigin["BottomLeft"] = "bottomleft";
35
- ImageOrigin["BottomRight"] = "bottomright";
36
- })(ImageOrigin || (ImageOrigin = {}));
12
+ export const ImageResizeMode = defineEnum('ImageResizeMode', {
13
+ Fit: 'fit',
14
+ Fill: 'fill',
15
+ });
16
+ export const ImageFormat = defineEnum('ImageFormat', {
17
+ Png: 'png',
18
+ Jpg: 'jpg',
19
+ Jpeg: 'jpeg',
20
+ Webp: 'webp',
21
+ Avif: 'avif',
22
+ });
23
+ export const ImageOrigin = defineEnum('ImageOrigin', {
24
+ Center: 'center',
25
+ Smart: 'smart',
26
+ Top: 'top',
27
+ Left: 'left',
28
+ Right: 'right',
29
+ Bottom: 'bottom',
30
+ TopLeft: 'topleft',
31
+ TopRight: 'topright',
32
+ BottomLeft: 'bottomleft',
33
+ BottomRight: 'bottomright',
34
+ });
37
35
  export class ImageOptions {
38
36
  resizeMode;
39
37
  width;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tstdl/base",
3
- "version": "0.93.72",
3
+ "version": "0.93.74",
4
4
  "author": "Patrick Hein",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -140,7 +140,7 @@
140
140
  "type-fest": "^5.3"
141
141
  },
142
142
  "peerDependencies": {
143
- "@genkit-ai/google-genai": "^1.26",
143
+ "@genkit-ai/google-genai": "^1.27",
144
144
  "@google-cloud/storage": "^7.18",
145
145
  "@google/genai": "^1.34",
146
146
  "@toon-format/toon": "^2.1.0",
@@ -151,7 +151,7 @@
151
151
  "@zxcvbn-ts/language-en": "^3.0",
152
152
  "drizzle-orm": "^0.45",
153
153
  "file-type": "^21.1",
154
- "genkit": "^1.26",
154
+ "genkit": "^1.27",
155
155
  "handlebars": "^4.7",
156
156
  "minio": "^8.0",
157
157
  "mjml": "^4.18",
@@ -187,7 +187,7 @@
187
187
  "typedoc-plugin-markdown": "4.9",
188
188
  "typedoc-plugin-missing-exports": "4.1",
189
189
  "typescript": "5.9",
190
- "typescript-eslint": "8.49"
190
+ "typescript-eslint": "8.50"
191
191
  },
192
192
  "overrides": {
193
193
  "drizzle-kit": {
@@ -1,9 +1,11 @@
1
+ import { type EnumType } from '../enumeration/enumeration.js';
1
2
  import type { PromiseExecutor } from './types.js';
2
- export declare const enum PromiseState {
3
- Pending = 0,
4
- Resolved = 1,
5
- Rejected = 2
6
- }
3
+ export declare const PromiseState: {
4
+ readonly Pending: 0;
5
+ readonly Resolved: 1;
6
+ readonly Rejected: 2;
7
+ };
8
+ export type PromiseState = EnumType<typeof PromiseState>;
7
9
  export declare class DeferredPromise<T = void> extends Promise<T> {
8
10
  private backingPromise;
9
11
  private resolvePromise;
@@ -1,9 +1,9 @@
1
- export var PromiseState;
2
- (function (PromiseState) {
3
- PromiseState[PromiseState["Pending"] = 0] = "Pending";
4
- PromiseState[PromiseState["Resolved"] = 1] = "Resolved";
5
- PromiseState[PromiseState["Rejected"] = 2] = "Rejected";
6
- })(PromiseState || (PromiseState = {}));
1
+ import { defineEnum } from '../enumeration/enumeration.js';
2
+ export const PromiseState = defineEnum('PromiseState', {
3
+ Pending: 0,
4
+ Resolved: 1,
5
+ Rejected: 2,
6
+ });
7
7
  export class DeferredPromise extends Promise {
8
8
  backingPromise;
9
9
  resolvePromise;
@@ -3,6 +3,7 @@ import { registerFinalization } from '../../memory/finalization.js';
3
3
  import { assertNotInReactiveContext } from './asserts.js';
4
4
  import { computed } from './computed.js';
5
5
  import { signal } from './writable-signal.js';
6
+ import { defineEnum } from '../../enumeration/enumeration.js';
6
7
  /**
7
8
  * Get the current value of an `Observable` as a reactive `Signal`.
8
9
  *
@@ -72,9 +73,8 @@ export function toSignal(source, options) {
72
73
  function makeToSignalEqual(userEquality = Object.is) {
73
74
  return (a, b) => a.kind === StateKind.Value && b.kind === StateKind.Value && userEquality(a.value, b.value);
74
75
  }
75
- var StateKind;
76
- (function (StateKind) {
77
- StateKind[StateKind["NoValue"] = 0] = "NoValue";
78
- StateKind[StateKind["Value"] = 1] = "Value";
79
- StateKind[StateKind["Error"] = 2] = "Error";
80
- })(StateKind || (StateKind = {}));
76
+ const StateKind = defineEnum('StateKind', {
77
+ NoValue: 0,
78
+ Value: 1,
79
+ Error: 2,
80
+ });
@@ -1,21 +1,17 @@
1
+ import { type EnumType } from '../enumeration/enumeration.js';
1
2
  import { type Observable } from 'rxjs';
2
3
  /**
3
4
  * Represents the possible states of a Server-Sent Events connection.
4
5
  */
5
- export declare enum ServerSentEventsState {
6
- /**
7
- * The connection is currently being established.
8
- */
9
- Connecting = 0,
10
- /**
11
- * The connection is open and ready to receive events.
12
- */
13
- Open = 1,
14
- /**
15
- * The connection is closed.
16
- */
17
- Closed = 2
18
- }
6
+ export declare const ServerSentEventsState: {
7
+ /** The connection is currently being established. */
8
+ readonly Connecting: 0;
9
+ /** The connection is open and ready to receive events. */
10
+ readonly Open: 1;
11
+ /** The connection is closed. */
12
+ readonly Closed: 2;
13
+ };
14
+ export type ServerSentEventsState = EnumType<typeof ServerSentEventsState>;
19
15
  /**
20
16
  * A wrapper around the EventSource API, providing an RxJS-friendly interface for Server-Sent Events.
21
17
  */
@@ -1,23 +1,17 @@
1
+ import { defineEnum } from '../enumeration/enumeration.js';
1
2
  import { NotSupportedError } from '../errors/not-supported.error.js';
2
3
  import { ReplaySubject, distinctUntilChanged, filter, fromEvent, map, merge, share, shareReplay, startWith, takeUntil } from 'rxjs';
3
4
  /**
4
5
  * Represents the possible states of a Server-Sent Events connection.
5
6
  */
6
- export var ServerSentEventsState;
7
- (function (ServerSentEventsState) {
8
- /**
9
- * The connection is currently being established.
10
- */
11
- ServerSentEventsState[ServerSentEventsState["Connecting"] = 0] = "Connecting";
12
- /**
13
- * The connection is open and ready to receive events.
14
- */
15
- ServerSentEventsState[ServerSentEventsState["Open"] = 1] = "Open";
16
- /**
17
- * The connection is closed.
18
- */
19
- ServerSentEventsState[ServerSentEventsState["Closed"] = 2] = "Closed";
20
- })(ServerSentEventsState || (ServerSentEventsState = {}));
7
+ export const ServerSentEventsState = defineEnum('ServerSentEventsState', {
8
+ /** The connection is currently being established. */
9
+ Connecting: 0,
10
+ /** The connection is open and ready to receive events. */
11
+ Open: 1,
12
+ /** The connection is closed. */
13
+ Closed: 2,
14
+ });
21
15
  /**
22
16
  * A wrapper around the EventSource API, providing an RxJS-friendly interface for Server-Sent Events.
23
17
  */
package/types/types.d.ts CHANGED
@@ -190,11 +190,9 @@ export type DeepFlatten<T> = T extends readonly (infer R)[] ? DeepFlatten<R> : T
190
190
  [P in keyof T]: DeepFlatten<T[P]>;
191
191
  } : T;
192
192
  export type DeepArray<T> = (T | DeepArray<T>)[];
193
- export type DeepReadonly<T> = T extends BuiltIn ? T : T extends (any[] | readonly any[]) ? DeepReadonlyArray<T[number]> : DeepReadonlyObject<T>;
194
- export type DeepReadonlyObject<T> = {
193
+ export type DeepReadonly<T> = T extends BuiltIn ? T : {
195
194
  readonly [P in keyof T]: DeepReadonly<T[P]>;
196
195
  };
197
- export type DeepReadonlyArray<T> = readonly DeepReadonly<T>[];
198
196
  export type ReplaceKey<T, K extends keyof T, U> = SimplifyObject<{
199
197
  [P in keyof T]: P extends K ? U : T[P];
200
198
  }>;
@@ -1,12 +1,14 @@
1
- export declare enum Alphabet {
2
- LowerCase = "abcdefghijklmnopqrstuvwxyz",
3
- UpperCase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
4
- Numbers = "0123456789",
5
- LowerUpperCase = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",
6
- LowerCaseNumbers = "abcdefghijklmnopqrstuvwxyz0123456789",
7
- UpperCaseNumbers = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",
8
- LowerUpperCaseNumbers = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",
9
- ZBase32 = "ybndrfg8ejkmcpqxot1uwisza345h769",
10
- LowerCaseHex = "0123456789abcdef",
11
- UpperCaseHex = "0123456789ABCDEF"
12
- }
1
+ import { type EnumType } from '../enumeration/enumeration.js';
2
+ export declare const Alphabet: {
3
+ readonly LowerCase: "abcdefghijklmnopqrstuvwxyz";
4
+ readonly UpperCase: "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
5
+ readonly Numbers: "0123456789";
6
+ readonly LowerUpperCase: "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
7
+ readonly LowerCaseNumbers: "abcdefghijklmnopqrstuvwxyz0123456789";
8
+ readonly UpperCaseNumbers: "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
9
+ readonly LowerUpperCaseNumbers: "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
10
+ readonly ZBase32: "ybndrfg8ejkmcpqxot1uwisza345h769";
11
+ readonly LowerCaseHex: "0123456789abcdef";
12
+ readonly UpperCaseHex: "0123456789ABCDEF";
13
+ };
14
+ export type Alphabet = EnumType<typeof Alphabet>;
package/utils/alphabet.js CHANGED
@@ -1,13 +1,13 @@
1
- export var Alphabet;
2
- (function (Alphabet) {
3
- Alphabet["LowerCase"] = "abcdefghijklmnopqrstuvwxyz";
4
- Alphabet["UpperCase"] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
5
- Alphabet["Numbers"] = "0123456789";
6
- Alphabet["LowerUpperCase"] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
7
- Alphabet["LowerCaseNumbers"] = "abcdefghijklmnopqrstuvwxyz0123456789";
8
- Alphabet["UpperCaseNumbers"] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
9
- Alphabet["LowerUpperCaseNumbers"] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
10
- Alphabet["ZBase32"] = "ybndrfg8ejkmcpqxot1uwisza345h769";
11
- Alphabet["LowerCaseHex"] = "0123456789abcdef";
12
- Alphabet["UpperCaseHex"] = "0123456789ABCDEF";
13
- })(Alphabet || (Alphabet = {}));
1
+ import { defineEnum } from '../enumeration/enumeration.js';
2
+ export const Alphabet = defineEnum('Alphabet', {
3
+ LowerCase: 'abcdefghijklmnopqrstuvwxyz',
4
+ UpperCase: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
5
+ Numbers: '0123456789',
6
+ LowerUpperCase: 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
7
+ LowerCaseNumbers: 'abcdefghijklmnopqrstuvwxyz0123456789',
8
+ UpperCaseNumbers: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789',
9
+ LowerUpperCaseNumbers: 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789',
10
+ ZBase32: 'ybndrfg8ejkmcpqxot1uwisza345h769',
11
+ LowerCaseHex: '0123456789abcdef',
12
+ UpperCaseHex: '0123456789ABCDEF',
13
+ });
@@ -1,3 +1,4 @@
1
+ import { type EnumType } from '../enumeration/enumeration.js';
1
2
  import type { Comparator } from './sort.js';
2
3
  export type BinarySearchOptions = {
3
4
  /** minimum index to search at */
@@ -5,6 +6,12 @@ export type BinarySearchOptions = {
5
6
  /** maximum index to search at */
6
7
  max?: number;
7
8
  };
9
+ export declare const Position: {
10
+ readonly Undefined: 0;
11
+ readonly First: 1;
12
+ readonly Last: 2;
13
+ };
14
+ export type Position = EnumType<typeof Position>;
8
15
  export declare function binarySearch<T extends TComparator, TComparator>(values: ArrayLike<T>, searchValue: TComparator, comparator?: Comparator<TComparator>, options?: BinarySearchOptions): number | undefined;
9
16
  export declare function binarySearchFirst<T extends TComparator, TComparator>(values: ArrayLike<T>, searchValue: TComparator, comparator?: Comparator<TComparator>, options?: BinarySearchOptions): number | undefined;
10
17
  export declare function binarySearchLast<T extends TComparator, TComparator>(values: ArrayLike<T>, searchValue: TComparator, comparator?: Comparator<TComparator>, options?: BinarySearchOptions): number | undefined;
@@ -1,10 +1,10 @@
1
+ import { defineEnum } from '../enumeration/enumeration.js';
1
2
  import { compareByValue } from './comparison.js';
2
- var Position;
3
- (function (Position) {
4
- Position[Position["Undefined"] = 0] = "Undefined";
5
- Position[Position["First"] = 1] = "First";
6
- Position[Position["Last"] = 2] = "Last";
7
- })(Position || (Position = {}));
3
+ export const Position = defineEnum('Position', {
4
+ Undefined: 0,
5
+ First: 1,
6
+ Last: 2,
7
+ });
8
8
  export function binarySearch(values, searchValue, comparator = compareByValue, options) {
9
9
  return _binarySearch(values, searchValue, Position.Undefined, comparator, options);
10
10
  }
@@ -1,4 +1,4 @@
1
- import type { DeepArray, Record } from '../types/index.js';
1
+ import type { DeepArray, DeepReadonly, Record } from '../types/index.js';
2
2
  /**
3
3
  * Create an structured clone of an value using Notification if available, otherwise history state (may alters history)
4
4
  *
@@ -17,7 +17,9 @@ export declare function structuredClone<T>(value: T): T;
17
17
  export declare function structuredCloneAsync<T>(value: T, options?: {
18
18
  transfer?: any[];
19
19
  }): Promise<T>;
20
- export declare function valueOfType<T>(value: T): T;
20
+ export declare function valueOfType<const T>(value: T): T;
21
+ export declare function frozenValueOfType<const T>(value: T): Readonly<T>;
22
+ export declare function deepFrozenValueOfType<const T>(value: T): DeepReadonly<T>;
21
23
  export declare function flatten<T>(array: DeepArray<T>): T[];
22
24
  export declare function toError(obj: any): Error;
23
25
  export declare function select<T extends Record, K extends keyof T>(key: K): (item: T) => T[K];
package/utils/helpers.js CHANGED
@@ -1,7 +1,8 @@
1
1
  import { DetailsError } from '../errors/details.error.js';
2
2
  import { supportsNotification } from '../supports.js';
3
3
  import { decycle } from './object/decycle.js';
4
- import { isArray } from './type-guards.js';
4
+ import { mapObjectValues } from './object/object.js';
5
+ import { isArray, isObject } from './type-guards.js';
5
6
  /**
6
7
  * Create an structured clone of an value using Notification if available, otherwise history state (may alters history)
7
8
  *
@@ -35,6 +36,17 @@ export async function structuredCloneAsync(value, options) {
35
36
  export function valueOfType(value) {
36
37
  return value;
37
38
  }
39
+ export function frozenValueOfType(value) {
40
+ return Object.freeze(value);
41
+ }
42
+ export function deepFrozenValueOfType(value) {
43
+ const valueToFreeze = isArray(value)
44
+ ? value.map(deepFrozenValueOfType)
45
+ : isObject(value)
46
+ ? mapObjectValues(value, deepFrozenValueOfType)
47
+ : value;
48
+ return Object.freeze(valueToFreeze);
49
+ }
38
50
  export function flatten(array) {
39
51
  return array.reduce((acc, item) => (isArray(item) ? [...(acc), ...flatten(item)] : [...(acc), item]), []);
40
52
  }
package/utils/index.d.ts CHANGED
@@ -16,7 +16,6 @@ export * from './date-time.js';
16
16
  export * from './encoding.js';
17
17
  export * from './enum.js';
18
18
  export * from './equals.js';
19
- export * from './event-loop.js';
20
19
  export * from './factory-map.js';
21
20
  export * from './feedable-async-iterable.js';
22
21
  export * from './file-reader.js';
@@ -35,8 +34,6 @@ export * from './noop.js';
35
34
  export * from './ordered-feedable-async-iterable.js';
36
35
  export * from './patch-worker.js';
37
36
  export * from './patterns.js';
38
- export * from './periodic-reporter.js';
39
- export * from './periodic-sampler.js';
40
37
  export * from './provider-function-iterable.js';
41
38
  export * from './proxy.js';
42
39
  export * from './random.js';
package/utils/index.js CHANGED
@@ -16,7 +16,6 @@ export * from './date-time.js';
16
16
  export * from './encoding.js';
17
17
  export * from './enum.js';
18
18
  export * from './equals.js';
19
- export * from './event-loop.js';
20
19
  export * from './factory-map.js';
21
20
  export * from './feedable-async-iterable.js';
22
21
  export * from './file-reader.js';
@@ -35,8 +34,6 @@ export * from './noop.js';
35
34
  export * from './ordered-feedable-async-iterable.js';
36
35
  export * from './patch-worker.js';
37
36
  export * from './patterns.js';
38
- export * from './periodic-reporter.js';
39
- export * from './periodic-sampler.js';
40
37
  export * from './provider-function-iterable.js';
41
38
  export * from './proxy.js';
42
39
  export * from './random.js';
@@ -1,15 +1,17 @@
1
- export declare enum MetricAggregation {
2
- Sum = 0,
3
- Mean = 1,
4
- Median = 2,
5
- Minimum = 3,
6
- Maximum = 4,
7
- Count = 5,
8
- Quantile = 6,
9
- Rate = 7,
10
- RateBySum = 8
11
- }
12
- export type MetricAggregationOptions<T extends MetricAggregation> = T extends MetricAggregation.Quantile ? {
1
+ import { type EnumType } from '../enumeration/enumeration.js';
2
+ export declare const MetricAggregation: {
3
+ readonly Sum: "sum";
4
+ readonly Mean: "mean";
5
+ readonly Median: "median";
6
+ readonly Minimum: "minimum";
7
+ readonly Maximum: "maximum";
8
+ readonly Count: "count";
9
+ readonly Quantile: "quantile";
10
+ readonly Rate: "rate";
11
+ readonly RateBySum: "rate-by-sum";
12
+ };
13
+ export type MetricAggregation = EnumType<typeof MetricAggregation>;
14
+ export type MetricAggregationOptions<T extends MetricAggregation> = T extends (typeof MetricAggregation)['Quantile'] ? {
13
15
  scalar: number;
14
16
  } : never;
15
17
  export declare class MovingMetric {
@@ -1,16 +1,16 @@
1
+ import { defineEnum } from '../enumeration/enumeration.js';
1
2
  import { Timer } from './timer.js';
2
- export var MetricAggregation;
3
- (function (MetricAggregation) {
4
- MetricAggregation[MetricAggregation["Sum"] = 0] = "Sum";
5
- MetricAggregation[MetricAggregation["Mean"] = 1] = "Mean";
6
- MetricAggregation[MetricAggregation["Median"] = 2] = "Median";
7
- MetricAggregation[MetricAggregation["Minimum"] = 3] = "Minimum";
8
- MetricAggregation[MetricAggregation["Maximum"] = 4] = "Maximum";
9
- MetricAggregation[MetricAggregation["Count"] = 5] = "Count";
10
- MetricAggregation[MetricAggregation["Quantile"] = 6] = "Quantile";
11
- MetricAggregation[MetricAggregation["Rate"] = 7] = "Rate";
12
- MetricAggregation[MetricAggregation["RateBySum"] = 8] = "RateBySum";
13
- })(MetricAggregation || (MetricAggregation = {}));
3
+ export const MetricAggregation = defineEnum('MetricAggregation', {
4
+ Sum: 'sum',
5
+ Mean: 'mean',
6
+ Median: 'median',
7
+ Minimum: 'minimum',
8
+ Maximum: 'maximum',
9
+ Count: 'count',
10
+ Quantile: 'quantile',
11
+ Rate: 'rate',
12
+ RateBySum: 'rate-by-sum',
13
+ });
14
14
  export class MovingMetric {
15
15
  interval;
16
16
  samples;
@@ -1,4 +1,10 @@
1
+ import { type EnumType } from '../enumeration/index.js';
1
2
  import type { UndefinableJsonObject, UndefinableJsonPrimitive } from '../types/index.js';
3
+ export declare const UrlBuilderPartType: {
4
+ readonly Literal: 0;
5
+ readonly Parameter: 1;
6
+ };
7
+ export type UrlBuilderPartType = EnumType<typeof UrlBuilderPartType>;
2
8
  export type UrlBuilderParameterValue = UndefinableJsonPrimitive;
3
9
  export type UrlBuilderParameters = UndefinableJsonObject;
4
10
  export type UrlBuilderOptions = {
@@ -1,11 +1,11 @@
1
+ import { defineEnum } from '../enumeration/index.js';
1
2
  import { normalizeSingleHttpValue } from '../http/types.js';
2
3
  import { memoizeSingle } from './function/memoize.js';
3
4
  import { isArray, isDefined, isObject, isUndefined } from './type-guards.js';
4
- var UrlBuilderPartType;
5
- (function (UrlBuilderPartType) {
6
- UrlBuilderPartType[UrlBuilderPartType["Literal"] = 0] = "Literal";
7
- UrlBuilderPartType[UrlBuilderPartType["Parameter"] = 1] = "Parameter";
8
- })(UrlBuilderPartType || (UrlBuilderPartType = {}));
5
+ export const UrlBuilderPartType = defineEnum('UrlBuilderPartType', {
6
+ Literal: 0,
7
+ Parameter: 1,
8
+ });
9
9
  const urlParseRegex = /(?<literal>[^:]+|:\/+|:\d[^:]+)|:(?<parameter>[\w-]+)/ug;
10
10
  export function compileUrlBuilder(url) {
11
11
  const parts = [];
@@ -1,29 +0,0 @@
1
- export declare enum KeyedSetMode {
2
- Keep = 0,
3
- Overwrite = 1
4
- }
5
- export type Selector<T> = (value: T) => any;
6
- export declare class KeyedSet<T> implements Set<T> {
7
- private readonly selector;
8
- private readonly mode;
9
- private readonly backingMap;
10
- readonly [Symbol.toStringTag]: 'KeyedSet';
11
- constructor(selector: Selector<T>, mode?: KeyedSetMode);
12
- get size(): number;
13
- add(value: T): this;
14
- clear(): void;
15
- delete(value: T): boolean;
16
- union<U>(_other: ReadonlySetLike<U>): Set<T | U>;
17
- intersection<U>(_other: ReadonlySetLike<U>): Set<T & U>;
18
- difference<U>(_other: ReadonlySetLike<U>): Set<T>;
19
- symmetricDifference<U>(_other: ReadonlySetLike<U>): Set<T | U>;
20
- isSubsetOf(_other: ReadonlySetLike<unknown>): boolean;
21
- isSupersetOf(_other: ReadonlySetLike<unknown>): boolean;
22
- isDisjointFrom(_other: ReadonlySetLike<unknown>): boolean;
23
- forEach(callback: (value: T, value2: T, set: KeyedSet<T>) => void, thisArg?: any): void;
24
- has(value: T): boolean;
25
- [Symbol.iterator](): SetIterator<T>;
26
- entries(): SetIterator<[T, T]>;
27
- keys(): SetIterator<T>;
28
- values(): SetIterator<T>;
29
- }
@@ -1,78 +0,0 @@
1
- import { NotSupportedError } from '../errors/not-supported.error.js';
2
- import { map } from '../utils/iterable-helpers/map.js';
3
- export var KeyedSetMode;
4
- (function (KeyedSetMode) {
5
- KeyedSetMode[KeyedSetMode["Keep"] = 0] = "Keep";
6
- KeyedSetMode[KeyedSetMode["Overwrite"] = 1] = "Overwrite";
7
- })(KeyedSetMode || (KeyedSetMode = {}));
8
- export class KeyedSet {
9
- selector;
10
- mode;
11
- backingMap;
12
- [Symbol.toStringTag];
13
- constructor(selector, mode = KeyedSetMode.Overwrite) {
14
- this.selector = selector;
15
- this.mode = mode;
16
- this[Symbol.toStringTag] = 'KeyedSet';
17
- this.backingMap = new Map();
18
- }
19
- get size() {
20
- return this.backingMap.size;
21
- }
22
- add(value) {
23
- const key = this.selector(value);
24
- if (this.mode == KeyedSetMode.Keep && this.backingMap.has(key)) {
25
- return this;
26
- }
27
- this.backingMap.set(key, value);
28
- return this;
29
- }
30
- clear() {
31
- this.backingMap.clear();
32
- }
33
- delete(value) {
34
- const key = this.selector(value);
35
- return this.backingMap.delete(key);
36
- }
37
- union(_other) {
38
- throw new NotSupportedError();
39
- }
40
- intersection(_other) {
41
- throw new NotSupportedError();
42
- }
43
- difference(_other) {
44
- throw new NotSupportedError();
45
- }
46
- symmetricDifference(_other) {
47
- throw new NotSupportedError();
48
- }
49
- isSubsetOf(_other) {
50
- throw new NotSupportedError();
51
- }
52
- isSupersetOf(_other) {
53
- throw new NotSupportedError();
54
- }
55
- isDisjointFrom(_other) {
56
- throw new NotSupportedError();
57
- }
58
- forEach(callback, thisArg) {
59
- const boundCallback = callback.bind(thisArg);
60
- this.backingMap.forEach((value) => boundCallback(value, value, this));
61
- }
62
- has(value) {
63
- const key = this.selector(value);
64
- return this.backingMap.has(key);
65
- }
66
- [Symbol.iterator]() {
67
- return this.backingMap.values();
68
- }
69
- *entries() {
70
- yield* map(this.backingMap.values(), (value) => [value, value]);
71
- }
72
- keys() {
73
- return this.backingMap.values();
74
- }
75
- values() {
76
- return this.backingMap.values();
77
- }
78
- }
@@ -1,4 +0,0 @@
1
- import type { CancellationSignal } from '../cancellation/token.js';
2
- import type { Logger } from '../logger/index.js';
3
- export declare function measureEventLoopDelay(): Promise<number>;
4
- export declare function runEventLoopWatcher(logger: Logger, cancellationSignal: CancellationSignal): void;
@@ -1,21 +0,0 @@
1
- import { formatDuration } from './format.js';
2
- import { AggregationMode, PeriodicSampler } from './periodic-sampler.js';
3
- import { Timer } from './timer.js';
4
- export async function measureEventLoopDelay() {
5
- return new Promise((resolve) => {
6
- const stopwatch = new Timer();
7
- setImmediate(() => {
8
- stopwatch.start();
9
- // inner setImmediate, to measure an full event-loop-cycle
10
- setImmediate(() => resolve(stopwatch.milliseconds));
11
- });
12
- });
13
- }
14
- export function runEventLoopWatcher(logger, cancellationSignal) {
15
- const sampler = new PeriodicSampler(measureEventLoopDelay, 50);
16
- sampler
17
- .watch(0, 100, AggregationMode.ThirdQuartile)
18
- .subscribe((delay) => logger.debug(`eventloop: ${formatDuration(delay, 2)}`));
19
- sampler.start();
20
- void cancellationSignal.then(async () => sampler.stop());
21
- }
@@ -1,18 +0,0 @@
1
- import { type Observable } from 'rxjs';
2
- export declare class PeriodicReporter {
3
- private readonly reportSubject;
4
- private readonly interval;
5
- private readonly ignoreZero;
6
- private readonly resetAfterReport;
7
- private readonly stopToken;
8
- private readonly stopped;
9
- private running;
10
- private counter;
11
- private stopRequested;
12
- get report(): Observable<number>;
13
- constructor(interval: number, ignoreZero: boolean, resetAfterReport: boolean);
14
- increase(count: number): void;
15
- run(): void;
16
- stop(): Promise<void>;
17
- private emitReport;
18
- }
@@ -1,64 +0,0 @@
1
- import { Subject } from 'rxjs';
2
- import { CancellationToken } from '../cancellation/token.js';
3
- import { DeferredPromise } from '../promise/deferred-promise.js';
4
- import { cancelableTimeout } from './timing.js';
5
- export class PeriodicReporter {
6
- reportSubject;
7
- interval;
8
- ignoreZero;
9
- resetAfterReport;
10
- stopToken;
11
- stopped;
12
- running;
13
- counter;
14
- stopRequested;
15
- get report() {
16
- return this.reportSubject.asObservable();
17
- }
18
- constructor(interval, ignoreZero, resetAfterReport) {
19
- this.interval = interval;
20
- this.ignoreZero = ignoreZero;
21
- this.resetAfterReport = resetAfterReport;
22
- this.running = false;
23
- this.stopToken = new CancellationToken();
24
- this.stopped = new DeferredPromise();
25
- this.reportSubject = new Subject();
26
- }
27
- increase(count) {
28
- this.counter += count;
29
- }
30
- run() {
31
- if (this.running) {
32
- throw new Error('already started');
33
- }
34
- this.running = true;
35
- void (async () => {
36
- this.counter = 0;
37
- this.stopRequested = false;
38
- this.stopToken.unset();
39
- this.stopped.reset();
40
- while (!this.stopRequested) { // eslint-disable-line @typescript-eslint/no-unnecessary-condition
41
- await cancelableTimeout(this.interval, this.stopToken);
42
- if (!this.stopRequested && (!this.ignoreZero || (this.counter > 0))) { // eslint-disable-line @typescript-eslint/no-unnecessary-condition
43
- this.emitReport(this.resetAfterReport);
44
- }
45
- }
46
- this.running = false;
47
- this.stopped.resolve();
48
- })();
49
- }
50
- async stop() {
51
- if (!this.running) {
52
- return;
53
- }
54
- this.stopRequested = true;
55
- this.stopToken.set();
56
- await this.stopped;
57
- }
58
- emitReport(resetAfterReport) {
59
- this.reportSubject.next(this.counter);
60
- if (resetAfterReport) {
61
- this.counter = 0;
62
- }
63
- }
64
- }
@@ -1,22 +0,0 @@
1
- import { type Observable } from 'rxjs';
2
- export declare enum AggregationMode {
3
- Minimum = 0,
4
- Maximum = 1,
5
- Mean = 2,
6
- Median = 3,
7
- FirstQuartile = 4,
8
- ThirdQuartile = 5
9
- }
10
- export type SampleFunction = () => number | Promise<number>;
11
- export declare class PeriodicSampler {
12
- private readonly sampleFunction;
13
- private readonly subject;
14
- private run;
15
- private stopped;
16
- sampleInterval: number;
17
- constructor(sampleFunction: SampleFunction, sampleInterval?: number);
18
- start(): void;
19
- stop(): Promise<void>;
20
- watch(threshold?: number, samples?: number, aggregation?: AggregationMode): Observable<number>;
21
- private runSampleLoop;
22
- }
@@ -1,75 +0,0 @@
1
- import { Subject, bufferCount, filter, map } from 'rxjs';
2
- import { compareByValue } from './comparison.js';
3
- import { average } from './math.js';
4
- import { timeout } from './timing.js';
5
- export var AggregationMode;
6
- (function (AggregationMode) {
7
- AggregationMode[AggregationMode["Minimum"] = 0] = "Minimum";
8
- AggregationMode[AggregationMode["Maximum"] = 1] = "Maximum";
9
- AggregationMode[AggregationMode["Mean"] = 2] = "Mean";
10
- AggregationMode[AggregationMode["Median"] = 3] = "Median";
11
- AggregationMode[AggregationMode["FirstQuartile"] = 4] = "FirstQuartile";
12
- AggregationMode[AggregationMode["ThirdQuartile"] = 5] = "ThirdQuartile";
13
- })(AggregationMode || (AggregationMode = {}));
14
- export class PeriodicSampler {
15
- sampleFunction;
16
- subject;
17
- run;
18
- stopped;
19
- sampleInterval;
20
- constructor(sampleFunction, sampleInterval = 100) {
21
- this.sampleFunction = sampleFunction;
22
- this.sampleInterval = sampleInterval;
23
- this.run = false;
24
- this.subject = new Subject();
25
- }
26
- start() {
27
- if (this.run) {
28
- throw new Error('already started');
29
- }
30
- this.run = true;
31
- this.stopped = this.runSampleLoop();
32
- }
33
- async stop() {
34
- this.run = false;
35
- await this.stopped;
36
- }
37
- watch(threshold = 0, samples = 1, aggregation = AggregationMode.Maximum) {
38
- const observable = this.subject.pipe(bufferCount(samples), map((measures) => aggregate(aggregation, measures)), filter((ms) => ms >= threshold));
39
- return observable;
40
- }
41
- async runSampleLoop() {
42
- while (this.run) {
43
- const delay = await this.sampleFunction();
44
- this.subject.next(delay);
45
- await timeout(this.sampleInterval);
46
- }
47
- }
48
- }
49
- function aggregate(aggregation, values) {
50
- switch (aggregation) {
51
- case AggregationMode.Minimum:
52
- return Math.min(...values);
53
- case AggregationMode.Maximum:
54
- return Math.max(...values);
55
- case AggregationMode.Mean:
56
- return average(values);
57
- case AggregationMode.Median: {
58
- values.sort(compareByValue);
59
- const median = Math.floor(values.length / 2);
60
- return values[median];
61
- }
62
- case AggregationMode.FirstQuartile: {
63
- values.sort(compareByValue);
64
- const firstQuartile = Math.floor(values.length / 4 * 1);
65
- return values[firstQuartile];
66
- }
67
- case AggregationMode.ThirdQuartile: {
68
- values.sort(compareByValue);
69
- const thirdQuartile = Math.floor(values.length / 4 * 3);
70
- return values[thirdQuartile];
71
- }
72
- default:
73
- throw new Error(`aggregation mode ${aggregation} not implemented`);
74
- }
75
- }