{
  "id": "fn-flow-trans",
  "dataComponent": "flow",
  "heading": {
    "title": "trans",
    "badges": [
      "Flow",
      "PARTIAL"
    ]
  },
  "synopsis": "Applies a user-defined function to each item from an InkIterator or InkTransform, returning a new InkTransform that yields transformed items one at a time.",
  "codeBlocks": [
    "extend(\"flow\")\n\n# 1) Use an InkIterator as input:\ntransform = flow:trans(x => x+1, ink(1,5))\n# => an InkTransform that yields each integer from [1..5), adding 1 => [2..6).\n\n# 2) Retrieve the items => flow:to_array\nresult = flow:to_array(transform)\nsput(result)\n# => [2,3,4,5,6]\n\n# 3) Chain multiple transforms:\nstepA = flow:trans(x => x * 2)\nstepB = flow:trans(x => x + 100)\n\n# Compose them:\nchain = flow:trans(x => x - 1, stepA( stepB( ink(2,5) ) ))\n\n# ... or partial usage, etc.\n\n# 4) Example partial usage => only define the transform function:\nmyTrans = flow:trans(x => x * 10)\n\nsput( flow:to_array( myTrans( ink(1,4) ) ) )\n# => [10,20,30]\n"
  ],
  "notes": [
    "If called with two arguments (userFunc, source), it returns a new InkTransform. The source can be an InkIterator or another InkTransform (chaining).",
    "If fewer arguments or placeholders are provided, partial usage is returned until both a function and a source are known.",
    "The user-defined function receives each item individually. If it returns an error or 'NO_MORE_DATA', iteration stops. Typical bridging expects a single transformed item per call.",
    "Combine with flow:to_array(...) to gather all transformed items into an in-memory array."
  ]
}
