• A bus factory that allows a bus to be wrapped in an Option.

    Example

    import * as io from "@prelude-io/core";

    const optionalNumber = io.Optional(io.number);

    console.log(await optionalNumber.deserialize(1)); // => IORight containing `Some(1)`
    console.log(await optionalNumber.deserialize("one")); // => IOLeft containing errors
    console.log(await optionalNumber.deserialize(null)); // => IORight containing `None`

    Type Parameters

    • I

      Inner bus' input. This is widened to I | null | undefined in the newly created bus.

    • O

      Inner bus' output. This is transformed to Option<O> in the newly created bus.

    Parameters

    • innerBus: Bus<I, O>
    • name: string = ...

    Returns Bus<I, Option<O>>

Generated using TypeDoc