diff --git a/.changeset/gold-doors-wish.md b/.changeset/gold-doors-wish.md new file mode 100644 index 00000000000..ea03a8eae9d --- /dev/null +++ b/.changeset/gold-doors-wish.md @@ -0,0 +1,5 @@ +--- +"effect": patch +--- + +Add `Chunk.getSomes` diff --git a/packages/effect/src/Chunk.ts b/packages/effect/src/Chunk.ts index 8afd6da9f17..4fb4ff819da 100644 --- a/packages/effect/src/Chunk.ts +++ b/packages/effect/src/Chunk.ts @@ -1493,3 +1493,10 @@ export const difference: { 2, (self: Chunk, that: Chunk): Chunk => unsafeFromArray(RA.difference(that, self)) ) + +/** + * @category filtering + * @since 3.20.0 + */ +export const getSomes: (self: Chunk>) => Chunk = (self) => + unsafeFromArray(RA.getSomes(toReadonlyArray(self))) diff --git a/packages/effect/test/Chunk.test.ts b/packages/effect/test/Chunk.test.ts index 55d8de45fe4..02fb869ca3c 100644 --- a/packages/effect/test/Chunk.test.ts +++ b/packages/effect/test/Chunk.test.ts @@ -887,4 +887,9 @@ describe("Chunk", () => { assertEquals(Chunk.difference(curr, Chunk.empty()), Chunk.empty()) assertEquals(Chunk.difference(curr, curr), Chunk.empty()) }) + + it("getSomes", () => { + assertEquals(Chunk.getSomes(Chunk.empty()), Chunk.empty()) + assertEquals(Chunk.getSomes(Chunk.make(Option.some(1), Option.none())), Chunk.of(1)) + }) })