Vana SDK - v2.2.2
    Preparing search index...

    Type Alias MaybePromise<T>

    MaybePromise: T | Promise<T>

    Creates a type that accepts either T or a Promise

    Type Parameters

    • T

    This utility type is useful for functions that can work with both synchronous and asynchronous values. It allows flexible APIs that can accept immediate values or promises that resolve to those values.

    // Function that accepts either a value or a promise of that value
    async function processData(data: MaybePromise<string>): Promise<string> {
    // await works on both promises and regular values
    const resolved = await data;
    return resolved.toUpperCase();
    }

    // Both calls are valid:
    processData('hello'); // Synchronous value
    processData(Promise.resolve('world')); // Asynchronous value

    // Common use case in SDK callbacks
    interface StorageProvider {
    // Provider can implement sync or async file reading
    read(path: string): MaybePromise<Buffer>;
    }