@avstantso/core 1.0.3 → 1.1.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/CHANGELOG.md CHANGED
@@ -2,6 +2,29 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [1.1.0] - 2026-01-18
6
+
7
+ ### Added
8
+
9
+ - `RegisterGlobalNamespace` factory - allows creating custom global namespaces similar to `AVStantso/avstantso`
10
+ - `_CodeReg` namespace with types for custom global namespace registration
11
+
12
+ ### Changed
13
+
14
+ - Refactored global registration to use reusable `RegisterGlobalNamespace` factory
15
+ - Replaced `HasSymbol` with `Symbol.Has` from `@avstantso/std-ext`
16
+ - Now uses `Object.definePropertyOnce` and `Object.definePropertiesOnce` for safe property definition
17
+
18
+ ### Removed
19
+
20
+ - `HasSymbol` function (replaced by `Symbol.Has` from `@avstantso/std-ext`)
21
+
22
+ ## [1.0.4] - 2026-01-16
23
+
24
+ ### Fixed
25
+
26
+ - Fix `ReferenceError: process is not defined` in Vite build by using `globalThis.Buffer` instead of `process?.versions?.node`
27
+
5
28
  ## [1.0.3] - 2026-01-16
6
29
 
7
30
  ### Fixed
package/README.md CHANGED
@@ -37,7 +37,7 @@ Import the package once in your application entry point to enable the global sin
37
37
  import '@avstantso/core';
38
38
 
39
39
  // The AVStantso singleton is now available globally
40
- const hasSymbolIterator = avstantso.HasSymbol(Symbol.iterator);
40
+ avstantso.Catch(error); // Handle errors using centralized error handling
41
41
  ```
42
42
 
43
43
  ### Direct Member Imports
@@ -64,7 +64,8 @@ promise.then(X).catch(X); // Ignore both success and error
64
64
 
65
65
  ### AVStantso.TS - TypeScript Type Helpers
66
66
 
67
- Essential TypeScript utility types for building robust type-safe applications.
67
+ Essential TypeScript utility types for building robust type-safe applications.\
68
+ _These are foundational types that [@avstantso/ts](https://www.npmjs.com/package/@avstantso/ts) extends with additional utilities._
68
69
 
69
70
  #### `AVStantso.TS.Key`
70
71
 
@@ -520,24 +521,90 @@ The `avstantso` global object provides runtime access to all features.
520
521
 
521
522
  **Properties:**
522
523
 
523
- - `avstantso.HasSymbol<Symb>(symbol)` - Factory for creating symbol presence checkers
524
524
  - `avstantso.freeze()` - Recursively freeze all internals (call after setup)
525
525
  - `avstantso.symbolFreeze` - Symbol for custom freeze behavior
526
526
  - `avstantso.debugState` - External state for debugging (available until freeze)
527
+ - `avstantso.RegisterGlobalNamespace(name, statics?)` - Factory for creating custom global namespaces
528
+
529
+ #### `avstantso.RegisterGlobalNamespace<TCode>(name, statics?)`
530
+
531
+ Registers a global namespace and singleton, similar to how `AVStantso`/`avstantso` itself is created. Creates two global references:
532
+ - `globalThis.Name` (capitalized) - the namespace for TypeScript type declarations
533
+ - `globalThis.name` (lowercase) - the singleton for runtime code access
534
+
535
+ The lowercase singleton avoids reference errors in Jest and other test environments where global namespace access may be restricted.
536
+
537
+ **Type Parameters:**
538
+ - `TCode` - Interface describing the runtime structure of the singleton (e.g., `MyApp.Code`)
539
+
540
+ **Parameters:**
541
+ - `name: string` - The global name to register (e.g., `'MyApp'` creates `MyApp` and `myapp`)
542
+ - `statics?: object` - Optional initial static properties to include in the singleton
543
+
544
+ **Returns:** The created singleton object with registration utilities (`_reg`, `freeze()`, `symbolFreeze`)
545
+
546
+ **Features:**
547
+ - Creates a freezable singleton accessible globally by both capitalized and lowercase names
548
+ - Provides `_reg` proxy for registering new fields with lazy initialization
549
+ - Supports `freeze()` method to recursively freeze all internals
550
+ - Includes `symbolFreeze` for custom freeze behavior on specific objects
551
+
552
+ **Important:** All exported namespace constants and functions (UPPERCASE) must be expressed through the lowercase singleton global variable. This ensures consistent runtime behavior across different environments.
553
+
554
+ **Important:** In TypeScript namespace (e.g. `MyApp`) runtime features must be **only** in the root namespace (**not in nested namespaces**). If you use complex structure and nesting:
555
+ - define internal-used runtimes only in the root namespace
556
+ - define export consts from `_reg` only in the root namespace
557
+ - for nested features use `_reg` without saving the result
558
+ - see my source code as a reference to avoid hard-to-catch errors in different environments
527
559
 
528
560
  **Example:**
529
561
  ```typescript
