theprogrammablemind_4wp 7.5.8-beta.76 → 7.5.8-beta.78
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/package.json +1 -1
 - package/src/config.js +21 -75
 
    
        package/package.json
    CHANGED
    
    
    
        package/src/config.js
    CHANGED
    
    | 
         @@ -23,13 +23,6 @@ const indent = (string, indent) => { 
     | 
|
| 
       23 
23 
     | 
    
         
             
            }
         
     | 
| 
       24 
24 
     | 
    
         | 
| 
       25 
25 
     | 
    
         
             
            const config_toServer = (config) => {
         
     | 
| 
       26 
     | 
    
         
            -
              /*
         
     | 
| 
       27 
     | 
    
         
            -
              if (config.contextual_priorities) {
         
     | 
| 
       28 
     | 
    
         
            -
                config.contextual_priorities = config.contextual_priorities.map((cp) => {
         
     | 
| 
       29 
     | 
    
         
            -
                  return [cp.context, cp.choose]
         
     | 
| 
       30 
     | 
    
         
            -
                })
         
     | 
| 
       31 
     | 
    
         
            -
              }
         
     | 
| 
       32 
     | 
    
         
            -
              */
         
     | 
| 
       33 
26 
     | 
    
         
             
            }
         
     | 
| 
       34 
27 
     | 
    
         | 
| 
       35 
28 
     | 
    
         
             
            const debugPriority = (priority) => {
         
     | 
| 
         @@ -48,14 +41,6 @@ const debugAssociation = (association) => { 
     | 
|
| 
       48 
41 
     | 
    
         
             
              }
         
     | 
| 
       49 
42 
     | 
    
         
             
            }
         
     | 
| 
       50 
43 
     | 
    
         | 
| 
       51 
     | 
    
         
            -
            const debugContextualPriority = (contextual_priority) => {
         
     | 
| 
       52 
     | 
    
         
            -
              if (global.entodictonDebugContextualPriority) {
         
     | 
| 
       53 
     | 
    
         
            -
                if (helpers.safeEquals(entodictonDebugContextualPriority, contextual_priority)) {
         
     | 
| 
       54 
     | 
    
         
            -
                  debugger; // debug hierarchy hit
         
     | 
| 
       55 
     | 
    
         
            -
                }
         
     | 
| 
       56 
     | 
    
         
            -
              }
         
     | 
| 
       57 
     | 
    
         
            -
            }
         
     | 
| 
       58 
     | 
    
         
            -
             
     | 
| 
       59 
