source: trip-planner-front/node_modules/webpack/lib/util/makeSerializable.js@ 8d391a1

Last change on this file since 8d391a1 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 640 bytes
Line 
1/*
2 MIT License http://www.opensource.org/licenses/mit-license.php
3*/
4
5"use strict";
6
7const { register } = require("./serialization");
8
9class ClassSerializer {
10 constructor(Constructor) {
11 this.Constructor = Constructor;
12 }
13
14 serialize(obj, context) {
15 obj.serialize(context);
16 }
17
18 deserialize(context) {
19 if (typeof this.Constructor.deserialize === "function") {
20 return this.Constructor.deserialize(context);
21 }
22 const obj = new this.Constructor();
23 obj.deserialize(context);
24 return obj;
25 }
26}
27
28module.exports = (Constructor, request, name = null) => {
29 register(Constructor, request, name, new ClassSerializer(Constructor));
30};
Note: See TracBrowser for help on using the repository browser.