@axi-engine/utils 0.2.0 → 0.2.2

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 (51) hide show
  1. package/dist/index.d.mts +35 -1
  2. package/dist/index.d.ts +327 -12
  3. package/dist/index.js +296 -12
  4. package/dist/index.mjs +9 -0
  5. package/package.json +1 -1
  6. package/dist/arrays.d.ts +0 -72
  7. package/dist/arrays.d.ts.map +0 -1
  8. package/dist/arrays.js +0 -115
  9. package/dist/arrays.js.map +0 -1
  10. package/dist/assertion.d.ts +0 -31
  11. package/dist/assertion.d.ts.map +0 -1
  12. package/dist/assertion.js +0 -41
  13. package/dist/assertion.js.map +0 -1
  14. package/dist/config.d.ts +0 -10
  15. package/dist/config.d.ts.map +0 -1
  16. package/dist/config.js +0 -12
  17. package/dist/config.js.map +0 -1
  18. package/dist/constructor-registry.d.ts +0 -40
  19. package/dist/constructor-registry.d.ts.map +0 -1
  20. package/dist/constructor-registry.js +0 -52
  21. package/dist/constructor-registry.js.map +0 -1
  22. package/dist/emitter.d.ts +0 -32
  23. package/dist/emitter.d.ts.map +0 -1
  24. package/dist/emitter.js +0 -43
  25. package/dist/emitter.js.map +0 -1
  26. package/dist/guards.d.ts +0 -12
  27. package/dist/guards.d.ts.map +0 -1
  28. package/dist/guards.js +0 -24
  29. package/dist/guards.js.map +0 -1
  30. package/dist/index.d.ts.map +0 -1
  31. package/dist/index.js.map +0 -1
  32. package/dist/math.d.ts +0 -17
  33. package/dist/math.d.ts.map +0 -1
  34. package/dist/math.js +0 -26
  35. package/dist/math.js.map +0 -1
  36. package/dist/misc.d.ts +0 -7
  37. package/dist/misc.d.ts.map +0 -1
  38. package/dist/misc.js +0 -9
  39. package/dist/misc.js.map +0 -1
  40. package/dist/path.d.ts +0 -10
  41. package/dist/path.d.ts.map +0 -1
  42. package/dist/path.js +0 -14
  43. package/dist/path.js.map +0 -1
  44. package/dist/random.d.ts +0 -14
  45. package/dist/random.d.ts.map +0 -1
  46. package/dist/random.js +0 -21
  47. package/dist/random.js.map +0 -1
  48. package/dist/types.d.ts +0 -50
  49. package/dist/types.d.ts.map +0 -1
  50. package/dist/types.js +0 -2
  51. package/dist/types.js.map +0 -1
