{
  "id": "@typed/fx#Fx.groupedWithin",
  "canonicalId": "@typed/fx/Fx#groupedWithin",
  "symbol": {
    "id": "@typed/fx#Fx.groupedWithin",
    "packageName": "@typed/fx",
    "moduleName": ".",
    "exportName": "Fx.groupedWithin",
    "kind": "constant",
    "signatures": [
      "export declare const groupedWithin: {\n    (n: number, duration: Duration.Input): <A, E, R>(self: Fx<A, E, R>) => Fx<NonEmptyReadonlyArray<A>, E | Cause.IllegalArgumentError, R | Scope.Scope>;\n    <A, E, R>(self: Fx<A, E, R>, n: number, duration: Duration.Input): Fx<NonEmptyReadonlyArray<A>, E | Cause.IllegalArgumentError, R | Scope.Scope>;\n};"
    ],
    "summary": "Partitions the stream into arrays, emitting when `n` is reached or `duration`\nelapses after the first element of the current group.\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.groupedWithin`.",
    "sections": {
      "Why": "`groupedWithin` bounds a batch by both cardinality and time. The timer starts with the first value,\nand whichever boundary wins emits the ordered non-empty group and resets both buffer and timer.\nA partial group is also flushed when the source run returns, including after delivered failure.",
      "Ownership and lifetime": "Each run retains at most `n` values and at most one timer fiber in the required Scope. A source\nfailure is Sink delivery, so `flushNow` still runs afterward unless the consumer interrupts the\nrun. Flushing or interruption cancels the timer; invalid sizes fail before subscription."
    },
    "examples": [
      {
        "language": "ts",
        "code": "import { Cause, Effect } from \"effect\"\nimport { Fx, Sink } from \"@typed/fx\"\nconst source = Fx.make<number, string>((sink) =>\n  sink.onSuccess(1).pipe(Effect.andThen(sink.onFailure(Cause.fail(\"boom\"))))\n)\nconst program = Fx.groupedWithin(source, 2, \"1 hour\").run(\n  Sink.make(Effect.logError, (group) => Effect.log(group))\n) // logs the failure, then flushes [1]"
      }
    ],
    "relations": [],
    "source": {
      "file": "packages/fx/src/Fx/combinators/grouped.ts",
      "line": 136
    },
    "since": "1.0.0",
    "category": "Time and rate"
  },
  "exposure": {
    "recordKind": "declaration",
    "id": "@typed/fx#Fx.groupedWithin",
    "packageName": "@typed/fx",
    "packageVersion": "2.0.0-beta.7",
    "moduleName": ".",
    "consumerSpecifier": "@typed/fx",
    "exportName": "Fx",
    "qualifiedName": "Fx.groupedWithin",
    "declarationKey": "declaration:f0db7cf84153a4dd678228e6",
    "family": "variable",
    "signatures": [
      "export declare const groupedWithin: {\n    (n: number, duration: Duration.Input): <A, E, R>(self: Fx<A, E, R>) => Fx<NonEmptyReadonlyArray<A>, E | Cause.IllegalArgumentError, R | Scope.Scope>;\n    <A, E, R>(self: Fx<A, E, R>, n: number, duration: Duration.Input): Fx<NonEmptyReadonlyArray<A>, E | Cause.IllegalArgumentError, R | Scope.Scope>;\n};"
    ],
    "sourceSpans": [
      {
        "file": "packages/fx/src/Fx/combinators/grouped.ts",
        "start": {
          "line": 136,
          "column": 14
        },
        "end": {
          "line": 209,
          "column": 2
        }
      },
      {
        "file": "packages/fx/src/Fx/combinators/grouped.ts",
        "start": {
          "line": 137,
          "column": 3
        },
        "end": {
          "line": 142,
          "column": 86
        }
      },
      {
        "file": "packages/fx/src/Fx/combinators/grouped.ts",
        "start": {
          "line": 143,
          "column": 3
        },
        "end": {
          "line": 147,
          "column": 84
        }
      }
    ],
    "aliases": [
      "@typed/fx/Fx#groupedWithin"
    ],
    "isAlias": true,
    "parentId": "@typed/fx#Fx",
    "static": false,
    "importedFrom": "declaration:f0db7cf84153a4dd678228e6"
  },
  "declaration": {
    "declarationKey": "declaration:f0db7cf84153a4dd678228e6",
    "name": "groupedWithin",
    "family": "variable",
    "facets": [
      {
        "family": "variable",
        "syntaxKind": "VariableDeclaration",
        "signatures": [
          "export declare const groupedWithin: {\n    (n: number, duration: Duration.Input): <A, E, R>(self: Fx<A, E, R>) => Fx<NonEmptyReadonlyArray<A>, E | Cause.IllegalArgumentError, R | Scope.Scope>;\n    <A, E, R>(self: Fx<A, E, R>, n: number, duration: Duration.Input): Fx<NonEmptyReadonlyArray<A>, E | Cause.IllegalArgumentError, R | Scope.Scope>;\n};"
        ],
        "typeParameters": [],
        "sourceSpans": [
          {
            "file": "packages/fx/src/Fx/combinators/grouped.ts",
            "start": {
              "line": 136,
              "column": 14
            },
            "end": {
              "line": 209,
              "column": 2
            }
          }
        ],
        "static": false,
        "readonly": false,
        "optional": false
      },
      {
        "family": "call-signature",
        "syntaxKind": "CallSignature",
        "signatures": [
          "(n: number, duration: Duration.Input): <A, E, R>(self: Fx<A, E, R>) => Fx<NonEmptyReadonlyArray<A>, E | Cause.IllegalArgumentError, R | Scope.Scope>;",
          "<A, E, R>(self: Fx<A, E, R>, n: number, duration: Duration.Input): Fx<NonEmptyReadonlyArray<A>, E | Cause.IllegalArgumentError, R | Scope.Scope>;"
        ],
        "typeParameters": [
          "A",
          "E",
          "R"
        ],
        "sourceSpans": [
          {
            "file": "packages/fx/src/Fx/combinators/grouped.ts",
            "start": {
              "line": 137,
              "column": 3
            },
            "end": {
              "line": 142,
              "column": 86
            }
          },
          {
            "file": "packages/fx/src/Fx/combinators/grouped.ts",
            "start": {
              "line": 143,
              "column": 3
            },
            "end": {
              "line": 147,
              "column": 84
            }
          }
        ],
        "static": false,
        "readonly": false,
        "optional": false
      }
    ],
    "signatures": [
      "export declare const groupedWithin: {\n    (n: number, duration: Duration.Input): <A, E, R>(self: Fx<A, E, R>) => Fx<NonEmptyReadonlyArray<A>, E | Cause.IllegalArgumentError, R | Scope.Scope>;\n    <A, E, R>(self: Fx<A, E, R>, n: number, duration: Duration.Input): Fx<NonEmptyReadonlyArray<A>, E | Cause.IllegalArgumentError, R | Scope.Scope>;\n};"
    ],
    "typeParameters": [
      "A",
      "E",
      "R"
    ],
    "summary": "Partitions the stream into arrays, emitting when `n` is reached or `duration`\nelapses after the first element of the current group.\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.groupedWithin`.",
    "sections": {
      "Why": "`groupedWithin` bounds a batch by both cardinality and time. The timer starts with the first value,\nand whichever boundary wins emits the ordered non-empty group and resets both buffer and timer.\nA partial group is also flushed when the source run returns, including after delivered failure.",
      "Ownership and lifetime": "Each run retains at most `n` values and at most one timer fiber in the required Scope. A source\nfailure is Sink delivery, so `flushNow` still runs afterward unless the consumer interrupts the\nrun. Flushing or interruption cancels the timer; invalid sizes fail before subscription."
    },
    "examples": [
      {
        "language": "ts",
        "code": "import { Cause, Effect } from \"effect\"\nimport { Fx, Sink } from \"@typed/fx\"\nconst source = Fx.make<number, string>((sink) =>\n  sink.onSuccess(1).pipe(Effect.andThen(sink.onFailure(Cause.fail(\"boom\"))))\n)\nconst program = Fx.groupedWithin(source, 2, \"1 hour\").run(\n  Sink.make(Effect.logError, (group) => Effect.log(group))\n) // logs the failure, then flushes [1]"
      }
    ],
    "sourceSpans": [
      {
        "file": "packages/fx/src/Fx/combinators/grouped.ts",
        "start": {
          "line": 136,
          "column": 14
        },
        "end": {
          "line": 209,
          "column": 2
        }
      },
      {
        "file": "packages/fx/src/Fx/combinators/grouped.ts",
        "start": {
          "line": 137,
          "column": 3
        },
        "end": {
          "line": 142,
          "column": 86
        }
      },
      {
        "file": "packages/fx/src/Fx/combinators/grouped.ts",
        "start": {
          "line": 143,
          "column": 3
        },
        "end": {
          "line": 147,
          "column": 84
        }
      }
    ],
    "since": "1.0.0",
    "category": "Time and rate"
  }
}
