mirror of
https://github.com/swc-project/swc.git
synced 2024-12-21 04:32:01 +03:00
44 lines
806 B
JavaScript
44 lines
806 B
JavaScript
function resolveAfter2Seconds(x) {
|
|
return new Promise(resolve => {
|
|
setTimeout(() => {
|
|
resolve(x);
|
|
}, 2000);
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Add a number.
|
|
* @param {number} x - The number to add.
|
|
*/
|
|
async function add(x) {
|
|
var a = resolveAfter2Seconds(20);
|
|
var b = resolveAfter2Seconds(30);
|
|
return x + await a + await b;
|
|
}
|
|
|
|
/**
|
|
* Subtract a number.
|
|
* @param {number} x - The number to subtract.
|
|
*/
|
|
var subtract = async function subtract(x) {
|
|
var a = resolveAfter2Seconds(20);
|
|
var b = resolveAfter2Seconds(30);
|
|
return await a + await b - x;
|
|
}
|
|
|
|
/**
|
|
* Adder class.
|
|
*/
|
|
class Adder {
|
|
/**
|
|
* Construct an Adder instance.
|
|
*/
|
|
constructor() {}
|
|
|
|
/**
|
|
* Add a number.
|
|
* @param {number} x - The number to add.
|
|
*/
|
|
async add(x) {}
|
|
}
|