Skip to content

Commit f6656a9

Browse files
committed
Use async function instead of IIFE
1 parent 252e719 commit f6656a9

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

JavaScript/Tasks/5-reject.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const electronics = [
2424
{ name: 'HDMI cable', price: 10 },
2525
];
2626

27-
(async () => {
27+
const main = async () => {
2828
const items = iterate(electronics);
2929
const item1 = await items.next();
3030
console.log(item1);
@@ -34,4 +34,6 @@ const electronics = [
3434
console.log(item3);
3535
const item4 = await items.next();
3636
console.log(item4);
37-
})();
37+
};
38+
39+
main();

JavaScript/d-resolvers.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,12 @@ const sumAsync = (a, b, callback) => {
3737

3838
// New approach
3939

40-
(async () => {
40+
const main = async () => {
4141
const { promise, resolve, reject } = Promise.withResolvers();
4242
setTimeout(reject, 1000, new Error('Timed out'));
4343
sumAsync(6, 7, resolve);
4444
const result = await promise;
4545
console.log({ result });
46-
})();
46+
};
47+
48+
main();

0 commit comments

Comments
 (0)