MCPcopy Create free account
hub / github.com/effect-app/libs / paginate

Function paginate

repos/effect/packages/effect/src/Stream.ts:1684–1705  ·  view source on GitHub ↗
(
  s: S,
  f: (
    s: S
  ) => Effect.Effect<readonly [ReadonlyArray<A>, Option.Option<S>], E, R>
)

Source from the content-addressed store, hash-verified

1682 * @category mapping
1683 * @since 2.0.0
1684 */
1685export const map: {
1686 <A, B>(f: (a: A, i: number) => B): <E, R>(self: Stream<A, E, R>) => Stream<B, E, R>
1687 <A, E, R, B>(self: Stream<A, E, R>, f: (a: A, i: number) => B): Stream<B, E, R>
1688} = dual(2, <A, E, R, B>(self: Stream<A, E, R>, f: (a: A, i: number) => B): Stream<B, E, R> =>
1689 suspend(() => {
1690 let i = 0
1691 return fromChannel(Channel.map(
1692 self.channel,
1693 Arr.map((o) => f(o, i++))
1694 ))
1695 }))
1696
1697/**
1698 * Maps both the failure and success channels of a stream.
1699 *
1700 * **Example** (Mapping both the failure and success channels of a stream)
1701 *
1702 * ```ts import.meta.vitest
1703 * import { Effect, Stream } from "effect"
1704 *
1705 * const mapper = {
1706 * onFailure: (error: string) => `error: ${error}`,
1707 * onSuccess: (value: number) => value * 2
1708 * }

Callers

nothing calls this directly

Calls 6

syncMethod · 0.80
doneMethod · 0.80
fromPullFunction · 0.70
loopFunction · 0.70
fFunction · 0.50
succeedMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…