leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

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 };