2637.js (329B)
1 /** 2 * @param {Function} fn 3 * @param {number} t 4 * @return {Function} 5 */ 6 7 var timeLimit = function(fn, t) { 8 return async function(...args) { 9 return new Promise((resolve, reject) => { 10 setTimeout(() => { 11 reject("Time Limit Exceeded"); 12 }, t); 13 fn(...args).then(resolve).catch(reject); 14 }) 15 } 16 };