@zvenigora/ng-eval-core 0.1.105 → 0.1.107
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/esm2022/lib/actual/services/eval.service.mjs +13 -1
- package/esm2022/lib/internal/classes/common/public-api.mjs +1 -3
- package/esm2022/lib/internal/classes/eval/eval-context.mjs +24 -6
- package/esm2022/lib/internal/classes/eval/eval-lookup.mjs +1 -1
- package/esm2022/lib/internal/classes/eval/eval-result.mjs +19 -3
- package/esm2022/lib/internal/classes/eval/eval-scope.mjs +86 -0
- package/esm2022/lib/internal/classes/eval/eval-state.mjs +1 -1
- package/esm2022/lib/internal/classes/eval/eval-trace.mjs +22 -0
- package/esm2022/lib/internal/classes/eval/public-api.mjs +3 -1
- package/esm2022/lib/internal/interfaces/public-api.mjs +1 -1
- package/esm2022/lib/internal/interfaces/registry-type.mjs +1 -1
- package/esm2022/lib/internal/visitors/member-expression.mjs +7 -1
- package/esm2022/lib/internal/visitors/visitor-result.mjs +3 -9
- package/fesm2022/zvenigora-ng-eval-core.mjs +351 -371
- package/fesm2022/zvenigora-ng-eval-core.mjs.map +1 -1
- package/lib/internal/classes/common/public-api.d.ts +0 -2
- package/lib/internal/classes/eval/eval-context.d.ts +11 -3
- package/lib/internal/classes/eval/eval-lookup.d.ts +1 -1
- package/lib/internal/classes/eval/eval-result.d.ts +16 -3
- package/lib/internal/classes/eval/eval-scope.d.ts +51 -0
- package/lib/internal/classes/eval/eval-state.d.ts +4 -4
- package/lib/internal/classes/eval/eval-trace.d.ts +20 -0
- package/lib/internal/classes/eval/public-api.d.ts +2 -0
- package/lib/internal/interfaces/public-api.d.ts +1 -1
- package/lib/internal/interfaces/registry-type.d.ts +0 -6
- package/package.json +1 -1
- package/esm2022/lib/internal/classes/common/scope-registry.mjs +0 -116
- package/esm2022/lib/internal/classes/common/scope.mjs +0 -55
- package/lib/internal/classes/common/scope-registry.d.ts +0 -83
- package/lib/internal/classes/common/scope.d.ts +0 -30
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
export { BaseRegistry } from './base-registry';
|
|
2
2
|
export { CaseInsensitiveRegistry } from './case-insensitive-registry';
|
|
3
|
-
export { ScopeRegistry, RegistryScopeOptionType } from './scope-registry';
|
|
4
3
|
export { Registry } from './registry';
|
|
5
4
|
export { Queue } from './queue';
|
|
6
5
|
export { Stack } from './stack';
|
|
7
|
-
export { Scope } from './scope';
|
|
8
6
|
export { Cache } from './cache';
|
|
9
7
|
export { BaseContext, Context, isRegistryContext, fromContext, getContextValue, getContextKey } from './context';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { Context,
|
|
1
|
+
import { Context, Stack } from '../common';
|
|
2
2
|
import { EvalLookup } from './eval-lookup';
|
|
3
3
|
import { EvalOptions } from './eval-options';
|
|
4
|
+
import { EvalScope } from './eval-scope';
|
|
4
5
|
/**
|
|
5
6
|
* Represents the evaluation context for the code execution.
|
|
6
7
|
*/
|
|
@@ -18,7 +19,7 @@ export declare class EvalContext {
|
|
|
18
19
|
/**
|
|
19
20
|
* Gets the scopes registry.
|
|
20
21
|
*/
|
|
21
|
-
get priorScopes():
|
|
22
|
+
get priorScopes(): EvalScope[];
|
|
22
23
|
/**
|
|
23
24
|
* Gets the scopes registry.
|
|
24
25
|
*/
|
|
@@ -26,7 +27,7 @@ export declare class EvalContext {
|
|
|
26
27
|
/**
|
|
27
28
|
* Gets the lookups registry.
|
|
28
29
|
*/
|
|
29
|
-
get lookups():
|
|
30
|
+
get lookups(): EvalLookup[];
|
|
30
31
|
/**
|
|
31
32
|
* Gets the evaluation options.
|
|
32
33
|
*/
|
|
@@ -82,4 +83,11 @@ export declare class EvalContext {
|
|
|
82
83
|
* Pops a context from the scope stack.
|
|
83
84
|
*/
|
|
84
85
|
pop(): void;
|
|
86
|
+
/**
|
|
87
|
+
* Converts the EvalContext instance to an object representation.
|
|
88
|
+
* If the original value is an instance of Registry, it converts it to an object using the toObject method of the registry.
|
|
89
|
+
* If the original value is an object, it returns the original object.
|
|
90
|
+
* @returns The object representation of the EvalContext instance.
|
|
91
|
+
*/
|
|
92
|
+
toObject(): Record<string | number | symbol, unknown> | undefined;
|
|
85
93
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { EvalOptions } from './eval-options';
|
|
2
|
-
export type EvalLookup = (key: unknown, thisArg
|
|
2
|
+
export type EvalLookup = (key: unknown, thisArg?: unknown, options?: EvalOptions) => unknown;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Stack } from "../common";
|
|
2
2
|
import { EvalContext } from "./eval-context";
|
|
3
3
|
import { EvalOptions } from "./eval-options";
|
|
4
|
+
import { EvalTrace } from "./eval-trace";
|
|
4
5
|
type UnknownValue = unknown | Promise<unknown>;
|
|
5
6
|
/**
|
|
6
7
|
* Represents the result of an evaluation.
|
|
@@ -17,10 +18,11 @@ export declare class EvalResult {
|
|
|
17
18
|
private _context;
|
|
18
19
|
private _startDate?;
|
|
19
20
|
private _endDate?;
|
|
21
|
+
private _expression?;
|
|
20
22
|
/**
|
|
21
23
|
* Gets the stack of evaluated values.
|
|
22
24
|
*/
|
|
23
|
-
get stack():
|
|
25
|
+
get stack(): Stack<UnknownValue>;
|
|
24
26
|
/**
|
|
25
27
|
* Gets the evaluated value.
|
|
26
28
|
*/
|
|
@@ -48,7 +50,7 @@ export declare class EvalResult {
|
|
|
48
50
|
/**
|
|
49
51
|
* Gets the trace of evaluated values.
|
|
50
52
|
*/
|
|
51
|
-
get trace():
|
|
53
|
+
get trace(): EvalTrace;
|
|
52
54
|
/**
|
|
53
55
|
* Gets the evaluation context.
|
|
54
56
|
*/
|
|
@@ -62,6 +64,17 @@ export declare class EvalResult {
|
|
|
62
64
|
* @returns The duration in milliseconds.
|
|
63
65
|
*/
|
|
64
66
|
get duration(): number | undefined;
|
|
67
|
+
/**
|
|
68
|
+
* Gets the expression associated with the evaluation result.
|
|
69
|
+
* @returns The expression as a string, or undefined if no expression is associated.
|
|
70
|
+
*/
|
|
71
|
+
get expression(): string | undefined;
|
|
72
|
+
/**
|
|
73
|
+
* Sets the expression for the evaluation result.
|
|
74
|
+
*
|
|
75
|
+
* @param value - The expression to be set.
|
|
76
|
+
*/
|
|
77
|
+
set expression(value: string | undefined);
|
|
65
78
|
/**
|
|
66
79
|
* Creates a new instance of EvalResult.
|
|
67
80
|
* @param trace The trace of evaluated values.
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Context } from "../common";
|
|
2
|
+
export interface EvalScopeOptions {
|
|
3
|
+
global?: boolean;
|
|
4
|
+
caseInsensitive?: boolean;
|
|
5
|
+
namespace?: string;
|
|
6
|
+
thisArg?: unknown;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Represents an evaluation scope.
|
|
10
|
+
*/
|
|
11
|
+
export declare class EvalScope {
|
|
12
|
+
type: string;
|
|
13
|
+
private _context;
|
|
14
|
+
private _options;
|
|
15
|
+
/**
|
|
16
|
+
* Gets the context of the evaluation scope.
|
|
17
|
+
* @returns The context object.
|
|
18
|
+
*/
|
|
19
|
+
get context(): Context;
|
|
20
|
+
/**
|
|
21
|
+
* Gets the options for evaluating the scope.
|
|
22
|
+
* @returns The evaluation options.
|
|
23
|
+
*/
|
|
24
|
+
get options(): EvalScopeOptions;
|
|
25
|
+
/**
|
|
26
|
+
* Creates a new instance of EvalScope.
|
|
27
|
+
* @param context - The context of the evaluation scope.
|
|
28
|
+
* @param options - The options for evaluating the scope.
|
|
29
|
+
*/
|
|
30
|
+
constructor(context?: Context, options?: EvalScopeOptions);
|
|
31
|
+
/**
|
|
32
|
+
* Creates an instance of EvalScope from the given context and options.
|
|
33
|
+
*
|
|
34
|
+
* @param context - The context object.
|
|
35
|
+
* @param options - The options object.
|
|
36
|
+
* @returns An instance of EvalScope.
|
|
37
|
+
*/
|
|
38
|
+
static fromObject(context?: Context, options?: EvalScopeOptions): EvalScope;
|
|
39
|
+
/**
|
|
40
|
+
* Gets the value of the specified key.
|
|
41
|
+
* @param key - The key to retrieve the value for.
|
|
42
|
+
* @returns The value of the specified key, or undefined if the key is not found.
|
|
43
|
+
*/
|
|
44
|
+
get(key: unknown): unknown | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* Sets the value of the specified key.
|
|
47
|
+
* @param key - The key to set the value for.
|
|
48
|
+
* @param value - The value to set.
|
|
49
|
+
*/
|
|
50
|
+
set(key: string, value: unknown): void;
|
|
51
|
+
}
|
|
@@ -13,19 +13,19 @@ export declare class EvalState {
|
|
|
13
13
|
/**
|
|
14
14
|
* Gets the evaluation context.
|
|
15
15
|
*/
|
|
16
|
-
get context():
|
|
16
|
+
get context(): EvalContext | undefined;
|
|
17
17
|
/**
|
|
18
18
|
* Gets the evaluation result.
|
|
19
19
|
*/
|
|
20
|
-
get result():
|
|
20
|
+
get result(): EvalResult;
|
|
21
21
|
/**
|
|
22
22
|
* Gets the evaluation options.
|
|
23
23
|
*/
|
|
24
|
-
get options():
|
|
24
|
+
get options(): EvalOptions | undefined;
|
|
25
25
|
/**
|
|
26
26
|
* Gets whether the evaluation is asynchronous.
|
|
27
27
|
*/
|
|
28
|
-
get isAsync():
|
|
28
|
+
get isAsync(): boolean | undefined;
|
|
29
29
|
/**
|
|
30
30
|
* Represents the state of an evaluation.
|
|
31
31
|
* @param context The evaluation context.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { AnyNode } from "acorn";
|
|
2
|
+
export interface EvalTraceItem {
|
|
3
|
+
start?: number;
|
|
4
|
+
end?: number;
|
|
5
|
+
type: string;
|
|
6
|
+
expression?: string;
|
|
7
|
+
value: unknown;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Represents a trace of evaluation for a specific code execution.
|
|
11
|
+
*/
|
|
12
|
+
export declare class EvalTrace extends Array<EvalTraceItem> {
|
|
13
|
+
/**
|
|
14
|
+
* Adds a new trace item to the evaluation trace.
|
|
15
|
+
* @param node - The AST node associated with the trace item.
|
|
16
|
+
* @param value - The value of the evaluated expression.
|
|
17
|
+
* @param expression - The expression being evaluated.
|
|
18
|
+
*/
|
|
19
|
+
add(node: AnyNode, value?: unknown, expression?: string): void;
|
|
20
|
+
}
|
|
@@ -4,3 +4,5 @@ export { EvalResult } from './eval-result';
|
|
|
4
4
|
export { EvalState } from './eval-state';
|
|
5
5
|
export { EvalLookup } from './eval-lookup';
|
|
6
6
|
export { defaultParserOptions } from './parser-options';
|
|
7
|
+
export { EvalTraceItem, EvalTrace } from './eval-trace';
|
|
8
|
+
export { EvalScope, EvalScopeOptions } from './eval-scope';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export * from './parser-types';
|
|
2
|
-
export { RegistryType,
|
|
2
|
+
export { RegistryType, RegistryEntries } from './registry-type';
|
|
3
3
|
export { StackType } from './stack-type';
|
|
4
4
|
export { QueueType } from './queue-type';
|
|
5
5
|
export { ScopeType, RegistryOptionType, ScopeOptions } from './scope-type';
|
|
@@ -64,10 +64,4 @@ export interface RegistryType<TKey, TValue> extends Iterable<[TKey, TValue]> {
|
|
|
64
64
|
*/
|
|
65
65
|
[Symbol.iterator](): IterableIterator<[TKey, TValue]>;
|
|
66
66
|
}
|
|
67
|
-
export interface ScopeRegistryOptions {
|
|
68
|
-
caseInsensitive: boolean;
|
|
69
|
-
global: boolean;
|
|
70
|
-
namespace: string;
|
|
71
|
-
thisArg: unknown;
|
|
72
|
-
}
|
|
73
67
|
export type RegistryEntries<TKey, TValue> = [TKey, TValue][] | Record<string | number | symbol, TValue>;
|
package/package.json
CHANGED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import { Registry } from "./registry";
|
|
2
|
-
const defaultOptions = {
|
|
3
|
-
caseInsensitive: false,
|
|
4
|
-
namespace: '',
|
|
5
|
-
global: false,
|
|
6
|
-
thisArg: undefined
|
|
7
|
-
};
|
|
8
|
-
/**
|
|
9
|
-
* Represents a registry that stores key-value pairs within a specific scope.
|
|
10
|
-
* @template TKey The type of the keys in the registry.
|
|
11
|
-
* @template TValue The type of the values in the registry.
|
|
12
|
-
*/
|
|
13
|
-
export class ScopeRegistry {
|
|
14
|
-
/**
|
|
15
|
-
* Creates a new instance of ScopeRegistry.
|
|
16
|
-
* @param entries Optional. An array of key-value pairs to initialize the registry.
|
|
17
|
-
* @param options Optional. Options for the registry.
|
|
18
|
-
*/
|
|
19
|
-
constructor(entries, options = defaultOptions) {
|
|
20
|
-
this.type = 'ScopeRegistry';
|
|
21
|
-
/**
|
|
22
|
-
* Options for the registry.
|
|
23
|
-
*/
|
|
24
|
-
this.options = defaultOptions;
|
|
25
|
-
this.options = { ...defaultOptions, ...options };
|
|
26
|
-
this._registry = new Registry(entries, options);
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Creates a new ScopeRegistry instance from an object.
|
|
30
|
-
* @param object The object containing key-value pairs.
|
|
31
|
-
* @param options Optional. Options for the registry.
|
|
32
|
-
* @returns A new ScopeRegistry instance.
|
|
33
|
-
*/
|
|
34
|
-
static fromObject(object, options = defaultOptions) {
|
|
35
|
-
const registry = Registry.fromObject(object, options);
|
|
36
|
-
return registry;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Gets the value associated with the specified key.
|
|
40
|
-
* @param key The key to retrieve the value for.
|
|
41
|
-
* @returns The value associated with the key, or undefined if the key does not exist.
|
|
42
|
-
*/
|
|
43
|
-
get(key) {
|
|
44
|
-
return this._registry.get(key);
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Sets the value for the specified key.
|
|
48
|
-
* @param key The key to set the value for.
|
|
49
|
-
* @param value The value to set.
|
|
50
|
-
*/
|
|
51
|
-
set(key, value) {
|
|
52
|
-
this._registry.set(key, value);
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Checks if the registry contains the specified key.
|
|
56
|
-
* @param key The key to check.
|
|
57
|
-
* @returns True if the key exists in the registry, false otherwise.
|
|
58
|
-
*/
|
|
59
|
-
has(key) {
|
|
60
|
-
return this._registry.has(key);
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Deletes the key-value pair associated with the specified key.
|
|
64
|
-
* @param key The key to delete.
|
|
65
|
-
* @returns True if the key-value pair was deleted, false if the key does not exist.
|
|
66
|
-
*/
|
|
67
|
-
delete(key) {
|
|
68
|
-
return this._registry.delete(key);
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Clears all key-value pairs from the registry.
|
|
72
|
-
*/
|
|
73
|
-
clear() {
|
|
74
|
-
this._registry.clear();
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Gets the number of key-value pairs in the registry.
|
|
78
|
-
*/
|
|
79
|
-
get size() {
|
|
80
|
-
return this._registry.size;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Gets an iterator for the keys in the registry.
|
|
84
|
-
*/
|
|
85
|
-
get keys() {
|
|
86
|
-
return this._registry.keys;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Gets an iterator for the values in the registry.
|
|
90
|
-
*/
|
|
91
|
-
get values() {
|
|
92
|
-
return this._registry.values;
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Gets an iterator for the key-value pairs in the registry.
|
|
96
|
-
*/
|
|
97
|
-
get entries() {
|
|
98
|
-
return this._registry.entries;
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Executes a provided function once for each key-value pair in the registry.
|
|
102
|
-
* @param callbackfn The function to execute for each key-value pair.
|
|
103
|
-
* @param thisArg Optional. The value to use as `this` when executing the callback function.
|
|
104
|
-
*/
|
|
105
|
-
forEach(callbackfn, thisArg) {
|
|
106
|
-
this._registry.forEach(callbackfn, thisArg);
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Gets an iterator for the key-value pairs in the registry.
|
|
110
|
-
* @returns An iterator for the key-value pairs in the registry.
|
|
111
|
-
*/
|
|
112
|
-
[Symbol.iterator]() {
|
|
113
|
-
return this._registry.entries;
|
|
114
|
-
}
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SXRlcmFibGVJdGVyYXRvcjxbVEtleSwgVFZhbHVlXT4ge1xyXG4gICAgcmV0dXJuIHRoaXMuX3JlZ2lzdHJ5LmVudHJpZXM7XHJcbiAgfVxyXG59XHJcbiJdfQ==
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Represents a scope that holds key-value pairs.
|
|
3
|
-
* @template TKey The type of the keys in the scope.
|
|
4
|
-
* @template TValue The type of the values in the scope.
|
|
5
|
-
*/
|
|
6
|
-
export class Scope {
|
|
7
|
-
/**
|
|
8
|
-
* Gets the registries in the scope.
|
|
9
|
-
*/
|
|
10
|
-
get registries() {
|
|
11
|
-
return this._registries;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Creates a new scope.
|
|
15
|
-
* @param registries Optional array of registries to initialize the scope with.
|
|
16
|
-
*/
|
|
17
|
-
constructor(registries) {
|
|
18
|
-
this._registries = [];
|
|
19
|
-
if (registries) {
|
|
20
|
-
this._registries = registries;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Adds a registry to the scope.
|
|
25
|
-
* @param registry The registry to add.
|
|
26
|
-
*/
|
|
27
|
-
add(registry) {
|
|
28
|
-
this._registries.push(registry);
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Gets the value associated with the specified key in the scope.
|
|
32
|
-
* @param key The key to search for.
|
|
33
|
-
* @param namespace Optional namespace to filter the search by.
|
|
34
|
-
* @returns An array containing the key and value if found, otherwise undefined.
|
|
35
|
-
*/
|
|
36
|
-
get(key, namespace) {
|
|
37
|
-
const registries = this._registries.filter((registry) => {
|
|
38
|
-
if (registry.options.global) {
|
|
39
|
-
return true;
|
|
40
|
-
}
|
|
41
|
-
if (namespace && registry.options.namespace !== namespace) {
|
|
42
|
-
return false;
|
|
43
|
-
}
|
|
44
|
-
return true;
|
|
45
|
-
});
|
|
46
|
-
for (const registry of registries) {
|
|
47
|
-
if (registry.registry.has(key)) {
|
|
48
|
-
const value = registry.registry.get(key);
|
|
49
|
-
return [key, value];
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return undefined;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2NvcGUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi8uLi8uLi9tb2R1bGVzL2V2YWwtY29yZS9zcmMvbGliL2ludGVybmFsL2NsYXNzZXMvY29tbW9uL3Njb3BlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUVBOzs7O0dBSUc7QUFDSCxNQUFNLE9BQU8sS0FBSztJQUdoQjs7T0FFRztJQUNILElBQVcsVUFBVTtRQUNuQixPQUFPLElBQUksQ0FBQyxXQUFXLENBQUM7SUFDMUIsQ0FBQztJQUVEOzs7T0FHRztJQUNILFlBQVksVUFBK0M7UUFibkQsZ0JBQVcsR0FBdUMsRUFBRSxDQUFDO1FBYzNELElBQUksVUFBVSxFQUFFO1lBQ2QsSUFBSSxDQUFDLFdBQVcsR0FBRyxVQUFVLENBQUM7U0FDL0I7SUFDSCxDQUFDO0lBRUQ7OztPQUdHO0lBQ0ksR0FBRyxDQUFDLFFBQTBDO1FBQ25ELElBQUksQ0FBQyxXQUFXLENBQUMsSUFBSSxDQUFDLFFBQVEsQ0FBQyxDQUFDO0lBQ2xDLENBQUM7SUFFRDs7Ozs7T0FLRztJQUNJLEdBQUcsQ0FBQyxHQUFTLEVBQUUsU0FBa0I7UUFDdEMsTUFBTSxVQUFVLEdBQUcsSUFBSSxDQUFDLFdBQVcsQ0FBQyxNQUFNLENBQUMsQ0FBQyxRQUFRLEVBQUUsRUFBRTtZQUN0RCxJQUFJLFFBQVEsQ0FBQyxPQUFPLENBQUMsTUFBTSxFQUFFO2dCQUMzQixPQUFPLElBQUksQ0FBQzthQUNiO1lBQ0QsSUFBS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0aW9uYWwgbmFtZXNwYWNlIHRvIGZpbHRlciB0aGUgc2VhcmNoIGJ5LlxyXG4gICAqIEByZXR1cm5zIEFuIGFycmF5IGNvbnRhaW5pbmcgdGhlIGtleSBhbmQgdmFsdWUgaWYgZm91bmQsIG90aGVyd2lzZSB1bmRlZmluZWQuXHJcbiAgICovXHJcbiAgcHVibGljIGdldChrZXk6IFRLZXksIG5hbWVzcGFjZT86IHN0cmluZyk6IFtUS2V5LCBUVmFsdWVdIHwgdW5kZWZpbmVkIHtcclxuICAgIGNvbnN0IHJlZ2lzdHJpZXMgPSB0aGlzLl9yZWdpc3RyaWVzLmZpbHRlcigocmVnaXN0cnkpID0+IHtcclxuICAgICAgaWYgKHJlZ2lzdHJ5Lm9wdGlvbnMuZ2xvYmFsKSB7XHJcbiAgICAgICAgcmV0dXJuIHRydWU7XHJcbiAgICAgIH1cclxuICAgICAgaWYgKG5hbWVzcGFjZSAmJiByZWdpc3RyeS5vcHRpb25zLm5hbWVzcGFjZSAhPT0gbmFtZXNwYWNlKSB7XHJcbiAgICAgICAgcmV0dXJuIGZhbHNlO1xyXG4gICAgICB9XHJcbiAgICAgIHJldHVybiB0cnVlO1xyXG4gICAgfSk7XHJcblxyXG4gICAgZm9yIChjb25zdCByZWdpc3RyeSBvZiByZWdpc3RyaWVzKSB7XHJcbiAgICAgIGlmIChyZWdpc3RyeS5yZWdpc3RyeS5oYXMoa2V5KSkge1xyXG4gICAgICAgIGNvbnN0IHZhbHVlID0gcmVnaXN0cnkucmVnaXN0cnkuZ2V0KGtleSkgYXMgVFZhbHVlO1xyXG4gICAgICAgIHJldHVybiBba2V5LCB2YWx1ZV07XHJcbiAgICAgIH1cclxuICAgIH1cclxuICAgIHJldHVybiB1bmRlZmluZWQ7XHJcbiAgfVxyXG59XHJcblxyXG5cclxuIl19
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { RegistryType, ScopeRegistryOptions } from "../../interfaces";
|
|
2
|
-
export type RegistryScopeOptionType = Readonly<Record<string, unknown> | ScopeRegistryOptions>;
|
|
3
|
-
/**
|
|
4
|
-
* Represents a registry that stores key-value pairs within a specific scope.
|
|
5
|
-
* @template TKey The type of the keys in the registry.
|
|
6
|
-
* @template TValue The type of the values in the registry.
|
|
7
|
-
*/
|
|
8
|
-
export declare class ScopeRegistry<TKey, TValue> implements RegistryType<TKey, TValue> {
|
|
9
|
-
private readonly _registry;
|
|
10
|
-
type: Readonly<string>;
|
|
11
|
-
/**
|
|
12
|
-
* Options for the registry.
|
|
13
|
-
*/
|
|
14
|
-
options: Readonly<RegistryScopeOptionType>;
|
|
15
|
-
/**
|
|
16
|
-
* Creates a new instance of ScopeRegistry.
|
|
17
|
-
* @param entries Optional. An array of key-value pairs to initialize the registry.
|
|
18
|
-
* @param options Optional. Options for the registry.
|
|
19
|
-
*/
|
|
20
|
-
constructor(entries?: [TKey, TValue][] | null, options?: RegistryScopeOptionType);
|
|
21
|
-
/**
|
|
22
|
-
* Creates a new ScopeRegistry instance from an object.
|
|
23
|
-
* @param object The object containing key-value pairs.
|
|
24
|
-
* @param options Optional. Options for the registry.
|
|
25
|
-
* @returns A new ScopeRegistry instance.
|
|
26
|
-
*/
|
|
27
|
-
static fromObject<TKey extends string | number | symbol, TValue>(object: Record<TKey, TValue>, options?: RegistryScopeOptionType): RegistryType<TKey, TValue>;
|
|
28
|
-
/**
|
|
29
|
-
* Gets the value associated with the specified key.
|
|
30
|
-
* @param key The key to retrieve the value for.
|
|
31
|
-
* @returns The value associated with the key, or undefined if the key does not exist.
|
|
32
|
-
*/
|
|
33
|
-
get(key: TKey): TValue | undefined;
|
|
34
|
-
/**
|
|
35
|
-
* Sets the value for the specified key.
|
|
36
|
-
* @param key The key to set the value for.
|
|
37
|
-
* @param value The value to set.
|
|
38
|
-
*/
|
|
39
|
-
set(key: TKey, value: TValue): void;
|
|
40
|
-
/**
|
|
41
|
-
* Checks if the registry contains the specified key.
|
|
42
|
-
* @param key The key to check.
|
|
43
|
-
* @returns True if the key exists in the registry, false otherwise.
|
|
44
|
-
*/
|
|
45
|
-
has(key: TKey): boolean;
|
|
46
|
-
/**
|
|
47
|
-
* Deletes the key-value pair associated with the specified key.
|
|
48
|
-
* @param key The key to delete.
|
|
49
|
-
* @returns True if the key-value pair was deleted, false if the key does not exist.
|
|
50
|
-
*/
|
|
51
|
-
delete(key: TKey): boolean;
|
|
52
|
-
/**
|
|
53
|
-
* Clears all key-value pairs from the registry.
|
|
54
|
-
*/
|
|
55
|
-
clear(): void;
|
|
56
|
-
/**
|
|
57
|
-
* Gets the number of key-value pairs in the registry.
|
|
58
|
-
*/
|
|
59
|
-
get size(): number;
|
|
60
|
-
/**
|
|
61
|
-
* Gets an iterator for the keys in the registry.
|
|
62
|
-
*/
|
|
63
|
-
get keys(): IterableIterator<TKey>;
|
|
64
|
-
/**
|
|
65
|
-
* Gets an iterator for the values in the registry.
|
|
66
|
-
*/
|
|
67
|
-
get values(): IterableIterator<TValue>;
|
|
68
|
-
/**
|
|
69
|
-
* Gets an iterator for the key-value pairs in the registry.
|
|
70
|
-
*/
|
|
71
|
-
get entries(): IterableIterator<[TKey, TValue]>;
|
|
72
|
-
/**
|
|
73
|
-
* Executes a provided function once for each key-value pair in the registry.
|
|
74
|
-
* @param callbackfn The function to execute for each key-value pair.
|
|
75
|
-
* @param thisArg Optional. The value to use as `this` when executing the callback function.
|
|
76
|
-
*/
|
|
77
|
-
forEach(callbackfn: (value: TValue, key: TKey, map: Map<TKey, TValue>) => void, thisArg?: TValue): void;
|
|
78
|
-
/**
|
|
79
|
-
* Gets an iterator for the key-value pairs in the registry.
|
|
80
|
-
* @returns An iterator for the key-value pairs in the registry.
|
|
81
|
-
*/
|
|
82
|
-
[Symbol.iterator](): IterableIterator<[TKey, TValue]>;
|
|
83
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { RegistryOptionType, ScopeType } from '../../interfaces';
|
|
2
|
-
/**
|
|
3
|
-
* Represents a scope that holds key-value pairs.
|
|
4
|
-
* @template TKey The type of the keys in the scope.
|
|
5
|
-
* @template TValue The type of the values in the scope.
|
|
6
|
-
*/
|
|
7
|
-
export declare class Scope<TKey, TValue> implements ScopeType<TKey, TValue> {
|
|
8
|
-
private _registries;
|
|
9
|
-
/**
|
|
10
|
-
* Gets the registries in the scope.
|
|
11
|
-
*/
|
|
12
|
-
get registries(): RegistryOptionType<TKey, TValue>[];
|
|
13
|
-
/**
|
|
14
|
-
* Creates a new scope.
|
|
15
|
-
* @param registries Optional array of registries to initialize the scope with.
|
|
16
|
-
*/
|
|
17
|
-
constructor(registries?: RegistryOptionType<TKey, TValue>[]);
|
|
18
|
-
/**
|
|
19
|
-
* Adds a registry to the scope.
|
|
20
|
-
* @param registry The registry to add.
|
|
21
|
-
*/
|
|
22
|
-
add(registry: RegistryOptionType<TKey, TValue>): void;
|
|
23
|
-
/**
|
|
24
|
-
* Gets the value associated with the specified key in the scope.
|
|
25
|
-
* @param key The key to search for.
|
|
26
|
-
* @param namespace Optional namespace to filter the search by.
|
|
27
|
-
* @returns An array containing the key and value if found, otherwise undefined.
|
|
28
|
-
*/
|
|
29
|
-
get(key: TKey, namespace?: string): [TKey, TValue] | undefined;
|
|
30
|
-
}
|