UNPKG

@safejs/serializer

Version:

Serializer is a superset of JSON that includes recursive objects, dates, regular expressions, functions and others which you also can expand by yourself

8 lines (6 loc) 279 B
import { ExtraSerializer } from "../../types"; export const functionSerializer: ExtraSerializer<(...v: any[]) => any, string> = { determine: (v) => typeof v === "function", serialize: (v) => v.toString(), deserialize: (v) => new Function(`return ${v}`)(), };