UNPKG

@ima/plugin-http-client

Version:

Generic http client for the IMA application framework.

28 lines (27 loc) 924 B
import { BaseMapper } from './BaseMapper'; import { EntityMapper } from './EntityMapper'; /** * EntityListMapper transform array of object into entity property with array of entities. */ export class EntityListMapper extends BaseMapper { #entityMapper; /** * Creates a mapper with the specified entity that is used for the transformation of a field containing array of objects. * @param entity */ constructor(entity){ super(); this.#entityMapper = new EntityMapper(entity); } deserialize(data) { if (!data || !Array.isArray(data)) { return data; } return data.map((entity)=>this.#entityMapper.deserialize(entity)); } serialize(data) { if (!data || !Array.isArray(data)) { return data; } return data.map((item)=>this.#entityMapper.serialize(item)); } } //# sourceMappingURL=EntityListMapper.js.map