@@ -1,40 +0,0 @@
1
- import { Constructor } from './types';
2
- /**
3
- * A generic registry for mapping string identifiers to class constructors.
4
- *
5
- * This utility is fundamental for building extensible systems like dependency injection containers,
6
- * factories, and serialization engines where types need to be dynamically resolved.
7
- *
8
- * @template T - A base type that all registered constructors must produce an instance of.
9
- */
10
- export declare class ConstructorRegistry<T> {
11
- private readonly items;
12
- /**
13
- * Registers a constructor with a unique string identifier.
14
- *
15
- * @param typeId - The unique identifier for the constructor (e.g., a static `typeName` property from a class).
16
- * @param ctor - The class constructor to register.
17
- * @returns The registry instance for chainable calls.
18
- * @throws If a constructor with the same `typeId` is already registered.
19
- */
20
- register(typeId: string, ctor: Constructor<T>): this;
21
- /**
22
- * Retrieves a constructor by its identifier.
23
- *
24
- * @param typeId - The identifier of the constructor to retrieve.
25
- * @returns The found class constructor.
26
- * @throws If no constructor is found for the given `typeId`.
27
- */
28
- get(typeId: string): Constructor<T>;
29
- /**
30
- * Checks if a constructor for a given identifier is registered.
31
- * @param typeId - The identifier to check.
32
- * @returns `true` if a constructor is registered, otherwise `false`.
33
- */
34
- has(typeId: string): boolean;
35
- /**
36
- * Clears all registered constructors from the registry.
37
- */
38
- clear(): void;
39
- }
40
- //# sourceMappingURL=constructor-registry.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constructor-registry.d.ts","sourceRoot":"","sources":["../src/constructor-registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,SAAS,CAAC;AAGpC;;;;;;;GAOG;AACH,qBAAa,mBAAmB,CAAC,CAAC;IAChC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAqC;IAE3D;;;;;;;OAOG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,IAAI;IAMpD;;;;;;OAMG;IACH,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,CAAC,CAAC,CAAC;IAMnC;;;;OAIG;IACH,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;IAI5B;;OAEG;IACH,KAAK,IAAI,IAAI;CAGd"}
@@ -1,52 +0,0 @@
1
- import { throwIf, throwIfEmpty } from './assertion';
2
- /**
3
- * A generic registry for mapping string identifiers to class constructors.
4
- *
5
- * This utility is fundamental for building extensible systems like dependency injection containers,
6
- * factories, and serialization engines where types need to be dynamically resolved.
7
- *
8
- * @template T - A base type that all registered constructors must produce an instance of.
9
- */
10
- export class ConstructorRegistry {
11
- items = new Map();
12
- /**
13
- * Registers a constructor with a unique string identifier.
14
- *
15
- * @param typeId - The unique identifier for the constructor (e.g., a static `typeName` property from a class).
16
- * @param ctor - The class constructor to register.
17
- * @returns The registry instance for chainable calls.
18
- * @throws If a constructor with the same `typeId` is already registered.
19
- */
20
- register(typeId, ctor) {
21
- throwIf(this.items.has(typeId), `A constructor with typeId '${typeId}' is already registered.`);
22
- this.items.set(typeId, ctor);
23
- return this;
24
- }
25
- /**
26
- * Retrieves a constructor by its identifier.
27
- *
28
- * @param typeId - The identifier of the constructor to retrieve.
29
- * @returns The found class constructor.
30
- * @throws If no constructor is found for the given `typeId`.
31
- */
32
- get(typeId) {
33
- const Ctor = this.items.get(typeId);
34
- throwIfEmpty(Ctor, `No constructor found for typeId '${typeId}'`);
35
- return Ctor;
36
- }
37
- /**
38
- * Checks if a constructor for a given identifier is registered.
39
- * @param typeId - The identifier to check.
40
- * @returns `true` if a constructor is registered, otherwise `false`.
41
- */
42
- has(typeId) {
43
- return this.items.has(typeId);
44
- }
45
- /**
46
- * Clears all registered constructors from the registry.
47
- */
48
- clear() {
49
- this.items.clear();
50
- }
51
- }
52
- //# sourceMappingURL=constructor-registry.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constructor-registry.js","sourceRoot":"","sources":["../src/constructor-registry.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,OAAO,EAAE,YAAY,EAAC,MAAM,aAAa,CAAC;AAElD;;;;;;;GAOG;AACH,MAAM,OAAO,mBAAmB;IACb,KAAK,GAAG,IAAI,GAAG,EAA0B,CAAC;IAE3D;;;;;;;OAOG;IACH,QAAQ,CAAC,MAAc,EAAE,IAAoB;QAC3C,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,8BAA8B,MAAM,0BAA0B,CAAC,CAAC;QAChG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;OAMG;IACH,GAAG,CAAC,MAAc;QAChB,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACpC,YAAY,CAAC,IAAI,EAAE,oCAAoC,MAAM,GAAG,CAAC,CAAC;QAClE,OAAO,IAAK,CAAC;IACf,CAAC;IAED;;;;OAIG;IACH,GAAG,CAAC,MAAc;QAChB,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAChC,CAAC;IAED;;OAEG;IACH,KAAK;QACH,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;CACF"}
package/dist/emitter.d.ts DELETED
@@ -1,32 +0,0 @@
1
- import { Subscribable } from './types';
2
- /**
3
- * A minimal, type-safe event emitter for a single event.
4
- * It does not manage state, it only manages subscribers and event dispatching.
5
- * @template T A tuple representing the types of the event arguments.
6
- */
7
- export declare class Emitter<T extends any[]> implements Subscribable<T> {
8
- private listeners;
9
- /**
10
- * Returns the number of listeners.
11
- */
12
- get listenerCount(): number;
13
- /**
14
- * Subscribes a listener to this event.
15
- * @returns A function to unsubscribe the listener.
16
- */
17
- subscribe(listener: (...args: T) => void): () => void;
18
- /**
19
- * Manually unsubscribe by listener
20
- * @returns returns true if an listener has been removed, or false if the listener does not exist.
21
- */
22
- unsubscribe(listener: (...args: T) => void): boolean;
23
- /**
24
- * Dispatches the event to all subscribed listeners.
25
- */
26
- emit(...args: T): void;
27
- /**
28
- * Clears all listeners.
29
- */
30
- clear(): void;
31
- }
32
- //# sourceMappingURL=emitter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"emitter.d.ts","sourceRoot":"","sources":["../src/emitter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,YAAY,EAAC,MAAM,SAAS,CAAC;AAErC;;;;GAIG;AACH,qBAAa,OAAO,CAAC,CAAC,SAAS,GAAG,EAAE,CAAE,YAAW,YAAY,CAAC,CAAC,CAAC;IAC9D,OAAO,CAAC,SAAS,CAAwC;IAEzD;;OAEG;IACH,IAAI,aAAa,IAAI,MAAM,CAE1B;IAED;;;OAGG;IACH,SAAS,CAAC,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,IAAI,GAAG,MAAM,IAAI;IAKrD;;;OAGG;IACH,WAAW,CAAC,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,IAAI;IAI1C;;OAEG;IACH,IAAI,CAAC,GAAG,IAAI,EAAE,CAAC,GAAG,IAAI;IAItB;;OAEG;IACH,KAAK,IAAI,IAAI;CAGd"}
package/dist/emitter.js DELETED
@@ -1,43 +0,0 @@
1
- // file: packages/utils/src/emitter.ts
2
- /**
3
- * A minimal, type-safe event emitter for a single event.
4
- * It does not manage state, it only manages subscribers and event dispatching.
5
- * @template T A tuple representing the types of the event arguments.
6
- */
7
- export class Emitter {
8
- listeners = new Set();
9
- /**
10
- * Returns the number of listeners.
11
- */
12
- get listenerCount() {
13
- return this.listeners.size;
14
- }
15
- /**
16
- * Subscribes a listener to this event.
17
- * @returns A function to unsubscribe the listener.
18
- */
19
- subscribe(listener) {
20
- this.listeners.add(listener);
21
- return () => this.listeners.delete(listener);
22
- }
23
- /**
24
- * Manually unsubscribe by listener
25
- * @returns returns true if an listener has been removed, or false if the listener does not exist.
26
- */
27
- unsubscribe(listener) {
28
- return this.listeners.delete(listener);
29
- }
30
- /**
31
- * Dispatches the event to all subscribed listeners.
32
- */
33
- emit(...args) {
34
- this.listeners.forEach(listener => listener(...args));
35
- }
36
- /**
37
- * Clears all listeners.
38
- */
39
- clear() {
40
- this.listeners.clear();
41
- }
42
- }
43
- //# sourceMappingURL=emitter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"emitter.js","sourceRoot":"","sources":["../src/emitter.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAItC;;;;GAIG;AACH,MAAM,OAAO,OAAO;IACV,SAAS,GAA8B,IAAI,GAAG,EAAE,CAAC;IAEzD;;OAEG;IACH,IAAI,aAAa;QACf,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;IAC7B,CAAC;IAED;;;OAGG;IACH,SAAS,CAAC,QAA8B;QACtC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC7B,OAAO,GAAG,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC/C,CAAC;IAED;;;OAGG;IACH,WAAW,CAAC,QAA8B;QACxC,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACzC,CAAC;IAED;;OAEG;IACH,IAAI,CAAC,GAAG,IAAO;QACb,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;IACxD,CAAC;IAED;;OAEG;IACH,KAAK;QACH,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;IACzB,CAAC;CACF"}
package/dist/guards.d.ts DELETED
@@ -1,12 +0,0 @@
1
- export declare function isNullOrUndefined(val: unknown): val is null | undefined;
2
- export declare function isUndefined(val: unknown): val is undefined;
3
- export declare function isNumber(val: unknown): val is number;
4
- export declare function isBoolean(val: unknown): val is boolean;
5
- export declare function isString(val: unknown): val is string;
6
- /**
7
- * Type guard to check if a value is a string that ends with '%'.
8
- * @param val The value to check.
9
- * @returns `true` if the value is a percentage string.
10
- */
11
- export declare function isPercentageString(val: unknown): val is string;
12
- //# sourceMappingURL=guards.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"guards.d.ts","sourceRoot":"","sources":["../src/guards.ts"],"names":[],"mappings":"AAAA,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,IAAI,GAAG,SAAS,CAEvE;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,SAAS,CAE1D;AAED,wBAAgB,QAAQ,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,MAAM,CAEpD;AAED,wBAAgB,SAAS,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,OAAO,CAEtD;AAED,wBAAgB,QAAQ,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,MAAM,CAEpD;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,MAAM,CAE9D"}
package/dist/guards.js DELETED
@@ -1,24 +0,0 @@
1
- export function isNullOrUndefined(val) {
2
- return val === undefined || val === null;
3
- }
4
- export function isUndefined(val) {
5
- return typeof val === 'undefined';
6
- }
7
- export function isNumber(val) {
8
- return typeof val === "number";
9
- }
10
- export function isBoolean(val) {
11
- return typeof val === "boolean";
12
- }
13
- export function isString(val) {
14
- return typeof val === "string";
15
- }
16
- /**
17
- * Type guard to check if a value is a string that ends with '%'.
18
- * @param val The value to check.
19
- * @returns `true` if the value is a percentage string.
20
- */
21
- export function isPercentageString(val) {
22
- return typeof val === "string" && val.endsWith("%");
23
- }
24
- //# sourceMappingURL=guards.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"guards.js","sourceRoot":"","sources":["../src/guards.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,iBAAiB,CAAC,GAAY;IAC5C,OAAO,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,IAAI,CAAC;AAC3C,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,GAAY;IACtC,OAAO,OAAO,GAAG,KAAK,WAAW,CAAC;AACpC,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,GAAY;IACnC,OAAO,OAAO,GAAG,KAAK,QAAQ,CAAC;AACjC,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,GAAY;IACpC,OAAO,OAAO,GAAG,KAAK,SAAS,CAAC;AAClC,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,GAAY;IACnC,OAAO,OAAO,GAAG,KAAK,QAAQ,CAAC;AACjC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,GAAY;IAC7C,OAAO,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;AACtD,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,mBAAmB,SAAS,CAAC;AAG7B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,wBAAwB,CAAC;AACvC,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC"}
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,EAAE;AACF,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,wBAAwB,CAAC;AACvC,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC"}
package/dist/math.d.ts DELETED
@@ -1,17 +0,0 @@
1
- /**
2
- * Clamps a number between an optional minimum and maximum value.
3
- * @param val The number to clamp.
4
- * @param min The minimum value. If null or undefined, it's ignored.
5
- * @param max The maximum value. If null or undefined, it's ignored.
6
- * @returns The clamped number.
7
- */
8
- export declare function clampNumber(val: number, min?: number | null, max?: number | null): number;
9
- /**
10
- * Calculates a percentage of a given value.
11
- * @param val The base value.
12
- * @param percents The percentage to get.
13
- * @returns The calculated percentage of the value.
14
- * @example getPercentOf(200, 10); // returns 20
15
- */
16
- export declare function getPercentOf(val: number, percents: number): number;
17
- //# sourceMappingURL=math.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"math.d.ts","sourceRoot":"","sources":["../src/math.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAIzF;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,UAEzD"}
package/dist/math.js DELETED
@@ -1,26 +0,0 @@
1
- import { isNullOrUndefined } from './guards';
2
- /**
3
- * Clamps a number between an optional minimum and maximum value.
4
- * @param val The number to clamp.
5
- * @param min The minimum value. If null or undefined, it's ignored.
6
- * @param max The maximum value. If null or undefined, it's ignored.
7
- * @returns The clamped number.
8
- */
9
- export function clampNumber(val, min, max) {
10
- if (!isNullOrUndefined(min))
11
- val = Math.max(val, min);
12
- if (!isNullOrUndefined(max))
13
- val = Math.min(val, max);
14
- return val;
15
- }
16
- /**
17
- * Calculates a percentage of a given value.
18
- * @param val The base value.
19
- * @param percents The percentage to get.
20
- * @returns The calculated percentage of the value.
21
- * @example getPercentOf(200, 10); // returns 20
22
- */
23
- export function getPercentOf(val, percents) {
24
- return (percents / 100) * val;
25
- }
26
- //# sourceMappingURL=math.js.map
package/dist/math.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"math.js","sourceRoot":"","sources":["../src/math.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAC,MAAM,UAAU,CAAC;AAG3C;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAAC,GAAW,EAAE,GAAmB,EAAE,GAAmB;IAC/E,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC;QAAE,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACtD,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC;QAAE,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACtD,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAC,GAAW,EAAE,QAAgB;IACxD,OAAO,CAAC,QAAQ,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC;AAChC,CAAC"}
package/dist/misc.d.ts DELETED
@@ -1,7 +0,0 @@
1
- /**
2
- * Returns the first key of an object.
3
- * @param obj The object from which to get the key.
4
- * @returns The first key of the object as a string.
5
- */
6
- export declare function firstKeyOf(obj: any): string;
7
- //# sourceMappingURL=misc.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"misc.d.ts","sourceRoot":"","sources":["../src/misc.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,GAAG,UAElC"}
package/dist/misc.js DELETED
@@ -1,9 +0,0 @@
1
- /**
2
- * Returns the first key of an object.
3
- * @param obj The object from which to get the key.
4
- * @returns The first key of the object as a string.
5
- */
6
- export function firstKeyOf(obj) {
7
- return Object.keys(obj)[0];
8
- }
9
- //# sourceMappingURL=misc.js.map
package/dist/misc.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"misc.js","sourceRoot":"","sources":["../src/misc.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,GAAQ;IACjC,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AAC7B,CAAC"}
package/dist/path.d.ts DELETED
@@ -1,10 +0,0 @@
1
- import { PathType } from "./types";
2
- /**
3
- * Ensures that the given path is returned as an array of segments.
4
- */
5
- export declare function ensurePathArray(path: PathType, separator?: string): string[];
6
- /**
7
- * Ensures that the given path is returned as a single string.
8
- */
9
- export declare function ensurePathString(path: PathType, separator?: string): string;
10
- //# sourceMappingURL=path.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../src/path.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,SAAS,CAAC;AAGjC;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,QAAQ,EAAE,SAAS,SAA4B,GAAG,MAAM,EAAE,CAE/F;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,QAAQ,EAAE,SAAS,SAA4B,GAAG,MAAM,CAE9F"}
package/dist/path.js DELETED
@@ -1,14 +0,0 @@
1
- import { axiSettings } from './config';
2
- /**
3
- * Ensures that the given path is returned as an array of segments.
4
- */
5
- export function ensurePathArray(path, separator = axiSettings.pathSeparator) {
6
- return Array.isArray(path) ? [...path] : path.split(separator);
7
- }
8
- /**
9
- * Ensures that the given path is returned as a single string.
10
- */
11
- export function ensurePathString(path, separator = axiSettings.pathSeparator) {
12
- return !Array.isArray(path) ? path : path.join(separator);
13
- }
14
- //# sourceMappingURL=path.js.map
package/dist/path.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"path.js","sourceRoot":"","sources":["../src/path.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,WAAW,EAAC,MAAM,UAAU,CAAC;AAErC;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,IAAc,EAAE,SAAS,GAAG,WAAW,CAAC,aAAa;IACnF,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;AACjE,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAc,EAAE,SAAS,GAAG,WAAW,CAAC,aAAa;IACpF,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AAC5D,CAAC"}
package/dist/random.d.ts DELETED
@@ -1,14 +0,0 @@
1
- /**
2
- * Returns a random integer between min (inclusive) and max (exclusive).
3
- * @param min The minimum integer (inclusive).
4
- * @param max The maximum integer (exclusive).
5
- * @returns A random integer.
6
- * @example randInt(1, 5); // returns 1, 2, 3, or 4
7
- */
8
- export declare function randInt(min: number, max: number): number;
9
- /**
10
- * Generates a unique identifier using uuidv4.
11
- * @returns A unique string ID.
12
- */
13
- export declare function randId(): string;
14
- //# sourceMappingURL=random.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"random.d.ts","sourceRoot":"","sources":["../src/random.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAIxD;AAED;;;GAGG;AACH,wBAAgB,MAAM,WAErB"}
package/dist/random.js DELETED
@@ -1,21 +0,0 @@
1
- import { v4 as uuidv4 } from 'uuid';
2
- /**
3
- * Returns a random integer between min (inclusive) and max (exclusive).
4
- * @param min The minimum integer (inclusive).
5
- * @param max The maximum integer (exclusive).
6
- * @returns A random integer.
7
- * @example randInt(1, 5); // returns 1, 2, 3, or 4
8
- */
9
- export function randInt(min, max) {
10
- min = Math.ceil(min);
11
- max = Math.floor(max);
12
- return Math.floor(Math.random() * (max - min) + min);
13
- }
14
- /**
15
- * Generates a unique identifier using uuidv4.
16
- * @returns A unique string ID.
17
- */
18
- export function randId() {
19
- return uuidv4();
20
- }
21
- //# sourceMappingURL=random.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"random.js","sourceRoot":"","sources":["../src/random.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AAEpC;;;;;;GAMG;AACH,MAAM,UAAU,OAAO,CAAC,GAAW,EAAE,GAAW;IAC9C,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACrB,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACtB,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC;AACvD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,MAAM;IACpB,OAAO,MAAM,EAAE,CAAC;AAClB,CAAC"}
package/dist/types.d.ts DELETED
@@ -1,50 +0,0 @@
1
- /**
2
- * Represents a path that can be provided as a single string
3
- * or an array of segments.
4
- * @example
5
- * 'player/stats/health'
6
- * ['player', 'stats', 'health']
7
- */
8
- export type PathType = string | string[];
9
- /**
10
- * Represents a generic constructor for any class.
11
- *
12
- * This utility type is essential for implementing higher-order patterns
13
- * like mixins, where a function takes a class as an argument and returns
14
- * a new, extended class.
15
- *
16
- * The `...args: any[]` signature allows it to represent constructors
17
- * with any number and type of arguments, making it universally applicable.
18
- *
19
- * @template T - The type of the instance created by the constructor. Defaults to `{}`.
20
- *
21
- * @example
22
- * // Used as a constraint for a base class in a mixin
23
- * function Timestamped<TBase extends Constructor>(Base: TBase) {
24
- * return class extends Base {
25
- * timestamp = new Date();
26
- * };
27
- * }
28
- *
29
- * class User {}
30
- * const TimestampedUser = Timestamped(User);
31
- * const userInstance = new TimestampedUser();
32
- * console.log(userInstance.timestamp); // Logs the current date
33
- */
34
- export type Constructor<T = {}> = new (...args: any[]) => T;
35
- /**
36
- * Defines the public, read-only contract for an event emitter.
37
- * It allows subscribing to an event but not emitting it.
38
- * @template T A tuple representing the types of the event arguments.
39
- */
40
- export type Subscribable<T extends any[]> = {
41
- readonly listenerCount: number;
42
- /**
43
- * Subscribes a listener to this event.
44
- * @returns A function to unsubscribe the listener.
45
- */
46
- subscribe(listener: (...args: T) => void): () => void;
47
- unsubscribe(listener: (...args: T) => void): boolean;
48
- clear(): void;
49
- };
50
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,MAAM,EAAE,CAAC;AAEzC;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,GAAG,EAAE,IAAI,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;AAE5D;;;;GAIG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,GAAG,EAAE,IAAI;IAC1C,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAE/B;;;OAGG;IACH,SAAS,CAAC,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;IAEtD,WAAW,CAAC,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,IAAI,GAAG,OAAO,CAAC;IAErD,KAAK,IAAI,IAAI,CAAC;CACf,CAAA"}
package/dist/types.js DELETED
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=types.js.map
package/dist/types.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}