@openframe-org/criteria-set-protocol 1.4.7 → 1.4.8

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 (2) hide show
  1. package/dist/v1/utils.js +11 -22
  2. package/package.json +1 -1
package/dist/v1/utils.js CHANGED
@@ -51,31 +51,20 @@ exports.resolveCode = resolveCode;
51
51
  * Find an element in the criteria tree by its code
52
52
  */
53
53
  const findInTree = (tree, code) => {
54
- for (const quality of tree.qualities) {
55
- if (quality.code === code) {
56
- return quality;
57
- }
58
- for (const criteria of quality.items) {
59
- if (criteria.code === code) {
60
- return criteria;
54
+ const searchElements = (elements) => {
55
+ for (const element of elements) {
56
+ if (element.code == code) {
57
+ return element;
61
58
  }
62
- for (const taskGroup of criteria.items) {
63
- if (taskGroup.code === code) {
64
- return taskGroup;
65
- }
66
- for (const task of taskGroup.items) {
67
- if (task.code === code) {
68
- return task;
69
- }
70
- for (const taskItem of task.items) {
71
- if (taskItem.code === code) {
72
- return taskItem;
73
- }
74
- }
59
+ if (!(0, exports.isTaskItem)(element)) {
60
+ const foundElement = searchElements(element.items);
61
+ if (foundElement != null) {
62
+ return foundElement;
75
63
  }
76
64
  }
77
65
  }
78
- }
79
- return null;
66
+ return null;
67
+ };
68
+ return searchElements(tree.qualities);
80
69
  };
81
70
  exports.findInTree = findInTree;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openframe-org/criteria-set-protocol",
3
- "version": "1.4.7",
3
+ "version": "1.4.8",
4
4
  "description": "A protocol and tools for defining and working with criteria sets",
5
5
  "private": false,
6
6
  "author": "Andrés Angulo <aa@openframe.org>",