{
  "name": "Function to Code node - converted workflow (tested on n8n 2.47.7 and 3.0.1)",
  "nodes": [
    {
      "parameters": {},
      "id": "t1",
      "name": "When clicking 'Execute workflow'",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        0,
        0
      ]
    },
    {
      "parameters": {
        "jsCode": "// Sample orders (runs once for all items)\nconst orders = [\n  { order: 'A-101', customer: 'Ali Traders', amount: 12000 },\n  { order: 'A-102', customer: 'Noor Foods', amount: 4500 },\n  { order: 'A-103', customer: 'Lahore Tiles', amount: 31000 },\n];\nreturn orders.map(o => ({ json: o }));"
      },
      "id": "c1",
      "name": "Sample orders (Code)",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        220,
        0
      ]
    },
    {
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "// Add 17% sales tax to each order (Run Once for Each Item)\nconst item = $input.item.json;\nitem.tax = Math.round(item.amount * 0.17);\nitem.total = item.amount + item.tax;\nreturn $input.item;"
      },
      "id": "c2",
      "name": "Add tax (Code, each item)",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        440,
        0
      ]
    },
    {
      "parameters": {
        "jsCode": "// Keep only big orders and add a summary field (Run Once for All Items)\nconst big = $input.all().filter(i => i.json.amount >= 10000);\nfor (const i of big) { i.json.priority = 'high'; }\nreturn big;"
      },
      "id": "c3",
      "name": "Big orders (Code)",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        660,
        0
      ]
    }
  ],
  "connections": {
    "When clicking 'Execute workflow'": {
      "main": [
        [
          {
            "node": "Sample orders (Code)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Sample orders (Code)": {
      "main": [
        [
          {
            "node": "Add tax (Code, each item)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Add tax (Code, each item)": {
      "main": [
        [
          {
            "node": "Big orders (Code)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  }
}