Skip to content

Commit 3bcd765

Browse files
committed
added
1 parent 8254bf7 commit 3bcd765

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

AsyncFunction.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
// Given an array of asynchronous functions functions, return a new promise promise. Each function in the array accepts no arguments and returns a promise. All the promises should be executed in parallel.
2+
3+
// promise resolves:
4+
5+
// When all the promises returned from functions were resolved successfully in parallel. The resolved value of promise should be an array of all the resolved values of promises in the same order as they were in the functions. The promise should resolve when all the asynchronous functions in the array have completed execution in parallel.
6+
// promise rejects:
7+
8+
// When any of the promises returned from functions were rejected. promise should also reject with the reason of the first rejection.
9+
// Please solve it without using the built-in Promise.all function.
10+
111
var promiseAll = function (functions) {
212
return new Promise((res, rej) => {
313
const result = [];

Debounce.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
// Given a function fn and a time in milliseconds t, return a debounced version of that function.
2+
3+
// A debounced function is a function whose execution is delayed by t milliseconds and whose execution is cancelled if it is called again within that window of time. The debounced function should also receive the passed parameters.
4+
5+
// For example, let's say t = 50ms, and the function was called at 30ms, 60ms, and 100ms.
6+
7+
// The first 2 function calls would be cancelled, and the 3rd function call would be executed at 150ms.
8+
9+
// If instead t = 35ms, The 1st call would be cancelled, the 2nd would be executed at 95ms, and the 3rd would be executed at 135ms.
10+
11+
112
var debounce = function (fn, t) {
213
let timerId = undefined
314
return function (...args) {

Is Object Empty.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
// Given an object or an array, return if it is empty.
2+
3+
// An empty object contains no key-value pairs.
4+
// An empty array contains no elements.
5+
// You may assume the object or array is the output of JSON.parse.
6+
17
var isEmpty = function (obj) {
28
if (Object.keys(obj).length === 0) {
39
return true;

0 commit comments

Comments
 (0)