effect-io-ai

Package: effect
Module: Option

Option.fromNullable

Converts a nullable value into an Option. Returns None if the value is null or undefined, otherwise wraps the value in a Some.

Example

import { Option } from "effect"

console.log(Option.fromNullable(undefined))
// Output: { _id: 'Option', _tag: 'None' }

console.log(Option.fromNullable(null))
// Output: { _id: 'Option', _tag: 'None' }

console.log(Option.fromNullable(1))
// Output: { _id: 'Option', _tag: 'Some', value: 1 }

Signature

declare const fromNullable: <A>(nullableValue: A) => Option<NonNullable<A>>

Source

Since v2.0.0