530
- // Check for symbol presence
531
- const hasIterator = avstantso.HasSymbol(Symbol.iterator);
532
- if (hasIterator(myObject)) {
533
- // myObject has Symbol.iterator
534
- for (const item of myObject) {
535
- console.log(item);
562
+ // Create a custom namespace for your application
563
+ const myApp = avstantso.RegisterGlobalNamespace<MyApp.Code>('MyApp', {
564
+ version: '1.0.0'
565
+ });
566
+
567
+ // TypeScript namespace declarations use uppercase
568
+ declare namespace MyApp {
569
+ export interface Config { debug: boolean, apiUrl: string };
570
+ export interface Utils {
571
+ format(value: string): string;
572
+ };
573
+
574
+ // Runtime interface of myApp
575
+ export interface Code {
576
+ Config: Config;
577
+ Utils: Utils;
536
578
  }
579
+
580
+ // Register new fields using the _reg proxy
581
+ export const Config = myApp._reg.Config({ debug: true, apiUrl: '/api' });
582
+ export const Utils = myApp._reg.Utils.format((singleton) => {
583
+ // Lazy initialization with access to partial singleton
584
+ return (value: string) => value.trim().toLowerCase();
585
+ });
537
586
  }
538
587
 
539
- // After all setup, freeze the singleton
540
- avstantso.freeze();
588
+ // Access globally via lowercase singleton (recommended)
589
+ console.log(myapp.version); // '1.0.0'
590
+ console.log(myapp.Config.debug); // true
591
+
592
+ // In file my-app.export.ts
593
+ import version = MyApp.version;
594
+ import Config = MyApp.Config;
595
+ import Utils = MyApp.Utils;
596
+
597
+ export { version, Config, Utils };
598
+
599
+ // In any file of your app:
600
+ import { version, Config } from './my-app.export';
601
+
602
+ console.log(version); // '1.0.0'
603
+ console.log(Config.debug); // true
604
+
605
+ // In index file
606
+ // Freeze when setup is complete
607
+ myapp.freeze();
541
608
  ```
542
609
 
543
610
  ## Requirements
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@avstantso/core",
3
3
  "license": "MIT",
4
4
  "author": "avstantso",
5
- "version": "1.0.3",
5
+ "version": "1.1.0",
6
6
  "description": "Core global AVStantso singleton",
7
7
  "keywords": [
8
8
  "AVStantso singleton"
@@ -23,7 +23,7 @@
23
23
  "test": "NODE_ENV=test jest --coverage"
24
24
  },
25
25
  "dependencies": {
26
- "@avstantso/std-ext": "1.0.2"
26
+ "@avstantso/std-ext": "1.1.0"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@avstantso/dev-basic": "1.0.0"
@@ -1,14 +0,0 @@
1
- declare namespace AVStantso {
2
- interface Code {
3
- /**
4
- * @summary Not `X`, but an oblique cross `❌`. It can be fed to `Promise.then` / `Promise.catch` instead of an empty value
5
- * @returns `undefined`
6
- */
7
- X<T = any>(): T;
8
- }
9
- /**
10
- * @summary Not `X`, but an oblique cross `❌`. It can be fed to `Promise.then` / `Promise.catch` instead of an empty value
11
- * @returns `undefined`
12
- */
13
- const X: <T = any>() => T;
14
- }
@@ -1,192 +0,0 @@
1
- declare namespace AVStantso {
2
- /**
3
- * @summary TypeScript helpers
4
- */
5
- namespace TS {
6
- /**
7
- * @summary Object key types union supported by TypeScript
8
- */
9
- type Key = string | number | symbol;
10
- /**
11
- * @summary Array of object keys types union supported by TypeScript
12
- * @see Key
13
- */
14
- type Keys = readonly Key[];
15
- /**
16
- * @summary Record of key to key
17
- * @example
18
- * type k2k = CheckType<Key2Key<'a' | 'b' | 'c'>, { a: 'a', b: 'b', c: 'c' }>;
19
- */
20
- type Key2Key<K extends Key> = {
21
- [K0 in K]: K0;
22
- };
23
- /**
24
- * @summary Any array.\
25
- * ⚠ Please use for check or constraint, not for define
26
- * @example
27
- * type IsStruct<T extends object> = T extends Arr ? false : true;
28
- */
29
- type Arr = any[];
30
- /**
31
- * @summary Any readonly array.\
32
- * ⚠ Please use for check or constraint, not for define
33
- * @example
34
- * type IsStruct<T extends object> = T extends ArrR ? false : true;
35
- */
36
- type ArrR = readonly any[];
37
- /**
38
- * @summary [O]ne or readonly [L]ist of `T`
39
- * @template T Value or item type
40
- */
41
- type OL<T> = T | readonly T[];
42
- /**
43
- * @summary Function type
44
- * @template R Result type
45
- * @template P Params array
46
- */
47
- type Func<R = unknown, P extends Arr = Arr> = (...params: P) => R;
48
- namespace Func {
49
- /**
50
- * @summary Check extends `T` to `Function`
51
- * @template T Tested type
52
- * @template IfTrue Result, if `T` extends `Function`
53
- * @template IfFalse Result, if NOT `T` extends `Function`
54
- * @returns `IfFalse` or `IfTrue` param
55
- * @example
56
- * type n = CheckType<Is<never>, never>;
57
- * type ud = CheckType<Is<undefined>, false>;
58
- * type uk = CheckType<Is<unknown>, false>;
59
- *
60
- * type o = CheckType<Is<{ name: string }>, false>;
61
- * type e = CheckType<Is<{}>, false>;
62
- * type f = CheckType<Is<() => 42>, true>;
63
- */
64
- type Is<T, IfTrue = true, IfFalse = false> = T extends undefined ? false : T extends Function ? IfTrue : IfFalse;
65
- /**
66
- * @summary Function type returns `Promise`
67
- * @template R Result of promise type
68
- * @template P Params array
69
- */
70
- type Promise<R = unknown, P extends Arr = Arr> = Func<globalThis.Promise<R>, P>;
71
- }
72
- /**
73
- * @summary Procedure type
74
- * @template P Params array
75
- */
76
- type Proc<P extends Arr = Arr> = (...params: P) => void;
77
- namespace Proc {
78
- /**
79
- * @summary Procedure type returns `Promise<void>`
80
- * @template P Params array
81
- */
82
- type Promise<P extends Arr = Arr> = Func.Promise<void, P>;
83
- }
84
- /**
85
- * @summary Function type
86
- * @template I Instance type
87
- * @template P Params array
88
- */
89
- type Class<I = unknown, P extends Arr = Arr> = new (...params: P) => I;
90
- /**
91
- * @summary `U` union includes `string`, not a set of literals only or other types
92
- * @template U Tested type union
93
- * @template IfTrue Result, if `T` includes `string`
94
- * @template IfFalse Result, if `T` NOT includes `string`
95
- * @returns `IfFalse` or `IfTrue` param
96
- * @example
97
- * type n = CheckType<HasString<never>, false>;
98
- * type u = CheckType<HasString<undefined>, false>;
99
- * type uk = CheckType<HasString<unknown>, false>;
100
- * type a = CheckType<HasString<any>, false>;
101
- *
102
- * type r1 = CheckType<HasString<string>, true>;
103
- * type r2 = CheckType<HasString<1 | 2 | 3>, false>;
104
- * type r3 = CheckType<HasString<'A' | 'B' | 'C'>, false>;
105
- * type r4 = CheckType<HasString<'A' | 'B' | 'C' | string>, true>;
106
- * type r5 = CheckType<HasString<''>, false>;
107
- * type r6 = CheckType<HasString<{}>, false>;
108
- */
109
- type HasString<U, IfTrue = true, IfFalse = false> = 'some string unused elsewhere: fd3d7784-363b-415f-817a-8575171d736f' extends U ? {} extends U ? IfFalse : IfTrue : IfFalse;
110
- }
111
- /**
112
- * @summary Interface for access to `AVStantso` namespace code through `avstantso` global property
113
- */
114
- interface Code {
115
- /**
116
- * @summary Has `symbol` factory function
117
- */
118
- HasSymbol<Symb extends symbol>(symb: Symb): <R>(obj: unknown) => obj is {
119
- [K in Symb]: R;
120
- };
121
- /**
122
- * @summary Recursively freeze all internals.\
123
- * ⚠ Must called from applications index files after all extensions by libraries\
124
- * Unavailable after call `freeze` method
125
- */
126
- freeze?(): void;
127
- /**
128
- * @summary `symbol` for custom freeze
129
- * @see freeze
130
- */
131
- symbolFreeze: symbol;
132
- /**
133
- * @summary External state for debugging\
134
- * Unavailable after call `freeze` method
135
- * @description Used in tests, for separate initilizing code and test code
136
- * @example
137
- * // in debugging _global file
138
- * namespace AVStantso {
139
- * avstantso._reg.foo(() => () => {
140
- * if (avstantso.debugState) console.log(`foo called!`);
141
- *
142
- * return 123;
143
- * });
144
- *
145
- * avstantso.foo(); // don`t write to console
146
- * }
147
- *
148
- * // in test file
149
- * avstantso.debugState = true;
150
- *
151
- * avstantso.foo(); // write to console
152
- */
153
- debugState: unknown;
154
- }
155
- namespace Code {
156
- namespace _Reg {
157
- namespace Initializer {
158
- type Func<T> = (code: Partial<AVStantso.Code>) => T;
159
- }
160
- /**
161
- * @summary Registration method
162
- * @param initializer Initializer for field `TField`
163
- */
164
- export type Method<T extends object, TField extends keyof T, F extends T[TField] = T[TField], P extends Partial<F> = Partial<F>> = (initializer: F extends Function ? Initializer.Func<F> : P | Initializer.Func<P>) => F;
165
- export type Recursive<T extends object> = {
166
- [K in keyof T]: T[K] extends object ? T[K] extends TS.Arr[] ? Method<T, K> : Recursive<T[K]> & Method<T, K> : Method<T, K>;
167
- };
168
- export {};
169
- }
170
- /**
171
- * @summary Access to registration proxy structure
172
- */
173
- type _Reg = _Reg.Recursive<Code>;
174
- }
175
- }
176
- /**
177
- * @summary Access to `AVStantso` namespace code
178
- * @description Lowercase uses in `avstantso` for avoid errors in `Jest`
179
- *
180
- * ⚠ In all cases usage constants and functions from namespace `AVStantso`\
181
- * this must be through `avstantso` global variable
182
- *
183
- * ⚠ All exported namespace `AVStantso` constants and functions\
184
- * must be expressed through `avstantso` global variable
185
- */
186
- declare const avstantso: AVStantso.Code & {
187
- /**
188
- * @summary Access to registration proxy structure.\
189
- * Unavailable after call `freeze` method
190
- */
191
- _reg?: AVStantso.Code._Reg;
192
- };
@@ -1,83 +0,0 @@
1
- declare namespace AVStantso {
2
- /**
3
- * @summary Interface registry of atomic objects types
4
- */
5
- namespace AtomicObjects {
6
- /**
7
- * @summary Atomic object class options
8
- */
9
- interface Options<TClass extends TS.Class = TS.Class> {
10
- empty?(): InstanceType<TClass>;
11
- /**
12
- * @summary Clone rule for atomic object
13
- */
14
- clone(instance: InstanceType<TClass>): InstanceType<TClass>;
15
- }
16
- /**
17
- * @summary Atomic object class descriptor
18
- */
19
- type Descriptor<TClass extends TS.Class = TS.Class> = {
20
- Class: TClass;
21
- } & Options<TClass>;
22
- }
23
- interface AtomicObjects {
24
- Date: Date;
25
- /**
26
- * @requires `'buffer'` library required for browser and register manually.\
27
- * For Node-js: automatic register builtin class `Buffer`
28
- */
29
- Buffer: Buffer;
30
- }
31
- namespace Code {
32
- /**
33
- * @summary Atomic objects registry management
34
- */
35
- interface AtomicObjects {
36
- /**
37
- * @summary Readonly map of registered classes of atomic objects and class options
38
- */
39
- classes: ReadonlyMap<TS.Class, AVStantso.AtomicObjects.Options>;
40
- /**
41
- * @summary Class registration of atomic object and add options
42
- * @param atomicObjectClass Class of atomic object
43
- * @param options Atomic object class options
44
- */
45
- register<TClass extends TS.Class>(atomicObjectClass: TClass, options: AVStantso.AtomicObjects.Options<TClass>): void;
46
- /**
47
- * @summary Check object is atomic. 'false' for non-object values
48
- * @param testObject Tested object
49
- * @returns 'true' is object is atomic, else `false`
50
- */
51
- is(testObject: object | unknown): boolean;
52
- /**
53
- * @summary Get atomic object descriptor or `undefined`, if not class name, object not atomic or non-object value
54
- * @param testObjectOrClassName Tested object or class name
55
- * @returns 'AtomicObjects.AVStantso.AtomicObjects.Descriptor' if object is atomic or find class name, else `undefined`
56
- * @see AVStantso.AtomicObjects.Descriptor
57
- */
58
- descriptor: {
59
- /**
60
- * @summary Get atomic object descriptor or `undefined`, if object not atomic or non-object value
61
- * @param testObject Tested object
62
- * @returns 'AtomicObjects.AVStantso.AtomicObjects.Descriptor' if object is atomic, else `undefined`
63
- * @see AVStantso.AtomicObjects.Descriptor
64
- */
65
- (testObject: object | unknown): AVStantso.AtomicObjects.Descriptor;
66
- /**
67
- * @summary Get atomic object descriptor or `undefined`, if class name not found
68
- * @param className Class name
69
- * @returns 'AtomicObjects.AVStantso.AtomicObjects.Descriptor' if find class name, else `undefined`
70
- * @see AVStantso.AtomicObjects.Descriptor
71
- */
72
- (className: string): AVStantso.AtomicObjects.Descriptor;
73
- };
74
- }
75
- }
76
- interface Code {
77
- /**
78
- * @summary Atomic objects registry management
79
- */
80
- AtomicObjects: Code.AtomicObjects;
81
- }
82
- const AtomicObjects: Code.AtomicObjects;
83
- }
@@ -1 +0,0 @@
1
- import './_register';
@@ -1,44 +0,0 @@
1
- declare namespace AVStantso {
2
- namespace Catch {
3
- /**
4
- * @summary Catch handler
5
- * @param error Error
6
- */
7
- type Handler<T = unknown> = (error: T) => unknown;
8
- namespace Core {
9
- /**
10
- * @summary `Core` catch handler version
11
- * @param error Error
12
- */
13
- type Handler = Catch.Handler;
14
- }
15
- }
16
- /**
17
- * @summary Common catch method for errors
18
- */
19
- interface Catch extends Catch.Core.Handler {
20
- }
21
- namespace Code {
22
- namespace Catch {
23
- /**
24
- * @summary Catch filter handler
25
- * @param error Error
26
- */
27
- type Filter<T = unknown> = (error: T) => boolean;
28
- }
29
- /**
30
- * @summary Catch helpers utility
31
- */
32
- interface Catch extends AVStantso.Catch {
33
- _addFilter(...filters: [Catch.Filter, ...Catch.Filter[]]): void;
34
- _default: AVStantso.Catch.Handler;
35
- }
36
- }
37
- interface Code {
38
- /**
39
- * @summary Catch helpers utility
40
- */
41
- Catch: Code.Catch;
42
- }
43
- const Catch: Code.Catch;
44
- }
@@ -1 +0,0 @@
1
- import './_register';
@@ -1,15 +0,0 @@
1
- declare namespace AVStantso {
2
- /**
3
- * @summary Checker for `TActual` type. Its must extends `TExpected`
4
- * @template TActual Actual calculated type
5
- * @template TExpected Expected type
6
- * @description Used for debug and in examples
7
- * @example
8
- * type o = {id: string; version: number};
9
- *
10
- * type t = CheckType<o, Pick<o, 'id'>>;
11
- * type f = CheckType<o, {name: string}>;
12
- * 👆⛔ Type 'o' does not satisfy the constraint '{ name: string; }'.
13
- */
14
- type CheckType<TActual extends TExpected, TExpected> = TActual;
15
- }
@@ -1,248 +0,0 @@
1
- declare namespace AVStantso {
2
- const fpd: {
3
- apply: TypedPropertyDescriptor<(this: Function, thisArg: any, argArray?: any) => any>;
4
- call: TypedPropertyDescriptor<(this: Function, thisArg: any, ...argArray: any[]) => any>;
5
- bind: TypedPropertyDescriptor<(this: Function, thisArg: any, ...argArray: any[]) => any>;
6
- toString: TypedPropertyDescriptor<() => string>;
7
- prototype: TypedPropertyDescriptor<any>;
8
- readonly length: TypedPropertyDescriptor<number>;
9
- arguments: TypedPropertyDescriptor<any>;
10
- caller: TypedPropertyDescriptor<Function>;
11
- readonly name: TypedPropertyDescriptor<string>;
12
- [Symbol.hasInstance]: TypedPropertyDescriptor<(value: any) => boolean>;
13
- } & {
14
- [x: string]: PropertyDescriptor;
15
- } & {};
16
- export namespace TS.Func {
17
- /**
18
- * @summary `getOwnPropertyDescriptors` of basic function type
19
- */
20
- type PropertyDescriptors = {
21
- [K in keyof typeof fpd as TS.HasString<K, never, K>]: (typeof fpd)[K];
22
- };
23
- /**
24
- * @summary You must exclude this keys on add new props of function
25
- * @example
26
- * type MyKeys = 'id' | 'value' | 'name';
27
- *
28
- * // ❌
29
- * type Is_$Bad: (<T extends MyKeys>(k: T, candidate: unknown) => candidate is T) & {
30
- * [K in MyKeys]: (candidate: unknown) => candidate is K;
31
- * }
32
- *
33
- * // ✅
34
- * type Is_$Good: (<T extends MyKeys>(k: T, candidate: unknown) => candidate is T) & {
35
- * [K in TS.Func.Restrict<MyKeys>]: (candidate: unknown) => candidate is K;
36
- * }
37
- */
38
- type RestrictionsForExt = keyof PropertyDescriptors;
39
- /**
40
- * @summary Restricted keys exclude shortcut
41
- * @example
42
- * type MyKeys = 'id' | 'value' | 'name';
43
- *
44
- * // ❌
45
- * type Is_$Bad: (<T extends MyKeys>(k: T, candidate: unknown) => candidate is T) & {
46
- * [K in MyKeys]: (candidate: unknown) => candidate is K;
47
- * }
48
- *
49
- * // ✅
50
- * type Is_$Good: (<T extends MyKeys>(k: T, candidate: unknown) => candidate is T) & {
51
- * [K in TS.Func.Restrict<MyKeys>]: (candidate: unknown) => candidate is K;
52
- * }
53
- */
54
- type Restrict<T extends Key> = Exclude<T, RestrictionsForExt>;
55
- }
56
- export namespace Code {
57
- /**
58
- * @summary Functions utilities
59
- */
60
- interface Func {
61
- /**
62
- * @summary `getOwnPropertyDescriptors` of basic function
63
- */
64
- OwnPropertyDescriptors: AVStantso.TS.Func.PropertyDescriptors;
65
- /**
66
- * @summary Check can use prop for function extends
67
- * @param propName Ext prop name
68
- * @returns `true` — can add to function, else `false`
69
- * @example
70
- * const Types = ['insert', 'update', 'name'] as const;
71
- * type Type = typeof Types[number];
72
- * type Data<T extends Type> =
73
- * | (T extends 'insert' ? {
74
- * type: 'insert',
75
- * value: 'xxx'
76
- * } : never)
77
- * | (T extends 'update' ? {
78
- * type: 'update',
79
- * value: 15
80
- * } : never)
81
- * | (T extends 'name' ? {
82
- * type: 'name',
83
- * id: string;
84
- * value: string;
85
- * }: never);
86
- *
87
- * function _isTypeOfData<T extends Type>(type: T, data: Data<Type>): data is Data<T> {
88
- * return data.type === type;
89
- * }
90
- *
91
- * const isTypeOfData = Object.assign(
92
- * _isTypeOfData,
93
- * Object.fromEntries(
94
- * Types
95
- * // 👇
96
- * .filter(Func.isPropAllowed)
97
- * .map((type) => [
98
- * type,
99
- * _isTypeOfData.bind(null, type)
100
- * ])
101
- * )
102
- * )
103
- * @example
104
- * expect(isPropAllowed('abc')).toBe(true);
105
- *
106
- * expect(isPropAllowed('length')).toBe(false);
107
- * expect(isPropAllowed('name')).toBe(false);
108
- * expect(isPropAllowed('arguments')).toBe(false);
109
- * expect(isPropAllowed('caller')).toBe(false);
110
- * expect(isPropAllowed('constructor')).toBe(false);
111
- * expect(isPropAllowed('apply')).toBe(false);
112
- * expect(isPropAllowed('bind')).toBe(false);
113
- * expect(isPropAllowed('call')).toBe(false);
114
- * expect(isPropAllowed('toString')).toBe(false);
115
- * expect(isPropAllowed('prototype')).toBe(false);
116
- * expect(isPropAllowed(Symbol.hasInstance)).toBe(false);
117
- */
118
- isPropAllowed: {
119
- (propName: TS.Key): boolean;
120
- /**
121
- * @summary Check can NOT use prop for function extends
122
- * @param propName Ext prop name
123
- * @returns `true` — can't add to function, else `false`
124
- * @example
125
- * expect(isPropAllowed.Not('abc')).toBe(false);
126
- *
127
- * expect(isPropAllowed.Not('length')).toBe(true);
128
- * expect(isPropAllowed.Not('name')).toBe(true);
129
- * expect(isPropAllowed.Not('arguments')).toBe(true);
130
- * expect(isPropAllowed.Not('caller')).toBe(true);
131
- * expect(isPropAllowed.Not('constructor')).toBe(true);
132
- * expect(isPropAllowed.Not('apply')).toBe(true);
133
- * expect(isPropAllowed.Not('bind')).toBe(true);
134
- * expect(isPropAllowed.Not('call')).toBe(true);
135
- * expect(isPropAllowed.Not('toString')).toBe(true);
136
- * expect(isPropAllowed.Not('prototype')).toBe(true);
137
- * expect(isPropAllowed.Not(Symbol.hasInstance)).toBe(true);
138
- */
139
- Not: (propName: TS.Key) => boolean;
140
- };
141
- /**
142
- * @summary Function has extended properties
143
- * @param f Function being tested
144
- * @returns 'true' if has extended properties, else 'false'
145
- * @example
146
- * function a() {
147
- * return 14;
148
- * }
149
- * expect(isExt(a)).toBe(false);
150
- *
151
- * const aa = () => 'xyz';
152
- * expect(isExt(aa)).toBe(false);
153
- *
154
- * const b = Object.assign(
155
- * function b() {
156
- * return 14;
157
- * },
158
- * { x: 19 }
159
- * );
160
- * expect(isExt(b)).toBe(true);
161
- *
162
- * const bb = Object.assign(
163
- * () => 14,
164
- * { x: 19 }
165
- * );
166
- * expect(isExt(bb)).toBe(true);
167
- *
168
- * function c() {
169
- * return 'abc';
170
- * }
171
- * Object.defineProperties(c, { y: { value: 34 } });
172
- * expect(isExt(c)).toBe(true);
173
- *
174
- * const cc = () => 'abc';
175
- * Object.defineProperties(cc, { y: { value: 34 } });
176
- * expect(isExt(cc)).toBe(true);
177
- *
178
- * function d() {
179
- * return 'abcd';
180
- * }
181
- * d.z = 16;
182
- * expect(isExt(d)).toBe(true);
183
- *
184
- * const dd = () => 'abcd';
185
- * dd.z = 16;
186
- * expect(isExt(dd)).toBe(true);
187
- * @example
188
- * function a() {
189
- * return 14;
190
- * }
191
- * expect(isExt(a)).toBe(false);
192
- *
193
- * const aa = () => 'xyz';
194
- * expect(isExt(aa)).toBe(false);
195
- *
196
- * const b = Object.assign(
197
- * function b() {
198
- * return 14;
199
- * },
200
- * { x: 19 }
201
- * );
202
- * expect(isExt(b)).toBe(true);
203
- *
204
- * const bb = Object.assign(
205
- * () => 14,
206
- * { x: 19 }
207
- * );
208
- * expect(isExt(bb)).toBe(true);
209
- *
210
- * function c() {
211
- * return 'abc';
212
- * }
213
- * Object.defineProperties(c, { y: { value: 34 } });
214
- * expect(isExt(c)).toBe(true);
215
- *
216
- * const cc = () => 'abc';
217
- * Object.defineProperties(cc, { y: { value: 34 } });
218
- * expect(isExt(cc)).toBe(true);
219
- *
220
- * function d() {
221
- * return 'abcd';
222
- * }
223
- * d.z = 16;
224
- * expect(isExt(d)).toBe(true);
225
- *
226
- * const dd = () => 'abcd';
227
- * dd.z = 16;
228
- * expect(isExt(dd)).toBe(true);
229
- */
230
- isExt(f: Function): boolean;
231
- /**
232
- * @summary `DEV` dynamic function named as `name`. No affect in `PROD`.
233
- * @param name Name
234
- * @param func Implementation
235
- * @returns In `DEV` — Named function; In `PROD` — `func`
236
- */
237
- Dynamic<N extends string, F extends Function>(name: N, func: F): F;
238
- }
239
- }
240
- export interface Code {
241
- /**
242
- * @summary Functions utilities
243
- */
244
- Func: Code.Func;
245
- }
246
- export const Func: Code.Func;
247
- export {};
248
- }
@@ -1,73 +0,0 @@
1
- declare namespace AVStantso {
2
- namespace Code {
3
- /**
4
- * @summary Generics utils
5
- */
6
- namespace Generic {
7
- /**
8
- * @summary Generics validator
9
- * @template B Base type
10
- */
11
- interface Validator<B = unknown> {
12
- /**
13
- * @summary Type validation function
14
- * @template T Type for validation
15
- */
16
- <T extends B>(value: T): T;
17
- /**
18
- * @summary Type validation with `Object.freeze` function
19
- * @template T Type for validation
20
- */
21
- withFreeze<T extends B>(value: T): Readonly<T>;
22
- }
23
- /**
24
- * @summary Cast to avoid generics problem.\
25
- * ⛔ Use with caution, risk of bad code
26
- * @param from as TFrom
27
- * @returns `from` as `any` or `TTo`
28
- */
29
- interface Cast {
30
- /**
31
- * @summary Cast to avoid generics problem\
32
- * ⛔ Use with caution, risk of bad code
33
- * @param from as TFrom
34
- * @returns `from` as `any`
35
- */
36
- <TFrom = any>(from: TFrom): any;
37
- /**
38
- * @summary Cast to avoid generics problem\
39
- * ⛔ Use with caution, risk of bad code
40
- * @param from as TFrom
41
- * @returns `from` as `TTo`
42
- */
43
- To<TTo = any, TFrom = any>(from: TFrom): TTo;
44
- }
45
- }
46
- interface Generic {
47
- /**
48
- * @summary Generics validator factory
49
- * @template B Base type
50
- */
51
- Validator<B = unknown>(): Generic.Validator<B>;
52
- /**
53
- * @summary Type validation function
54
- * @template T Type for validation
55
- */
56
- validate: Generic.Validator;
57
- /**
58
- * @summary Cast to avoid generics problem.\
59
- * ⛔ Use with caution, risk of bad code
60
- * @param from as TFrom
61
- * @returns `from` as `any` or `TTo`
62
- */
63
- Cast: Generic.Cast;
64
- }
65
- }
66
- interface Code {
67
- /**
68
- * @summary Generics utils
69
- */
70
- Generic: Code.Generic;
71
- }
72
- const Generic: Code.Generic;
73
- }
@@ -1,9 +0,0 @@
1
- import '@avstantso/std-ext';
2
- import './_register';
3
- import './check-type';
4
- import './generic';
5
- import './func';
6
- import './catch';
7
- import './atomic-objects';
8
- import './metadata-literals';
9
- import './X';
@@ -1,26 +0,0 @@
1
- declare namespace AVStantso {
2
- /**
3
- * @summary `__KEY__` literal
4
- */
5
- type __KEY__ = '__KEY__';
6
- /**
7
- * @summary `__KEYS__` literal
8
- */
9
- type __KEYS__ = '__KEYS__';
10
- /**
11
- * @summary `__META__` literal
12
- */
13
- type __META__ = '__META__';
14
- /**
15
- * @summary '__BASE_TYPE__' literal
16
- */
17
- type __BASE_TYPE__ = '__BASE_TYPE__';
18
- /**
19
- * @summary `__INPUT__` literal
20
- */
21
- type __INPUT__ = '__INPUT__';
22
- /**
23
- * @summary `__RESULT__` literal
24
- */
25
- type __RESULT__ = '__RESULT__';
26
- }
package/dist/export.d.ts DELETED
@@ -1,4 +0,0 @@
1
- import Func = AVStantso.Func;
2
- import X = AVStantso.X;
3
- import Generic = AVStantso.Generic;
4
- export { Func, X, Generic };
package/dist/index.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import '@avstantso/std-ext';
2
- import './_global';
3
- export * from './export';
package/dist/index.js DELETED
@@ -1,259 +0,0 @@
1
- 'use strict';
2
-
3
- require('@avstantso/std-ext');
4
-
5
- /**
6
- * @summary Access to `AVStantso` namespace code
7
- * @description Lowercase uses in `avstantso` for avoid errors in `Jest`
8
- *
9
- * ⚠ In all cases usage constants and functions from namespace `AVStantso`\
10
- * this must be through `avstantso` global variable
11
- *
12
- * ⚠ All exported namespace `AVStantso` constants and functions\
13
- * must be expressed through `avstantso` global variable
14
- */
15
- const avstantso$1 = {};
16
- // A.V.Stantso:
17
- // To bypass `Jest` restrictions on global variables,
18
- // + rewrite protection
19
- if (!('avstantso' in globalThis))
20
- Object.defineProperties(globalThis, {
21
- avstantso: {
22
- value: avstantso$1,
23
- writable: false,
24
- configurable: false
25
- }
26
- });
27
- // A.V.Stantso:
28
- // For use in import in modules code
29
- if (!('AVStantso' in globalThis))
30
- Object.defineProperties(globalThis, {
31
- AVStantso: {
32
- get: () => avstantso$1,
33
- configurable: false
34
- }
35
- });
36
- {
37
- const structs = ['object', 'function'];
38
- function isStruct(obj) {
39
- const r = obj && (structs.indexOf(typeof obj) + 1);
40
- return r;
41
- }
42
- function HasSymbol(symb) {
43
- return (obj) => isStruct(obj) && symb in obj;
44
- }
45
- const symbolFreeze = Symbol('freeze');
46
- /**
47
- * @summary Register `field`. ⚠ Override not supported now
48
- * @this this Hierarchy level
49
- * @param field Field for registration
50
- * @param initializer Initializaton value or callback
51
- * @returns Current value of `field`
52
- */
53
- function regField(field, initializer) {
54
- if (field in this)
55
- return this[field]; // Override not supported now
56
- const value = 'function' === typeof initializer ? initializer(avstantso$1) : initializer;
57
- Object.defineProperty(this, field, { value, writable: false });
58
- return value;
59
- }
60
- /**
61
- * @summary `_reg` factory for one level
62
- * @param level Hierarchy level
63
- * @returns Registration proxy
64
- */
65
- function RegLevel(level) {
66
- return new Proxy(regField.bind(level), {
67
- get(target, p) {
68
- return p in target
69
- ? Reflect.get(target, p)
70
- : p in level
71
- ? RegLevel(level[p])
72
- : regField.bind(level, p);
73
- }
74
- });
75
- }
76
- function freeze() {
77
- delete this._reg;
78
- delete this.debugState;
79
- delete this.freeze;
80
- const walked = new Set();
81
- const hasCustomFreeze = HasSymbol(symbolFreeze);
82
- function deepFreeze(obj, path = []) {
83
- try {
84
- const ti = structs.indexOf(typeof obj);
85
- if (!obj || ti < 0 || walked.has(obj))
86
- return obj;
87
- walked.add(obj);
88
- if (hasCustomFreeze(obj))
89
- return obj[symbolFreeze].call(obj);
90
- const entries = Object.entries(Object.getOwnPropertyDescriptors(obj));
91
- // console.log('Freeze %O entries: %O',
92
- // path.length ? path.join('.') : 'root',
93
- // entries
94
- // );
95
- for (const [key, dsc] of entries)
96
- if (ti
97
- ? !(key in deepFreeze) // Except standard function properties
98
- : !Array.isArray(dsc.value))
99
- deepFreeze(dsc.value, [...path, key]);
100
- return Object.freeze(obj);
101
- }
102
- catch (e) {
103
- throw ('path' in e) ? e : Object.assign(e, { path });
104
- }
105
- }
106
- deepFreeze(this);
107
- }
108
- Object.defineProperties(avstantso$1, {
109
- _reg: {
110
- value: RegLevel(avstantso$1),
111
- configurable: true
112
- },
113
- HasSymbol: {
114
- value: HasSymbol,
115
- writable: false
116
- },
117
- symbolFreeze: {
118
- value: symbolFreeze,
119
- writable: false
120
- },
121
- freeze: {
122
- value: freeze,
123
- configurable: true
124
- },
125
- debugState: {
126
- value: undefined, writable: true, configurable: true
127
- }
128
- });
129
- }
130
-
131
- var AVStantso$5;
132
- (function (AVStantso) {
133
- /* eslint-disable @typescript-eslint/no-explicit-any */
134
- AVStantso.Generic = avstantso._reg.Generic(() => {
135
- function Validator() {
136
- function validate(value) {
137
- return value;
138
- }
139
- function validateWithFreez(value) {
140
- return Object.freeze(value);
141
- }
142
- return Object.assign(validate, { withFreeze: validateWithFreez });
143
- }
144
- function Cast(from) {
145
- return from;
146
- }
147
- return {
148
- Validator,
149
- validate: Validator(),
150
- Cast: Object.assign(Cast, { To: Cast })
151
- };
152
- });
153
- })(AVStantso$5 || (AVStantso$5 = {}));
154
-
155
- var AVStantso$4;
156
- (function (AVStantso) {
157
- const fpd = Object.assign({}, Object.getOwnPropertyDescriptors(Function.prototype), Object.getOwnPropertyDescriptors(function () { }));
158
- AVStantso.Func = avstantso._reg.Func({
159
- OwnPropertyDescriptors: fpd,
160
- isPropAllowed: Object.assign(function isPropAllowed(propName) {
161
- return !(propName in fpd);
162
- }, {
163
- /**
164
- * @summary Check can NOT use prop for function extends
165
- */
166
- Not: function isPropNotAllowed(propName) {
167
- return propName in fpd;
168
- }
169
- }),
170
- isExt(f) {
171
- for (const k in Object.getOwnPropertyDescriptors(f))
172
- if (!(k in fpd))
173
- return true;
174
- return false;
175
- },
176
- // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
177
- Dynamic(name, func) {
178
- return !process.env.IS_DEV
179
- ? func
180
- : new Function('func', `return function ${name}(...params){ return func(...params); };`)(func);
181
- }
182
- });
183
- })(AVStantso$4 || (AVStantso$4 = {}));
184
-
185
- var AVStantso$3;
186
- (function (AVStantso) {
187
- AVStantso.Catch = avstantso._reg.Catch(() => {
188
- const catchFilters = [];
189
- function DoCatch(error) {
190
- return catchFilters.length && catchFilters.some((f) => f(error))
191
- ? undefined
192
- : DoCatch._default(error);
193
- }
194
- DoCatch._addFilter = (...filters) => {
195
- catchFilters.push(...filters);
196
- };
197
- DoCatch._default = (error) => {
198
- if (error instanceof Error)
199
- throw error;
200
- else
201
- throw new Error(`${error}`);
202
- };
203
- return DoCatch;
204
- });
205
- })(AVStantso$3 || (AVStantso$3 = {}));
206
-
207
- var AVStantso$2;
208
- (function (AVStantso) {
209
- AVStantso.AtomicObjects = avstantso._reg.AtomicObjects(() => {
210
- const classes = new Map();
211
- function register(atomicObjectClass, options) {
212
- classes.set(atomicObjectClass, options);
213
- }
214
- function is(testObject) {
215
- if ('object' === typeof testObject)
216
- for (const Class of classes.keys())
217
- if (testObject instanceof Class)
218
- return true;
219
- return false;
220
- }
221
- function descriptor(param) {
222
- const i = ['object', 'string'].indexOf(typeof param);
223
- if (i >= 0)
224
- for (const [Class, options] of classes.entries())
225
- if (i ? param === Class.name : param instanceof Class)
226
- return { Class, ...options };
227
- }
228
- register(Date, {
229
- empty: () => new Date(0),
230
- clone: (instance) => new Date(instance)
231
- });
232
- // Only for Node-js
233
- if (process?.versions?.node)
234
- register(Buffer, {
235
- empty: () => Buffer.from(''),
236
- clone: (instance) => Buffer.from(instance)
237
- });
238
- return { classes, register, is, descriptor };
239
- });
240
- })(AVStantso$2 || (AVStantso$2 = {}));
241
-
242
- var AVStantso$1;
243
- (function (AVStantso) {
244
- /* eslint-disable @typescript-eslint/no-explicit-any */
245
- /**
246
- * @summary Not `X`, but an oblique cross `❌`. It can be fed to `Promise.then` / `Promise.catch` instead of an empty value
247
- * @returns `undefined`
248
- */
249
- AVStantso.X = avstantso._reg.X(() => function X() { });
250
- })(AVStantso$1 || (AVStantso$1 = {}));
251
-
252
- var Func = AVStantso.Func;
253
- var X = AVStantso.X;
254
- var Generic = AVStantso.Generic;
255
-
256
- exports.Func = Func;
257
- exports.Generic = Generic;
258
- exports.X = X;
259
- //# sourceMappingURL=index.js.map
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":["../src/_global/_register.ts","../src/_global/generic.ts","../src/_global/func.ts","../src/_global/catch/_register.ts","../src/_global/atomic-objects/_register.ts","../src/_global/X.ts","../src/export.ts"],"sourcesContent":["namespace AVStantso {\n /**\n * @summary TypeScript helpers\n */\n export namespace TS {\n /**\n * @summary Object key types union supported by TypeScript\n */\n export type Key = string | number | symbol;\n\n /**\n * @summary Array of object keys types union supported by TypeScript\n * @see Key\n */\n export type Keys = readonly Key[];\n\n /**\n * @summary Record of key to key\n * @example\n * type k2k = CheckType<Key2Key<'a' | 'b' | 'c'>, { a: 'a', b: 'b', c: 'c' }>;\n */\n export type Key2Key<K extends Key> = { [K0 in K]: K0 };\n\n /**\n * @summary Any array.\\\n * ⚠ Please use for check or constraint, not for define\n * @example\n * type IsStruct<T extends object> = T extends Arr ? false : true;\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n export type Arr = any[];\n\n /**\n * @summary Any readonly array.\\\n * ⚠ Please use for check or constraint, not for define\n * @example\n * type IsStruct<T extends object> = T extends ArrR ? false : true;\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n export type ArrR = readonly any[];\n\n /**\n * @summary [O]ne or readonly [L]ist of `T`\n * @template T Value or item type\n */\n export type OL<T> = T | readonly T[];\n\n /**\n * @summary Function type\n * @template R Result type\n * @template P Params array\n */\n export type Func<R = unknown, P extends Arr = Arr> = (...params: P) => R;\n export namespace Func {\n //#region Is\n /**\n * @summary Check extends `T` to `Function`\n * @template T Tested type\n * @template IfTrue Result, if `T` extends `Function`\n * @template IfFalse Result, if NOT `T` extends `Function`\n * @returns `IfFalse` or `IfTrue` param\n * @EXAMPLE(@Is.Flat.Tests)\n */\n export type Is<T, IfTrue = true, IfFalse = false> = T extends undefined\n ? false\n // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\n : T extends Function\n ? IfTrue\n : IfFalse;\n\n namespace Is {\n //#region @Is.Flat.Tests — Tests:\n /* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-object-type */\n\n type n = CheckType<Is<never>, never>;\n type ud = CheckType<Is<undefined>, false>;\n type uk = CheckType<Is<unknown>, false>;\n\n type o = CheckType<Is<{ name: string }>, false>;\n type e = CheckType<Is<{}>, false>;\n type f = CheckType<Is<() => 42>, true>;\n\n /* eslint-enable @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-object-type */\n //#endregion\n }\n //#endregion\n\n /**\n * @summary Function type returns `Promise`\n * @template R Result of promise type\n * @template P Params array\n */\n export type Promise<R = unknown, P extends Arr = Arr> = Func<globalThis.Promise<R>, P>;\n }\n\n /**\n * @summary Procedure type\n * @template P Params array\n */\n export type Proc<P extends Arr = Arr> = (...params: P) => void;\n export namespace Proc {\n /**\n * @summary Procedure type returns `Promise<void>`\n * @template P Params array\n */\n export type Promise<P extends Arr = Arr> = Func.Promise<void, P>;\n }\n\n /**\n * @summary Function type\n * @template I Instance type\n * @template P Params array\n */\n export type Class<I = unknown, P extends Arr = Arr> = new (...params: P) => I;\n\n\n //#region HasString\n /**\n * @summary `U` union includes `string`, not a set of literals only or other types\n * @template U Tested type union\n * @template IfTrue Result, if `T` includes `string`\n * @template IfFalse Result, if `T` NOT includes `string`\n * @returns `IfFalse` or `IfTrue` param\n * @EXAMPLE(@HasString)\n */\n export type HasString<U, IfTrue = true, IfFalse = false> =\n 'some string unused elsewhere: fd3d7784-363b-415f-817a-8575171d736f' extends U\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n ? {} extends U\n ? IfFalse\n : IfTrue\n : IfFalse;\n //#endregion\n\n namespace HasString {\n //#region @HasString — Tests:\n /* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-empty-object-type */\n\n type n = CheckType<HasString<never>, false>;\n type u = CheckType<HasString<undefined>, false>;\n type uk = CheckType<HasString<unknown>, false>;\n type a = CheckType<HasString<any>, false>;\n\n type r1 = CheckType<HasString<string>, true>;\n type r2 = CheckType<HasString<1 | 2 | 3>, false>;\n type r3 = CheckType<HasString<'A' | 'B' | 'C'>, false>;\n type r4 = CheckType<HasString<'A' | 'B' | 'C' | string>, true>;\n type r5 = CheckType<HasString<''>, false>;\n type r6 = CheckType<HasString<{}>, false>;\n\n /* eslint-enable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-empty-object-type */\n //#endregion\n }\n }\n\n /**\n * @summary Interface for access to `AVStantso` namespace code through `avstantso` global property\n */\n export interface Code {\n /**\n * @summary Has `symbol` factory function\n */\n HasSymbol<Symb extends symbol>(symb: Symb): <R>(obj: unknown) => obj is { [K in Symb]: R };\n\n /**\n * @summary Recursively freeze all internals.\\\n * ⚠ Must called from applications index files after all extensions by libraries\\\n * Unavailable after call `freeze` method\n */\n freeze?(): void;\n\n /**\n * @summary `symbol` for custom freeze\n * @see freeze\n */\n symbolFreeze: symbol;\n\n /**\n * @summary External state for debugging\\\n * Unavailable after call `freeze` method\n * @description Used in tests, for separate initilizing code and test code\n * @example\n * // in debugging _global file\n * namespace AVStantso {\n * avstantso._reg.foo(() => () => {\n * if (avstantso.debugState) console.log(`foo called!`);\n *\n * return 123;\n * });\n *\n * avstantso.foo(); // don`t write to console\n * }\n *\n * // in test file\n * avstantso.debugState = true;\n *\n * avstantso.foo(); // write to console\n */\n debugState: unknown;\n }\n\n export namespace Code {\n export namespace _Reg {\n namespace Initializer {\n export type Func<T> = (code: Partial<AVStantso.Code>) => T;\n }\n\n /**\n * @summary Registration method\n * @param initializer Initializer for field `TField`\n */\n export type Method<\n T extends object,\n TField extends keyof T,\n F extends T[TField] = T[TField],\n P extends Partial<F> = Partial<F>\n > =\n // ⚠ TS.Func.Is not works in this place\n // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\n (initializer: F extends Function\n ? Initializer.Func<F>\n : P | Initializer.Func<P>\n ) => F;\n\n export type Recursive<T extends object> =\n {\n [K in keyof T]: T[K] extends object\n ? T[K] extends TS.Arr[]\n ? Method<T, K>\n : Recursive<T[K]> & Method<T, K>\n : Method<T, K>;\n };\n }\n\n /**\n * @summary Access to registration proxy structure\n */\n export type _Reg = _Reg.Recursive<Code>;\n }\n}\n\n/**\n * @summary Access to `AVStantso` namespace code\n * @description Lowercase uses in `avstantso` for avoid errors in `Jest`\n *\n * ⚠ In all cases usage constants and functions from namespace `AVStantso`\\\n * this must be through `avstantso` global variable\n *\n * ⚠ All exported namespace `AVStantso` constants and functions\\\n * must be expressed through `avstantso` global variable\n */\nconst avstantso = {} as AVStantso.Code & {\n /**\n * @summary Access to registration proxy structure.\\\n * Unavailable after call `freeze` method\n */\n _reg?: AVStantso.Code._Reg;\n};\n\n// A.V.Stantso:\n// To bypass `Jest` restrictions on global variables,\n// + rewrite protection\nif (!('avstantso' in globalThis))\n Object.defineProperties(globalThis, {\n avstantso: {\n value: avstantso,\n writable: false,\n configurable: false\n }\n });\n\n// A.V.Stantso:\n// For use in import in modules code\nif (!('AVStantso' in globalThis))\n Object.defineProperties(globalThis, {\n AVStantso: {\n get: () => avstantso,\n configurable: false\n }\n });\n\n{\n const structs = ['object', 'function'];\n function isStruct(obj: unknown): obj is AVStantso.TS.Func | object {\n const r = obj && (structs.indexOf(typeof obj) + 1);\n return r as unknown as boolean;\n }\n\n function HasSymbol<Symb extends symbol>(symb: Symb) {\n return <R>(obj: unknown): obj is { [K in Symb]: R } =>\n isStruct(obj) && symb in obj;\n }\n\n const symbolFreeze = Symbol('freeze');\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n type Level = object & any;\n type Field = keyof Level;\n\n /**\n * @summary Register `field`. ⚠ Override not supported now\n * @this this Hierarchy level\n * @param field Field for registration\n * @param initializer Initializaton value or callback\n * @returns Current value of `field`\n */\n function regField(this: Level, field: Field, initializer: unknown) {\n if (field in this) return this[field]; // Override not supported now\n\n const value = 'function' === typeof initializer ? initializer(avstantso) : initializer;\n\n Object.defineProperty(this, field, { value, writable: false });\n\n return value;\n }\n\n /**\n * @summary `_reg` factory for one level\n * @param level Hierarchy level\n * @returns Registration proxy\n */\n function RegLevel(level: Level): unknown {\n return new Proxy(regField.bind(level), {\n get(target, p) {\n return p in target\n ? Reflect.get(target, p)\n : p in level\n ? RegLevel(level[p])\n : regField.bind(level, p);\n }\n });\n }\n\n\n function freeze(this: typeof avstantso) {\n delete this._reg;\n delete this.debugState;\n delete this.freeze;\n\n const walked = new Set();\n\n const hasCustomFreeze = HasSymbol(symbolFreeze);\n\n function deepFreeze(obj: unknown, path: string[] = []) {\n try {\n const ti = structs.indexOf(typeof obj);\n\n if (!obj || ti < 0 || walked.has(obj)) return obj;\n\n walked.add(obj);\n\n if (hasCustomFreeze<() => void>(obj))\n return obj[symbolFreeze].call(obj);\n\n const entries = Object.entries(Object.getOwnPropertyDescriptors(obj));\n // console.log('Freeze %O entries: %O',\n // path.length ? path.join('.') : 'root',\n // entries\n // );\n\n for (const [key, dsc] of entries)\n if (ti\n ? !(key in deepFreeze) // Except standard function properties\n : !Array.isArray(dsc.value)\n )\n deepFreeze(dsc.value, [...path, key]);\n\n return Object.freeze(obj);\n } catch (e) {\n throw ('path' in e) ? e : Object.assign(e, { path });\n }\n };\n\n deepFreeze(this);\n }\n\n Object.defineProperties(avstantso, {\n _reg: {\n value: RegLevel(avstantso),\n configurable: true\n },\n\n HasSymbol: {\n value: HasSymbol,\n writable: false\n },\n\n symbolFreeze: {\n value: symbolFreeze,\n writable: false\n },\n\n freeze: {\n value: freeze,\n configurable: true\n },\n\n debugState: {\n value: undefined, writable: true, configurable: true\n }\n });\n}\n","namespace AVStantso {\n\n /* eslint-disable @typescript-eslint/no-explicit-any */\n\n export namespace Code {\n /**\n * @summary Generics utils\n */\n export namespace Generic {\n /**\n * @summary Generics validator\n * @template B Base type\n */\n export interface Validator<B = unknown> {\n /**\n * @summary Type validation function\n * @template T Type for validation\n */\n <T extends B>(value: T): T;\n\n /**\n * @summary Type validation with `Object.freeze` function\n * @template T Type for validation\n */\n withFreeze<T extends B>(value: T): Readonly<T>;\n }\n\n /**\n * @summary Cast to avoid generics problem.\\\n * ⛔ Use with caution, risk of bad code\n * @param from as TFrom\n * @returns `from` as `any` or `TTo`\n */\n export interface Cast {\n /**\n * @summary Cast to avoid generics problem\\\n * ⛔ Use with caution, risk of bad code\n * @param from as TFrom\n * @returns `from` as `any`\n */\n <TFrom = any>(from: TFrom): any;\n\n /**\n * @summary Cast to avoid generics problem\\\n * ⛔ Use with caution, risk of bad code\n * @param from as TFrom\n * @returns `from` as `TTo`\n */\n To<TTo = any, TFrom = any>(from: TFrom): TTo;\n }\n }\n\n export interface Generic {\n /**\n * @summary Generics validator factory\n * @template B Base type\n */\n Validator<B = unknown>(): Generic.Validator<B>;\n\n /**\n * @summary Type validation function\n * @template T Type for validation\n */\n validate: Generic.Validator;\n\n /**\n * @summary Cast to avoid generics problem.\\\n * ⛔ Use with caution, risk of bad code\n * @param from as TFrom\n * @returns `from` as `any` or `TTo`\n */\n Cast: Generic.Cast;\n }\n }\n\n export interface Code {\n /**\n * @summary Generics utils\n */\n Generic: Code.Generic;\n }\n\n export const Generic: Code.Generic = avstantso._reg.Generic(() => {\n function Validator<B = unknown>() {\n function validate<T extends B>(value: T): T {\n return value;\n };\n\n function validateWithFreez<T extends B>(value: T): T {\n return Object.freeze(value);\n };\n\n return Object.assign(\n validate,\n { withFreeze: validateWithFreez }\n );\n }\n\n function Cast<TFrom = any>(from: TFrom): any {\n return from as any;\n }\n\n return {\n Validator,\n validate: Validator(),\n Cast: Object.assign(\n Cast,\n { To: Cast }\n )\n };\n });\n}\n","namespace AVStantso {\n const fpd = Object.assign(\n {},\n Object.getOwnPropertyDescriptors(Function.prototype),\n Object.getOwnPropertyDescriptors(function () {})\n );\n\n export namespace TS.Func {\n /**\n * @summary `getOwnPropertyDescriptors` of basic function type\n */\n export type PropertyDescriptors = {\n [K in keyof typeof fpd as TS.HasString<K, never, K>]: (typeof fpd)[K]\n };\n\n /**\n * @summary You must exclude this keys on add new props of function\n * @example\n * type MyKeys = 'id' | 'value' | 'name';\n *\n * // ❌\n * type Is_$Bad: (<T extends MyKeys>(k: T, candidate: unknown) => candidate is T) & {\n * [K in MyKeys]: (candidate: unknown) => candidate is K;\n * }\n *\n * // ✅\n * type Is_$Good: (<T extends MyKeys>(k: T, candidate: unknown) => candidate is T) & {\n * [K in TS.Func.Restrict<MyKeys>]: (candidate: unknown) => candidate is K;\n * }\n */\n export type RestrictionsForExt = keyof PropertyDescriptors;\n\n /**\n * @summary Restricted keys exclude shortcut\n * @example\n * type MyKeys = 'id' | 'value' | 'name';\n *\n * // ❌\n * type Is_$Bad: (<T extends MyKeys>(k: T, candidate: unknown) => candidate is T) & {\n * [K in MyKeys]: (candidate: unknown) => candidate is K;\n * }\n *\n * // ✅\n * type Is_$Good: (<T extends MyKeys>(k: T, candidate: unknown) => candidate is T) & {\n * [K in TS.Func.Restrict<MyKeys>]: (candidate: unknown) => candidate is K;\n * }\n */\n export type Restrict<T extends Key> = Exclude<T, RestrictionsForExt>;\n }\n\n export namespace Code {\n /**\n * @summary Functions utilities\n */\n export interface Func {\n /**\n * @summary `getOwnPropertyDescriptors` of basic function\n */\n OwnPropertyDescriptors: AVStantso.TS.Func.PropertyDescriptors;\n\n /**\n * @summary Check can use prop for function extends\n * @param propName Ext prop name\n * @returns `true` — can add to function, else `false`\n * @example\n * const Types = ['insert', 'update', 'name'] as const;\n * type Type = typeof Types[number];\n * type Data<T extends Type> =\n * | (T extends 'insert' ? {\n * type: 'insert',\n * value: 'xxx'\n * } : never)\n * | (T extends 'update' ? {\n * type: 'update',\n * value: 15\n * } : never)\n * | (T extends 'name' ? {\n * type: 'name',\n * id: string;\n * value: string;\n * }: never);\n *\n * function _isTypeOfData<T extends Type>(type: T, data: Data<Type>): data is Data<T> {\n * return data.type === type;\n * }\n *\n * const isTypeOfData = Object.assign(\n * _isTypeOfData,\n * Object.fromEntries(\n * Types\n * // 👇\n * .filter(Func.isPropAllowed)\n * .map((type) => [\n * type,\n * _isTypeOfData.bind(null, type)\n * ])\n * )\n * )\n * @EXAMPLE(@Code.Func.isPropAllowed)\n */\n isPropAllowed: {\n (propName: TS.Key): boolean;\n\n /**\n * @summary Check can NOT use prop for function extends\n * @param propName Ext prop name\n * @returns `true` — can't add to function, else `false`\n * @EXAMPLE(@Code.Func.isPropAllowed.Not)\n */\n Not: (propName: TS.Key) => boolean\n }\n\n /**\n * @summary Function has extended properties\n * @param f Function being tested\n * @returns 'true' if has extended properties, else 'false'\n * @example\n * function a() {\n * return 14;\n * }\n * expect(isExt(a)).toBe(false);\n *\n * const aa = () => 'xyz';\n * expect(isExt(aa)).toBe(false);\n *\n * const b = Object.assign(\n * function b() {\n * return 14;\n * },\n * { x: 19 }\n * );\n * expect(isExt(b)).toBe(true);\n *\n * const bb = Object.assign(\n * () => 14,\n * { x: 19 }\n * );\n * expect(isExt(bb)).toBe(true);\n *\n * function c() {\n * return 'abc';\n * }\n * Object.defineProperties(c, { y: { value: 34 } });\n * expect(isExt(c)).toBe(true);\n *\n * const cc = () => 'abc';\n * Object.defineProperties(cc, { y: { value: 34 } });\n * expect(isExt(cc)).toBe(true);\n *\n * function d() {\n * return 'abcd';\n * }\n * d.z = 16;\n * expect(isExt(d)).toBe(true);\n *\n * const dd = () => 'abcd';\n * dd.z = 16;\n * expect(isExt(dd)).toBe(true);\n * @EXAMPLE(@Code.Func.isExt)\n */\n // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\n isExt(f: Function): boolean;\n\n /**\n * @summary `DEV` dynamic function named as `name`. No affect in `PROD`.\n * @param name Name\n * @param func Implementation\n * @returns In `DEV` — Named function; In `PROD` — `func`\n */\n // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\n Dynamic<N extends string, F extends Function>(name: N, func: F): F;\n }\n }\n\n export interface Code {\n /**\n * @summary Functions utilities\n */\n Func: Code.Func;\n }\n\n export const Func = avstantso._reg.Func( {\n OwnPropertyDescriptors: fpd,\n isPropAllowed: Object.assign(\n function isPropAllowed(propName: string): boolean {\n return !(propName in fpd);\n },\n {\n /**\n * @summary Check can NOT use prop for function extends\n */\n Not: function isPropNotAllowed(propName: string): boolean {\n return propName in fpd;\n }\n }\n ),\n isExt(f: unknown) {\n for (const k in Object.getOwnPropertyDescriptors(f))\n if (!(k in fpd))\n return true;\n\n return false;\n },\n // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\n Dynamic<N extends string, F extends Function>(\n name: N,\n func: F\n ): F {\n return !process.env.IS_DEV\n ? func\n : new Function(\n 'func',\n `return function ${name}(...params){ return func(...params); };`\n )(func);\n }\n } as Code.Func);\n}\n","namespace AVStantso {\n export namespace Catch {\n /**\n * @summary Catch handler\n * @param error Error\n */\n export type Handler<T = unknown> = (error: T) => unknown;\n\n export namespace Core {\n /**\n * @summary `Core` catch handler version\n * @param error Error\n */\n export type Handler = Catch.Handler;\n }\n }\n\n /**\n * @summary Common catch method for errors\n */\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n export interface Catch extends Catch.Core.Handler { }\n\n export namespace Code {\n export namespace Catch {\n /**\n * @summary Catch filter handler\n * @param error Error\n */\n export type Filter<T = unknown> = (error: T) => boolean;\n }\n\n /**\n * @summary Catch helpers utility\n */\n export interface Catch extends AVStantso.Catch {\n _addFilter(...filters: [Catch.Filter, ...Catch.Filter[]]): void;\n _default: AVStantso.Catch.Handler;\n }\n }\n\n export interface Code {\n /**\n * @summary Catch helpers utility\n */\n Catch: Code.Catch;\n }\n\n export const Catch = avstantso._reg.Catch(() => {\n type Filter = Code.Catch.Filter;\n\n const catchFilters: Filter[] = [];\n\n function DoCatch(error: unknown): unknown {\n return catchFilters.length && catchFilters.some((f) => f(error))\n ? undefined\n : DoCatch._default(error);\n }\n\n DoCatch._addFilter = (...filters: [Filter, ...Filter[]]): void => {\n catchFilters.push(...filters);\n };\n\n DoCatch._default = (error: unknown) => {\n if (error instanceof Error)\n throw error;\n else\n throw new Error(`${error}`);\n };\n\n return DoCatch;\n });\n}\n","namespace AVStantso {\n /**\n * @summary Interface registry of atomic objects types\n */\n export namespace AtomicObjects {\n /**\n * @summary Atomic object class options\n */\n export interface Options<TClass extends TS.Class = TS.Class> {\n empty?(): InstanceType<TClass>;\n\n /**\n * @summary Clone rule for atomic object\n */\n clone(instance: InstanceType<TClass>): InstanceType<TClass>\n }\n\n /**\n * @summary Atomic object class descriptor\n */\n export type Descriptor<TClass extends TS.Class = TS.Class> =\n { Class: TClass } & Options<TClass>;\n }\n\n export interface AtomicObjects {\n Date: Date;\n\n /**\n * @requires `'buffer'` library required for browser and register manually.\\\n * For Node-js: automatic register builtin class `Buffer`\n */\n Buffer: Buffer;\n }\n\n export namespace Code {\n /**\n * @summary Atomic objects registry management\n */\n export interface AtomicObjects {\n /**\n * @summary Readonly map of registered classes of atomic objects and class options\n */\n classes: ReadonlyMap<TS.Class, AVStantso.AtomicObjects.Options>;\n\n /**\n * @summary Class registration of atomic object and add options\n * @param atomicObjectClass Class of atomic object\n * @param options Atomic object class options\n */\n register<TClass extends TS.Class>(\n atomicObjectClass: TClass,\n options : AVStantso.AtomicObjects.Options<TClass>\n ): void;\n\n /**\n * @summary Check object is atomic. 'false' for non-object values\n * @param testObject Tested object\n * @returns 'true' is object is atomic, else `false`\n */\n is(testObject: object | unknown): boolean;\n\n /**\n * @summary Get atomic object descriptor or `undefined`, if not class name, object not atomic or non-object value\n * @param testObjectOrClassName Tested object or class name\n * @returns 'AtomicObjects.AVStantso.AtomicObjects.Descriptor' if object is atomic or find class name, else `undefined`\n * @see AVStantso.AtomicObjects.Descriptor\n */\n descriptor: {\n /**\n * @summary Get atomic object descriptor or `undefined`, if object not atomic or non-object value\n * @param testObject Tested object\n * @returns 'AtomicObjects.AVStantso.AtomicObjects.Descriptor' if object is atomic, else `undefined`\n * @see AVStantso.AtomicObjects.Descriptor\n */\n (testObject: object | unknown): AVStantso.AtomicObjects.Descriptor;\n\n /**\n * @summary Get atomic object descriptor or `undefined`, if class name not found\n * @param className Class name\n * @returns 'AtomicObjects.AVStantso.AtomicObjects.Descriptor' if find class name, else `undefined`\n * @see AVStantso.AtomicObjects.Descriptor\n */\n (className: string): AVStantso.AtomicObjects.Descriptor;\n }\n }\n }\n\n export interface Code {\n /**\n * @summary Atomic objects registry management\n */\n AtomicObjects: Code.AtomicObjects;\n }\n\n export const AtomicObjects = avstantso._reg.AtomicObjects(() => {\n const classes = new Map<TS.Class, AVStantso.AtomicObjects.Options>();\n\n function register<TClass extends TS.Class>(\n atomicObjectClass: TClass,\n options : AVStantso.AtomicObjects.Options<TClass>\n ) {\n classes.set(atomicObjectClass, options);\n }\n\n function is(testObject: object): boolean {\n if ('object' === typeof testObject)\n for (const Class of classes.keys())\n if (testObject instanceof Class) return true;\n\n return false;\n }\n\n function descriptor(param: object | string): AVStantso.AtomicObjects.Descriptor {\n const i = ['object', 'string'].indexOf(typeof param);\n\n if (i >= 0)\n for (const [Class, options] of classes.entries())\n if (i ? param === Class.name : param instanceof Class)\n return { Class, ...options };\n }\n\n register(Date, {\n empty: () => new Date(0),\n clone: (instance) => new Date(instance)\n });\n\n // Only for Node-js\n if (process?.versions?.node) register(Buffer, {\n empty: () => Buffer.from(''),\n clone: (instance) => Buffer.from(instance)\n });\n\n return { classes, register, is, descriptor } as AVStantso.Code.AtomicObjects;\n });\n}\n","namespace AVStantso {\n\n /* eslint-disable @typescript-eslint/no-explicit-any */\n\n export interface Code {\n /**\n * @summary Not `X`, but an oblique cross `❌`. It can be fed to `Promise.then` / `Promise.catch` instead of an empty value\n * @returns `undefined`\n */\n X<T = any>(): T;\n }\n\n /**\n * @summary Not `X`, but an oblique cross `❌`. It can be fed to `Promise.then` / `Promise.catch` instead of an empty value\n * @returns `undefined`\n */\n export const X = avstantso._reg.X(() => function X(){} as Code['X']);\n}\n","import Func = AVStantso.Func;\nimport X = AVStantso.X;\nimport Generic = AVStantso.Generic;\nexport { Func, X, Generic };\n"],"names":["avstantso","AVStantso"],"mappings":";;;;AAiPA;;;;;;;;;AASG;AACH,MAAMA,WAAS,GAAG,EAMjB;AAED;AACA;AACA;AACA,IAAI,EAAE,WAAW,IAAI,UAAU,CAAC;AAC9B,IAAA,MAAM,CAAC,gBAAgB,CAAC,UAAU,EAAE;AAClC,QAAA,SAAS,EAAE;AACT,YAAA,KAAK,EAAEA,WAAS;AAChB,YAAA,QAAQ,EAAE,KAAK;AACf,YAAA,YAAY,EAAE;AACf;AACF,KAAA,CAAC;AAEJ;AACA;AACA,IAAI,EAAE,WAAW,IAAI,UAAU,CAAC;AAC9B,IAAA,MAAM,CAAC,gBAAgB,CAAC,UAAU,EAAE;AAClC,QAAA,SAAS,EAAE;AACT,YAAA,GAAG,EAAE,MAAMA,WAAS;AACpB,YAAA,YAAY,EAAE;AACf;AACF,KAAA,CAAC;AAEJ;AACE,IAAA,MAAM,OAAO,GAAG,CAAC,QAAQ,EAAE,UAAU,CAAC;IACtC,SAAS,QAAQ,CAAC,GAAY,EAAA;AAC5B,QAAA,MAAM,CAAC,GAAG,GAAG,KAAK,OAAO,CAAC,OAAO,CAAC,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC;AAClD,QAAA,OAAO,CAAuB;IAChC;IAEA,SAAS,SAAS,CAAsB,IAAU,EAAA;AAChD,QAAA,OAAO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