Package: effect
Module: Optic
Returns a function that extracts all elements focused by a
Traversal as a plain mutable array.
When to use
Use when you need the focused values as a simple Array<A> for further
processing.
Details
Example (Collecting positive numbers)
import { Optic, Schema } from "effect"
type S = { readonly values: ReadonlyArray<number> }
const _pos = Optic.id<S>()
.key("values")
.forEach((n) => n.check(Schema.isGreaterThan(0)))
const getPositive = Optic.getAll(_pos)
console.log(getPositive({ values: [3, -1, 5] }))
// Output: [3, 5]
console.log(getPositive({ values: [-1, -2] }))
// Output: []
See
Traversal — the optic type this operates onSignature
declare const getAll: <S, A>(traversal: Traversal<S, A>) => (s: S) => Array<A>
Since v4.0.0