-
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy path3-class.js
More file actions
29 lines (24 loc) · 482 Bytes
/
Copy path3-class.js
File metadata and controls
29 lines (24 loc) · 482 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
'use strict';
class Result {
then(onFulfilled) {
this.onFulfilled = onFulfilled;
}
ready(data) {
if (this.onFulfilled) this.onFulfilled(data);
}
}
class Security {
static getPerson(id) {
const res = new Result();
setTimeout(() => {
const person = { id, name: 'Marcus Aurelius' };
res.ready(person);
}, 1000);
return res;
}
}
// Usage
(async () => {
const person = await Security.getPerson(10);
console.dir({ person });
})();