UNPKG

@abaplint/runtime

Version:
29 lines 852 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.alphaOut = alphaOut; exports.alphaIn = alphaIn; const types_1 = require("./types"); function alphaOut(source) { const txt = source.get() + ""; return txt.replace(/^0+/, ""); } function alphaIn(source, context) { let txt = source.get() + ""; if (txt.match(/^[0-9 ]+$/) === null) { // contains letters return txt; } let length = 0; if (context instanceof types_1.String && source instanceof types_1.String) { return txt; } else if (context instanceof types_1.Character) { length = context.getLength(); } else if (source instanceof types_1.Character) { length = source.getLength(); } txt = txt.trimEnd(); return txt.padStart(length, "0"); } //# sourceMappingURL=alpha.js.map