function promiseTimeout(prom, ms) {
    let id;
    const timeout = new Promise((_, reject)=>{
        id = setTimeout(()=>{
            reject(new Error('Promise timed out.'));
        }, ms);
    });
    return Promise.race([
        prom,
        timeout
    ]).then((value)=>{
        clearTimeout(id);
        return value;
    });
}
export { promiseTimeout };
