@xaendar/common 0.1.8 → 0.2.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xaendar/common",
3
- "version": "0.1.8",
3
+ "version": "0.2.0",
4
4
  "description": "A library containing common utils and types",
5
5
  "type": "module",
6
6
  "main": "./xaendar-common.es.js",
@@ -1,119 +1,3 @@
1
- /**
2
- * A type representing an abstract constructor function for a given type T.
3
- * This type can be used to define abstract classes.
4
- */
5
- export declare type AbstractConstructor<T extends Object = Object> = abstract new (...args: any[]) => T;
6
-
7
- /**
8
- * An abstract constructor function type that can accept any number of arguments
9
- * and return an instance of the specified type.
10
- */
11
- export declare type AbstractConstructorFunction<T extends object = object, Statics extends Record<string, unknown> | undefined = undefined> = (abstract new (...args: any[]) => T) & (Statics extends undefined ? object : Statics);
12
-
13
- export declare type AccessorDecorator<Class extends Object, Field = unknown, ReturnTypeField = Field> = (value: ClassAccessorDecoratorValue<Field>, context: ClassAccessorDecoratorContext<Class, ReturnTypeField>) => {
14
- get?: () => ReturnTypeField;
15
- set?: (value: ReturnTypeField) => void;
16
- init?: (initialValue: Field) => ReturnTypeField;
17
- } | void;
18
-
19
- /**
20
- * A function type that can accept any number of arguments and return a promise of any type.
21
- */
22
- export declare type AsyncFunction<Arguments extends any[] = any[], ReturnType = void> = Arguments extends Array<any> ? (...args: Arguments) => Promise<ReturnType> : () => Promise<ReturnType>;
23
-
24
- /**
25
- * An async function type that accepts arguments but always resolves to void.
26
- * Typically used for async callbacks or side-effect functions.
27
- * @template Arguments - The types of the function arguments
28
- * @example
29
- * type OnUserChangeAsync = AsyncVoidFunction<[user: User]>;
30
- * const handleUserChangeAsync: OnUserChangeAsync = async (user) => await api.logChange(user);
31
- */
32
- export declare type AsyncVoidFunction<Arguments extends any[] = any[]> = (...args: Arguments) => Promise<void>;
33
-
34
- export declare type Beautify<T extends Object> = {
35
- [K in keyof T]: T[K];
36
- } & {};
37
-
38
- export declare type ClassAccessorDecoratorValue<Field = unknown> = {
39
- get?: () => Field;
40
- set: (value: Field) => void;
41
- };
42
-
43
- declare type ClassDecorator_2<T extends Object, Statics extends {
44
- [key: string]: any;
45
- } = {
46
- [key: string]: any;
47
- }> = (klass: Constructor<T, Statics>, context: ClassDecoratorContext) => void;
48
- export { ClassDecorator_2 as ClassDecorator }
49
-
50
- /**
51
- * A type representing a constructor function for a given type T.
52
- * This type can be used to define classes or factory functions
53
- */
54
- export declare type Constructor<T extends Object = Object, Statics extends Record<string, unknown> = {}> = (new (...args: any[]) => T) & Statics;
55
-
56
- /**
57
- * A constructor function type that can accept any number of arguments and return an instance of any type.
58
- */
59
- export declare type ConstructorFunction<T extends object = object, Statics extends Record<string, unknown> | undefined = undefined> = (new (...args: any[]) => T) & (Statics extends undefined ? object : Statics);
60
-
61
- export declare type ContainsChar<String extends string, Contains extends string> = String extends `${infer First}${infer Rest}` ? First extends Contains ? true : ContainsChar<Rest, Contains> : false;
62
-
63
- export declare type Dictionary<Key extends string | number, Value> = {
64
- [K in Key]?: Value;
65
- };
66
-
67
- export declare type FieldDecorator<Class extends Object, Field, ReturnType = Field> = (field: undefined, context: ClassFieldDecoratorContext<Class, Field>) => ((value: Field) => ReturnType);
68
-
69
- /**
70
- * A function type that can accept any number of arguments and return any type.
71
- */
72
- declare type Function_2<Arguments extends any[] = any[], ReturnType = void> = Arguments extends Array<any> ? (...args: Arguments) => ReturnType : () => ReturnType;
73
- export { Function_2 as Function }
74
-
75
- declare type MethodDecorator_2<T extends Object, Method extends Function_2> = (value: Method, context: ClassMethodDecoratorContext<T, Method>) => Method | void;
76
- export { MethodDecorator_2 as MethodDecorator }
77
-
78
- export declare type Mutable<T extends Object> = {
79
- -readonly [P in keyof T]: T[P];
80
- };
81
-
82
- /**
83
- * An async function type that accepts no arguments and returns a promise of the specified type.
84
- * @template ReturnType - The type that the promise resolves to (defaults to void)
85
- * @example
86
- * type FetchUser = AsyncFunctionNoArgs<User>;
87
- * const fetchUser: FetchUser = async () => await api.getUser();
88
- */
89
- export declare type NoArgsAsyncFunction<ReturnType = void> = () => Promise<ReturnType>;
90
-
91
- /**
92
- * An async function type that accepts arguments but always resolves to void.
93
- */
94
- export declare type NoArgsAsyncVoidFunction = () => Promise<void>;
95
-
96
- /**
97
- * A function type that accepts no arguments and returns a value of the specified type.
98
- * Also known as a 'thunk' in functional programming.
99
- * @template ReturnType - The return type of the function (defaults to void)
100
- * @example
101
- * type GetUser = FunctionNoArgs<User>;
102
- * const getUser: GetUser = () => ({ id: 1, name: 'John' });
103
- */
104
- export declare type NoArgsFunction<ReturnType = void> = () => ReturnType;
105
-
106
- /**
107
- * A function type that accepts arguments but always returns void.
108
- */
109
- export declare type NoArgsVoidFunction = () => void;
110
-
111
- export declare type PositiveInteger<Value extends number> = ContainsChar<`${Value}`, '-'> extends true ? never : ContainsChar<`${Value}`, '.'> extends true ? never : Value;
112
-
113
- export declare type RequireOne<T extends Object, Keys extends keyof T = keyof T> = Pick<T, Exclude<keyof T, Keys>> & {
114
- [K in Keys]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<Keys, K>>>;
115
- }[Keys];
116
-
117
1
  /**
118
2
  * A generic LIFO (Last In, First Out) stack data structure.
119
3
  *
@@ -150,17 +34,4 @@ export declare class Stack<T = unknown> {
150
34
  push(element: T): number;
151
35
  }
152
36
 
153
- export declare type TupleOfLength<Length extends number, TupleType = number, Acc extends TupleType[] = []> = PositiveInteger<Length> extends never ? never : Acc['length'] extends Length ? Acc : TupleOfLength<Length, TupleType, [...Acc, TupleType]>;
154
-
155
- /**
156
- * A function type that accepts arguments but always returns void.
157
- * Typically used for callbacks, event handlers, or side-effect functions.
158
- * @template Arguments - The types of the function arguments
159
- * @example
160
- * type OnUserChange = VoidFunction<[user: User]>;
161
- * const handleUserChange: OnUserChange = (user) => console.log(user);
162
- */
163
- declare type VoidFunction_2<Arguments extends any[] = any[]> = (...args: Arguments) => void;
164
- export { VoidFunction_2 as VoidFunction }
165
-
166
37
  export { }