greybel-interpreter 1.4.5 → 1.4.6

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.
@@ -6,17 +6,18 @@ import HandlerContainer from './handler-container';
6
6
  import Operation from './operations/operation';
7
7
  import CustomValue from './types/base';
8
8
  import CustomString from './types/string';
9
+ import ObjectValue from './utils/object-value';
9
10
  export declare const PARAMS_PROPERTY: CustomString;
10
11
  export interface InterpreterOptions {
11
12
  target?: string;
12
- api?: Map<CustomValue, CustomValue>;
13
+ api?: ObjectValue;
13
14
  params?: Array<string>;
14
15
  handler?: HandlerContainer;
15
16
  debugger?: Debugger;
16
17
  }
17
18
  export default class Interpreter extends EventEmitter {
18
19
  target: string;
19
- api: Map<CustomValue, CustomValue>;
20
+ api: ObjectValue;
20
21
  params: Array<string>;
21
22
  handler: HandlerContainer;
22
23
  debugger: Debugger;
@@ -26,7 +27,7 @@ export default class Interpreter extends EventEmitter {
26
27
  constructor(options: InterpreterOptions);
27
28
  setTarget(target: string): Interpreter;
28
29
  setDebugger(dbgr: Debugger): Interpreter;
29
- setApi(newApi: Map<CustomValue, CustomValue>): Interpreter;
30
+ setApi(newApi: ObjectValue): Interpreter;
30
31
  setHandler(handler: HandlerContainer): Interpreter;
31
32
  prepare(code: string): Promise<Operation>;
32
33
  inject(code: string, context?: OperationContext): Promise<Interpreter>;
@@ -47,13 +47,14 @@ const list_1 = __importDefault(require("./types/list"));
47
47
  const map_1 = __importDefault(require("./types/map"));
48
48
  const number_1 = __importDefault(require("./types/number"));
49
49
  const string_1 = __importDefault(require("./types/string"));
50
+ const object_value_1 = __importDefault(require("./utils/object-value"));
50
51
  exports.PARAMS_PROPERTY = new string_1.default('params');
51
52
  class Interpreter extends events_1.default {
52
53
  constructor(options) {
53
54
  super();
54
55
  this.handler = options.handler || new handler_container_1.default();
55
56
  this.debugger = options.debugger || new context_1.Debugger();
56
- this.api = options.api || new Map();
57
+ this.api = options.api || new object_value_1.default();
57
58
  this.params = options.params || [];
58
59
  this.apiContext = null;
59
60
  this.globalContext = null;
package/dist/types/map.js CHANGED
@@ -85,9 +85,7 @@ class CustomMap extends with_intrinsics_1.CustomObject {
85
85
  if (map instanceof CustomMap) {
86
86
  map = map.value;
87
87
  }
88
- for (const [key, value] of map) {
89
- this.value.set(key, value);
90
- }
88
+ this.value.extend(map);
91
89
  return this;
92
90
  }
93
91
  has(path) {
@@ -3,4 +3,5 @@ export default class ObjectValue extends Map<CustomValue, CustomValue> {
3
3
  get(mapKey: CustomValue): CustomValue;
4
4
  has(mapKey: CustomValue): boolean;
5
5
  set(mapKey: CustomValue, mapValue: CustomValue): this;
6
+ extend(objVal: ObjectValue): this;
6
7
  }
@@ -32,5 +32,11 @@ class ObjectValue extends Map {
32
32
  super.set(mapKey, mapValue);
33
33
  return this;
34
34
  }
35
+ extend(objVal) {
36
+ for (const [key, value] of objVal) {
37
+ this.set(key, value);
38
+ }
39
+ return this;
40
+ }
35
41
  }
36
42
  exports.default = ObjectValue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "greybel-interpreter",
3
- "version": "1.4.5",
3
+ "version": "1.4.6",
4
4
  "description": "Interpreter",
5
5
  "main": "dist/index",
6
6
  "typings": "dist/index",