UNPKG

md-curcuma

Version:

A Typescript library for transporting and converting markdown and other data.

44 lines (43 loc) 1.48 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Mapper = void 0; class Mapper { constructor() { this.mappings = []; } addMapping(mapping) { this.mappings.push(mapping); } addMappings(mappings) { this.mappings = mappings; } do_mappings(source, target) { if (this.mappings != null || this.mappings != undefined) { if ((source != null || source != undefined) && (target != null || target != undefined)) { this.mappings.forEach((map) => { map.mapping_items.forEach((mapping_item) => { this.do_mapping(mapping_item, source, target, map.task); }); }); } } } do_mapping(mapping_item, source, target, task) { let props = { source: source, target: target, source_property_name: mapping_item.source_property_name, target_poperty_name: mapping_item.target_poperty_name, source_value: source.data[mapping_item.source_property_name], target_value: target.data[mapping_item.target_poperty_name], }; if (task != null) { target.data[mapping_item.target_poperty_name] = task.perform(props); } else { target.data[mapping_item.target_poperty_name] = props.source_value; } } } exports.Mapper = Mapper;