Package: effect
Module: Option
Converts a possibly null value into an Option, leaving undefined
as a valid Some.
When to use
Use when you want to treat only null as absent while preserving
undefined as a meaningful value.
Details
null → Noneundefined) → SomeExample (Converting possibly null values to an Option)
import { Option } from "effect"
console.log(Option.fromNullOr(null))
// Output: { _id: 'Option', _tag: 'None' }
console.log(Option.fromNullOr(undefined))
// Output: { _id: 'Option', _tag: 'Some', value: undefined }
console.log(Option.fromNullOr(42))
// Output: { _id: 'Option', _tag: 'Some', value: 42 }
See
fromNullishOr to treat both null and undefined as absentfromUndefinedOr to only treat undefined as absentSignature
declare const fromNullOr: <A>(a: A) => Option<Exclude<A, null>>
Since v4.0.0