effect-io-ai

Package: effect
Module: Option

Option.zipWith

Combines two Options using a provided function.

When to use

Use when you need to combine two present Option values into a computed result.

Details

Example (Combining with a function)

import { Option } from "effect"

const person = Option.zipWith(
  Option.some("John"),
  Option.some(25),
  (name, age) => ({ name: name.toUpperCase(), age })
)

console.log(person)
// Output:
// { _id: 'Option', _tag: 'Some', value: { name: 'JOHN', age: 25 } }

See

Signature

declare const zipWith: { <B, A, C>(that: Option<B>, f: (a: A, b: B) => C): (self: Option<A>) => Option<C>; <A, B, C>(self: Option<A>, that: Option<B>, f: (a: A, b: B) => C): Option<C>; }

Source

Since v2.0.0