@avstantso/utils-enum-class 1.1.0 → 1.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/CHANGELOG.md +7 -0
- package/dist/_global/_register.d.ts +464 -0
- package/dist/_global/index.d.ts +1 -0
- package/dist/export.d.ts +2 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +375 -0
- package/dist/index.js.map +1 -0
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -0,0 +1,464 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @summary Enum implementation where every item is instance of class
|
|
3
|
+
* @example
|
|
4
|
+
* export namespace CollectionAction {
|
|
5
|
+
* export type Item = typeof CollectionAction.Item;
|
|
6
|
+
*
|
|
7
|
+
* export type Signs = typeof _CollectionAction.signs;
|
|
8
|
+
* export type SignsUnion = keyof {
|
|
9
|
+
* [K in keyof Signs as Extract<Signs[K], string>]: 0;
|
|
10
|
+
* };
|
|
11
|
+
*
|
|
12
|
+
* export type Sign<Index extends number> = Index extends keyof Signs
|
|
13
|
+
* ? Signs[Index]
|
|
14
|
+
* : SignsUnion;
|
|
15
|
+
* }
|
|
16
|
+
*
|
|
17
|
+
* export class _CollectionAction<
|
|
18
|
+
* TValue extends number = number
|
|
19
|
+
* > extends EnumClass<TValue> {
|
|
20
|
+
* public static signs = ['+', '✎', '-', '🔥'] as const;
|
|
21
|
+
*
|
|
22
|
+
* public static Items = {
|
|
23
|
+
* add: new _CollectionAction(0),
|
|
24
|
+
* update: new _CollectionAction(1),
|
|
25
|
+
* delete: new _CollectionAction(2),
|
|
26
|
+
* clear: new _CollectionAction(3)
|
|
27
|
+
* };
|
|
28
|
+
*
|
|
29
|
+
* private _sign: CollectionAction.Sign<TValue>;
|
|
30
|
+
*
|
|
31
|
+
* constructor(value: TValue) {
|
|
32
|
+
* super(value);
|
|
33
|
+
*
|
|
34
|
+
* this._sign = _CollectionAction.signs[
|
|
35
|
+
* +this
|
|
36
|
+
* ] as CollectionAction.Sign<TValue>;
|
|
37
|
+
* }
|
|
38
|
+
*
|
|
39
|
+
* public get sign() {
|
|
40
|
+
* return this._sign;
|
|
41
|
+
* }
|
|
42
|
+
* }
|
|
43
|
+
*
|
|
44
|
+
* export const CollectionAction = _CollectionAction.Init();
|
|
45
|
+
* @example
|
|
46
|
+
* export namespace FileMode {
|
|
47
|
+
* export type Item = typeof FileMode.Item;
|
|
48
|
+
* }
|
|
49
|
+
*
|
|
50
|
+
* export class _FileMode<
|
|
51
|
+
* TValue extends number = number
|
|
52
|
+
* > extends EnumClass<TValue> {
|
|
53
|
+
* public static IsFlags = true as const;
|
|
54
|
+
*
|
|
55
|
+
* public static Items = {
|
|
56
|
+
* read: new _FileMode(1),
|
|
57
|
+
* write: new _FileMode(2),
|
|
58
|
+
* readWrite: new _FileMode(3), // 👈 Predefined combination
|
|
59
|
+
* delete: new _FileMode(4),
|
|
60
|
+
* upload: new _FileMode(8),
|
|
61
|
+
* download: new _FileMode(16),
|
|
62
|
+
* append: new _FileMode(32),
|
|
63
|
+
* zeroing: new _FileMode(64)
|
|
64
|
+
* };
|
|
65
|
+
* }
|
|
66
|
+
*
|
|
67
|
+
* export const FileMode = _FileMode.Init((fm) => {
|
|
68
|
+
* const readDelete = fm.read.or.delete;
|
|
69
|
+
*
|
|
70
|
+
* return { readDelete };
|
|
71
|
+
* });
|
|
72
|
+
* @example
|
|
73
|
+
* export namespace Direction {
|
|
74
|
+
* export type Item = typeof Direction.Item;
|
|
75
|
+
* }
|
|
76
|
+
*
|
|
77
|
+
* export class _Direction<
|
|
78
|
+
* TValue extends number = number,
|
|
79
|
+
* TArrow extends string = string
|
|
80
|
+
* > extends EnumClass<TValue> {
|
|
81
|
+
* static Center = class DirectionCenter<
|
|
82
|
+
* TValue extends number = number,
|
|
83
|
+
* TArrow extends string = string
|
|
84
|
+
* > extends _Direction<TValue, TArrow> {
|
|
85
|
+
* step([x, y]: [number, number]): [number, number] {
|
|
86
|
+
* return [x, y];
|
|
87
|
+
* }
|
|
88
|
+
* } as typeof _Direction;
|
|
89
|
+
*
|
|
90
|
+
* public static ToJSONField = 'arrow';
|
|
91
|
+
*
|
|
92
|
+
* public static Items = {
|
|
93
|
+
* top: new _Direction(0, '↑'),
|
|
94
|
+
* left: new _Direction(1, '←'),
|
|
95
|
+
* bottom: new _Direction(2, '↓'),
|
|
96
|
+
* right: new _Direction(3, '→'),
|
|
97
|
+
* center: new _Direction.Center(-1, '⊕')
|
|
98
|
+
* };
|
|
99
|
+
*
|
|
100
|
+
* public readonly arrow: TArrow;
|
|
101
|
+
*
|
|
102
|
+
* constructor(value: TValue, arrow: TArrow) {
|
|
103
|
+
* super(value);
|
|
104
|
+
* this.arrow = arrow;
|
|
105
|
+
* }
|
|
106
|
+
*
|
|
107
|
+
* step([x, y]: [number, number], d = 1): [number, number] {
|
|
108
|
+
* return Direction.switch(this, {
|
|
109
|
+
* top: [x, y - d],
|
|
110
|
+
* left: [x - d, y],
|
|
111
|
+
* bottom: [x, y + d],
|
|
112
|
+
* right: [x + d, y]
|
|
113
|
+
* });
|
|
114
|
+
* }
|
|
115
|
+
* }
|
|
116
|
+
*
|
|
117
|
+
* export const Direction = _Direction.Init();
|
|
118
|
+
*/
|
|
119
|
+
declare namespace AVStantso_EnumClass {
|
|
120
|
+
type KVO<TClass extends AVStantso_EnumClass.Class = AVStantso_EnumClass.Class> = AVStantso_EnumClass.KeyOrValueOrObject<TClass>;
|
|
121
|
+
export namespace Item {
|
|
122
|
+
type Name = string;
|
|
123
|
+
type Value = number;
|
|
124
|
+
type Template = {
|
|
125
|
+
readonly name: Name;
|
|
126
|
+
readonly value: Value;
|
|
127
|
+
};
|
|
128
|
+
namespace Or {
|
|
129
|
+
type Cases<TClass extends Class, TRestNames extends keyof TClass['Items'], TNames extends keyof TClass['Items']> = {
|
|
130
|
+
[K in TRestNames]: Item<TClass, TNames | K> & Next<TClass, Exclude<TRestNames, K>, TNames | K>;
|
|
131
|
+
};
|
|
132
|
+
type Next<TClass extends Class, TRestNames extends keyof TClass['Items'], TNames extends keyof TClass['Items']> = [TRestNames] extends [never] ? unknown : {
|
|
133
|
+
/**
|
|
134
|
+
* @summary Chaining access to flags combinations
|
|
135
|
+
*/
|
|
136
|
+
or: Cases<TClass, TRestNames, TNames>;
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
export namespace Switch {
|
|
141
|
+
type Cases<TClass extends Class, TCase> = AVStantso.Switch.Cases<keyof TClass['Items'] | keyof Meta.ValuesMap<TClass>, {
|
|
142
|
+
Case: TCase;
|
|
143
|
+
}>;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* @summary This is analog of switch construction supports values from type enum
|
|
147
|
+
* @example enum E {a, b, c, d, e }
|
|
148
|
+
* const x = switch<number>(E.d, {a: 1, b: 2, "c|d|e": 3, default: 4} );
|
|
149
|
+
* // x = 3
|
|
150
|
+
*/
|
|
151
|
+
export type Switch<TClass extends Class> = {
|
|
152
|
+
<TCase, TCases extends Switch.Cases<TClass, TCase> = Switch.Cases<TClass, TCase>>(value: KVO, cases: TCases): TCase;
|
|
153
|
+
};
|
|
154
|
+
export type Item<TClass extends Class, TName extends keyof TClass['Items'] = keyof TClass['Items'], IsDetermined extends boolean = false> = TClass['Items'][TName] & {
|
|
155
|
+
/**
|
|
156
|
+
* @summary Name casted to `keyof TClass['Items']`
|
|
157
|
+
*/
|
|
158
|
+
readonly key: TName;
|
|
159
|
+
/**
|
|
160
|
+
* @summary Prev enum item. Turns first to last
|
|
161
|
+
*/
|
|
162
|
+
readonly prev: Item<TClass>;
|
|
163
|
+
/**
|
|
164
|
+
* @summary Next enum item. Turns last to first
|
|
165
|
+
*/
|
|
166
|
+
readonly next: Item<TClass>;
|
|
167
|
+
/**
|
|
168
|
+
* @summary Scroll enum item `by`. Turns last to first and first to last
|
|
169
|
+
* @param by If positive: scroll up (turns last to first) / If negative: scroll down (turns first to last)
|
|
170
|
+
*/
|
|
171
|
+
scroll(by?: number): Item<TClass>;
|
|
172
|
+
/**
|
|
173
|
+
* @summary Check if `other` is an enum of objects with some value. Use `tryFrom`
|
|
174
|
+
*/
|
|
175
|
+
is(other: KVO<TClass>): boolean;
|
|
176
|
+
/**
|
|
177
|
+
* @summary Switch case for this enum item
|
|
178
|
+
* @see AVStantso.Switch
|
|
179
|
+
*/
|
|
180
|
+
switch<TCase, TCases extends AVStantso_EnumClass.Switch.Cases<TClass, TCase> = AVStantso_EnumClass.Switch.Cases<TClass, TCase>>(cases: TCases): TCase;
|
|
181
|
+
} & (TClass['IsFlags'] extends true ? IsDetermined extends true ? Item.Or.Next<TClass, Exclude<keyof TClass['Items'], TName>, TName> : unknown : unknown);
|
|
182
|
+
export type Class = {
|
|
183
|
+
new <TValue extends number = number>(value: TValue, ...params: AVStantso.TS.Arr): AVStantso_EnumClass<TValue>;
|
|
184
|
+
/**
|
|
185
|
+
* @summary Design time only. Type source of Enum.Meta.Statics
|
|
186
|
+
* @description All public statics must be declared as type and override this property
|
|
187
|
+
* @default {}
|
|
188
|
+
*/
|
|
189
|
+
Statics?: object;
|
|
190
|
+
/**
|
|
191
|
+
* @summary `true` — allow create values combinations
|
|
192
|
+
* @default false
|
|
193
|
+
*/
|
|
194
|
+
IsFlags: boolean;
|
|
195
|
+
/**
|
|
196
|
+
* @summary Field name for JSON serialization
|
|
197
|
+
* @default `value`
|
|
198
|
+
*/
|
|
199
|
+
ToJSONField: string;
|
|
200
|
+
/**
|
|
201
|
+
* @summary Enum items. Must be overridden in Enum child class
|
|
202
|
+
*/
|
|
203
|
+
Items: NodeJS.Dict<Item.Template>;
|
|
204
|
+
};
|
|
205
|
+
export type KeyOrValueOrObject<TClass extends Class> = string | number | InstanceType<TClass>;
|
|
206
|
+
export namespace Meta {
|
|
207
|
+
type ValuesMap<TClass extends Class> = {
|
|
208
|
+
[K in keyof TClass['Items'] as TClass['Items'][K]['value']]: Item<TClass, K, true>;
|
|
209
|
+
};
|
|
210
|
+
/**
|
|
211
|
+
* @summary Get item object by name, by value or by object or `ToJSONField` field value
|
|
212
|
+
* @param candidate Input data
|
|
213
|
+
* @param defaultValue Default value for fails get
|
|
214
|
+
*/
|
|
215
|
+
type From<TClass extends Class> = {
|
|
216
|
+
/**
|
|
217
|
+
* @summary Get item object by name, by value or by object or `ToJSONField` field value
|
|
218
|
+
* @param candidate Input data
|
|
219
|
+
* @param defaultValue Default value for fails get
|
|
220
|
+
*/
|
|
221
|
+
(candidate: KVO<TClass>, defaultValue?: Item<TClass>): Item<TClass>;
|
|
222
|
+
/**
|
|
223
|
+
* @summary Get item object by capitalized name
|
|
224
|
+
* @param candidate Input data
|
|
225
|
+
* @param defaultValue Default value for fails get
|
|
226
|
+
*/
|
|
227
|
+
capitalized(candidate: string, defaultValue?: Item<TClass>): Item<TClass>;
|
|
228
|
+
/**
|
|
229
|
+
* @summary Get item object by uncapitalized name
|
|
230
|
+
* @param candidate Input data
|
|
231
|
+
* @param defaultValue Default value for fails get
|
|
232
|
+
*/
|
|
233
|
+
uncapitalized(candidate: string, defaultValue?: Item<TClass>): Item<TClass>;
|
|
234
|
+
/**
|
|
235
|
+
* @summary Get item object by case insensitive name
|
|
236
|
+
* @param candidate Input data
|
|
237
|
+
* @param defaultValue Default value for fails get
|
|
238
|
+
*/
|
|
239
|
+
caseInsensitive(candidate: string, defaultValue?: Item<TClass>): Item<TClass>;
|
|
240
|
+
};
|
|
241
|
+
namespace Is {
|
|
242
|
+
namespace Or {
|
|
243
|
+
type Cases<TClass extends Class, TRestNames extends keyof TClass['Items'], TNames extends keyof TClass['Items']> = {
|
|
244
|
+
[K in TRestNames]: {
|
|
245
|
+
/**
|
|
246
|
+
* @summary Check `candidate` is Enum class item instance
|
|
247
|
+
*/
|
|
248
|
+
(candidate: unknown): candidate is Item<TClass, TNames | K>;
|
|
249
|
+
} & Next<TClass, Exclude<TRestNames, K>, TNames | K>;
|
|
250
|
+
};
|
|
251
|
+
type Next<TClass extends Class, TRestNames extends keyof TClass['Items'], TNames extends keyof TClass['Items']> = [TRestNames] extends [never] ? unknown : {
|
|
252
|
+
/**
|
|
253
|
+
* @summary Chaining access to fill `is` filter.
|
|
254
|
+
* @example
|
|
255
|
+
* // 👇 See below: Only inline calls are supported
|
|
256
|
+
* class _ABCD<TValue extends number = number> extends Enum<TValue> {
|
|
257
|
+
* public static Items = {
|
|
258
|
+
* A: new _ABCD(0),
|
|
259
|
+
* B: new _ABCD(1),
|
|
260
|
+
* C: new _ABCD(2),
|
|
261
|
+
* D: new _ABCD(3),
|
|
262
|
+
* };
|
|
263
|
+
* }
|
|
264
|
+
*
|
|
265
|
+
* export const ABCD = _ABCD.Init();
|
|
266
|
+
*
|
|
267
|
+
* // ✔
|
|
268
|
+
* console.log(ABCD.is.A.or.B(ABCD.C)); // prints: false
|
|
269
|
+
* console.log(ABCD.is.A.or.B(ABCD.B)); // prints: true
|
|
270
|
+
*
|
|
271
|
+
* // ❌
|
|
272
|
+
* const or = ABCD.is.A.or; // `or` is stateful, state: [A]
|
|
273
|
+
* console.log(or.B(ABCD.D)); // state: [A, B] | prints: false
|
|
274
|
+
* console.log(or.C(ABCD.D)); // state: [A, B, C] | prints: false
|
|
275
|
+
* console.log(or.D(ABCD.B)); // state: [A, B, C, D] | prints: true ⚠
|
|
276
|
+
* console.log(or.D(ABCD.C)); // state: [A, B, C, D] | prints: true ⚠
|
|
277
|
+
*/
|
|
278
|
+
or: Cases<TClass, TRestNames, TNames>;
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
namespace String {
|
|
282
|
+
namespace Or {
|
|
283
|
+
type Cases<TClass extends Class, TRestNames extends keyof TClass['Items'], TNames extends keyof TClass['Items']> = {
|
|
284
|
+
[K in TRestNames]: {
|
|
285
|
+
/**
|
|
286
|
+
* @summary Check `candidate` is enum item name-like string
|
|
287
|
+
*/
|
|
288
|
+
(candidate: string): boolean;
|
|
289
|
+
} & Next<TClass, Exclude<TRestNames, K>, TNames | K>;
|
|
290
|
+
};
|
|
291
|
+
type Next<TClass extends Class, TRestNames extends keyof TClass['Items'], TNames extends keyof TClass['Items']> = [TRestNames] extends [never] ? unknown : {
|
|
292
|
+
/**
|
|
293
|
+
* @summary Chaining access to fill `is` name-like string filter.
|
|
294
|
+
* @see AVStantso_EnumClass.Meta.Is.Or ⚠ `or` is stateful
|
|
295
|
+
*/
|
|
296
|
+
or: Cases<TClass, TRestNames, TNames>;
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* @summary Check `candidate` is enum item name-like string
|
|
302
|
+
*/
|
|
303
|
+
type String<TClass extends Class> = {
|
|
304
|
+
/**
|
|
305
|
+
* @summary Check `candidate` is enum item name-like string
|
|
306
|
+
*/
|
|
307
|
+
(candidate: string, ...filters: InstanceType<TClass>[]): boolean;
|
|
308
|
+
} & {
|
|
309
|
+
[K in keyof TClass['Items']]: {
|
|
310
|
+
/**
|
|
311
|
+
* @summary Check `candidate` enum item name-like string
|
|
312
|
+
*/
|
|
313
|
+
(candidate: string): boolean;
|
|
314
|
+
} & String.Or.Next<TClass, Exclude<keyof TClass['Items'], K>, K>;
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* @summary Check `candidate` is Enum class instance and match to filter if it's defined
|
|
319
|
+
*/
|
|
320
|
+
type Is<TClass extends Class> = {
|
|
321
|
+
/**
|
|
322
|
+
* @summary Check `candidate` is Enum class instance (+ use `tryFrom`) and match to filter if it's defined
|
|
323
|
+
*/
|
|
324
|
+
(candidate: unknown, ...filters: InstanceType<TClass>[]): candidate is Item<TClass>;
|
|
325
|
+
/**
|
|
326
|
+
* @summary Check `candidate` is enum item name-like capitalized string
|
|
327
|
+
*/
|
|
328
|
+
capitalized: Is.String<TClass>;
|
|
329
|
+
/**
|
|
330
|
+
* @summary Check `candidate` is enum item name-like uncapitalized string
|
|
331
|
+
*/
|
|
332
|
+
uncapitalized: Is.String<TClass>;
|
|
333
|
+
/**
|
|
334
|
+
* @summary Check `candidate` is enum item name-like caseInsensitive string
|
|
335
|
+
*/
|
|
336
|
+
caseInsensitive: Is.String<TClass>;
|
|
337
|
+
} & {
|
|
338
|
+
[K in keyof TClass['Items']]: {
|
|
339
|
+
/**
|
|
340
|
+
* @summary Check `candidate` is Enum class item instance
|
|
341
|
+
*/
|
|
342
|
+
(candidate: unknown): candidate is Item<TClass>;
|
|
343
|
+
} & Is.Or.Next<TClass, Exclude<keyof TClass['Items'], K>, K>;
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
export type Meta<TClass extends Class = Class, TKey extends keyof TClass['Items'] = keyof TClass['Items']> = {
|
|
347
|
+
[K in TKey]: Item<TClass, K, true>;
|
|
348
|
+
} & Meta.ValuesMap<TClass> & {
|
|
349
|
+
/**
|
|
350
|
+
* @summary Enum class access
|
|
351
|
+
*/
|
|
352
|
+
readonly enumClass: TClass;
|
|
353
|
+
/**
|
|
354
|
+
* @summary Enum class name without firsts `_`
|
|
355
|
+
*/
|
|
356
|
+
readonly enumName: string;
|
|
357
|
+
/**
|
|
358
|
+
* @summary Check `candidate` is string key of enum items
|
|
359
|
+
*/
|
|
360
|
+
hasKey(candidate: unknown): candidate is TKey;
|
|
361
|
+
/**
|
|
362
|
+
* @summary Design time only. May be used with `typeof` for get key item type
|
|
363
|
+
*/
|
|
364
|
+
readonly Key?: TKey;
|
|
365
|
+
/**
|
|
366
|
+
* @summary Design time only. May be used with `typeof` for get common item type
|
|
367
|
+
*/
|
|
368
|
+
readonly Item?: Item<TClass>;
|
|
369
|
+
/**
|
|
370
|
+
* @summary Design time only. May be used with `typeof` for get `KeyOrValueOrObject` type
|
|
371
|
+
*/
|
|
372
|
+
readonly KVO?: KeyOrValueOrObject<TClass>;
|
|
373
|
+
/**
|
|
374
|
+
* @summary Array of all keys (sorted by `this.values` order). Not including flags combinations.
|
|
375
|
+
*/
|
|
376
|
+
readonly keys: ReadonlyArray<TKey>;
|
|
377
|
+
/**
|
|
378
|
+
* @summary Array of all names (sorted by `this.values` order). Not including flags combinations.
|
|
379
|
+
*/
|
|
380
|
+
readonly names: ReadonlyArray<string>;
|
|
381
|
+
/**
|
|
382
|
+
* @summary Array of all numbers values (sorted ascending). Not including flags combinations.
|
|
383
|
+
*/
|
|
384
|
+
readonly values: ReadonlyArray<number>;
|
|
385
|
+
/**
|
|
386
|
+
* @summary Try get item object by name, by value or by object or `ToJSONField` field value
|
|
387
|
+
* @param candidate Input data
|
|
388
|
+
* @param defaultValue Default value for fails get
|
|
389
|
+
* @returns Object if found. `defaultValue` or `null` if not found
|
|
390
|
+
*/
|
|
391
|
+
tryFrom: Meta.From<TClass>;
|
|
392
|
+
/**
|
|
393
|
+
* @summary Get item object by name, by value or by object or `ToJSONField` field value
|
|
394
|
+
* @param candidate Input data
|
|
395
|
+
* @param defaultValue Default value for fails get
|
|
396
|
+
* @returns Object if found. If not found: `defaultValue` if it's defined, else throws `InvalidArgumentError`
|
|
397
|
+
*/
|
|
398
|
+
from: Meta.From<TClass>;
|
|
399
|
+
/**
|
|
400
|
+
* @summary Get random itemitem object by name, by value or by object
|
|
401
|
+
* @returns Object. Throws `InvalidArgumentError` if not found
|
|
402
|
+
*/
|
|
403
|
+
random(): Item<TClass>;
|
|
404
|
+
/**
|
|
405
|
+
* @summary Check `candidate` is Enum class instance and match to filter if it's defined
|
|
406
|
+
*/
|
|
407
|
+
is: Meta.Is<TClass>;
|
|
408
|
+
/**
|
|
409
|
+
* @summary Create mapping for enum
|
|
410
|
+
* @see AVStantso.Mapping
|
|
411
|
+
*/
|
|
412
|
+
Mapping<TTemplate extends object>(template: TTemplate): AVStantso.Mapping<TClass['Items'], TTemplate, 'value'>;
|
|
413
|
+
/**
|
|
414
|
+
* @summary Switch case for enum
|
|
415
|
+
* @see AVStantso.Switch
|
|
416
|
+
*/
|
|
417
|
+
switch: AVStantso_EnumClass.Switch<TClass>;
|
|
418
|
+
/**
|
|
419
|
+
* @summary Add fields to passed entity by record with enum key
|
|
420
|
+
* @param original Entity for extend
|
|
421
|
+
* @param extender Addition item by key
|
|
422
|
+
* @returns Extended entity
|
|
423
|
+
* @see AVStantso.Extend
|
|
424
|
+
*/
|
|
425
|
+
Extender: AVStantso.Extend.ByRecord<TKey, Item<TClass>>;
|
|
426
|
+
} & TClass['Statics'];
|
|
427
|
+
export {};
|
|
428
|
+
}
|
|
429
|
+
declare class AVStantso_EnumClass<TValue extends number = number> extends AVStantso_ValueWrap<TValue> implements AVStantso_EnumClass.Item.Template {
|
|
430
|
+
#private;
|
|
431
|
+
/**
|
|
432
|
+
* @see AVStantso_EnumClass.Class.Statics
|
|
433
|
+
*/
|
|
434
|
+
static Statics?: object;
|
|
435
|
+
/**
|
|
436
|
+
* @see AVStantso_EnumClass.Class.IsFlags
|
|
437
|
+
*/
|
|
438
|
+
static IsFlags: boolean;
|
|
439
|
+
/**
|
|
440
|
+
* @see AVStantso_EnumClass.Class.ToJSONField
|
|
441
|
+
*/
|
|
442
|
+
static ToJSONField: string;
|
|
443
|
+
/**
|
|
444
|
+
* @see AVStantso_EnumClass.Class.Items
|
|
445
|
+
*/
|
|
446
|
+
static Items: object;
|
|
447
|
+
/**
|
|
448
|
+
* @summary Test `candidate` is initialized enumeration.
|
|
449
|
+
*/
|
|
450
|
+
static isEnum(candidate: unknown): candidate is AVStantso_EnumClass.Meta;
|
|
451
|
+
static random<TClass extends AVStantso_EnumClass.Class>(this: TClass): InstanceType<TClass>;
|
|
452
|
+
static Init<TClass extends AVStantso_EnumClass.Class, TExtension extends (meta: AVStantso_EnumClass.Meta<TClass>) => unknown, R extends AVStantso_EnumClass.Meta<TClass> & ReturnType<TExtension> = AVStantso_EnumClass.Meta<TClass> & ReturnType<TExtension>>(this: TClass, initExt?: TExtension): {
|
|
453
|
+
[K in keyof R]: R[K];
|
|
454
|
+
};
|
|
455
|
+
/**
|
|
456
|
+
* @summary Access to `class`. ⚠ Use with caution when there is a complex hierarchy
|
|
457
|
+
*/
|
|
458
|
+
protected get meta(): any;
|
|
459
|
+
private _name;
|
|
460
|
+
constructor(value: TValue);
|
|
461
|
+
get name(): string;
|
|
462
|
+
protected toString(): string;
|
|
463
|
+
protected toJSON(): any;
|
|
464
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './_register';
|
package/dist/export.d.ts
ADDED
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
require('@avstantso/errors');
|
|
4
|
+
require('@avstantso/js');
|
|
5
|
+
require('@avstantso/concepts');
|
|
6
|
+
|
|
7
|
+
let AVStantso_EnumClass$1 = class AVStantso_EnumClass extends AVStantso_ValueWrap {
|
|
8
|
+
static #FROM_MODES = {
|
|
9
|
+
capitalized: 1,
|
|
10
|
+
uncapitalized: 2,
|
|
11
|
+
caseInsensitive: 3
|
|
12
|
+
};
|
|
13
|
+
//#region static implements Enum.Class
|
|
14
|
+
/**
|
|
15
|
+
* @see AVStantso_EnumClass.Class.Statics
|
|
16
|
+
*/
|
|
17
|
+
static Statics;
|
|
18
|
+
/**
|
|
19
|
+
* @see AVStantso_EnumClass.Class.IsFlags
|
|
20
|
+
*/
|
|
21
|
+
static IsFlags = false;
|
|
22
|
+
/**
|
|
23
|
+
* @see AVStantso_EnumClass.Class.ToJSONField
|
|
24
|
+
*/
|
|
25
|
+
static ToJSONField = 'value';
|
|
26
|
+
/**
|
|
27
|
+
* @see AVStantso_EnumClass.Class.Items
|
|
28
|
+
*/
|
|
29
|
+
static Items = null;
|
|
30
|
+
//#endregion
|
|
31
|
+
/**
|
|
32
|
+
* @summary Test `candidate` is initialized enumeration.
|
|
33
|
+
*/
|
|
34
|
+
static isEnum(candidate) {
|
|
35
|
+
return (candidate
|
|
36
|
+
&& avstantso.JS.is.function(candidate)
|
|
37
|
+
&& !!candidate.enumClass);
|
|
38
|
+
}
|
|
39
|
+
static random() {
|
|
40
|
+
const { values } = this;
|
|
41
|
+
const i = Math.floor(Math.random() * values.length);
|
|
42
|
+
return this[values[i]];
|
|
43
|
+
}
|
|
44
|
+
static Init(initExt) {
|
|
45
|
+
const { JS, Switch, Extend } = avstantso;
|
|
46
|
+
const FROM_MODES = AVStantso_EnumClass.#FROM_MODES;
|
|
47
|
+
const enumClass = this;
|
|
48
|
+
const { IsFlags, ToJSONField, Items } = this;
|
|
49
|
+
const combinations = IsFlags && {};
|
|
50
|
+
const hasKey = function hasKey(candidate) {
|
|
51
|
+
return JS.is.string(candidate) && candidate in this.Items;
|
|
52
|
+
}.bind(this);
|
|
53
|
+
//#region from
|
|
54
|
+
function findFrom(candidate, mode, safe) {
|
|
55
|
+
if (undefined === candidate && safe)
|
|
56
|
+
return;
|
|
57
|
+
function badData() {
|
|
58
|
+
if (!safe)
|
|
59
|
+
throw new AVStantso_InvalidArgumentTypeError(this, 'findFrom', [this.name, 'string', 'number'], { candidate });
|
|
60
|
+
}
|
|
61
|
+
if (undefined !== mode) {
|
|
62
|
+
if (JS.is.string(candidate)) {
|
|
63
|
+
const [, v] = Object.entries(Items).find(([key]) => {
|
|
64
|
+
switch (mode) {
|
|
65
|
+
case FROM_MODES.capitalized:
|
|
66
|
+
return (candidate.toCapitalized() === String(key).toCapitalized());
|
|
67
|
+
case FROM_MODES.uncapitalized:
|
|
68
|
+
return (candidate.toUncapitalized()
|
|
69
|
+
=== String(key).toUncapitalized());
|
|
70
|
+
case FROM_MODES.caseInsensitive:
|
|
71
|
+
return candidate.toUpperCase() === String(key).toUpperCase();
|
|
72
|
+
default:
|
|
73
|
+
throw new AVStantso_InvalidArgumentError(this, 'findFrom', { mode });
|
|
74
|
+
}
|
|
75
|
+
}) || [];
|
|
76
|
+
return v;
|
|
77
|
+
}
|
|
78
|
+
badData.call(this);
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
if (JS.is.object(candidate)) {
|
|
82
|
+
if (candidate instanceof this)
|
|
83
|
+
return candidate;
|
|
84
|
+
}
|
|
85
|
+
else if (JS.is.number(candidate)) {
|
|
86
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
87
|
+
const v = !Number.isNaN(candidate) && this[candidate];
|
|
88
|
+
if (v)
|
|
89
|
+
return v;
|
|
90
|
+
}
|
|
91
|
+
else if (JS.is.string(candidate)) {
|
|
92
|
+
{
|
|
93
|
+
const [, v] = Object.entries(Items).find(([key]) => candidate === key) || [];
|
|
94
|
+
if (v)
|
|
95
|
+
return v;
|
|
96
|
+
}
|
|
97
|
+
if ('value' === ToJSONField) {
|
|
98
|
+
const n = Number.parseInt(candidate, 10);
|
|
99
|
+
if (!Number.isNaN(n)) {
|
|
100
|
+
const v = findFrom.call(this, n);
|
|
101
|
+
if (v)
|
|
102
|
+
return v;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
const finder = (item) =>
|
|
107
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
108
|
+
item[ToJSONField] === candidate;
|
|
109
|
+
{
|
|
110
|
+
const v = Object.values(Items).find(finder);
|
|
111
|
+
if (v)
|
|
112
|
+
return v;
|
|
113
|
+
}
|
|
114
|
+
if (combinations) {
|
|
115
|
+
const v = Object.values(combinations).find(finder);
|
|
116
|
+
if (v)
|
|
117
|
+
return v;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
else
|
|
122
|
+
badData.call(this);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
function doFrom(candidate, defaultValue, mode, safe) {
|
|
126
|
+
const v = findFrom.call(this, candidate, mode, safe || undefined !== defaultValue);
|
|
127
|
+
if (v)
|
|
128
|
+
return v;
|
|
129
|
+
if (!v && undefined !== defaultValue)
|
|
130
|
+
return defaultValue;
|
|
131
|
+
if (!v && safe)
|
|
132
|
+
return null;
|
|
133
|
+
// console.warn(`%O`, this);
|
|
134
|
+
throw new AVStantso_InvalidArgumentError(this, 'from', { candidate }, 'invalid enum value %FV');
|
|
135
|
+
}
|
|
136
|
+
function WrapFrom(f, safe) {
|
|
137
|
+
return Object.assign(f, {
|
|
138
|
+
capitalized: function tryFromCapitalized(candidate, defaultValue) {
|
|
139
|
+
return doFrom.call(this, candidate, defaultValue, FROM_MODES.capitalized, safe);
|
|
140
|
+
}.bind(this),
|
|
141
|
+
uncapitalized: function tryFromUncapitalized(candidate, defaultValue) {
|
|
142
|
+
return doFrom.call(this, candidate, defaultValue, FROM_MODES.uncapitalized, safe);
|
|
143
|
+
}.bind(this),
|
|
144
|
+
caseInsensitive: function tryFromCaseInsensitive(candidate, defaultValue) {
|
|
145
|
+
return doFrom.call(this, candidate, defaultValue, FROM_MODES.caseInsensitive, safe);
|
|
146
|
+
}.bind(this)
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
const tryFrom = WrapFrom.call(this, function tryFrom(candidate, defaultValue) {
|
|
150
|
+
return doFrom.call(this, candidate, defaultValue, undefined, true);
|
|
151
|
+
}.bind(this), true);
|
|
152
|
+
const from = WrapFrom.call(this, function from(candidate, defaultValue) {
|
|
153
|
+
return doFrom.call(this, candidate, defaultValue);
|
|
154
|
+
}.bind(this));
|
|
155
|
+
//#endregion
|
|
156
|
+
const toName = (value) => tryFrom(value)?.name;
|
|
157
|
+
const _switch = Switch(toName);
|
|
158
|
+
const Mapping = avstantso.Mapping('value', toName);
|
|
159
|
+
const Extender = Extend.ByRecord(Object.keys(Items), from);
|
|
160
|
+
function IsEnumItem(mode) {
|
|
161
|
+
return Extender(function isEnumItem(candidate, ...filters) {
|
|
162
|
+
const obj = doFrom.call(this, candidate, undefined, mode, true);
|
|
163
|
+
if (obj) {
|
|
164
|
+
if (!filters.length)
|
|
165
|
+
return true;
|
|
166
|
+
const v = +obj;
|
|
167
|
+
for (const f of filters)
|
|
168
|
+
if (+f === v)
|
|
169
|
+
return true;
|
|
170
|
+
}
|
|
171
|
+
return false;
|
|
172
|
+
}.bind(this), function (item, original) {
|
|
173
|
+
const filters = new Set([item]);
|
|
174
|
+
const isOr = function isOr(candidate) {
|
|
175
|
+
return original.call(this, candidate, ...filters);
|
|
176
|
+
}.bind(this);
|
|
177
|
+
const proxy = new Proxy(isOr, {
|
|
178
|
+
get(target, p) {
|
|
179
|
+
if (hasKey(p)) {
|
|
180
|
+
filters.add(from(p));
|
|
181
|
+
return isOr;
|
|
182
|
+
}
|
|
183
|
+
return Reflect.get(target, p);
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
Object.defineProperties(isOr, {
|
|
187
|
+
or: { value: proxy, writable: false }
|
|
188
|
+
});
|
|
189
|
+
return proxy;
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
const isEnumItem = Object.assign(IsEnumItem.call(this), {
|
|
193
|
+
capitalized: IsEnumItem.call(this, FROM_MODES.capitalized),
|
|
194
|
+
uncapitalized: IsEnumItem.call(this, FROM_MODES.uncapitalized),
|
|
195
|
+
caseInsensitive: IsEnumItem.call(this, FROM_MODES.caseInsensitive)
|
|
196
|
+
});
|
|
197
|
+
// Protect from runtime access. Will redefine as property
|
|
198
|
+
delete this.Statics;
|
|
199
|
+
const designtimeOnly = {
|
|
200
|
+
value: undefined,
|
|
201
|
+
writable: false,
|
|
202
|
+
configurable: false
|
|
203
|
+
};
|
|
204
|
+
Object.defineProperties(this, {
|
|
205
|
+
Statics: designtimeOnly,
|
|
206
|
+
Key: designtimeOnly,
|
|
207
|
+
Item: designtimeOnly,
|
|
208
|
+
KVO: designtimeOnly,
|
|
209
|
+
enumClass: { value: enumClass, writable: false },
|
|
210
|
+
enumName: { value: this.name.replace(/$_+/, ''), writable: false },
|
|
211
|
+
hasKey: { value: hasKey, writable: false },
|
|
212
|
+
map: { value: Items, writable: false },
|
|
213
|
+
...(combinations
|
|
214
|
+
? { combinations: { value: combinations, writable: false } }
|
|
215
|
+
: {}),
|
|
216
|
+
tryFrom: { value: tryFrom, writable: false },
|
|
217
|
+
from: { value: from, writable: false },
|
|
218
|
+
is: { value: isEnumItem, writable: false },
|
|
219
|
+
switch: { value: _switch, writable: false },
|
|
220
|
+
Mapping: { value: Mapping, writable: false },
|
|
221
|
+
Extender: { value: Extender, writable: false }
|
|
222
|
+
});
|
|
223
|
+
function add(item, name) {
|
|
224
|
+
function is(other) {
|
|
225
|
+
const obj = tryFrom(other);
|
|
226
|
+
return obj && +this === +obj;
|
|
227
|
+
}
|
|
228
|
+
function scroll(by = 1) {
|
|
229
|
+
if (0 === by)
|
|
230
|
+
return this;
|
|
231
|
+
const { value } = this;
|
|
232
|
+
AVStantso_InvalidArgumentTypeError.validate.number(this, scroll, { by });
|
|
233
|
+
const { values } = enumClass;
|
|
234
|
+
const lastI = values.length - 1;
|
|
235
|
+
const step = Math.sign(by);
|
|
236
|
+
let i = values.findIndex((ind) => ind === value);
|
|
237
|
+
for (let j = Math.abs(by % values.length); j > 0; j--) {
|
|
238
|
+
if (i <= 0)
|
|
239
|
+
i = lastI;
|
|
240
|
+
else if (i >= lastI)
|
|
241
|
+
i = 0;
|
|
242
|
+
else
|
|
243
|
+
i += step;
|
|
244
|
+
}
|
|
245
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
246
|
+
return enumClass[values[i]];
|
|
247
|
+
}
|
|
248
|
+
Object.assign(item, { _name: name, scroll, is });
|
|
249
|
+
Object.defineProperties(item, {
|
|
250
|
+
key: { value: name, writable: false },
|
|
251
|
+
prev: {
|
|
252
|
+
get() {
|
|
253
|
+
this.scroll(-1);
|
|
254
|
+
}
|
|
255
|
+
},
|
|
256
|
+
next: {
|
|
257
|
+
get() {
|
|
258
|
+
this.scroll(1);
|
|
259
|
+
}
|
|
260
|
+
},
|
|
261
|
+
switch: {
|
|
262
|
+
value: _switch.bind(null, item.value),
|
|
263
|
+
writable: false
|
|
264
|
+
},
|
|
265
|
+
...(!IsFlags
|
|
266
|
+
? {}
|
|
267
|
+
: {
|
|
268
|
+
/**
|
|
269
|
+
* @see AVStantso_EnumClass.Item.Or
|
|
270
|
+
*/
|
|
271
|
+
or: {
|
|
272
|
+
value: new Proxy(item, {
|
|
273
|
+
get(target, p) {
|
|
274
|
+
if (hasKey(p)) {
|
|
275
|
+
const next = from(p);
|
|
276
|
+
// eslint-disable-next-line no-bitwise
|
|
277
|
+
return from(+target | +next);
|
|
278
|
+
}
|
|
279
|
+
return Reflect.get(target, p);
|
|
280
|
+
}
|
|
281
|
+
}),
|
|
282
|
+
writable: false
|
|
283
|
+
}
|
|
284
|
+
})
|
|
285
|
+
});
|
|
286
|
+
for (const k of [name, item.value])
|
|
287
|
+
Object.defineProperty(this, k, { value: item, writable: false });
|
|
288
|
+
return Object.freeze(item);
|
|
289
|
+
}
|
|
290
|
+
for (const [k, v] of Object.entries(Items))
|
|
291
|
+
add.call(this, v, k);
|
|
292
|
+
if (IsFlags) {
|
|
293
|
+
function isPowerOfTwo(n) {
|
|
294
|
+
if (n == 0)
|
|
295
|
+
return false;
|
|
296
|
+
const r = Math.log(n) / Math.log(2);
|
|
297
|
+
return Math.ceil(r) === Math.floor(r);
|
|
298
|
+
}
|
|
299
|
+
const vs = Object.values(Items)
|
|
300
|
+
.filter((v) => isPowerOfTwo(+v)) // 👈 Exclude predefined combinations
|
|
301
|
+
.sort((a, b) => +a - +b);
|
|
302
|
+
/* eslint-disable no-bitwise */
|
|
303
|
+
for (let i = 0; i < 1 << vs.length; i++) {
|
|
304
|
+
const combination = [];
|
|
305
|
+
for (let j = 0; j < vs.length; j++)
|
|
306
|
+
if (i & (1 << j))
|
|
307
|
+
combination.push(vs[j]);
|
|
308
|
+
if (combination.length <= 1)
|
|
309
|
+
continue;
|
|
310
|
+
const v = combination.reduce((r, item) => r + +item, 0);
|
|
311
|
+
let c = enumClass[v];
|
|
312
|
+
if (!c) {
|
|
313
|
+
const n = combination.map(({ name }) => name).join('|');
|
|
314
|
+
c = add.call(this, new this(v), n);
|
|
315
|
+
}
|
|
316
|
+
combinations[c.name] = c;
|
|
317
|
+
}
|
|
318
|
+
/* eslint-enable no-bitwise */
|
|
319
|
+
Object.freeze(combinations);
|
|
320
|
+
for (const n of Object.keys(combinations))
|
|
321
|
+
delete Items[n]; // 👈 Transfer predefined combinations from Items
|
|
322
|
+
}
|
|
323
|
+
// After transfer predefined combinations
|
|
324
|
+
{
|
|
325
|
+
const values = Object.freeze(Object.values(Items)
|
|
326
|
+
.map(({ value }) => value)
|
|
327
|
+
.sort((a, b) => a - b));
|
|
328
|
+
// Sorted by `this.values` order!
|
|
329
|
+
const names = Object.freeze(values.map((v) => from(v).name));
|
|
330
|
+
Object.defineProperties(this, {
|
|
331
|
+
keys: { value: names, writable: false },
|
|
332
|
+
names: { value: names, writable: false },
|
|
333
|
+
values: { value: values, writable: false }
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
Object.freeze(Items);
|
|
337
|
+
return Object.assign(enumClass, initExt && initExt(enumClass)
|
|
338
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
339
|
+
);
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* @summary Access to `class`. ⚠ Use with caution when there is a complex hierarchy
|
|
343
|
+
*/
|
|
344
|
+
get meta() {
|
|
345
|
+
return Object.getPrototypeOf(this).constructor;
|
|
346
|
+
}
|
|
347
|
+
_name;
|
|
348
|
+
constructor(value) {
|
|
349
|
+
super(value);
|
|
350
|
+
}
|
|
351
|
+
get name() {
|
|
352
|
+
return this._name;
|
|
353
|
+
}
|
|
354
|
+
toString() {
|
|
355
|
+
return this.name;
|
|
356
|
+
}
|
|
357
|
+
toJSON() {
|
|
358
|
+
const { ToJSONField } = this.meta;
|
|
359
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
360
|
+
return this[ToJSONField];
|
|
361
|
+
}
|
|
362
|
+
};
|
|
363
|
+
if (!('AVStantso_EnumClass' in globalThis))
|
|
364
|
+
Object.defineProperties(globalThis, {
|
|
365
|
+
AVStantso_EnumClass: {
|
|
366
|
+
value: AVStantso_EnumClass$1,
|
|
367
|
+
writable: false,
|
|
368
|
+
configurable: false
|
|
369
|
+
}
|
|
370
|
+
});
|
|
371
|
+
|
|
372
|
+
var EnumClass = AVStantso_EnumClass;
|
|
373
|
+
|
|
374
|
+
exports.EnumClass = EnumClass;
|
|
375
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/_global/_register.ts","../src/export.ts"],"sourcesContent":["/**\n * @summary Enum implementation where every item is instance of class\n * @EXAMPLE(@EnumClass.CollectionAction)\n * @EXAMPLE(@EnumClass.FileMode)\n * @EXAMPLE(@EnumClass.Direction)\n */\nnamespace AVStantso_EnumClass {\n type KVO<TClass extends AVStantso_EnumClass.Class = AVStantso_EnumClass.Class> =\n AVStantso_EnumClass.KeyOrValueOrObject<TClass>;\n\n //#region Item\n export namespace Item {\n export type Name = string;\n export type Value = number;\n\n export type Template = {\n readonly name: Name;\n readonly value: Value;\n };\n\n export namespace Or {\n export type Cases<\n TClass extends Class,\n TRestNames extends keyof TClass['Items'],\n TNames extends keyof TClass['Items']\n > = {\n [K in TRestNames]: Item<TClass, TNames | K>\n & Next<TClass, Exclude<TRestNames, K>, TNames | K>;\n };\n\n export type Next<\n TClass extends Class,\n TRestNames extends keyof TClass['Items'],\n TNames extends keyof TClass['Items']\n > = [TRestNames] extends [never]\n ? unknown\n : {\n /**\n * @summary Chaining access to flags combinations\n */\n or: Cases<TClass, TRestNames, TNames>;\n };\n }\n }\n\n export namespace Switch {\n export type Cases<TClass extends Class, TCase> = AVStantso.Switch.Cases<\n keyof TClass['Items'] | keyof Meta.ValuesMap<TClass>,\n { Case: TCase }\n >;\n }\n\n /**\n * @summary This is analog of switch construction supports values from type enum\n * @example enum E {a, b, c, d, e }\n * const x = switch<number>(E.d, {a: 1, b: 2, \"c|d|e\": 3, default: 4} );\n * // x = 3\n */\n export type Switch<TClass extends Class> = {\n <\n TCase,\n TCases extends Switch.Cases<TClass, TCase> = Switch.Cases<TClass, TCase>\n >(\n value: KVO,\n cases: TCases\n ): TCase;\n };\n\n export type Item<\n TClass extends Class,\n TName extends keyof TClass['Items'] = keyof TClass['Items'],\n IsDetermined extends boolean = false\n > = TClass['Items'][TName] & {\n /**\n * @summary Name casted to `keyof TClass['Items']`\n */\n readonly key: TName;\n\n /**\n * @summary Prev enum item. Turns first to last\n */\n readonly prev: Item<TClass>;\n\n /**\n * @summary Next enum item. Turns last to first\n */\n readonly next: Item<TClass>;\n\n /**\n * @summary Scroll enum item `by`. Turns last to first and first to last\n * @param by If positive: scroll up (turns last to first) / If negative: scroll down (turns first to last)\n */\n scroll(by?: number): Item<TClass>;\n\n /**\n * @summary Check if `other` is an enum of objects with some value. Use `tryFrom`\n */\n is(other: KVO<TClass>): boolean;\n\n /**\n * @summary Switch case for this enum item\n * @see AVStantso.Switch\n */\n switch<\n TCase,\n TCases extends AVStantso_EnumClass.Switch.Cases<TClass, TCase> =\n AVStantso_EnumClass.Switch.Cases<\n TClass,\n TCase\n >\n >(\n cases: TCases\n ): TCase;\n } & (TClass['IsFlags'] extends true\n ? IsDetermined extends true\n ? Item.Or.Next<TClass, Exclude<keyof TClass['Items'], TName>, TName>\n : unknown\n : unknown);\n //#endregion\n\n export type Class = {\n new <TValue extends number = number>(\n value: TValue,\n ...params: AVStantso.TS.Arr\n ): AVStantso_EnumClass<TValue>;\n\n /**\n * @summary Design time only. Type source of Enum.Meta.Statics\n * @description All public statics must be declared as type and override this property\n * @default {}\n */\n Statics?: object;\n\n /**\n * @summary `true` — allow create values combinations\n * @default false\n */\n IsFlags: boolean;\n\n /**\n * @summary Field name for JSON serialization\n * @default `value`\n */\n ToJSONField: string;\n\n /**\n * @summary Enum items. Must be overridden in Enum child class\n */\n Items: NodeJS.Dict<Item.Template>;\n };\n\n export type KeyOrValueOrObject<TClass extends Class> =\n | string\n | number\n | InstanceType<TClass>;\n\n //#region Meta\n export namespace Meta {\n export type ValuesMap<TClass extends Class> = {\n [K in keyof TClass['Items'] as TClass['Items'][K]['value']]: Item<\n TClass,\n K,\n true\n >;\n };\n\n /**\n * @summary Get item object by name, by value or by object or `ToJSONField` field value\n * @param candidate Input data\n * @param defaultValue Default value for fails get\n */\n export type From<TClass extends Class> = {\n /**\n * @summary Get item object by name, by value or by object or `ToJSONField` field value\n * @param candidate Input data\n * @param defaultValue Default value for fails get\n */\n (candidate: KVO<TClass>, defaultValue?: Item<TClass>): Item<TClass>;\n\n /**\n * @summary Get item object by capitalized name\n * @param candidate Input data\n * @param defaultValue Default value for fails get\n */\n capitalized(candidate: string, defaultValue?: Item<TClass>): Item<TClass>;\n\n /**\n * @summary Get item object by uncapitalized name\n * @param candidate Input data\n * @param defaultValue Default value for fails get\n */\n uncapitalized(\n candidate: string,\n defaultValue?: Item<TClass>\n ): Item<TClass>;\n\n /**\n * @summary Get item object by case insensitive name\n * @param candidate Input data\n * @param defaultValue Default value for fails get\n */\n caseInsensitive(\n candidate: string,\n defaultValue?: Item<TClass>\n ): Item<TClass>;\n };\n\n export namespace Is {\n export namespace Or {\n export type Cases<\n TClass extends Class,\n TRestNames extends keyof TClass['Items'],\n TNames extends keyof TClass['Items']\n > = {\n [K in TRestNames]: {\n /**\n * @summary Check `candidate` is Enum class item instance\n */\n (candidate: unknown): candidate is Item<TClass, TNames | K>;\n } & Next<TClass, Exclude<TRestNames, K>, TNames | K>;\n };\n\n export type Next<\n TClass extends Class,\n TRestNames extends keyof TClass['Items'],\n TNames extends keyof TClass['Items']\n > = [TRestNames] extends [never]\n ? unknown\n : {\n /**\n * @summary Chaining access to fill `is` filter.\n * @example\n * // 👇 See below: Only inline calls are supported\n * class _ABCD<TValue extends number = number> extends Enum<TValue> {\n * public static Items = {\n * A: new _ABCD(0),\n * B: new _ABCD(1),\n * C: new _ABCD(2),\n * D: new _ABCD(3),\n * };\n * }\n *\n * export const ABCD = _ABCD.Init();\n *\n * // ✔\n * console.log(ABCD.is.A.or.B(ABCD.C)); // prints: false\n * console.log(ABCD.is.A.or.B(ABCD.B)); // prints: true\n *\n * // ❌\n * const or = ABCD.is.A.or; // `or` is stateful, state: [A]\n * console.log(or.B(ABCD.D)); // state: [A, B] | prints: false\n * console.log(or.C(ABCD.D)); // state: [A, B, C] | prints: false\n * console.log(or.D(ABCD.B)); // state: [A, B, C, D] | prints: true ⚠\n * console.log(or.D(ABCD.C)); // state: [A, B, C, D] | prints: true ⚠\n */\n or: Cases<TClass, TRestNames, TNames>;\n };\n }\n\n export namespace String {\n export namespace Or {\n export type Cases<\n TClass extends Class,\n TRestNames extends keyof TClass['Items'],\n TNames extends keyof TClass['Items']\n > = {\n [K in TRestNames]: {\n /**\n * @summary Check `candidate` is enum item name-like string\n */\n (candidate: string): boolean;\n } & Next<TClass, Exclude<TRestNames, K>, TNames | K>;\n };\n\n export type Next<\n TClass extends Class,\n TRestNames extends keyof TClass['Items'],\n TNames extends keyof TClass['Items']\n > = [TRestNames] extends [never]\n ? unknown\n : {\n /**\n * @summary Chaining access to fill `is` name-like string filter.\n * @see AVStantso_EnumClass.Meta.Is.Or ⚠ `or` is stateful\n */\n or: Cases<TClass, TRestNames, TNames>;\n };\n }\n }\n\n /**\n * @summary Check `candidate` is enum item name-like string\n */\n export type String<TClass extends Class> = {\n /**\n * @summary Check `candidate` is enum item name-like string\n */\n (candidate: string, ...filters: InstanceType<TClass>[]): boolean;\n } & {\n /**\n * @summary Check `candidate` is enum item name-like string\n */\n [K in keyof TClass['Items']]: {\n /**\n * @summary Check `candidate` enum item name-like string\n */\n (candidate: string): boolean;\n } & String.Or.Next<TClass, Exclude<keyof TClass['Items'], K>, K>;\n };\n }\n\n /**\n * @summary Check `candidate` is Enum class instance and match to filter if it's defined\n */\n export type Is<TClass extends Class> = {\n /**\n * @summary Check `candidate` is Enum class instance (+ use `tryFrom`) and match to filter if it's defined\n */\n (\n candidate: unknown,\n ...filters: InstanceType<TClass>[]\n ): candidate is Item<TClass>;\n\n /**\n * @summary Check `candidate` is enum item name-like capitalized string\n */\n capitalized: Is.String<TClass>;\n\n /**\n * @summary Check `candidate` is enum item name-like uncapitalized string\n */\n uncapitalized: Is.String<TClass>;\n\n /**\n * @summary Check `candidate` is enum item name-like caseInsensitive string\n */\n caseInsensitive: Is.String<TClass>;\n } & {\n /**\n * @summary Check `candidate` is Enum class item instance\n */\n [K in keyof TClass['Items']]: {\n /**\n * @summary Check `candidate` is Enum class item instance\n */\n (candidate: unknown): candidate is Item<TClass>;\n } & Is.Or.Next<TClass, Exclude<keyof TClass['Items'], K>, K>;\n };\n }\n\n export type Meta<\n TClass extends Class = Class,\n TKey extends keyof TClass['Items'] = keyof TClass['Items']\n > = {\n [K in TKey]: Item<TClass, K, true>;\n } & Meta.ValuesMap<TClass> & {\n /**\n * @summary Enum class access\n */\n readonly enumClass: TClass;\n\n /**\n * @summary Enum class name without firsts `_`\n */\n readonly enumName: string;\n\n /**\n * @summary Check `candidate` is string key of enum items\n */\n hasKey(candidate: unknown): candidate is TKey;\n\n /**\n * @summary Design time only. May be used with `typeof` for get key item type\n */\n readonly Key?: TKey;\n\n /**\n * @summary Design time only. May be used with `typeof` for get common item type\n */\n readonly Item?: Item<TClass>;\n\n /**\n * @summary Design time only. May be used with `typeof` for get `KeyOrValueOrObject` type\n */\n readonly KVO?: KeyOrValueOrObject<TClass>;\n\n /**\n * @summary Array of all keys (sorted by `this.values` order). Not including flags combinations.\n */\n readonly keys: ReadonlyArray<TKey>;\n\n /**\n * @summary Array of all names (sorted by `this.values` order). Not including flags combinations.\n */\n readonly names: ReadonlyArray<string>;\n\n /**\n * @summary Array of all numbers values (sorted ascending). Not including flags combinations.\n */\n readonly values: ReadonlyArray<number>;\n\n /**\n * @summary Try get item object by name, by value or by object or `ToJSONField` field value\n * @param candidate Input data\n * @param defaultValue Default value for fails get\n * @returns Object if found. `defaultValue` or `null` if not found\n */\n tryFrom: Meta.From<TClass>;\n\n /**\n * @summary Get item object by name, by value or by object or `ToJSONField` field value\n * @param candidate Input data\n * @param defaultValue Default value for fails get\n * @returns Object if found. If not found: `defaultValue` if it's defined, else throws `InvalidArgumentError`\n */\n from: Meta.From<TClass>;\n\n /**\n * @summary Get random itemitem object by name, by value or by object\n * @returns Object. Throws `InvalidArgumentError` if not found\n */\n random(): Item<TClass>;\n\n /**\n * @summary Check `candidate` is Enum class instance and match to filter if it's defined\n */\n is: Meta.Is<TClass>;\n\n /**\n * @summary Create mapping for enum\n * @see AVStantso.Mapping\n */\n Mapping<TTemplate extends object>(\n template: TTemplate\n ): AVStantso.Mapping<TClass['Items'], TTemplate, 'value'>;\n\n /**\n * @summary Switch case for enum\n * @see AVStantso.Switch\n */\n switch: AVStantso_EnumClass.Switch<TClass>;\n\n /**\n * @summary Add fields to passed entity by record with enum key\n * @param original Entity for extend\n * @param extender Addition item by key\n * @returns Extended entity\n * @see AVStantso.Extend\n */\n Extender: AVStantso.Extend.ByRecord<TKey, Item<TClass>>;\n } & TClass['Statics'];\n //#endregion\n}\n\nclass AVStantso_EnumClass<TValue extends number = number>\n extends AVStantso_ValueWrap<TValue>\n implements AVStantso_EnumClass.Item.Template\n{\n static #FROM_MODES = {\n capitalized: 1,\n uncapitalized: 2,\n caseInsensitive: 3\n } as const;\n\n //#region static implements Enum.Class\n /**\n * @see AVStantso_EnumClass.Class.Statics\n */\n public static Statics?: object;\n\n /**\n * @see AVStantso_EnumClass.Class.IsFlags\n */\n public static IsFlags: boolean = false;\n\n /**\n * @see AVStantso_EnumClass.Class.ToJSONField\n */\n public static ToJSONField = 'value';\n\n /**\n * @see AVStantso_EnumClass.Class.Items\n */\n public static Items: object = null;\n //#endregion\n\n /**\n * @summary Test `candidate` is initialized enumeration.\n */\n public static isEnum(candidate: unknown): candidate is AVStantso_EnumClass.Meta {\n return (\n candidate\n && avstantso.JS.is.function(candidate)\n && !!(candidate as unknown as AVStantso_EnumClass.Meta).enumClass\n );\n }\n\n public static random<TClass extends AVStantso_EnumClass.Class>(\n this: TClass\n ): InstanceType<TClass> {\n const { values } = this as unknown as AVStantso_EnumClass.Meta<TClass>;\n\n const i = Math.floor(Math.random() * values.length);\n return (this as unknown as NodeJS.Dict<InstanceType<TClass>>)[values[i]];\n }\n\n public static Init<\n TClass extends AVStantso_EnumClass.Class,\n TExtension extends (meta: AVStantso_EnumClass.Meta<TClass>) => unknown,\n R extends AVStantso_EnumClass.Meta<TClass> & ReturnType<TExtension> =\n AVStantso_EnumClass.Meta<TClass> & ReturnType<TExtension>\n >(this: TClass, initExt?: TExtension): { [K in keyof R]: R[K] } {\n const { JS, Switch, Extend } = avstantso;\n\n type KVO<TClass extends AVStantso_EnumClass.Class = AVStantso_EnumClass.Class> =\n AVStantso_EnumClass.KeyOrValueOrObject<TClass>;\n\n type TEnum = InstanceType<TClass>;\n const FROM_MODES = AVStantso_EnumClass.#FROM_MODES;\n\n const enumClass = this as AVStantso_EnumClass.Meta<TClass>;\n const { IsFlags, ToJSONField, Items } = this;\n\n const combinations: NodeJS.Dict<AVStantso_EnumClass.Item.Template> = IsFlags && {};\n\n const hasKey = function hasKey(\n this: TClass,\n candidate: unknown\n ): candidate is keyof TClass['Items'] {\n return JS.is.string(candidate) && candidate in this.Items;\n }.bind(this) as AVStantso_EnumClass.Meta<TClass>['hasKey'];\n\n //#region from\n function findFrom(\n this: TClass,\n candidate: unknown,\n mode?: number,\n safe?: boolean\n ): AVStantso_EnumClass.Item.Template {\n if (undefined === candidate && safe) return;\n\n function badData(this: TClass) {\n if (!safe)\n throw new AVStantso_InvalidArgumentTypeError(\n this,\n 'findFrom',\n [this.name, 'string', 'number'],\n { candidate }\n );\n }\n\n if (undefined !== mode) {\n if (JS.is.string(candidate)) {\n const [, v] =\n Object.entries(Items).find(([key]) => {\n switch (mode) {\n case FROM_MODES.capitalized:\n return (\n candidate.toCapitalized() === String(key).toCapitalized()\n );\n\n case FROM_MODES.uncapitalized:\n return (\n candidate.toUncapitalized()\n === String(key).toUncapitalized()\n );\n\n case FROM_MODES.caseInsensitive:\n return candidate.toUpperCase() === String(key).toUpperCase();\n\n default:\n throw new AVStantso_InvalidArgumentError(this, 'findFrom', { mode });\n }\n }) || [];\n\n return v;\n }\n\n badData.call(this);\n } else {\n if (JS.is.object(candidate)) {\n if (candidate instanceof this) return candidate;\n } else if (JS.is.number(candidate)) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const v = !Number.isNaN(candidate) && (this as any)[candidate];\n if (v) return v;\n } else if (JS.is.string(candidate)) {\n {\n const [, v] =\n Object.entries(Items).find(([key]) => candidate === key) || [];\n\n if (v) return v;\n }\n\n if ('value' === ToJSONField) {\n const n = Number.parseInt(candidate, 10);\n if (!Number.isNaN(n)) {\n const v = findFrom.call(this, n);\n if (v) return v;\n }\n } else {\n const finder = (item: AVStantso_EnumClass.Item.Template) =>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (item as any)[ToJSONField] === candidate;\n\n {\n const v = Object.values(Items).find(finder);\n if (v) return v;\n }\n\n if (combinations) {\n const v = Object.values(combinations).find(finder);\n if (v) return v;\n }\n }\n } else badData.call(this);\n }\n }\n\n function doFrom(\n this: TClass,\n candidate: unknown,\n defaultValue: AVStantso_EnumClass.Item.Template,\n mode?: number,\n safe?: boolean\n ): AVStantso_EnumClass.Item.Template {\n const v = findFrom.call(\n this,\n candidate,\n mode,\n safe || undefined !== defaultValue\n );\n if (v) return v;\n\n if (!v && undefined !== defaultValue) return defaultValue;\n\n if (!v && safe) return null;\n\n // console.warn(`%O`, this);\n throw new AVStantso_InvalidArgumentError(\n this,\n 'from',\n { candidate },\n 'invalid enum value %FV'\n );\n }\n\n function WrapFrom(\n this: TClass,\n f: (\n candidate: KVO<TClass>,\n defaultValue?: AVStantso_EnumClass.Item.Template\n ) => AVStantso_EnumClass.Item.Template,\n safe?: boolean\n ) {\n return Object.assign(f, {\n capitalized: function tryFromCapitalized(\n this: TClass,\n candidate: string,\n defaultValue?: AVStantso_EnumClass.Item.Template\n ) {\n return doFrom.call(\n this,\n candidate,\n defaultValue,\n FROM_MODES.capitalized,\n safe\n );\n }.bind(this),\n\n uncapitalized: function tryFromUncapitalized(\n this: TClass,\n candidate: string,\n defaultValue?: AVStantso_EnumClass.Item.Template\n ) {\n return doFrom.call(\n this,\n candidate,\n defaultValue,\n FROM_MODES.uncapitalized,\n safe\n );\n }.bind(this),\n\n caseInsensitive: function tryFromCaseInsensitive(\n this: TClass,\n candidate: string,\n defaultValue?: AVStantso_EnumClass.Item.Template\n ) {\n return doFrom.call(\n this,\n candidate,\n defaultValue,\n FROM_MODES.caseInsensitive,\n safe\n );\n }.bind(this)\n });\n }\n\n const tryFrom = WrapFrom.call(\n this,\n function tryFrom(\n this: TClass,\n candidate: KVO<TClass>,\n defaultValue?: AVStantso_EnumClass.Item.Template\n ) {\n return doFrom.call(this, candidate, defaultValue, undefined, true);\n }.bind(this),\n true\n );\n\n const from = WrapFrom.call(\n this,\n function from(\n this: TClass,\n candidate: KVO<TClass>,\n defaultValue?: AVStantso_EnumClass.Item.Template\n ) {\n return doFrom.call(this, candidate, defaultValue);\n }.bind(this)\n );\n //#endregion\n\n const toName = (value: unknown) => tryFrom(value as KVO<TClass>)?.name;\n const _switch = Switch(toName);\n const Mapping = avstantso.Mapping('value', toName);\n const Extender = Extend.ByRecord(Object.keys(Items), from);\n\n function IsEnumItem(this: TClass, mode?: number) {\n return Extender(\n function isEnumItem(\n this: TClass,\n candidate: unknown,\n ...filters: AVStantso_EnumClass.Item.Template[]\n ): boolean {\n const obj = doFrom.call(this, candidate, undefined, mode, true);\n if (obj) {\n if (!filters.length) return true;\n\n const v = +obj;\n for (const f of filters) if (+f === v) return true;\n }\n\n return false;\n }.bind(this),\n function (this: TClass, item, original) {\n const filters = new Set<AVStantso_EnumClass.Item.Template>([item]);\n\n const isOr = function isOr(this: TClass, candidate: unknown) {\n return original.call(this, candidate, ...filters);\n }.bind(this);\n\n const proxy = new Proxy(isOr, {\n get(target, p) {\n if (hasKey(p)) {\n filters.add(from(p));\n return isOr;\n }\n\n return Reflect.get(target, p);\n }\n });\n\n Object.defineProperties(isOr, {\n or: { value: proxy, writable: false }\n });\n\n return proxy;\n }\n );\n }\n\n const isEnumItem = Object.assign(IsEnumItem.call(this), {\n capitalized: IsEnumItem.call(this, FROM_MODES.capitalized),\n uncapitalized: IsEnumItem.call(this, FROM_MODES.uncapitalized),\n caseInsensitive: IsEnumItem.call(this, FROM_MODES.caseInsensitive)\n });\n\n // Protect from runtime access. Will redefine as property\n delete this.Statics;\n const designtimeOnly = {\n value: undefined as unknown,\n writable: false,\n configurable: false\n };\n\n Object.defineProperties(this, {\n Statics: designtimeOnly,\n Key: designtimeOnly,\n Item: designtimeOnly,\n KVO: designtimeOnly,\n\n enumClass: { value: enumClass, writable: false },\n enumName: { value: this.name.replace(/$_+/, ''), writable: false },\n hasKey: { value: hasKey, writable: false },\n\n map: { value: Items, writable: false },\n ...(combinations\n ? { combinations: { value: combinations, writable: false } }\n : {}),\n\n tryFrom: { value: tryFrom, writable: false },\n from: { value: from, writable: false },\n\n is: { value: isEnumItem, writable: false },\n\n switch: { value: _switch, writable: false },\n Mapping: { value: Mapping, writable: false },\n Extender: { value: Extender, writable: false }\n });\n\n function add(this: TClass, item: AVStantso_EnumClass.Item.Template, name: string) {\n function is(this: TEnum, other: KVO<TClass>): boolean {\n const obj = tryFrom(other);\n return obj && +this === +obj;\n }\n\n function scroll(this: TEnum, by = 1): TEnum {\n if (0 === by) return this;\n\n const { value } = this;\n\n AVStantso_InvalidArgumentTypeError.validate.number(this, scroll, { by });\n const { values } = enumClass;\n\n const lastI = values.length - 1;\n const step = Math.sign(by);\n\n let i = values.findIndex((ind: number) => ind === value);\n for (let j = Math.abs(by % values.length); j > 0; j--) {\n if (i <= 0) i = lastI;\n else if (i >= lastI) i = 0;\n else i += step;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return (enumClass as any)[values[i]];\n }\n\n Object.assign(item, { _name: name, scroll, is });\n\n Object.defineProperties(item, {\n key: { value: name, writable: false },\n prev: {\n get() {\n this.scroll(-1);\n }\n },\n next: {\n get() {\n this.scroll(+1);\n }\n },\n switch: {\n value: _switch.bind(null, item.value),\n writable: false\n },\n ...(!IsFlags\n ? {}\n : {\n /**\n * @see AVStantso_EnumClass.Item.Or\n */\n or: {\n value: new Proxy(item, {\n get(target, p) {\n if (hasKey(p)) {\n const next = from(p);\n // eslint-disable-next-line no-bitwise\n return from(+target | +next);\n }\n\n return Reflect.get(target, p);\n }\n }),\n writable: false\n }\n })\n });\n\n for (const k of [name, item.value])\n Object.defineProperty(this, k, { value: item, writable: false });\n\n return Object.freeze(item);\n }\n\n for (const [k, v] of Object.entries(Items)) add.call(this, v, k);\n\n if (IsFlags) {\n function isPowerOfTwo(n: number) {\n if (n == 0) return false;\n\n const r = Math.log(n) / Math.log(2);\n return Math.ceil(r) === Math.floor(r);\n }\n\n const vs = Object.values(Items)\n .filter((v) => isPowerOfTwo(+v)) // 👈 Exclude predefined combinations\n .sort((a, b) => +a - +b);\n\n /* eslint-disable no-bitwise */\n for (let i = 0; i < 1 << vs.length; i++) {\n const combination: AVStantso_EnumClass.Item.Template[] = [];\n for (let j = 0; j < vs.length; j++)\n if (i & (1 << j)) combination.push(vs[j]);\n\n if (combination.length <= 1) continue;\n\n const v = combination.reduce((r, item) => r + +item, 0);\n let c: AVStantso_EnumClass.Item.Template = enumClass[v];\n if (!c) {\n const n = combination.map(({ name }) => name).join('|');\n c = add.call(this, new this(v), n);\n } else {\n // Predefined combination case, do nothing\n }\n\n combinations[c.name] = c;\n }\n /* eslint-enable no-bitwise */\n\n Object.freeze(combinations);\n\n for (const n of Object.keys(combinations)) delete Items[n]; // 👈 Transfer predefined combinations from Items\n }\n\n // After transfer predefined combinations\n {\n const values = Object.freeze(\n Object.values(Items)\n .map(({ value }) => value)\n .sort((a, b) => a - b)\n );\n\n // Sorted by `this.values` order!\n const names = Object.freeze(values.map((v) => from(v).name));\n\n Object.defineProperties(this, {\n keys: { value: names, writable: false },\n names: { value: names, writable: false },\n values: { value: values, writable: false }\n });\n }\n\n Object.freeze(Items);\n\n return Object.assign(\n enumClass,\n initExt && initExt(enumClass)\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ) as any;\n }\n\n /**\n * @summary Access to `class`. ⚠ Use with caution when there is a complex hierarchy\n */\n protected get meta() {\n return Object.getPrototypeOf(this).constructor;\n }\n\n private _name: string;\n\n constructor(value: TValue) {\n super(value);\n }\n\n public get name(): string {\n return this._name;\n }\n\n protected toString() {\n return this.name;\n }\n\n protected toJSON() {\n const { ToJSONField } = this.meta;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return (this as any)[ToJSONField];\n }\n}\n\nif (!('AVStantso_EnumClass' in globalThis))\n Object.defineProperties(globalThis, {\n AVStantso_EnumClass: {\n value: AVStantso_EnumClass,\n writable: false,\n configurable: false\n }\n });\n","import EnumClass = AVStantso_EnumClass;\n\nexport {\n EnumClass\n};\n"],"names":["AVStantso_EnumClass"],"mappings":";;;;;;4BAscA,MAAM,mBACJ,SAAQ,mBAA2B,CAAA;IAGnC,OAAO,WAAW,GAAG;AACnB,QAAA,WAAW,EAAE,CAAC;AACd,QAAA,aAAa,EAAE,CAAC;AAChB,QAAA,eAAe,EAAE;KACT;;AAGV;;AAEG;IACI,OAAO,OAAO;AAErB;;AAEG;AACI,IAAA,OAAO,OAAO,GAAY,KAAK;AAEtC;;AAEG;AACI,IAAA,OAAO,WAAW,GAAG,OAAO;AAEnC;;AAEG;AACI,IAAA,OAAO,KAAK,GAAW,IAAI;;AAGlC;;AAEG;IACI,OAAO,MAAM,CAAC,SAAkB,EAAA;AACrC,QAAA,QACE;eACG,SAAS,CAAC,EAAE,CAAC,EAAE,CAAC,QAAQ,CAAC,SAAS;AAClC,eAAA,CAAC,CAAE,SAAiD,CAAC,SAAS;IAErE;AAEO,IAAA,OAAO,MAAM,GAAA;AAGlB,QAAA,MAAM,EAAE,MAAM,EAAE,GAAG,IAAmD;AAEtE,QAAA,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC;AACnD,QAAA,OAAQ,IAAqD,CAAC,MAAM,CAAC,CAAC,CAAC,C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D;AAEQ,IAAA,KAAK;AAEb,IAAA,WAAA,CAAY,KAAa,EAAA;QACvB,KAAK,CAAC,KAAK,CAAC;IACd;AAEA,IAAA,IAAW,IAAI,GAAA;QACb,OAAO,IAAI,CAAC,KAAK;IACnB;IAEU,QAAQ,GAAA;QAChB,OAAO,IAAI,CAAC,IAAI;IAClB;IAEU,MAAM,GAAA;AACd,QAAA,MAAM,EAAE,WAAW,EAAE,GAAG,IAAI,CAAC,IAAI;;AAGjC,QAAA,OAAQ,IAAY,CAAC,WAAW,CAAC;IACnC;;AAGF,IAAI,EAAE,qBAAqB,IAAI,UAAU,CAAC;AACxC,IAAA,MAAM,CAAC,gBAAgB,CAAC,UAAU,EAAE;AAClC,QAAA,mBAAmB,EAAE;AACnB,YAAA,KAAK,EAAEA,qBAAmB;AAC1B,YAAA,QAAQ,EAAE,KAAK;AACf,YAAA,YAAY,EAAE;AACf;AACF,KAAA,CAAC;;AC99BJ,IAAO,SAAS,GAAG;;;;"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@avstantso/utils-enum-class",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"author": "avstantso",
|
|
5
|
-
"version": "1.1
|
|
5
|
+
"version": "1.2.1",
|
|
6
6
|
"description": "AVStantso framework utils: EnumClass",
|
|
7
7
|
"keywords": [
|
|
8
8
|
"EnumClass"
|
|
@@ -23,12 +23,12 @@
|
|
|
23
23
|
"test": "NODE_ENV=test jest --coverage"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@avstantso/concepts": "1.1
|
|
27
|
-
"@avstantso/core": "1.1
|
|
28
|
-
"@avstantso/errors": "1.1
|
|
29
|
-
"@avstantso/js": "1.1
|
|
30
|
-
"@avstantso/std-ext": "1.1
|
|
31
|
-
"@avstantso/ts": "1.1
|
|
26
|
+
"@avstantso/concepts": "1.2.1",
|
|
27
|
+
"@avstantso/core": "1.2.1",
|
|
28
|
+
"@avstantso/errors": "1.2.1",
|
|
29
|
+
"@avstantso/js": "1.2.1",
|
|
30
|
+
"@avstantso/std-ext": "1.2.1",
|
|
31
|
+
"@avstantso/ts": "1.2.1"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@avstantso/dev-basic": "1.0.0"
|