-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
55 lines (55 loc) · 1.17 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
let add = function (num1, num2) {
return new Promise((resolve, reject) => {
try {
const sum = num1 + num2;
setTimeout(function () { resolve(sum); }, 0);
}
catch (e) {
reject(e);
}
});
};
let subtract = function (num1, num2) {
return new Promise((resolve, reject) => {
try {
const difference = num1 - num2;
setTimeout(function () { resolve(difference); }, 0);
}
catch (e) {
reject(e);
}
});
};
let multiply = function (num1, num2) {
return new Promise((resolve, reject) => {
try {
const product = num1 * num2;
setTimeout(function () { resolve(product); }, 0);
}
catch (e) {
reject(e);
}
});
};
let divide = function (num1, num2) {
return new Promise((resolve, reject) => {
try {
const quotient = num1 / num2;
setTimeout(function () { resolve(quotient); }, 0);
}
catch (e) {
reject(e);
}
});
};
let shootMe = function () {
return new Promise((resolve, reject) => {
try {
setTimeout(() => { resolve("bang"); }, 0);
}
catch (e) {
reject(e);
}
});
};
module.exports = { add, subtract, multiply, divide, shootMe };