A bus factory that allows a bus to be wrapped in an Option.
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 errorsconsole.log(await optionalNumber.deserialize(null)); // => IORight containing `None` Copy
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 errorsconsole.log(await optionalNumber.deserialize(null)); // => IORight containing `None`
Inner bus' input. This is widened to I | null | undefined in the newly created bus.
I | null | undefined
Inner bus' output. This is transformed to Option<O> in the newly created bus.
Option<O>
Generated using TypeDoc
A bus factory that allows a bus to be wrapped in an Option.
Example