32 lines
740 B
TypeScript
32 lines
740 B
TypeScript
import 'reflect-metadata';
|
|
|
|
export function ObjectProperty(): PropertyDecorator {
|
|
return (target, propertyKey): void => {
|
|
let properties: Array<string> = Reflect.getOwnMetadata(
|
|
'properties',
|
|
target,
|
|
);
|
|
|
|
if (!properties) {
|
|
Reflect.defineMetadata('properties', (properties = []), target);
|
|
}
|
|
|
|
properties.push(String(propertyKey));
|
|
};
|
|
}
|
|
|
|
export function ObjectPropertyExclude(): PropertyDecorator {
|
|
return (target, propertyKey): void => {
|
|
let excluded: Array<string> = Reflect.getOwnMetadata(
|
|
'excludedProperties',
|
|
target,
|
|
);
|
|
|
|
if (!excluded) {
|
|
Reflect.defineMetadata('excludedProperties', (excluded = []), target);
|
|
}
|
|
|
|
excluded.push(String(propertyKey));
|
|
};
|
|
}
|