UNPKG

@abaplint/runtime

Version:
47 lines 1.44 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.split = split; const types_1 = require("../types"); function split(param) { let source = ""; if (typeof param.source === "string") { source = param.source; } else if (param.source instanceof types_1.Character) { source = param.source.getTrimEnd(); } else { source = param.source.get(); } const at = typeof param.at === "string" ? param.at : param.at.get(); const split = source.includes(at) ? source.split(at) : []; if (param.table) { if (source.endsWith(at)) { split.pop(); } param.table.clear(); for (const s of split) { param.table.append(new types_1.String().set(s)); } if (source !== "" && split.length === 0) { param.table.append(new types_1.String().set(source)); } } if (param.targets) { if (split.length === 0) { split.push(source); } for (const t of param.targets) { t.clear(); if (split.length > 0) { t.set(split.shift().replace(/ +$/, "")); } } if (split.length > 0) { const concat = split.join(at); const last = param.targets[param.targets.length - 1]; last.set(last.get() + at + concat); } } } //# sourceMappingURL=split.js.map