@zvenigora/ng-eval-core 0.1.107 → 0.2.2

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.
Files changed (144) hide show
  1. package/fesm2022/zvenigora-ng-eval-core.mjs +1321 -97
  2. package/fesm2022/zvenigora-ng-eval-core.mjs.map +1 -1
  3. package/index.d.ts +1270 -1
  4. package/package.json +3 -5
  5. package/esm2022/index.mjs +0 -2
  6. package/esm2022/lib/actual/services/base-eval.mjs +0 -50
  7. package/esm2022/lib/actual/services/compiler.service.mjs +0 -168
  8. package/esm2022/lib/actual/services/discovery.service.mjs +0 -56
  9. package/esm2022/lib/actual/services/eval.service.mjs +0 -134
  10. package/esm2022/lib/actual/services/index.mjs +0 -2
  11. package/esm2022/lib/actual/services/parser.service.mjs +0 -101
  12. package/esm2022/lib/actual/services/public-api.mjs +0 -5
  13. package/esm2022/lib/internal/classes/common/base-registry.mjs +0 -128
  14. package/esm2022/lib/internal/classes/common/cache.mjs +0 -132
  15. package/esm2022/lib/internal/classes/common/case-insensitive-registry.mjs +0 -147
  16. package/esm2022/lib/internal/classes/common/context.mjs +0 -94
  17. package/esm2022/lib/internal/classes/common/index.mjs +0 -2
  18. package/esm2022/lib/internal/classes/common/public-api.mjs +0 -8
  19. package/esm2022/lib/internal/classes/common/queue.mjs +0 -42
  20. package/esm2022/lib/internal/classes/common/registry.mjs +0 -119
  21. package/esm2022/lib/internal/classes/common/stack.mjs +0 -59
  22. package/esm2022/lib/internal/classes/eval/eval-context.mjs +0 -201
  23. package/esm2022/lib/internal/classes/eval/eval-lookup.mjs +0 -2
  24. package/esm2022/lib/internal/classes/eval/eval-options.mjs +0 -42
  25. package/esm2022/lib/internal/classes/eval/eval-result.mjs +0 -141
  26. package/esm2022/lib/internal/classes/eval/eval-scope.mjs +0 -86
  27. package/esm2022/lib/internal/classes/eval/eval-state.mjs +0 -59
  28. package/esm2022/lib/internal/classes/eval/eval-trace.mjs +0 -22
  29. package/esm2022/lib/internal/classes/eval/index.mjs +0 -2
  30. package/esm2022/lib/internal/classes/eval/parser-options.mjs +0 -8
  31. package/esm2022/lib/internal/classes/eval/public-api.mjs +0 -7
  32. package/esm2022/lib/internal/functions/compile.mjs +0 -41
  33. package/esm2022/lib/internal/functions/evaluate.mjs +0 -42
  34. package/esm2022/lib/internal/functions/extract.mjs +0 -20
  35. package/esm2022/lib/internal/functions/index.mjs +0 -2
  36. package/esm2022/lib/internal/functions/parse.mjs +0 -31
  37. package/esm2022/lib/internal/functions/public-api.mjs +0 -5
  38. package/esm2022/lib/internal/interfaces/cache-type.mjs +0 -2
  39. package/esm2022/lib/internal/interfaces/index.mjs +0 -2
  40. package/esm2022/lib/internal/interfaces/parser-types.mjs +0 -2
  41. package/esm2022/lib/internal/interfaces/public-api.mjs +0 -3
  42. package/esm2022/lib/internal/interfaces/queue-type.mjs +0 -2
  43. package/esm2022/lib/internal/interfaces/recursive-visitors.mjs +0 -6
  44. package/esm2022/lib/internal/interfaces/registry-type.mjs +0 -2
  45. package/esm2022/lib/internal/interfaces/scope-type.mjs +0 -2
  46. package/esm2022/lib/internal/interfaces/stack-type.mjs +0 -2
  47. package/esm2022/lib/internal/public-api.mjs +0 -3
  48. package/esm2022/lib/internal/visitors/after-visitor.mjs +0 -10
  49. package/esm2022/lib/internal/visitors/array-expression.mjs +0 -29
  50. package/esm2022/lib/internal/visitors/arrow-function-expression.mjs +0 -18
  51. package/esm2022/lib/internal/visitors/assignment-expression.mjs +0 -52
  52. package/esm2022/lib/internal/visitors/await-expression.mjs +0 -14
  53. package/esm2022/lib/internal/visitors/before-visitor.mjs +0 -10
  54. package/esm2022/lib/internal/visitors/binary-expression.mjs +0 -37
  55. package/esm2022/lib/internal/visitors/call-expression.mjs +0 -36
  56. package/esm2022/lib/internal/visitors/conditional-expression.mjs +0 -18
  57. package/esm2022/lib/internal/visitors/identifier.mjs +0 -33
  58. package/esm2022/lib/internal/visitors/index.mjs +0 -2
  59. package/esm2022/lib/internal/visitors/literal.mjs +0 -10
  60. package/esm2022/lib/internal/visitors/logical-expression.mjs +0 -26
  61. package/esm2022/lib/internal/visitors/member-expression.mjs +0 -50
  62. package/esm2022/lib/internal/visitors/new-expression.mjs +0 -21
  63. package/esm2022/lib/internal/visitors/object-expression.mjs +0 -53
  64. package/esm2022/lib/internal/visitors/pattern.mjs +0 -132
  65. package/esm2022/lib/internal/visitors/public-api.mjs +0 -25
  66. package/esm2022/lib/internal/visitors/recursive-visitors.mjs +0 -28
  67. package/esm2022/lib/internal/visitors/tagged-template-expression.mjs +0 -20
  68. package/esm2022/lib/internal/visitors/template-literal.mjs +0 -21
  69. package/esm2022/lib/internal/visitors/this-expression.mjs +0 -10
  70. package/esm2022/lib/internal/visitors/unary-expression.mjs +0 -19
  71. package/esm2022/lib/internal/visitors/update-expression.mjs +0 -32
  72. package/esm2022/lib/internal/visitors/utils.mjs +0 -59
  73. package/esm2022/lib/internal/visitors/visitor-result.mjs +0 -23
  74. package/esm2022/public-api.mjs +0 -6
  75. package/esm2022/zvenigora-ng-eval-core.mjs +0 -5
  76. package/lib/actual/services/base-eval.d.ts +0 -35
  77. package/lib/actual/services/compiler.service.d.ts +0 -69
  78. package/lib/actual/services/discovery.service.d.ts +0 -27
  79. package/lib/actual/services/eval.service.d.ts +0 -53
  80. package/lib/actual/services/index.d.ts +0 -1
  81. package/lib/actual/services/parser.service.d.ts +0 -45
  82. package/lib/actual/services/public-api.d.ts +0 -4
  83. package/lib/internal/classes/common/base-registry.d.ts +0 -84
  84. package/lib/internal/classes/common/cache.d.ts +0 -91
  85. package/lib/internal/classes/common/case-insensitive-registry.d.ts +0 -85
  86. package/lib/internal/classes/common/context.d.ts +0 -42
  87. package/lib/internal/classes/common/index.d.ts +0 -1
  88. package/lib/internal/classes/common/public-api.d.ts +0 -7
  89. package/lib/internal/classes/common/queue.d.ts +0 -33
  90. package/lib/internal/classes/common/registry.d.ts +0 -86
  91. package/lib/internal/classes/common/stack.d.ts +0 -43
  92. package/lib/internal/classes/eval/eval-context.d.ts +0 -93
  93. package/lib/internal/classes/eval/eval-lookup.d.ts +0 -2
  94. package/lib/internal/classes/eval/eval-options.d.ts +0 -6
  95. package/lib/internal/classes/eval/eval-result.d.ts +0 -105
  96. package/lib/internal/classes/eval/eval-scope.d.ts +0 -51
  97. package/lib/internal/classes/eval/eval-state.d.ts +0 -46
  98. package/lib/internal/classes/eval/eval-trace.d.ts +0 -20
  99. package/lib/internal/classes/eval/index.d.ts +0 -1
  100. package/lib/internal/classes/eval/parser-options.d.ts +0 -2
  101. package/lib/internal/classes/eval/public-api.d.ts +0 -8
  102. package/lib/internal/functions/compile.d.ts +0 -33
  103. package/lib/internal/functions/evaluate.d.ts +0 -17
  104. package/lib/internal/functions/extract.d.ts +0 -10
  105. package/lib/internal/functions/index.d.ts +0 -1
  106. package/lib/internal/functions/parse.d.ts +0 -15
  107. package/lib/internal/functions/public-api.d.ts +0 -4
  108. package/lib/internal/interfaces/cache-type.d.ts +0 -6
  109. package/lib/internal/interfaces/index.d.ts +0 -1
  110. package/lib/internal/interfaces/parser-types.d.ts +0 -7
  111. package/lib/internal/interfaces/public-api.d.ts +0 -7
  112. package/lib/internal/interfaces/queue-type.d.ts +0 -6
  113. package/lib/internal/interfaces/recursive-visitors.d.ts +0 -43
  114. package/lib/internal/interfaces/registry-type.d.ts +0 -67
  115. package/lib/internal/interfaces/scope-type.d.ts +0 -15
  116. package/lib/internal/interfaces/stack-type.d.ts +0 -6
  117. package/lib/internal/public-api.d.ts +0 -2
  118. package/lib/internal/visitors/after-visitor.d.ts +0 -3
  119. package/lib/internal/visitors/array-expression.d.ts +0 -5
  120. package/lib/internal/visitors/arrow-function-expression.d.ts +0 -4
  121. package/lib/internal/visitors/assignment-expression.d.ts +0 -4
  122. package/lib/internal/visitors/await-expression.d.ts +0 -4
  123. package/lib/internal/visitors/before-visitor.d.ts +0 -3
  124. package/lib/internal/visitors/binary-expression.d.ts +0 -4
  125. package/lib/internal/visitors/call-expression.d.ts +0 -5
  126. package/lib/internal/visitors/conditional-expression.d.ts +0 -4
  127. package/lib/internal/visitors/identifier.d.ts +0 -3
  128. package/lib/internal/visitors/index.d.ts +0 -1
  129. package/lib/internal/visitors/literal.d.ts +0 -3
  130. package/lib/internal/visitors/logical-expression.d.ts +0 -4
  131. package/lib/internal/visitors/member-expression.d.ts +0 -5
  132. package/lib/internal/visitors/new-expression.d.ts +0 -5
  133. package/lib/internal/visitors/object-expression.d.ts +0 -4
  134. package/lib/internal/visitors/pattern.d.ts +0 -6
  135. package/lib/internal/visitors/public-api.d.ts +0 -24
  136. package/lib/internal/visitors/recursive-visitors.d.ts +0 -7
  137. package/lib/internal/visitors/tagged-template-expression.d.ts +0 -4
  138. package/lib/internal/visitors/template-literal.d.ts +0 -4
  139. package/lib/internal/visitors/this-expression.d.ts +0 -3
  140. package/lib/internal/visitors/unary-expression.d.ts +0 -4
  141. package/lib/internal/visitors/update-expression.d.ts +0 -4
  142. package/lib/internal/visitors/utils.d.ts +0 -26
  143. package/lib/internal/visitors/visitor-result.d.ts +0 -6
  144. package/public-api.d.ts +0 -5
