// ets_tracing: off
import * as CK from "../../../Collections/Immutable/Chunk";
import * as T from "../../../Effect";
import { pipe } from "../../../Function";
import * as Chain from "./chain";
import * as FoldUntil from "./foldUntil";
import * as FromEffect from "./fromEffect";
import * as Map from "./map";
/**
 * A sink that collects first `n` elements into a chunk. Note that the chunk
 * is preallocated and must fit in memory.
 */

export function collectAllN(n) {
  return Map.map_(Chain.chain_(FromEffect.fromEffect(T.succeedWith(() => CK.builder())), cb => FoldUntil.foldUntil(cb, n, (s, in_) => s.append(in_))), _ => _.build());
}
//# sourceMappingURL=collectAllN.js.map