effect-io-ai

Package: effect
Module: Array

Array.fromOption

Converts an Option to an array: Some(a) becomes [a], None becomes [].

When to use

Use to convert a single Option into an array for downstream array operations.

Example (Converting an Option to an array)

import { Array, Option } from "effect"

console.log(Array.fromOption(Option.some(1))) // [1]
console.log(Array.fromOption(Option.none())) // []

See

Signature

declare const fromOption: <A>(self: Option.Option<A>) => Array<A>

Source

Since v2.0.0