@zvenigora/ng-eval-core 0.1.102 → 0.1.104
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/internal/classes/common/base-registry.mjs +10 -1
- package/esm2022/lib/internal/classes/common/case-insensitive-registry.mjs +10 -1
- package/esm2022/lib/internal/classes/common/context.mjs +36 -4
- package/esm2022/lib/internal/classes/common/public-api.mjs +2 -2
- package/esm2022/lib/internal/classes/common/registry.mjs +10 -1
- package/esm2022/lib/internal/classes/eval/eval-context.mjs +30 -2
- package/esm2022/lib/internal/visitors/assignment-expression.mjs +4 -2
- package/esm2022/lib/internal/visitors/identifier.mjs +24 -2
- package/esm2022/lib/internal/visitors/member-expression.mjs +27 -15
- package/esm2022/lib/internal/visitors/public-api.mjs +2 -1
- package/esm2022/lib/internal/visitors/update-expression.mjs +10 -4
- package/esm2022/lib/internal/visitors/utils.mjs +59 -0
- package/fesm2022/zvenigora-ng-eval-core.mjs +215 -31
- package/fesm2022/zvenigora-ng-eval-core.mjs.map +1 -1
- package/lib/internal/classes/common/base-registry.d.ts +6 -0
- package/lib/internal/classes/common/case-insensitive-registry.d.ts +6 -0
- package/lib/internal/classes/common/context.d.ts +11 -0
- package/lib/internal/classes/common/public-api.d.ts +1 -1
- package/lib/internal/classes/common/registry.d.ts +6 -0
- package/lib/internal/classes/eval/eval-context.d.ts +7 -0
- package/lib/internal/visitors/public-api.d.ts +1 -0
- package/lib/internal/visitors/utils.d.ts +26 -0
- package/package.json +2 -2
|
@@ -75,4 +75,10 @@ export declare class BaseRegistry<TKey, TValue> implements RegistryType<TKey, TV
|
|
|
75
75
|
* @returns An iterator that yields key-value pairs of type [TKey, TValue].
|
|
76
76
|
*/
|
|
77
77
|
[Symbol.iterator](): IterableIterator<[TKey, TValue]>;
|
|
78
|
+
/**
|
|
79
|
+
* Converts a BaseRegistry instance to an object.
|
|
80
|
+
* @param registry The BaseRegistry instance to convert.
|
|
81
|
+
* @returns An object representing the key-value pairs in the registry.
|
|
82
|
+
*/
|
|
83
|
+
toObject(): Record<string | number | symbol, TValue>;
|
|
78
84
|
}
|
|
@@ -76,4 +76,10 @@ export declare class CaseInsensitiveRegistry<TKey, TValue> implements RegistryTy
|
|
|
76
76
|
*/
|
|
77
77
|
[Symbol.iterator](): IterableIterator<[TKey, TValue]>;
|
|
78
78
|
private getKey;
|
|
79
|
+
/**
|
|
80
|
+
* Converts a BaseRegistry instance to an object.
|
|
81
|
+
* @param registry The BaseRegistry instance to convert.
|
|
82
|
+
* @returns An object representing the key-value pairs in the registry.
|
|
83
|
+
*/
|
|
84
|
+
toObject(): Record<string | number | symbol, TValue>;
|
|
79
85
|
}
|
|
@@ -2,6 +2,7 @@ import { Registry } from '../common';
|
|
|
2
2
|
import { EvalOptions } from '../eval';
|
|
3
3
|
export type BaseContext = Record<string | number | symbol, unknown>;
|
|
4
4
|
export type Context = Registry<unknown, unknown> | BaseContext;
|
|
5
|
+
export declare function isRegistryContext(context?: Context): boolean;
|
|
5
6
|
/**
|
|
6
7
|
* Converts a context object to a Context instance.
|
|
7
8
|
* @param context - The context object to convert.
|
|
@@ -29,3 +30,13 @@ export declare const getContextValue: (context?: Context, key?: unknown) => unkn
|
|
|
29
30
|
* @param value - The value to be set.
|
|
30
31
|
*/
|
|
31
32
|
export declare const setContextValue: (context: Context, key: unknown, value: unknown) => void;
|
|
33
|
+
/**
|
|
34
|
+
* Retrieves the key from the given context object.
|
|
35
|
+
* If the context is an instance of Registry, it searches for the key in a case-insensitive manner if specified.
|
|
36
|
+
* If the context is an instance of Object, it uses the getKeyValue function to retrieve the key-value pair.
|
|
37
|
+
* @param context - The context object.
|
|
38
|
+
* @param key - The key to retrieve.
|
|
39
|
+
* @param caseInsensitive - Specifies whether the search should be case-insensitive (only applicable for Registry instances).
|
|
40
|
+
* @returns The retrieved key, or undefined if the key is not found.
|
|
41
|
+
*/
|
|
42
|
+
export declare const getContextKey: (context: Context, key: string | number | symbol, caseInsensitive: boolean) => string | number | symbol | undefined;
|
|
@@ -6,4 +6,4 @@ export { Queue } from './queue';
|
|
|
6
6
|
export { Stack } from './stack';
|
|
7
7
|
export { Scope } from './scope';
|
|
8
8
|
export { Cache } from './cache';
|
|
9
|
-
export { BaseContext, Context, fromContext, getContextValue
|
|
9
|
+
export { BaseContext, Context, isRegistryContext, fromContext, getContextValue, getContextKey } from './context';
|
|
@@ -77,4 +77,10 @@ export declare class Registry<TKey, TValue> implements RegistryType<TKey, TValue
|
|
|
77
77
|
* @returns An iterator that yields key-value pairs of type [TKey, TValue].
|
|
78
78
|
*/
|
|
79
79
|
[Symbol.iterator](): IterableIterator<[TKey, TValue]>;
|
|
80
|
+
/**
|
|
81
|
+
* Converts a BaseRegistry instance to an object.
|
|
82
|
+
* @param registry The BaseRegistry instance to convert.
|
|
83
|
+
* @returns An object representing the key-value pairs in the registry.
|
|
84
|
+
*/
|
|
85
|
+
toObject(): Record<string | number | symbol, TValue>;
|
|
80
86
|
}
|
|
@@ -57,6 +57,13 @@ export declare class EvalContext {
|
|
|
57
57
|
* @returns The `this` value associated with the key, or undefined if not found.
|
|
58
58
|
*/
|
|
59
59
|
getThis(key: unknown): unknown | undefined;
|
|
60
|
+
/**
|
|
61
|
+
* Retrieves the value associated with the specified key from the evaluation context.
|
|
62
|
+
*
|
|
63
|
+
* @param key - The key to retrieve the value for.
|
|
64
|
+
* @returns The value associated with the key, or undefined if the key is not found.
|
|
65
|
+
*/
|
|
66
|
+
getKey(key: string | number | symbol): string | number | symbol | undefined;
|
|
60
67
|
/**
|
|
61
68
|
* Sets a key-value pair in the context.
|
|
62
69
|
* If the original context is a Registry, the key-value pair is set using the Registry's set method.
|
|
@@ -21,3 +21,4 @@ export { assignmentExpressionVisitor } from './assignment-expression';
|
|
|
21
21
|
export { updateExpressionVisitor } from './update-expression';
|
|
22
22
|
export { arrowFunctionExpressionVisitor } from './arrow-function-expression';
|
|
23
23
|
export { evaluatePattern, evaluatePatterns } from './pattern';
|
|
24
|
+
export { getKeyValue, equalIgnoreCase, getValueIgnoreCase } from './utils';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { BaseContext } from "../classes/common/context";
|
|
2
|
+
/**
|
|
3
|
+
* Retrieves the key-value pair from an object based on the provided key.
|
|
4
|
+
* @param obj - The object to search for the key-value pair.
|
|
5
|
+
* @param key - The key to search for in the object.
|
|
6
|
+
* @param caseInsesitive - Specifies whether the key comparison should be case-insensitive.
|
|
7
|
+
* @returns The key-value pair as an array, or undefined if the key is not found.
|
|
8
|
+
*/
|
|
9
|
+
export declare const getKeyValue: (obj: BaseContext, key: string | number | symbol, caseInsesitive: boolean) => [
|
|
10
|
+
string | number | symbol,
|
|
11
|
+
unknown
|
|
12
|
+
] | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* Compares two values for equality, ignoring case sensitivity.
|
|
15
|
+
* @param a - The first value to compare.
|
|
16
|
+
* @param b - The second value to compare.
|
|
17
|
+
* @returns `true` if the values are equal, `false` otherwise.
|
|
18
|
+
*/
|
|
19
|
+
export declare const equalIgnoreCase: (a: string | number | symbol, b: string | number | symbol) => boolean | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Retrieves the value from an object, ignoring the case of the key.
|
|
22
|
+
* @param obj - The object to retrieve the value from.
|
|
23
|
+
* @param key - The key to search for, ignoring the case.
|
|
24
|
+
* @returns The value associated with the key, or undefined if the key is not found.
|
|
25
|
+
*/
|
|
26
|
+
export declare const getValueIgnoreCase: (obj: BaseContext, key: string | number | symbol) => unknown | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zvenigora/ng-eval-core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.104",
|
|
4
4
|
"description": "An expression evaluator for Angular",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
],
|
|
13
13
|
"author": "Zvenigora (https://github.com/zvenigora)",
|
|
14
14
|
"license": "MIT",
|
|
15
|
-
"homepage": "https://github.com/
|
|
15
|
+
"homepage": "https://github.com/Zvenigora/ng-eval#readme",
|
|
16
16
|
"peerDependencies": {
|
|
17
17
|
"@angular/common": "^17.0.0",
|
|
18
18
|
"@angular/core": "^17.0.0",
|