import { fs, promisify } from '@empathize/framework';
// Call one function async
promisify(async () => {
const files = await fs.files('my_folder');
console.log(files);
});
// Wait for promise result
promisify(new Promise((resolve) => {
setTimeout(() => {
resolve('Hello, World!');
}, 3000);
})).then(console.log);
// Call several functions async
promisify({
callbacks: [
() => console.log(1),
() => console.log(2),
() => console.log(3)
]
});
// Call several functions async together
promisify({
callbacks: [
() => console.log(1),
() => console.log(2),
() => console.log(3)
],
callAtOnce: true
});
// Sum several callbacks results
promisify({
callbacks: [
() => 1,
() => 2,
() => 3
]
}).then((results) => {
// 1 + 2 + 3 = 6
console.log(results[0] + results[1] + results[2]);
});