UNPKG

@ima/plugin-http-client

Version:

Generic http client for the IMA application framework.

36 lines (35 loc) 1.07 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "EntityListMapper", { enumerable: true, get: function() { return EntityListMapper; } }); const _BaseMapper = require("./BaseMapper"); const _EntityMapper = require("./EntityMapper"); class EntityListMapper extends _BaseMapper.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.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