@axi-engine/utils 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +13 -1
- package/dist/index.d.ts +305 -12
- package/dist/index.js +296 -12
- package/dist/index.mjs +9 -0
- package/package.json +1 -1
- package/dist/arrays.d.ts +0 -72
- package/dist/arrays.d.ts.map +0 -1
- package/dist/arrays.js +0 -115
- package/dist/arrays.js.map +0 -1
- package/dist/assertion.d.ts +0 -31
- package/dist/assertion.d.ts.map +0 -1
- package/dist/assertion.js +0 -41
- package/dist/assertion.js.map +0 -1
- package/dist/config.d.ts +0 -10
- package/dist/config.d.ts.map +0 -1
- package/dist/config.js +0 -12
- package/dist/config.js.map +0 -1
- package/dist/constructor-registry.d.ts +0 -40
- package/dist/constructor-registry.d.ts.map +0 -1
- package/dist/constructor-registry.js +0 -52
- package/dist/constructor-registry.js.map +0 -1
- package/dist/emitter.d.ts +0 -32
- package/dist/emitter.d.ts.map +0 -1
- package/dist/emitter.js +0 -43
- package/dist/emitter.js.map +0 -1
- package/dist/guards.d.ts +0 -12
- package/dist/guards.d.ts.map +0 -1
- package/dist/guards.js +0 -24
- package/dist/guards.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/math.d.ts +0 -17
- package/dist/math.d.ts.map +0 -1
- package/dist/math.js +0 -26
- package/dist/math.js.map +0 -1
- package/dist/misc.d.ts +0 -7
- package/dist/misc.d.ts.map +0 -1
- package/dist/misc.js +0 -9
- package/dist/misc.js.map +0 -1
- package/dist/path.d.ts +0 -10
- package/dist/path.d.ts.map +0 -1
- package/dist/path.js +0 -14
- package/dist/path.js.map +0 -1
- package/dist/random.d.ts +0 -14
- package/dist/random.d.ts.map +0 -1
- package/dist/random.js +0 -21
- package/dist/random.js.map +0 -1
- package/dist/types.d.ts +0 -50
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -2
- package/dist/types.js.map +0 -1
package/dist/path.d.ts.map
DELETED
|
@@ -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
|
package/dist/random.d.ts.map
DELETED
|
@@ -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
|
package/dist/random.js.map
DELETED
|
@@ -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
|
package/dist/types.d.ts.map
DELETED
|
@@ -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
package/dist/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|