// ets_tracing: off import type * as E from "../../../../Either/index.js" import * as Tp from "../../Tuple/index.js" import * as Chunk from "../core.js" import { forEach_ } from "./forEach.js" /** * Partitions the elements of this chunk into two chunks using the specified * function. */ export function partitionMap_( self: Chunk.Chunk, f: (a: A) => E.Either ): Tp.Tuple<[Chunk.Chunk, Chunk.Chunk]> { let bs = Chunk.empty() let cs = Chunk.empty() forEach_(self, (a) => { const x = f(a) if (x._tag === "Left") { bs = Chunk.append_(bs, x.left) } else { cs = Chunk.append_(cs, x.right) } }) return Tp.tuple(bs, cs) } /** * Partitions the elements of this chunk into two chunks using the specified * function. * * @ets_data_first partitionMap_ */ export function partitionMap( f: (a: A) => E.Either ): (self: Chunk.Chunk) => Tp.Tuple<[Chunk.Chunk, Chunk.Chunk]> { return (self) => partitionMap_(self, f) }