@legalplace/tagextractor 1.2.0 → 1.3.0-alpha

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.
@@ -9,6 +9,8 @@ declare class ConditionsRunner {
9
9
  isOptionRelatedToOption(optionA: number, optionB: number): boolean;
10
10
  isVariableRelatedToOption(variableId: number, optionId: number): boolean;
11
11
  isVariableRelatedToVariable(variableA: number, variableB: number): boolean;
12
+ private executeConditionMemo;
13
+ private buildMemoizeKey;
12
14
  executeCondition(condition: {
13
15
  dataMap: ConditionDataMap;
14
16
  conditions: ConditionV3;
@@ -7,6 +7,8 @@ var lplogic_1 = __importDefault(require("@legalplace/lplogic"));
7
7
  var DataPopulator_1 = __importDefault(require("./DataPopulator"));
8
8
  var ConditionsRunner = (function () {
9
9
  function ConditionsRunner(references, ovc) {
10
+ this.executeConditionMemo = {};
11
+ this.buildMemoizeKey = function (condition, id, index, conditionType) { return JSON.stringify(condition) + "-" + id + "-" + index + "-" + conditionType; };
10
12
  this.references = references;
11
13
  this.ovc = ovc;
12
14
  }
@@ -47,9 +49,9 @@ var ConditionsRunner = (function () {
47
49
  return false;
48
50
  };
49
51
  ConditionsRunner.prototype.executeCondition = function (condition, id, index, conditionType) {
50
- var _this = this;
51
- if (Array.isArray(condition))
52
- return condition.map(function (_condition) { return _this.executeCondition(_condition, id, index, conditionType); });
52
+ var memoizedKey = this.buildMemoizeKey(condition, id, index, conditionType);
53
+ if (this.executeConditionMemo[memoizedKey])
54
+ return this.executeConditionMemo[memoizedKey];
53
55
  var currentData;
54
56
  if (conditionType === 'options' || conditionType === 'optionValidator') {
55
57
  currentData = new DataPopulator_1.default(this, this.references, this.ovc, condition.dataMap, id, index).getData();
@@ -61,7 +63,9 @@ var ConditionsRunner = (function () {
61
63
  else if (conditionType === 'sections' || conditionType === 'documents') {
62
64
  currentData = new DataPopulator_1.default(this, this.references, this.ovc, condition.dataMap, id, index).getData();
63
65
  }
64
- return lplogic_1.default(condition.conditions, currentData);
66
+ var result = lplogic_1.default(condition.conditions, currentData);
67
+ this.executeConditionMemo[memoizedKey] = result;
68
+ return result;
65
69
  };
66
70
  return ConditionsRunner;
67
71
  }());