/** * Separate elements based on a map function that also exposes the index of the * element. * * @tsplus static Chunk.Aspects partitionMapWithIndex * @tsplus pipeable Chunk partitionMapWithIndex */ export function partitionMapWithIndex(f: (i: number, a: A) => Either) { return (self: Chunk): readonly [Chunk, Chunk] => { const left: Array = [] const right: Array = [] for (let i = 0; i < self.length; i++) { const e = f(i, self.unsafeGet(i)) if (e._tag === "Left") { left.push(e.left) } else { right.push(e.right) } } return [Chunk.from(left), Chunk.from(right)] } }