UNPKG

any-serialize

Version:

Serialize / Deserialize any JavaScript objects, as long as you provides how-to. I have already provided `Date`, `RegExp`, `Set` and `Function`.

21 lines (20 loc) 485 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.MongoDateAdapter = { prefix: '', key: '$date', item: Date, fromJSON: (current) => new Date(current) }; exports.MongoRegExpAdapter = { prefix: '', key: '$regex', item: RegExp, fromJSON(current, parent) { return new RegExp(current, parent.$options); }, toJSON(_this, parent) { parent.$options = _this.flags; return _this.source; } };