MCPcopy Create free account
hub / github.com/effect-app/libs / all

Function all

repos/effect/packages/effect/src/Option.ts:1741–1764  ·  view source on GitHub ↗
(
    input: Iterable<Option<any>> | Record<string, Option<any>>
  )

Source from the content-addressed store, hash-verified

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 */
1764export 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`.

Callers

nothing calls this directly

Calls 4

isNoneFunction · 0.85
pushMethod · 0.80
noneFunction · 0.70
someFunction · 0.70

Tested by

no test coverage detected