commit 4516e1c87425148e4e5bb8c168a02971491ed9bd
parent d0cb66a4645312979c03b4b2bedbf564bae324fe
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date: Tue, 16 May 2023 20:56:18 +0200
JavaScript Challenge: Day 12
Diffstat:
2 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/Problems/2637.js b/Problems/2637.js
@@ -0,0 +1,16 @@
+/**
+ * @param {Function} fn
+ * @param {number} t
+ * @return {Function}
+ */
+
+var timeLimit = function(fn, t) {
+ return async function(...args) {
+ return new Promise((resolve, reject) => {
+ setTimeout(() => {
+ reject("Time Limit Exceeded");
+ }, t);
+ fn(...args).then(resolve).catch(reject);
+ })
+ }
+};
diff --git a/README.md b/README.md
@@ -548,6 +548,7 @@ for solving problems.
| 2632 | Medium | [Curry](Problems/2632.js) |
| 2634 | Easy | [Filter Elements from Array](Problems/2634.js) |
| 2635 | Easy | [Apply Transform Over Each Element in Array](Problems/2635.js) |
+| 2637 | Easy | [Promise Time Limit](Problems/2637.js) |
| 2665 | Easy | [Counter II](Problems/2665.js) |
| 2666 | Easy | [Allow One Function Call](Problems/2666.js) |
| 2667 | Easy | [Create Hello World Function](Problems/2667.js) |