Refactor serialization

This commit is contained in:
schmelczerandras 2020-10-07 10:04:05 +02:00
parent 8e44dd3733
commit b3da27e73b
35 changed files with 142 additions and 133 deletions

View file

@ -0,0 +1,8 @@
export const serialize = (object): string => {
return JSON.stringify(object, (_, value) => {
if (value?.__serializable_type) {
return [value.__serializable_type, ...value.toArray()];
}
return value?.toFixed ? Number(value.toFixed(3)) : value;
});
};