-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathinfosUser.ts
More file actions
59 lines (51 loc) · 1.51 KB
/
infosUser.ts
File metadata and controls
59 lines (51 loc) · 1.51 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import { wrapper } from "./decorators.ts";
@wrapper
export class InfosUser {
_dados: Record<string, any> = {};
get(p: { chave: string }): Promise<any | undefined> {
if (!p.chave) {
return Promise.reject("Parametro chave obrigatorio");
}
return Promise.resolve(this._dados[p.chave]);
}
set(p: { chave: string; conteudo: any }): Promise<boolean> {
if (!p.chave) {
return Promise.reject("Parametro chave obrigatorio");
}
this._dados[p.chave] = p.conteudo;
return Promise.resolve(true);
}
delete(p: { chave: string }): Promise<boolean> {
if (!p.chave) {
return Promise.reject("Parametro chave obrigatorio");
}
const existe = p.chave in this._dados;
delete this._dados[p.chave];
return Promise.resolve(existe);
}
}
@wrapper
export class InfosRobo {
_dados: Record<string, any> = {};
get(p: { chave: string }): Promise<any | undefined> {
if (!p.chave) {
return Promise.reject("Parametro chave obrigatorio");
}
return Promise.resolve(this._dados[p.chave]);
}
set(p: { chave: string; conteudo: any }): Promise<boolean> {
if (!p.chave) {
return Promise.reject("Parametro chave obrigatorio");
}
this._dados[p.chave] = p.conteudo;
return Promise.resolve(true);
}
delete(p: { chave: string }): Promise<boolean> {
if (!p.chave) {
return Promise.reject("Parametro chave obrigatorio");
}
const existe = p.chave in this._dados;
delete this._dados[p.chave];
return Promise.resolve(existe);
}
}