-
Notifications
You must be signed in to change notification settings - Fork 13
/
decorators.ts
34 lines (32 loc) · 949 Bytes
/
decorators.ts
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
/** A decorator for locking down a method */
export function locked() {
return function _locked(
target: unknown,
propertyKey: string,
descriptor: PropertyDescriptor
): void {
descriptor.configurable = false;
descriptor.enumerable = false;
descriptor.writable = false;
};
}
/** A decorator making changing the changing configurable property */
export function configurable(value: boolean) {
return function _configurable(
target: unknown,
propertyKey: string,
descriptor: PropertyDescriptor
): void {
descriptor.configurable = value;
};
}
/** A decorator for making a method enumerable or none-enumerable */
export function enumerable(enabled = true) {
return function _enumerable(
target: unknown,
propertyKey: string,
descriptor: PropertyDescriptor
): void {
descriptor.enumerable = enabled;
};
}