UNPKG

@abaplint/runtime

Version:
59 lines 1.91 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.concatenate = concatenate; const types_1 = require("../types"); function concatenate(input) { let sep = ""; if (input.separatedBy) { if (typeof input.separatedBy === "string" || typeof input.separatedBy === "number") { sep = input.separatedBy.toString(); } else { sep = input.separatedBy.get().toString(); } } if (input.lines === true) { const list = []; const tab = input.source[0]; if (tab instanceof types_1.Table) { for (const l of tab.array()) { if (input.respectingBlanks !== true) { list.push(l.get().trimEnd()); } else { list.push(l.get()); } } } input.target.set(list.join(sep)); } else { let result = ""; for (const source of input.source) { let val = ""; if (source instanceof types_1.Table) { throw new Error("concatenate, error: input is table"); } else if (typeof source === "string" || typeof source === "number") { val = source.toString(); } else if (source instanceof types_1.Character) { if (input.respectingBlanks !== true) { val = source.getTrimEnd(); } else { val = source.get(); } } else { val = source.get().toString(); } result += val + sep; } if (sep.length > 0 && result.length > 0) { result = result.slice(0, result.length - sep.length); } input.target.set(result); } } //# sourceMappingURL=concatenate.js.map