@@ -1,91 +0,0 @@
1
- import { CacheType } from '../../interfaces';
2
- /**
3
- * Represents a cache implementation that stores key-value pairs.
4
- * @template TValue The type of values stored in the cache.
5
- */
6
- export declare class Cache<TValue> implements CacheType<TValue> {
7
- private readonly _maxCacheSize;
8
- /**
9
- * The registry that stores the key-value pairs.
10
- */
11
- private readonly _registry;
12
- /**
13
- * The queue that keeps track of the keys in the cache.
14
- */
15
- private readonly _keyQueue;
16
- type: Readonly<string>;
17
- /**
18
- * Options for the cache.
19
- */
20
- options: Readonly<Record<string, unknown>>;
21
- /**
22
- * Creates a new instance of the Cache class.
23
- * @param _maxCacheSize The maximum size of the cache.
24
- */
25
- constructor(_maxCacheSize: number);
26
- /**
27
- * Gets the maximum size of the cache.
28
- */
29
- get maxCacheSize(): number;
30
- /**
31
- * Generates a hash key based on the given namespace and value.
32
- * @param namespace The namespace for the key.
33
- * @param value The value for the key.
34
- * @returns The generated hash key.
35
- */
36
- getHashKey(namespace: string, value: string): string;
37
- /**
38
- * Gets the value associated with the specified key.
39
- * @param key The key to retrieve the value for.
40
- * @returns The value associated with the key, or undefined if the key does not exist in the cache.
41
- */
42
- get(key: string): TValue | undefined;
43
- /**
44
- * Sets the value for the specified key in the cache.
45
- * @param key The key to set the value for.
46
- * @param value The value to set.
47
- */
48
- set(key: string, value: TValue): void;
49
- /**
50
- * Checks if the cache contains the specified key.
51
- * @param key The key to check.
52
- * @returns True if the cache contains the key, false otherwise.
53
- */
54
- has(key: string): boolean;
55
- /**
56
- * Deletes the value associated with the specified key from the cache.
57
- * @param key The key to delete.
58
- * @returns True if the value was successfully deleted, false otherwise.
59
- */
60
- delete(key: string): boolean;
61
- /**
62
- * Clears the cache, removing all key-value pairs.
63
- */
64
- clear(): void;
65
- /**
66
- * Gets the number of key-value pairs in the cache.
67
- */
68
- get size(): number;
69
- /**
70
- * Gets an iterator for the keys in the cache.
71
- */
72
- get keys(): IterableIterator<string>;
73
- /**
74
- * Gets an iterator for the values in the cache.
75
- */
76
- get values(): IterableIterator<TValue>;
77
- /**
78
- * Gets an iterator for the entries (key-value pairs) in the cache.
79
- */
80
- get entries(): IterableIterator<[string, TValue]>;
81
- /**
82
- * Executes a provided function once for each key-value pair in the cache.
83
- * @param callbackfn The function to execute for each key-value pair.
84
- * @param thisArg The value to use as `this` when executing the callback function.
85
- */
86
- forEach(callbackfn: (value: TValue, key: string, map: Map<string, TValue>) => void, thisArg?: TValue): void;
87
- /**
88
- * Returns an iterator for the entries (key-value pairs) in the cache.
89
- */
90
- [Symbol.iterator](): IterableIterator<[string, TValue]>;
91
- }
@@ -1,85 +0,0 @@
1
- import { RegistryEntries, RegistryType } from "../../interfaces";
2
- /**
3
- * Represents a case-insensitive registry that maps keys to values.
4
- */
5
- export declare class CaseInsensitiveRegistry<TKey, TValue> implements RegistryType<TKey, TValue> {
6
- private readonly registry;
7
- private keysMap;
8
- type: Readonly<string>;
9
- /**
10
- * Options for the registry.
11
- */
12
- options: Readonly<Record<string, unknown>>;
13
- /**
14
- * Creates a new instance of CaseInsensitiveRegistry.
15
- * @param entries - Optional initial entries to populate the registry.
16
- */
17
- constructor(entries?: RegistryEntries<TKey, TValue> | null);
18
- /**
19
- * Creates a new CaseInsensitiveRegistry from an object.
20
- * @param object - The object containing key-value pairs.
21
- * @returns A new CaseInsensitiveRegistry instance.
22
- */
23
- static fromObject<TKey extends string | number | symbol, TValue>(object: Record<TKey, TValue>): CaseInsensitiveRegistry<TKey, TValue>;
24
- /**
25
- * Retrieves the value associated with the specified key.
26
- * @param key - The key.
27
- * @returns The value associated with the key, or undefined if the key is not found.
28
- */
29
- get(key: TKey): TValue | undefined;
30
- /**
31
- * Sets a key-value pair in the registry.
32
- * @param key - The key.
33
- * @param value - The value.
34
- */
35
- set(key: TKey, value: TValue): void;
36
- /**
37
- * Checks if the registry contains the specified key.
38
- * @param key - The key.
39
- * @returns True if the key is found, false otherwise.
40
- */
41
- has(key: TKey): boolean;
42
- /**
43
- * Deletes the key-value pair associated with the specified key.
44
- * @param key - The key.
45
- * @returns True if the key-value pair is deleted, false if the key is not found.
46
- */
47
- delete(key: TKey): boolean;
48
- /**
49
- * Clears all key-value pairs from the registry.
50
- */
51
- clear(): void;
52
- /**
53
- * Gets the number of key-value pairs in the registry.
54
- */
55
- get size(): number;
56
- /**
57
- * Gets an iterator for the keys in the registry.
58
- */
59
- get keys(): IterableIterator<TKey>;
60
- /**
61
- * Gets an iterator for the values in the registry.
62
- */
63
- get values(): IterableIterator<TValue>;
64
- /**
65
- * Gets an iterator for the key-value pairs in the registry.
66
- */
67
- get entries(): IterableIterator<[TKey, TValue]>;
68
- /**
69
- * Executes a provided function once for each key-value pair in the registry.
70
- * @param callbackfn - The function to execute for each key-value pair.
71
- */
72
- forEach(callbackfn: (value: TValue, key: TKey, map: Map<TKey, TValue>) => void): void;
73
- /**
74
- * Returns an iterator for the entries of the registry.
75
- * @returns An iterator that yields key-value pairs of type [string, unknown].
76
- */
77
- [Symbol.iterator](): IterableIterator<[TKey, TValue]>;
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>;
85
- }
@@ -1,42 +0,0 @@
1
- import { Registry } from '../common';
2
- import { EvalOptions } from '../eval';
3
- export type BaseContext = Record<string | number | symbol, unknown>;
4
- export type Context = Registry<unknown, unknown> | BaseContext;
5
- export declare function isRegistryContext(context?: Context): boolean;
6
- /**
7
- * Converts a context object to a Context instance.
8
- * @param context - The context object to convert.
9
- * @param options - Optional evaluation options.
10
- * @returns The converted Context instance.
11
- */
12
- export declare const fromContext: (context?: Context, options?: EvalOptions) => Context;
13
- /**
14
- * Retrieves the value associated with the specified key from the given context.
15
- * If the context is an instance of Registry, it uses the `get` method to retrieve the value.
16
- * If the context is an object, it accesses the value using the key as a property name.
17
- * If the context is neither an instance of Registry nor an object, it returns undefined.
18
- *
19
- * @param context The context from which to retrieve the value.
20
- * @param key The key associated with the value to retrieve.
21
- * @returns The value associated with the specified key, or undefined if not found.
22
- */
23
- export declare const getContextValue: (context?: Context, key?: unknown) => unknown;
24
- /**
25
- * Sets a value in the given context object.
26
- * If the context is an instance of Registry, the value is set using the key.
27
- * If the context is a plain object, the value is set using the key as a property name.
28
- * @param context - The context object.
29
- * @param key - The key or property name.
30
- * @param value - The value to be set.
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;
@@ -1 +0,0 @@
1
- export * from './public-api';
@@ -1,7 +0,0 @@
1
- export { BaseRegistry } from './base-registry';
2
- export { CaseInsensitiveRegistry } from './case-insensitive-registry';
3
- export { Registry } from './registry';
4
- export { Queue } from './queue';
5
- export { Stack } from './stack';
6
- export { Cache } from './cache';
7
- export { BaseContext, Context, isRegistryContext, fromContext, getContextValue, getContextKey } from './context';
@@ -1,33 +0,0 @@
1
- import { QueueType } from '../../interfaces';
2
- /**
3
- * Represents a generic queue data structure.
4
- * @template T The type of elements stored in the queue.
5
- */
6
- export declare class Queue<T> implements QueueType<T> {
7
- private readonly _queue;
8
- /**
9
- * Creates a new instance of the Queue class.
10
- * @param _queue Optional initial array of elements.
11
- */
12
- constructor(_queue?: T[]);
13
- /**
14
- * Gets the number of elements in the queue.
15
- */
16
- get length(): number;
17
- /**
18
- * Removes and returns the first element in the queue.
19
- * @returns The first element in the queue, or undefined if the queue is empty.
20
- */
21
- dequeue(): T | undefined;
22
- /**
23
- * Adds an element to the end of the queue.
24
- * @param value The element to add to the queue.
25
- * @returns The new length of the queue.
26
- */
27
- enqueue(value: T): number;
28
- /**
29
- * Returns the first element in the queue without removing it.
30
- * @returns The first element in the queue.
31
- */
32
- peek(): T;
33
- }
@@ -1,86 +0,0 @@
1
- /**
2
- * Represents a generic registry that stores key-value pairs.
3
- * @template TKey The type of the keys in the registry.
4
- * @template TValue The type of the values in the registry.
5
- */
6
- import { RegistryEntries, RegistryType } from "../../interfaces";
7
- export declare class Registry<TKey, TValue> implements RegistryType<TKey, TValue> {
8
- private readonly _registry;
9
- type: Readonly<string>;
10
- /**
11
- * Options for the registry.
12
- */
13
- options: Readonly<Record<string, unknown>>;
14
- /**
15
- * Creates a new Registry instance.
16
- * @param entries - Optional array of key-value pairs to initialize the registry.
17
- */
18
- constructor(entries?: RegistryEntries<TKey, TValue> | null, options?: Record<string, unknown>);
19
- /**
20
- * Creates a new Registry instance from an object.
21
- * @param object - The object containing key-value pairs.
22
- * @returns A new Registry instance.
23
- */
24
- static fromObject<TKey extends string | number | symbol, TValue>(object: Record<TKey, TValue>, options?: Record<string, unknown>): Registry<TKey, TValue>;
25
- /**
26
- * Retrieves the value associated with the specified key.
27
- * @param key - The key to retrieve the value for.
28
- * @returns The value associated with the key, or undefined if the key does not exist.
29
- */
30
- get(key: TKey): TValue | undefined;
31
- /**
32
- * Sets the value for the specified key.
33
- * @param key - The key to set the value for.
34
- * @param value - The value to set.
35
- */
36
- set(key: TKey, value: TValue): void;
37
- /**
38
- * Checks if the registry contains the specified key.
39
- * @param key - The key to check.
40
- * @returns True if the registry contains the key, false otherwise.
41
- */
42
- has(key: TKey): boolean;
43
- /**
44
- * Deletes the key-value pair associated with the specified key.
45
- * @param key - The key to delete.
46
- * @returns True if the key-value pair was deleted, false if the key does not exist.
47
- */
48
- delete(key: TKey): boolean;
49
- /**
50
- * Clears all key-value pairs from the registry.
51
- */
52
- clear(): void;
53
- /**
54
- * Gets the number of key-value pairs in the registry.
55
- */
56
- get size(): number;
57
- /**
58
- * Gets an iterator for the keys in the registry.
59
- */
60
- get keys(): IterableIterator<TKey>;
61
- /**
62
- * Gets an iterator for the values in the registry.
63
- */
64
- get values(): IterableIterator<TValue>;
65
- /**
66
- * Gets an iterator for the key-value pairs in the registry.
67
- */
68
- get entries(): IterableIterator<[TKey, TValue]>;
69
- /**
70
- * Executes a provided function once for each key-value pair in the registry.
71
- * @param callbackfn - The function to execute for each key-value pair.
72
- * @param thisArg - Optional value to use as `this` when executing the callback function.
73
- */
74
- forEach(callbackfn: (value: TValue, key: TKey, map: Map<TKey, TValue>) => void, thisArg?: TValue): void;
75
- /**
76
- * Returns an iterator for the entries of the registry.
77
- * @returns An iterator that yields key-value pairs of type [TKey, TValue].
78
- */
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>;
86
- }
@@ -1,43 +0,0 @@
1
- import { StackType } from '../../interfaces';
2
- /**
3
- * Represents a stack data structure.
4
- * @template T The type of elements in the stack.
5
- */
6
- export declare class Stack<T> implements StackType<T> {
7
- private readonly _stack;
8
- /**
9
- * Creates a new instance of the Stack class.
10
- * @param _stack An optional array to initialize the stack.
11
- */
12
- constructor(_stack?: T[]);
13
- /**
14
- * Gets the number of elements in the stack.
15
- */
16
- get length(): number;
17
- /**
18
- * Returns the top element of the stack without removing it.
19
- * @returns The top element of the stack.
20
- */
21
- peek(): T;
22
- /**
23
- * Removes and returns the top element of the stack.
24
- * @returns The top element of the stack, or undefined if the stack is empty.
25
- */
26
- pop(): T | undefined;
27
- /**
28
- * Adds an element to the top of the stack.
29
- * @param value The element to be added to the stack.
30
- * @returns The new length of the stack.
31
- */
32
- push(value: T): number;
33
- /**
34
- * Swaps the positions of the top two elements in the stack.
35
- */
36
- swap(): void;
37
- /**
38
- * Returns the elements of the stack as an array in reverse order.
39
- *
40
- * @returns An array containing the elements of the stack in reverse order.
41
- */
42
- asArray(): T[];
43
- }
@@ -1,93 +0,0 @@
1
- import { Context, Stack } from '../common';
2
- import { EvalLookup } from './eval-lookup';
3
- import { EvalOptions } from './eval-options';
4
- import { EvalScope } from './eval-scope';
5
- /**
6
- * Represents the evaluation context for the code execution.
7
- */
8
- export declare class EvalContext {
9
- type: string;
10
- private _original;
11
- private _priorScopes;
12
- private _scopes;
13
- private _lookups;
14
- private _options;
15
- /**
16
- * Gets the original registry.
17
- */
18
- get original(): Context;
19
- /**
20
- * Gets the scopes registry.
21
- */
22
- get priorScopes(): EvalScope[];
23
- /**
24
- * Gets the scopes registry.
25
- */
26
- get scopes(): Readonly<Stack<Context>>;
27
- /**
28
- * Gets the lookups registry.
29
- */
30
- get lookups(): EvalLookup[];
31
- /**
32
- * Gets the evaluation options.
33
- */
34
- get options(): EvalOptions;
35
- /**
36
- * Creates a new instance of EvalContext.
37
- * @param original - The original registry or an object to create a registry from.
38
- * @param options - The evaluation options.
39
- */
40
- constructor(original: Context, options: EvalOptions);
41
- /**
42
- * Converts the given context to an instance of EvalContext.
43
- * @param context - The context to convert.
44
- * @param options - The evaluation options.
45
- * @returns The converted EvalContext instance.
46
- */
47
- static fromContext(context?: EvalContext | Context | undefined, options?: EvalOptions): EvalContext;
48
- /**
49
- * Gets the value associated with the specified key from the evaluation context.
50
- * @param key - The key to retrieve the value for.
51
- * @returns The value associated with the key, or undefined if not found.
52
- */
53
- get(key: unknown): unknown | undefined;
54
- /**
55
- * Retrieves the `this` value of the specified key from the evaluation context.
56
- * The value is searched in the original context, prior scopes, and lookup functions.
57
- * @param key - The key to retrieve the value for.
58
- * @returns The `this` value associated with the key, or undefined if not found.
59
- */
60
- getThis(key: unknown): unknown | undefined;
61
- /**
62
- * Retrieves the value associated with the specified key from the evaluation context.
63
- *
64
- * @param key - The key to retrieve the value for.
65
- * @returns The value associated with the key, or undefined if the key is not found.
66
- */
67
- getKey(key: string | number | symbol): string | number | symbol | undefined;
68
- /**
69
- * Sets a key-value pair in the context.
70
- * If the original context is a Registry, the key-value pair is set using the Registry's set method.
71
- * If the original context is an Object, the key-value pair is set directly on the object.
72
- * @param key - The key of the pair.
73
- * @param value - The value of the pair.
74
- */
75
- set(key: unknown, value: unknown): void;
76
- /**
77
- * Pushes a context to the scope stack.
78
- * @param context - The context to push.
79
- * @param options - The evaluation options.
80
- */
81
- push(context: Context, options?: EvalOptions): void;
82
- /**
83
- * Pops a context from the scope stack.
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;
93
- }
@@ -1,2 +0,0 @@
1
- import { EvalOptions } from './eval-options';
2
- export type EvalLookup = (key: unknown, thisArg?: unknown, options?: EvalOptions) => unknown;
@@ -1,6 +0,0 @@
1
- /**
2
- * Represents the options for evaluating expressions.
3
- */
4
- export type EvalOptions = Record<string, unknown> | {
5
- caseInsensitive: false;
6
- };
@@ -1,105 +0,0 @@
1
- import { Stack } from "../common";
2
- import { EvalContext } from "./eval-context";
3
- import { EvalOptions } from "./eval-options";
4
- import { EvalTrace } from "./eval-trace";
5
- type UnknownValue = unknown | Promise<unknown>;
6
- /**
7
- * Represents the result of an evaluation.
8
- */
9
- export declare class EvalResult {
10
- private _stack;
11
- private _value?;
12
- private _error?;
13
- private _errorMessage?;
14
- private _isError?;
15
- private _isSuccess?;
16
- private _isUndefined?;
17
- private _trace;
18
- private _context;
19
- private _startDate?;
20
- private _endDate?;
21
- private _expression?;
22
- /**
23
- * Gets the stack of evaluated values.
24
- */
25
- get stack(): Stack<UnknownValue>;
26
- /**
27
- * Gets the evaluated value.
28
- */
29
- get value(): UnknownValue | undefined;
30
- /**
31
- * Gets the error that occurred during evaluation.
32
- */
33
- get error(): unknown | undefined;
34
- /**
35
- * Gets the error message associated with the evaluation error.
36
- */
37
- get errorMessage(): string | undefined;
38
- /**
39
- * Gets whether the evaluation resulted in an error.
40
- */
41
- get isError(): boolean | undefined;
42
- /**
43
- * Gets whether the evaluation was successful.
44
- */
45
- get isSuccess(): boolean | undefined;
46
- /**
47
- * Gets whether the evaluated value is undefined.
48
- */
49
- get isUndefined(): boolean | undefined;
50
- /**
51
- * Gets the trace of evaluated values.
52
- */
53
- get trace(): EvalTrace;
54
- /**
55
- * Gets the evaluation context.
56
- */
57
- get context(): EvalContext;
58
- /**
59
- * Gets the evaluation options.
60
- */
61
- get options(): EvalOptions;
62
- /**
63
- * Gets the duration of the evaluation result.
64
- * @returns The duration in milliseconds.
65
- */
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);
78
- /**
79
- * Creates a new instance of EvalResult.
80
- * @param trace The trace of evaluated values.
81
- * @param context The evaluation context.
82
- */
83
- constructor(context: EvalContext);
84
- /**
85
- * Starts the evaluation process.
86
- */
87
- start(): void;
88
- /**
89
- * Stops the evaluation and records the end date.
90
- */
91
- stop(): number | undefined;
92
- /**
93
- * Sets the success value of the evaluation result.
94
- *
95
- * @param value The value to set as the success value.
96
- * @returns void
97
- */
98
- setSuccess(value: UnknownValue): void;
99
- /**
100
- * Sets the failure state of the evaluation result.
101
- * @param error The error object associated with the failure.
102
- */
103
- setFailure(error: unknown): void;
104
- }
105
- export {};
@@ -1,51 +0,0 @@
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
- }