-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathvarsUser.ts
More file actions
30 lines (26 loc) · 793 Bytes
/
varsUser.ts
File metadata and controls
30 lines (26 loc) · 793 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
30
import { wrapper } from "./decorators.ts";
@wrapper
export class VarsUser {
_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);
}
}