swc/ecmascript/jsdoc/tests/fixtures/asyncfunction.js
2020-08-14 18:20:25 +09:00

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) {}
}