import { Serializer } from "./serializers"; /** * An optional value of type T. * * Construct using [[Optional.of]] or [[Optional.empty]]. * * Collabs uses this utility type in places where `T | undefined` or * `T | null` is inappropriate because T may itself be * null/undefined. * * Local data structure - not a [[Collab]]. */ export declare class Optional { /** Whether the value is present. */ readonly isPresent: boolean; private readonly valueIfPresent; private constructor(); /** * Returns the value if present, else throwing an error. */ get(): T; /** * Returns the value if present, else returning other. */ orElse(other: T): T; /** * Map the value by f if present, else returning an empty Optional. * @param f [description] * @return [description] */ map(f: (value: T) => U): Optional; toString(): string; private static emptyInstance; /** * Returns an empty (not present) Optional. * * Internally, all empty Optionals are the same literal object. */ static empty(): Optional; /** * Returns a new present Optional representing value. */ static of(value: T): Optional; } /** * Serializes [[Optional]]`` using a serializer for T. * This is slightly more efficient * than [[DefaultSerializer]], and it works with arbitrary T. * * Construct using [[getInstance]]. */ export declare class OptionalSerializer implements Serializer> { private readonly valueSerializer; private constructor(); serialize(value: Optional): Uint8Array; deserialize(message: Uint8Array): Optional; private static cache; /** * Returns an instance of [[OptionalSerializer]] that uses valueSerializer * to serialize present values. * * This method may cache instances internally to save memory. */ static getInstance(valueSerializer: Serializer): OptionalSerializer; }