{
  "id": "@typed/fx/Fx#grouped",
  "canonicalId": "@typed/fx/Fx#grouped",
  "symbol": {
    "id": "@typed/fx/Fx#grouped",
    "packageName": "@typed/fx",
    "moduleName": "Fx",
    "exportName": "grouped",
    "kind": "constant",
    "signatures": [
      "export declare const grouped: {\n    (n: number): <A, E, R>(self: Fx<A, E, R>) => Fx<NonEmptyReadonlyArray<A>, E | Cause.IllegalArgumentError, R>;\n    <A, E, R>(self: Fx<A, E, R>, n: number): Fx<NonEmptyReadonlyArray<A>, E | Cause.IllegalArgumentError, R>;\n};"
    ],
    "summary": "Partitions the stream into non-empty arrays of size `n`. The final array\nmay be smaller if there are leftover elements.\nThe size must be a positive safe integer. A group can retain up to `n`\nvalues, so callers own the memory policy for valid sizes. Invalid sizes\nfail with `Cause.IllegalArgumentError`.\n\nMatches Effect `Stream.grouped`.",
    "sections": {
      "Why": "`grouped` exposes fixed-size batching without changing source order. Full groups contain exactly\n`n` values. Because failure is delivered to the Sink while `Fx.run` remains infallible, any\npartial group is flushed after the source run returns even if a failure was delivered first.",
      "Ownership and lifetime": "Each run retains at most `n` values and releases its buffer after the final flush or interruption.\nInvalid sizes deliver failure before source acquisition. A terminal observer may interrupt before\nthe post-failure flush, but a Sink that handles the Cause can receive the partial group afterward."
    },
    "examples": [
      {
        "language": "ts",
        "code": "import { Cause, Effect, Ref } from \"effect\"\nimport { Fx, Sink } from \"@typed/fx\"\nconst program = Effect.gen(function* () {\n  const deliveries = yield* Ref.make<Array<string>>([])\n  const source = Fx.make<number, string>((sink) =>\n    sink.onSuccess(1).pipe(Effect.andThen(sink.onFailure(Cause.fail(\"boom\"))))\n  )\n  yield* Fx.grouped(source, 2).run(Sink.make(\n    () => Ref.update(deliveries, (xs) => [...xs, \"failure\"]),\n    (group) => Ref.update(deliveries, (xs) => [...xs, `group:${group.join(\",\")}`])\n  ))\n  return yield* Ref.get(deliveries) // [\"failure\", \"group:1\"]\n})"
      }
    ],
    "relations": [],
    "source": {
      "file": "packages/fx/src/Fx/combinators/grouped.ts",
      "line": 60
    },
    "since": "1.0.0",
    "category": "Stateful transforms"
  },
  "exposure": {
    "recordKind": "declaration",
    "id": "@typed/fx/Fx#grouped",
    "packageName": "@typed/fx",
    "packageVersion": "2.0.0-beta.7",
    "moduleName": "Fx",
    "consumerSpecifier": "@typed/fx/Fx",
    "exportName": "grouped",
    "qualifiedName": "grouped",
    "declarationKey": "declaration:3be32dc436b4ad1b5aedb1a4",
    "family": "variable",
    "signatures": [
      "export declare const grouped: {\n    (n: number): <A, E, R>(self: Fx<A, E, R>) => Fx<NonEmptyReadonlyArray<A>, E | Cause.IllegalArgumentError, R>;\n    <A, E, R>(self: Fx<A, E, R>, n: number): Fx<NonEmptyReadonlyArray<A>, E | Cause.IllegalArgumentError, R>;\n};"
    ],
    "sourceSpans": [
      {
        "file": "packages/fx/src/Fx/combinators/grouped.ts",
        "start": {
          "line": 60,
          "column": 14
        },
        "end": {
          "line": 99,
          "column": 2
        }
      },
      {
        "file": "packages/fx/src/Fx/combinators/grouped.ts",
        "start": {
          "line": 61,
          "column": 3
        },
        "end": {
          "line": 65,
          "column": 72
        }
      },
      {
        "file": "packages/fx/src/Fx/combinators/grouped.ts",
        "start": {
          "line": 66,
          "column": 3
        },
        "end": {
          "line": 69,
          "column": 70
        }
      }
    ],
    "aliases": [
      "@typed/fx#Fx.grouped"
    ],
    "isAlias": false,
    "static": false
  },
  "declaration": {
    "declarationKey": "declaration:3be32dc436b4ad1b5aedb1a4",
    "name": "grouped",
    "family": "variable",
    "facets": [
      {
        "family": "variable",
        "syntaxKind": "VariableDeclaration",
        "signatures": [
          "export declare const grouped: {\n    (n: number): <A, E, R>(self: Fx<A, E, R>) => Fx<NonEmptyReadonlyArray<A>, E | Cause.IllegalArgumentError, R>;\n    <A, E, R>(self: Fx<A, E, R>, n: number): Fx<NonEmptyReadonlyArray<A>, E | Cause.IllegalArgumentError, R>;\n};"
        ],
        "typeParameters": [],
        "sourceSpans": [
          {
            "file": "packages/fx/src/Fx/combinators/grouped.ts",
            "start": {
              "line": 60,
              "column": 14
            },
            "end": {
              "line": 99,
              "column": 2
            }
          }
        ],
        "static": false,
        "readonly": false,
        "optional": false
      },
      {
        "family": "call-signature",
        "syntaxKind": "CallSignature",
        "signatures": [
          "(n: number): <A, E, R>(self: Fx<A, E, R>) => Fx<NonEmptyReadonlyArray<A>, E | Cause.IllegalArgumentError, R>;",
          "<A, E, R>(self: Fx<A, E, R>, n: number): Fx<NonEmptyReadonlyArray<A>, E | Cause.IllegalArgumentError, R>;"
        ],
        "typeParameters": [
          "A",
          "E",
          "R"
        ],
        "sourceSpans": [
          {
            "file": "packages/fx/src/Fx/combinators/grouped.ts",
            "start": {
              "line": 61,
              "column": 3
            },
            "end": {
              "line": 65,
              "column": 72
            }
          },
          {
            "file": "packages/fx/src/Fx/combinators/grouped.ts",
            "start": {
              "line": 66,
              "column": 3
            },
            "end": {
              "line": 69,
              "column": 70
            }
          }
        ],
        "static": false,
        "readonly": false,
        "optional": false
      }
    ],
    "signatures": [
      "export declare const grouped: {\n    (n: number): <A, E, R>(self: Fx<A, E, R>) => Fx<NonEmptyReadonlyArray<A>, E | Cause.IllegalArgumentError, R>;\n    <A, E, R>(self: Fx<A, E, R>, n: number): Fx<NonEmptyReadonlyArray<A>, E | Cause.IllegalArgumentError, R>;\n};"
    ],
    "typeParameters": [
      "A",
      "E",
      "R"
    ],
    "summary": "Partitions the stream into non-empty arrays of size `n`. The final array\nmay be smaller if there are leftover elements.\nThe size must be a positive safe integer. A group can retain up to `n`\nvalues, so callers own the memory policy for valid sizes. Invalid sizes\nfail with `Cause.IllegalArgumentError`.\n\nMatches Effect `Stream.grouped`.",
    "sections": {
      "Why": "`grouped` exposes fixed-size batching without changing source order. Full groups contain exactly\n`n` values. Because failure is delivered to the Sink while `Fx.run` remains infallible, any\npartial group is flushed after the source run returns even if a failure was delivered first.",
      "Ownership and lifetime": "Each run retains at most `n` values and releases its buffer after the final flush or interruption.\nInvalid sizes deliver failure before source acquisition. A terminal observer may interrupt before\nthe post-failure flush, but a Sink that handles the Cause can receive the partial group afterward."
    },
    "examples": [
      {
        "language": "ts",
        "code": "import { Cause, Effect, Ref } from \"effect\"\nimport { Fx, Sink } from \"@typed/fx\"\nconst program = Effect.gen(function* () {\n  const deliveries = yield* Ref.make<Array<string>>([])\n  const source = Fx.make<number, string>((sink) =>\n    sink.onSuccess(1).pipe(Effect.andThen(sink.onFailure(Cause.fail(\"boom\"))))\n  )\n  yield* Fx.grouped(source, 2).run(Sink.make(\n    () => Ref.update(deliveries, (xs) => [...xs, \"failure\"]),\n    (group) => Ref.update(deliveries, (xs) => [...xs, `group:${group.join(\",\")}`])\n  ))\n  return yield* Ref.get(deliveries) // [\"failure\", \"group:1\"]\n})"
      }
    ],
    "sourceSpans": [
      {
        "file": "packages/fx/src/Fx/combinators/grouped.ts",
        "start": {
          "line": 60,
          "column": 14
        },
        "end": {
          "line": 99,
          "column": 2
        }
      },
      {
        "file": "packages/fx/src/Fx/combinators/grouped.ts",
        "start": {
          "line": 61,
          "column": 3
        },
        "end": {
          "line": 65,
          "column": 72
        }
      },
      {
        "file": "packages/fx/src/Fx/combinators/grouped.ts",
        "start": {
          "line": 66,
          "column": 3
        },
        "end": {
          "line": 69,
          "column": 70
        }
      }
    ],
    "since": "1.0.0",
    "category": "Stateful transforms"
  }
}
