| 123456789101112131415161718192021222324 |
- import { AnyJson, DataPersisterArgs } from '~/types/interfaces'
- import { denormalizers } from '~/services/serializer/denormalizer/_import'
- import { normalizers } from '~/services/serializer/normalizer/_import'
- import { DENORMALIZER_TYPE } from '~/types/enums'
- class Serializer {
- public static normalize (args:DataPersisterArgs) {
- for (const Normalizer of normalizers) {
- if (Normalizer.support(args.type)) {
- return Normalizer.normalize(args)
- }
- }
- }
- public static denormalize (data: AnyJson, type: DENORMALIZER_TYPE): any {
- for (const Denormalizer of denormalizers) {
- if (Denormalizer.support(type)) {
- return Denormalizer.denormalize(data)
- }
- }
- }
- }
- export default Serializer
|