UNPKG

@ima/plugin-http-client

Version:

Generic http client for the IMA application framework.

38 lines (37 loc) 1.03 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "EntityMapper", { enumerable: true, get: function() { return EntityMapper; } }); const _BaseMapper = require("./BaseMapper"); const _BaseEntity = require("../BaseEntity"); class EntityMapper extends _BaseMapper.BaseMapper { #EntityClass; /** * Creates a mapper with the specified entity that is used for the transformation field. * @param entity */ constructor(entity){ super(); this.#EntityClass = entity; } deserialize(data) { if (!data || typeof data === 'string' || data instanceof _BaseEntity.BaseEntity) { return data; } return Reflect.construct(this.#EntityClass, [ data ]); } serialize(entity) { if (!entity || !(entity instanceof _BaseEntity.BaseEntity)) { return entity; } return entity.serialize(); } } //# sourceMappingURL=EntityMapper.js.map