UNPKG

@tsed/json-mapper

Version:
25 lines (24 loc) 446 B
import { JsonEntityFn } from "@tsed/schema"; /** * Call the function before property serialization. * * ### Example * * ```typescript * class Model { * @OnSerialize(v => v + 1) * property: string; * } * ``` * * @returns {Function} * @decorator * @schema * @property * @param cb */ export function OnSerialize(cb) { return JsonEntityFn((storedJson) => { storedJson.schema.$hooks.on("onSerialize", cb); }); }