-
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy path2-usage.js
More file actions
20 lines (17 loc) · 345 Bytes
/
Copy path2-usage.js
File metadata and controls
20 lines (17 loc) · 345 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
'use strict';
const getPerson = (id) => {
const thenable = {
then(onFulfilled) {
setTimeout(() => {
const person = { id, name: 'Marcus Aurelius' };
onFulfilled(person);
}, 1000);
},
};
return thenable;
};
// Usage
(async () => {
const person = await getPerson(10);
console.dir({ person });
})();