leetcodeSolution to some Leetcode problems written in C++ |
git clone git://git.dimitrijedobrota.com/leetcode.git |
Log | Files | Refs | README | LICENSE |
2637.js (329B)
0 /**
1 * @param {Function} fn
2 * @param {number} t
3 * @return {Function}
4 */
6 var timeLimit = function(fn, t) {
7 return async function(...args) {
8 return new Promise((resolve, reject) => {
9 setTimeout(() => {
10 reject("Time Limit Exceeded");
11 }, t);
12 fn(...args).then(resolve).catch(reject);
13 })
14 }
15 };