@adviser/cement - v0.0.0
    Preparing search index...

    Class Some<T>

    Option type for representing values that may or may not exist.

    Option is a type-safe way to handle nullable values, similar to Rust's Option type. It forces explicit handling of both present (Some) and absent (None) cases without using null or undefined.

    function findUser(id: string): Option<User> {
    const user = users.find(u => u.id === id);
    return user ? Option.Some(user) : Option.None();
    }

    const result = findUser('123');
    if (result.IsSome()) {
    console.log('Found user:', result.Unwrap());
    } else {
    console.log('User not found');
    }

    // Or use From to convert from nullable
    const maybeUser = Option.From(users[0]); // Some if exists, None if undefined

    Type Parameters

    • T

      The type of the value when present

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    _t: T

    Methods