44 
     | 
    
         
             
            const debugHierarchy = (pair) => {
         
     | 
| 
       60 
45 
     | 
    
         
             
              if (global.entodictonDebugHierarchy) {
         
     | 
| 
       61 
46 
     | 
    
         
             
                if (helpers.safeEquals(global.entodictonDebugHierarchy, pair)) {
         
     | 
| 
         @@ -87,7 +72,6 @@ const debugConfigProps = (config) => { 
     | 
|
| 
       87 
72 
     | 
    
         
             
              const checkProps = [
         
     | 
| 
       88 
73 
     | 
    
         
             
                { property: 'priorities', check: (v) => debugPriority(v) },
         
     | 
| 
       89 
74 
     | 
    
         
             
                { property: 'association', check: (v) => debugAssociation(v) },
         
     | 
| 
       90 
     | 
    
         
            -
                { property: 'contextual_priorities', check: (v) => debugContextualPriority(v) },
         
     | 
| 
       91 
75 
     | 
    
         
             
                { property: 'hierarchy', check: (v) => debugHierarchy(v) },
         
     | 
| 
       92 
76 
     | 
    
         
             
                { property: 'operators', check: (v) => debugOperator(v) },
         
     | 
| 
       93 
77 
     | 
    
         
             
                { property: 'bridges', check: (v) => debugBridge(v) },
         
     | 
| 
         @@ -109,7 +93,6 @@ const validConfigProps = (config) => { 
     | 
|
| 
       109 
93 
     | 
    
         
             
                'operators', 
         
     | 
| 
       110 
94 
     | 
    
         
             
                'words', 
         
     | 
| 
       111 
95 
     | 
    
         
             
                'priorities', 
         
     | 
| 
       112 
     | 
    
         
            -
                'contextual_priorities', 
         
     | 
| 
       113 
96 
     | 
    
         
             
                'associations', 
         
     | 
| 
       114 
97 
     | 
    
         
             
                'name', 
         
     | 
| 
       115 
98 
     | 
    
         
             
                'version', 
         
     | 
| 
         @@ -188,20 +171,20 @@ const elist = (list, check, prefix) => { 
     | 
|
| 
       188 
171 
     | 
    
         
             
                }
         
     | 
| 
       189 
172 
     | 
    
         
             
              }
         
     | 
| 
       190 
173 
     | 
    
         
             
            }
         
     | 
| 
       191 
     | 
    
         
            -
            const  
     | 
| 
       192 
     | 
    
         
            -
              elist(cps, (cp) =>  
     | 
| 
      
 174 
     | 
    
         
            +
            const priorities_valid = (cps) => {
         
     | 
| 
      
 175 
     | 
    
         
            +
              elist(cps, (cp) => priority_valid(cp),  (index, e) => `priorities has an invalid priority at position ${index}. ${e}`)
         
     | 
| 
       193 
176 
     | 
    
         
             
            }
         
     | 
| 
       194 
177 
     | 
    
         | 
| 
       195 
     | 
    
         
            -
            const  
     | 
| 
      
 178 
     | 
    
         
            +
            const priority_valid = (cp) => {
         
     | 
| 
       196 
179 
     | 
    
         
             
              if (!cp.context) {
         
     | 
| 
       197 
     | 
    
         
            -
                throw new Error(`The  
     | 
| 
      
 180 
     | 
    
         
            +
                throw new Error(`The priority ${JSON.stringify(cp)} is missing the "context" property. That is a list of the operator keys that are to be prioritized differently.`)
         
     | 
| 
       198 
181 
     | 
    
         
             
              }
         
     | 
| 
       199 
182 
     | 
    
         
             
              if (!_.isArray(cp.context)) {
         
     | 
| 
       200 
     | 
    
         
            -
                throw new Error(`The  
     | 
| 
      
 183 
     | 
    
         
            +
                throw new Error(`The priority ${JSON.stringify(cp)} has an invalid "context" value. That is a list of the operator keys that are to be prioritized differently.`)
         
     | 
| 
       201 
184 
     | 
    
         
             
              }
         
     | 
| 
       202 
     | 
    
         
            -
              elist(cp.context, (element) => operatorKey_valid(element), (index, e) => `The  
     | 
| 
      
 185 
     | 
    
         
            +
              elist(cp.context, (element) => operatorKey_valid(element), (index, e) => `The priority ${JSON.stringify(cp)} has an invalid operator key at position ${index}. ${e}`)
         
     | 
| 
       203 
186 
     | 
    
         
             
              if (!_.isArray(cp.choose)) {
         
     | 
| 
       204 
     | 
    
         
            -
                throw new Error(`The  
     | 
| 
      
 187 
     | 
    
         
            +
                throw new Error(`The priority ${JSON.stringify(cp)} has an invalid "choose" value. The value should be a list of the operators in the context to consider for prioritization.`)
         
     | 
| 
       205 
188 
     | 
    
         
             
              }
         
     | 
| 
       206 
189 
     | 
    
         
             
              elist(cp.choose, 
         
     | 
| 
       207 
190 
     | 
    
         
             
                  (element) => {
         
     | 
| 
         @@ -212,7 +195,7 @@ const contextual_priority_valid = (cp) => { 
     | 
|
| 
       212 
195 
     | 
    
         
             
                      throw new Error(`The value should be an index into the "context" property of the operator that is to be considered for prioritization. Valid values are between 0 and ${cp.context.length-1}.`)
         
     | 
| 
       213 
196 
     | 
    
         
             
                    }
         
     | 
| 
       214 
197 
     | 
    
         
             
                  }, 
         
     | 
| 
       215 
     | 
    
         
            -
                  (index, e) => `The choose property in the  
     | 
| 
      
 198 
     | 
    
         
            +
                  (index, e) => `The choose property in the priority ${JSON.stringify(cp)} has an invalid index at position ${index}. ${e}`
         
     | 
| 
       216 
199 
     | 
    
         
             
              )
         
     | 
| 
       217 
200 
     | 
    
         
             
            }
         
     | 
| 
       218 
201 
     | 
    
         | 
| 
         @@ -245,7 +228,7 @@ const handleBridgeProps = (config, bridge, addFirst) => { 
     | 
|
| 
       245 
228 
     | 
    
         
             
                      if (typeof after == 'string') {
         
     | 
| 
       246 
229 
     | 
    
         
             
                        after = [after, 0]
         
     | 
| 
       247 
230 
     | 
    
         
             
                      }
         
     | 
| 
       248 
     | 
    
         
            -
                      config.addPriorities({  
     | 
| 
      
 231 
     | 
    
         
            +
                      config.addPriorities({ context: [[bridge.id, bridge.level], after], choose: [0] })
         
     | 
| 
       249 
232 
     | 
    
         
             
                    }
         
     | 
| 
       250 
233 
     | 
    
         
             
                  }
         
     | 
| 
       251 
234 
     | 
    
         
             
                  if (bridge.after) {
         
     | 
| 
         @@ -253,7 +236,7 @@ const handleBridgeProps = (config, bridge, addFirst) => { 
     | 
|
| 
       253 
236 
     | 
    
         
             
                      if (typeof before == 'string') {
         
     | 
| 
       254 
237 
     | 
    
         
             
                        before = [before, 0]
         
     | 
| 
       255 
238 
     | 
    
         
             
                      }
         
     | 
| 
       256 
     | 
    
         
            -
                      config.addPriorities({  
     | 
| 
      
 239 
     | 
    
         
            +
                      config.addPriorities({ context: [before, [bridge.id, bridge.level]], choose: [0] })
         
     | 
| 
       257 
240 
     | 
    
         
             
                    }
         
     | 
| 
       258 
241 
     | 
    
         
             
                  }
         
     | 
| 
       259 
242 
     | 
    
         
             
                  if (bridge.words) {
         
     | 
| 
         @@ -739,7 +722,6 @@ class Config { 
     | 
|
| 
       739 
722 
     | 
    
         
             
                  addAssociation: (...args) => this.addAssociation(...args),
         
     | 
| 
       740 
723 
     | 
    
         
             
                  addAssociations: (...args) => this.addAssociations(...args),
         
     | 
| 
       741 
724 
     | 
    
         
             
                  addBridge: (...args) => this.addBridge(...args, uuid),
         
     | 
| 
       742 
     | 
    
         
            -
                  addContextualPriority: (...args) => this.addContextualPriority(...args),
         
     | 
| 
       743 
725 
     | 
    
         
             
                  addGenerator: (...args) => this.addGenerator(...args, uuid, config.name),
         
     | 
| 
       744 
726 
     | 
    
         
             
                  addHierarchy: (...args) => this.addHierarchy(...args),
         
     | 
| 
       745 
727 
     | 
    
         
             
                  addOperator: (...args) => this.addOperator(...args, uuid),
         
     | 
| 
         @@ -815,7 +797,6 @@ class Config { 
     | 
|
| 
       815 
797 
     | 
    
         
             
                  },
         
     | 
| 
       816 
798 
     | 
    
         
             
                  eqClasses: [],
         
     | 
| 
       817 
799 
     | 
    
         
             
                  priorities: [], // Done
         
     | 
| 
       818 
     | 
    
         
            -
                  contextual_priorities: [],
         
     | 
| 
       819 
800 
     | 
    
         
             
                  version: '3',
         
     | 
| 
       820 
801 
     | 
    
         
             
                  debug: false,
         
     | 
| 
       821 
802 
     | 
    
         
             
                  associations: { // Done
         
     | 
| 
         @@ -854,7 +835,6 @@ class Config { 
     | 
|
| 
       854 
835 
     | 
    
         
             
                      'namespaces',
         
     | 
| 
       855 
836 
     | 
    
         
             
                      'eqClasses',
         
     | 
| 
       856 
837 
     | 
    
         
             
                      'priorities',
         
     | 
| 
       857 
     | 
    
         
            -
                      'contextual_priorities',
         
     | 
| 
       858 
838 
     | 
    
         
             
                      'associations',
         
     | 
| 
       859 
839 
     | 
    
         
             
                      'words',
         
     | 
| 
       860 
840 
     | 
    
         
             
                      'floaters',
         
     | 
| 
         @@ -1053,16 +1033,6 @@ class Config { 
     | 
|
| 
       1053 
1033 
     | 
    
         
             
                this.validifyTemplate(template)
         
     | 
| 
       1054 
1034 
     | 
    
         
             
                instance.template = template
         
     | 
| 
       1055 
1035 
     | 
    
         
             
                this.logs.push(`loading template for ${this.name}`)
         
     | 
| 
       1056 
     | 
    
         
            -
                /*
         
     | 
| 
       1057 
     | 
    
         
            -
                if (instance && (instance.associations || instance.learned_contextual_priorities) && !options.rebuild) {
         
     | 
| 
       1058 
     | 
    
         
            -
                  if (instance.associations) {
         
     | 
| 
       1059 
     | 
    
         
            -
                    this.addAssociations(instance.associations)
         
     | 
| 
       1060 
     | 
    
         
            -
                  }
         
     | 
| 
       1061 
     | 
    
         
            -
                  if (instance.learned_contextual_priorities && instance.learned_contextual_priorities.length > 0) {
         
     | 
| 
       1062 
     | 
    
         
            -
                    this.addContextualPriorities(instance.learned_contextual_priorities)
         
     | 
| 
       1063 
     | 
    
         
            -
                  }
         
     | 
| 
       1064 
     | 
    
         
            -
                }
         
     | 
| 
       1065 
     | 
    
         
            -
                */
         
     | 
| 
       1066 
1036 
     | 
    
         
             
                if (options.rebuild) {
         
     | 
| 
       1067 
1037 
     | 
    
         
             
                  // TODO fix beforeQuery
         
     | 
| 
       1068 
1038 
     | 
    
         
             
                  template = { fragments: [], queries: [], ...template }
         
     | 
| 
         @@ -1111,12 +1081,6 @@ class Config { 
     | 
|
| 
       1111 
1081 
     | 
    
         
             
                }
         
     | 
| 
       1112 
1082 
     | 
    
         
             
              }
         
     | 
| 
       1113 
1083 
     | 
    
         | 
| 
       1114 
     | 
    
         
            -
              addContextualPriorities (cps) {
         
     | 
| 
       1115 
     | 
    
         
            -
                for (let cp of cps) {
         
     | 
| 
       1116 
     | 
    
         
            -
                  this.addContextualPriority(cp)
         
     | 
| 
       1117 
     | 
    
         
            -
                }
         
     | 
| 
       1118 
     | 
    
         
            -
              }
         
     | 
| 
       1119 
     | 
    
         
            -
             
     | 
| 
       1120 
1084 
     | 
    
         
             
              debugConfig() {
         
     | 
| 
       1121 
1085 
     | 
    
         
             
              }
         
     | 
| 
       1122 
1086 
     | 
    
         | 
| 
         @@ -1134,26 +1098,17 @@ class Config { 
     | 
|
| 
       1134 
1098 
     | 
    
         | 
| 
       1135 
1099 
     | 
    
         
             
              // TODO add more error checking to these like addHierarchy has
         
     | 
| 
       1136 
1100 
     | 
    
         
             
              // TODO change name from priorities to priority
         
     | 
| 
      
 1101 
     | 
    
         
            +
              // [ context: <list of [id, level]>, choose: [<indexes of prioritized operator>], [ordered: [true|false]] ]
         
     | 
| 
       1137 
1102 
     | 
    
         
             
              addPriorities (priorities) {
         
     | 
| 
       1138 
1103 
     | 
    
         
             
                if (!this.config.priorities) {
         
     | 
| 
       1139 
1104 
     | 
    
         
             
                  this.config.priorities = []
         
     | 
| 
       1140 
1105 
     | 
    
         
             
                }
         
     | 
| 
       1141 
1106 
     | 
    
         
             
                debugPriority(priorities)
         
     | 
| 
      
 1107 
     | 
    
         
            +
                priority_valid(priorities)
         
     | 
| 
       1142 
1108 
     | 
    
         
             
                this.config.priorities.push(priorities)
         
     | 
| 
       1143 
1109 
     | 
    
         
             
                this._delta.json.priorities.push({ action: 'add', priorities })
         
     | 
| 
       1144 
1110 
     | 
    
         
             
              }
         
     | 
| 
       1145 
1111 
     | 
    
         | 
| 
       1146 
     | 
    
         
            -
              // [ operators: <list of [id, level]>, select: <index of prioritized operator> ]
         
     | 
| 
       1147 
     | 
    
         
            -
              addContextualPriority(contextual_priority) {
         
     | 
| 
       1148 
     | 
    
         
            -
                if (!this.config.contextual_priorities) {
         
     | 
| 
       1149 
     | 
    
         
            -
                  this.config.contextual_priorities = []
         
     | 
| 
       1150 
     | 
    
         
            -
                }
         
     | 
| 
       1151 
     | 
    
         
            -
                debugContextualPriority(contextual_priority)
         
     | 
| 
       1152 
     | 
    
         
            -
                contextual_priority_valid(contextual_priority)
         
     | 
| 
       1153 
     | 
    
         
            -
                this.config.contextual_priorities.push(contextual_priority)
         
     | 
| 
       1154 
     | 
    
         
            -
                this._delta.json.contextual_priorities.push({ action: 'add', contextual_priority: contextual_priority })
         
     | 
| 
       1155 
     | 
    
         
            -
              }
         
     | 
| 
       1156 
     | 
    
         
            -
             
     | 
| 
       1157 
1112 
     | 
    
         
             
              addHierarchy (child, parent) {
         
     | 
| 
       1158 
1113 
     | 
    
         
             
                if (child && parent || !child || Array.isArray(child) || (typeof child == 'string' && !parent)) {
         
     | 
| 
       1159 
1114 
     | 
    
         
             
                  this.addHierarchyChildParent(child, parent)
         
     | 
| 
         @@ -1549,7 +1504,6 @@ class Config { 
     | 
|
| 
       1549 
1504 
     | 
    
         
             
                  config.hierarchy = config.hierarchy || []
         
     | 
| 
       1550 
1505 
     | 
    
         
             
                  config.associations = config.associations || { negative: [], positive: [] }
         
     | 
| 
       1551 
1506 
     | 
    
         
             
                  config.priorities = config.priorities || []
         
     | 
| 
       1552 
     | 
    
         
            -
                  config.contextual_priorities = config.contextual_priorities || []
         
     | 
| 
       1553 
1507 
     | 
    
         
             
                }
         
     | 
| 
       1554 
1508 
     | 
    
         | 
| 
       1555 
1509 
     | 
    
         
             
                this.maxDepth = 20 // for generators and semantics
         
     | 
| 
         @@ -1603,8 +1557,8 @@ class Config { 
     | 
|
| 
       1603 
1557 
     | 
    
         
             
                  }
         
     | 
| 
       1604 
1558 
     | 
    
         
             
                }
         
     | 
| 
       1605 
1559 
     | 
    
         | 
| 
       1606 
     | 
    
         
            -
                if (config && config. 
     | 
| 
       1607 
     | 
    
         
            -
                   
     | 
| 
      
 1560 
     | 
    
         
            +
                if (config && config.priorities) {
         
     | 
| 
      
 1561 
     | 
    
         
            +
                  priorities_valid(config.priorities)
         
     | 
| 
       1608 
1562 
     | 
    
         
             
                }
         
     | 
| 
       1609 
1563 
     | 
    
         | 
| 
       1610 
1564 
     | 
    
         
             
                normalizeConfig(config)
         
     | 
| 
         @@ -1692,7 +1646,6 @@ class Config { 
     | 
|
| 
       1692 
1646 
     | 
    
         
             
                    bridges: [],
         
     | 
| 
       1693 
1647 
     | 
    
         
             
                    associations: [],
         
     | 
| 
       1694 
1648 
     | 
    
         
             
                    priorities: [],
         
     | 
| 
       1695 
     | 
    
         
            -
                    contextual_priorities: [],
         
     | 
| 
       1696 
1649 
     | 
    
         
             
                    hierarchy: [],
         
     | 
| 
       1697 
1650 
     | 
    
         
             
                  }
         
     | 
| 
       1698 
1651 
     | 
    
         
             
                }
         
     | 
| 
         @@ -2322,7 +2275,6 @@ class Config { 
     | 
|
| 
       2322 
2275 
     | 
    
         
             
                    bridges: this.config.bridges,
         
     | 
| 
       2323 
2276 
     | 
    
         
             
                    hierarchy: this.config.hierarchy,
         
     | 
| 
       2324 
2277 
     | 
    
         
             
                    priorities: this.config.priorities,
         
     | 
| 
       2325 
     | 
    
         
            -
                    contextual_priorities: this.config.contextual_priorities,
         
     | 
| 
       2326 
2278 
     | 
    
         
             
                    associations: this.config.associations,
         
     | 
| 
       2327 
2279 
     | 
    
         
             
                    words: this.config.words
         
     | 
| 
       2328 
2280 
     | 
    
         
             
                  }
         
     | 
| 
         @@ -2331,7 +2283,6 @@ class Config { 
     | 
|
| 
       2331 
2283 
     | 
    
         
             
                  this.config.bridges = []
         
     | 
| 
       2332 
2284 
     | 
    
         
             
                  this.config.hierarchy = []
         
     | 
| 
       2333 
2285 
     | 
    
         
             
                  this.config.priorities = []
         
     | 
| 
       2334 
     | 
    
         
            -
                  this.config.contextual_priorities = []
         
     | 
| 
       2335 
2286 
     | 
    
         
             
                  this.config.associations = { positive: [], negative: [] }
         
     | 
| 
       2336 
2287 
     | 
    
         
             
                  this.config.words = {}
         
     | 
| 
       2337 
2288 
     | 
    
         | 
| 
         @@ -2540,25 +2491,20 @@ class Config { 
     | 
|
| 
       2540 
2491 
     | 
    
         | 
| 
       2541 
2492 
     | 
    
         
             
                if (config.priorities) {
         
     | 
| 
       2542 
2493 
     | 
    
         
             
                  let priorities = config.priorities
         
     | 
| 
       2543 
     | 
    
         
            -
                  priorities = priorities.map(( 
     | 
| 
       2544 
     | 
    
         
            -
                    return { ...p, context: p.context.map( (id) => [toNS(id[0]), id[1]] )}
         
     | 
| 
       2545 
     | 
    
         
            -
                  })
         
     | 
| 
       2546 
     | 
    
         
            -
                  config.priorities = priorities
         
     | 
| 
       2547 
     | 
    
         
            -
                }
         
     | 
| 
       2548 
     | 
    
         
            -
             
     | 
| 
       2549 
     | 
    
         
            -
                if (config.contextual_priorities) {
         
     | 
| 
       2550 
     | 
    
         
            -
                  let contextual_priorities = config.contextual_priorities
         
     | 
| 
       2551 
     | 
    
         
            -
                  contextual_priorities = contextual_priorities.map((cp) => {
         
     | 
| 
      
 2494 
     | 
    
         
            +
                  priorities = priorities.map((cp) => {
         
     | 
| 
       2552 
2495 
     | 
    
         
             
                    const { context, choose, ordered } = cp
         
     | 
| 
       2553 
     | 
    
         
            -
                     
     | 
| 
      
 2496 
     | 
    
         
            +
                    const priority = {
         
     | 
| 
       2554 
2497 
     | 
    
         
             
                      context: context.map((id) => {
         
     | 
| 
       2555 
2498 
     | 
    
         
             
                        return [toNS(id[0]), id[1]]
         
     | 
| 
       2556 
2499 
     | 
    
         
             
                      }),
         
     | 
| 
       2557 
2500 
     | 
    
         
             
                      choose,
         
     | 
| 
       2558 
     | 
    
         
            -
                      ordered
         
     | 
| 
       2559 
2501 
     | 
    
         
             
                    }
         
     | 
| 
      
 2502 
     | 
    
         
            +
                    if (ordered) {
         
     | 
| 
      
 2503 
     | 
    
         
            +
                      priority.ordered = ordered
         
     | 
| 
      
 2504 
     | 
    
         
            +
                    }
         
     | 
| 
      
 2505 
     | 
    
         
            +
                    return priority
         
     | 
| 
       2560 
2506 
     | 
    
         
             
                  })
         
     | 
| 
       2561 
     | 
    
         
            -
                  config. 
     | 
| 
      
 2507 
     | 
    
         
            +
                  config.priorities = priorities
         
     | 
| 
       2562 
2508 
     | 
    
         
             
                }
         
     | 
| 
       2563 
2509 
     | 
    
         | 
| 
       2564 
2510 
     | 
    
         
             
                for (const bag of bags) {
         
     |