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) 286 B
import { ExtraSerializer } from "../../types"; export const regExpSerializer: ExtraSerializer<RegExp, [string, string]> = { determine: (v) => v instanceof RegExp, serialize: (v) => [v.source, v.flags], deserialize: ([source, flags]) => new RegExp(source, flags), };