UNPKG

banggood-store

Version:

bang data store

55 lines (53 loc) 1.48 kB
/** * JsonProperty * * @function * @property {IDecoratorMetaData<T>|string} metadata, encapsulate it to DecoratorMetaData for standard use * @return {(target:Object, targetKey:string | symbol)=> void} decorator function */ export declare function JsonProperty<T>(metadata?: IDecoratorMetaData<T> | string): (target: Object, targetKey: string | symbol) => void; /** * deserialize * * @function * @param {{new():T}} clazz, class type which is going to initialize and hold a mapping json * @param {Object} json, input json object which to be mapped * * @return {T} return mapped object */ export declare function MapperEntity<T extends IGenericObject>(Clazz: { new (): T; }, json: IGenericObject): T; /** * IDecoratorMetaData<T> * DecoratorConstraint * * @interface * @property {ICustomConverter} customConverter, will be used for mapping the property, if specified * @property {boolean} excludeToJson, will exclude the property for serialization, if true */ export interface IDecoratorMetaData<T> { name?: string; clazz?: { new (): T; }; customConverter?: ICustomConverter; excludeToJson?: boolean; } /** * provide interface to indicate the object is allowed to be traversed * * @interface */ export interface IGenericObject { [key: string]: any; } /** * When custom mapping of a property is required. * * @interface */ export interface ICustomConverter { fromJson(data: any): any; toJson(data: any): any; }