Function create_promise

  • A nicer way to create promises. No-one can disagree.

    Type Parameters

    • T

    Returns [Promise<T>, ((data) => void), ((error) => void)]

    Example

    const [promise, res, rej] = create_promise();

    (async () => {
    console.log(await promise);
    })();

    if (Math.random() > 0.5) {
    res("Hello, world!");
    } else {
    rej(new Error());
    }

Generated using TypeDoc