@abaplint/runtime
Version:
Transpiler - Runtime
25 lines • 787 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.substring = substring;
const string_1 = require("../types/string");
const throw_error_1 = require("../throw_error");
function substring(input) {
let off = input?.off?.get();
if (off === undefined) {
off = 0;
}
else if (off < 0) {
(0, throw_error_1.throwError)("CX_SY_RANGE_OUT_OF_BOUNDS");
}
const len = input?.len?.get();
if (len && len < 0) {
(0, throw_error_1.throwError)("CX_SY_RANGE_OUT_OF_BOUNDS");
}
if (typeof input.val === "string") {
return new string_1.String().set(input.val.substr(off, len));
}
else {
return input.val.getOffset({ offset: off, length: len });
}
}
//# sourceMappingURL=substring.js.map