Open History to see the last commit
1export async function sleep(ms: number) {
2 return new Promise((resolve) => setTimeout(resolve, ms))
3}
4β
5export interface StoredUser {
6 firstName: string
7 lastName: string
8}
9β
10class DB {
11 private data: StoredUser = {
12 firstName: 'FirstName',
13 lastName: 'LastName',
14 }
15β
16 async getData(): Promise<StoredUser> {
17 await sleep(1000)
18 return { ...this.data }
19 }
20β
21 async saveUser(value: StoredUser) {
22 await sleep(1000)
23 this.data = value
24 return value
25 }
26}
27β
28export const db = new DB()