import * as tsplus_module_1 from "@tsplus/stdlib/collections/Chunk/single";
import * as tsplus_module_2 from "@tsplus/stdlib/data/Tuple/make";
import * as tsplus_module_3 from "@effect/core/stream/Stream/operations/paginateChunk";
/**
 * Like `unfold`, but allows the emission of values to end one step further than
 * the unfolding of the state. This is useful for embedding paginated APIs,
 * hence the name.
 *
 * @tsplus static ets/Stream/Ops paginate
 */

export function paginate(s, f, __tsplusTrace) {
  return tsplus_module_3.paginateChunk(s, s => {
    const {
      tuple: [a, maybeS]
    } = f(s);
    return tsplus_module_2.make(tsplus_module_1.single(a), maybeS);
  }, __tsplusTrace);
}
//# sourceMappingURL=paginate.mjs.map