| 1739 | * |
| 1740 | * **When to use** |
| 1741 | * |
| 1742 | * Use when you need to pass an `Option` to array-based APIs or spread optional |
| 1743 | * values into collections. |
| 1744 | * |
| 1745 | * **Details** |
| 1746 | * |
| 1747 | * - `Some` → single-element array `[value]` |
| 1748 | * - `None` → empty array `[]` |
| 1749 | * |
| 1750 | * **Example** (Converting to an array) |
| 1751 | * |
| 1752 | * ```ts import.meta.vitest |
| 1753 | * import { Option } from "effect" |
| 1754 | * |
| 1755 | * Option.toArray(Option.some(1)) // => [1] |
| 1756 | * Option.toArray(Option.none()) // => [] |
| 1757 | * ``` |
| 1758 | * |
| 1759 | * @see {@link fromIterable} for the inverse direction |
| 1760 | * |
| 1761 | * @category converting |
| 1762 | * @since 2.0.0 |
| 1763 | */ |
| 1764 | export const toArray = <A>(self: Option<A>): Array<A> => isNone(self) ? [] : [self.value] |
| 1765 | |
| 1766 | /** |
| 1767 | * Splits an `Option` into two `Option`s using a function that returns a `Result`. |