n8n-nodes-while-loop 0.1.3 → 0.1.4

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.
@@ -64,10 +64,9 @@ class WhileLoop {
64
64
  const conditionExpression = mode === "expression"
65
65
  ? this.getNodeParameter("conditionExpression", 0, "")
66
66
  : "";
67
- const state = this.getWorkflowStaticData("execution");
68
- const nodeKey = this.getNode().id;
69
- state.__whileLoop = state.__whileLoop || {};
70
- const loopState = state.__whileLoop[nodeKey] || { iteration: 0 };
67
+ const state = this.getWorkflowStaticData("node"); // safe context in n8n 2.x
68
+ state.loopState = state.loopState || { iteration: 0 };
69
+ const loopState = state.loopState;
71
70
  const continueItems = [];
72
71
  const doneItems = [];
73
72
  for (let i = 0; i < items.length; i++) {
@@ -113,15 +112,15 @@ class WhileLoop {
113
112
  }
114
113
  else {
115
114
  // reset state for next execution
116
- delete state.__whileLoop[nodeKey];
115
+ state.loopState = { iteration: 0 };
117
116
  doneItems.push(items[i]);
118
117
  }
119
118
  }
120
119
  if (continueItems.length) {
121
- state.__whileLoop[nodeKey] = loopState;
120
+ state.loopState = loopState;
122
121
  }
123
122
  else {
124
- delete state.__whileLoop[nodeKey];
123
+ state.loopState = { iteration: 0 };
125
124
  }
126
125
  return [continueItems, doneItems];
127
126
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-while-loop",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Simple while-loop control node for n8n with counter or expression conditions",
5
5
  "keywords": [
6
6
  "n8n-community-node-package",