/**
 * Creates a deferred promise, allowing manual control over its resolution or rejection.
 * @returns {{
 *   promise: Promise<any>;
 *   resolve: (value?: any) => void;
 *   reject: (reason?: any) => void;
 * }}
 */
export function createDeferredPromise(): {
    promise: Promise<any>;
    resolve: (value?: any) => void;
    reject: (reason?: any) => void;
}
{
    let resolve: (value?: any) => void;
    let reject: (reason?: any) => void;

    const promise = new Promise<any>((res, rej) =>
    {
        resolve = res;
        reject = rej;
    });

    return {
        promise, // The actual promise object
        resolve, // Method to manually resolve the promise
        reject, // Method to manually reject the promise
    };
}
