plainfp - v0.1.0
    Preparing search index...

    Function fromNullable

    • Lift a nullable value into a Result. null and undefined become err(onNullish); any other value becomes ok.

      Type Parameters

      • T
      • E

      Parameters

      • value: T | null | undefined
      • onNullish: E

      Returns ResultType<NonNullable<T>, E>

      const findUser = (id: string) =>
      fromNullable(users.get(id), { code: "NOT_FOUND", id })