@abaplint/runtime
Version:
Transpiler - Runtime
28 lines • 1.03 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.condense = condense;
const types_1 = require("../types");
function condense(input) {
let str = typeof input.val === "string" ? input.val : input.val.get().toString();
let from = " ";
if (input.from) {
from = typeof input.from === "string" ? input.from : input.from.get().toString();
}
let to = " ";
if (input.to) {
to = typeof input.to === "string" ? input.to : input.to.get().toString();
}
let del = " ";
if (input.del) {
del = typeof input.del === "string" ? input.del : input.del.get().toString();
}
const beginning = new RegExp(`[${del}]+$`);
const end = new RegExp(`^[${del}]+`);
str = str.replace(beginning, "");
str = str.replace(end, "");
for (const f of from.split("")) {
str = str.replace(new RegExp(f.replace(".", "\\."), "g"), to);
}
return new types_1.String().set(str.replace(/ {2,}/g, " "));
}
//# sourceMappingURL=condense.js.map