{
  "id": "fn-flow-filter",
  "dataComponent": "flow",
  "heading": {
    "title": "filter",
    "badges": [
      "Flow",
      "PARTIAL"
    ]
  },
  "synopsis": "Creates an InkTransform that only yields items for which your predicate function returns true or a non-zero numeric value.",
  "codeBlocks": [
    "extend(\"flow\")\n\n# 1) Provide a predicate and an InkIterator:\nfiltered = flow:filter(x => x > 10, ink(4,15))\n\narr = flow:to_array(filtered)\nsput(arr)\n# => [11,12,13,14]\n\n# 2) Partial usage => define the predicate, wait for the source:\npredFn = x => x % 2 == 0\nmyPartial = flow:filter(predFn)\n\nres = flow:to_array( myPartial( ink(1,8) ) )\n# => [2,4,6]\n\n# 3) If used with an InkTransform, it chains, discarding items not passing the filter.\n"
  ],
  "notes": [
    "Expects up to 2 arguments => (predicateFn, source). If fewer or placeholders, returns partial usage until both are known.",
    "source can be an InkIterator or an InkTransform. The resulting transform only yields items for which predicate returns a truthy result: bool(true) or a non-zero number.",
    "If the predicate returns bool(false), 0, or an error, that item is skipped or iteration stops. Mixed or invalid predicate results raise an error.",
    "Combine with flow:to_array(...) or another transform for final consumption or chaining."
  ]
}
