1
0

Better organization of tests & other files

This commit is contained in:
2020-03-06 12:00:39 -05:00
parent d0eac56e50
commit 6c101bb7b2
6 changed files with 67 additions and 68 deletions

18
src/decorators/pluck.ts Normal file
View File

@@ -0,0 +1,18 @@
export const PLUCK_PROPERTIES_KEY = 'serde:pluck_properties';
/**
* Adding this decorator allows for plucking out an T[] or {T: v}[]
*
* @param field - use 'fieldName' when creating string|number[],
* use ['fieldName'] when creating {[fieldName]: value}[]
*/
export function Pluck(field: string | string[]): Function {
return function (target: any, key: string): void {
Reflect.defineMetadata(PLUCK_PROPERTIES_KEY, {
...Reflect.getMetadata(PLUCK_PROPERTIES_KEY, target) || {},
...{ [key]: field }
}, target);
};
}
/* tslint:enable:variable-name */