Package: effect
Module: Option
Combines a primary Option with an iterable of Options into a tuple if
all are Some.
When to use
Use when you need several Option values of the same type to all be Some
and return them as a non-empty tuple.
Details
Some → Some([self.value, ...rest])None → NoneExample (Combining many Options)
import { Option } from "effect"
const first = Option.some(1)
const rest = [Option.some(2), Option.some(3)]
console.log(Option.productMany(first, rest))
// Output: { _id: 'Option', _tag: 'Some', value: [1, 2, 3] }
console.log(Option.productMany(first, [Option.some(2), Option.none()]))
// Output: { _id: 'Option', _tag: 'None' }
See
product for combining exactly twoall for tuples, structs, and iterablesSignature
declare const productMany: <A>(self: Option<A>, collection: Iterable<Option<A>>) => Option<[A, ...Array<A>]>
Since v2.0.0