const { log, clear } = console;
clear();
log('=================================================');
const add2 = (x, y) => x + y;
const add2P = (x, y) => Promise.resolve(x + y);
const logFn = fn => async (...args) => {
const rtn = await fn(...args);
log(`arguments: [${args.join(', ')}]`);
log(`result: ${rtn}`);
return rtn;
}
const logAdd2 = logFn(add2);
logAdd2(6, 4);
// // logs -> arguments: [1, 1]
// // logs -> result: 2
// // returns -> 2
const logAdd2P = logFn(add2P);
logAdd2P(2, 5);
// // logs -> arguments: [2, 5]
// // logs -> result: 7
// // returns -> Promise<7>