@abaplint/runtime
Version:
Transpiler - Runtime
47 lines • 1.44 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.to_mixed = to_mixed;
const throw_error_1 = require("../throw_error");
const types_1 = require("../types");
function to_mixed(input) {
let sep = input.sep;
if (sep === undefined) {
sep = "_";
}
if (typeof sep !== "string") {
sep = sep.get();
}
if (sep.length === 0) {
(0, throw_error_1.throwError)("CX_SY_STRG_PAR_VAL");
}
const min = 1;
if (min < 0) {
(0, throw_error_1.throwError)("CX_SY_STRG_PAR_VAL");
}
let val = input.val;
if (typeof val !== "string") {
val = val.get();
}
val = val.substring(0, min) + val.substring(min).toLowerCase();
if (input.case) {
if (typeof input.case === "string") {
if (input.case === input.case.toLowerCase()) {
val = val.substring(0, 1).toLowerCase() + val.substring(1);
}
}
else {
if (input.case.get() === input.case.get().toLowerCase()) {
val = val.substring(0, 1).toLowerCase() + val.substring(1);
}
}
}
const length = sep.length;
const regex = new RegExp(sep + "\\w");
while (val.match(regex)) {
val = val.replace(regex, (x) => {
return x.substring(length).toUpperCase();
});
}
return new types_1.String().set(val);
}
//# sourceMappingURL=to_mixed.js.map