@abaplint/runtime 2.0.16 → 2.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -50,6 +50,7 @@ __exportStar(require("./tan"), exports);
|
|
|
50
50
|
__exportStar(require("./to_lower"), exports);
|
|
51
51
|
__exportStar(require("./to_mixed"), exports);
|
|
52
52
|
__exportStar(require("./to_upper"), exports);
|
|
53
|
+
__exportStar(require("./translate"), exports);
|
|
53
54
|
__exportStar(require("./trunc"), exports);
|
|
54
55
|
__exportStar(require("./xstrlen"), exports);
|
|
55
56
|
exports.abap_true = new types_1.Character({ length: 1, qualifiedName: "ABAP_BOOL" }).set("X");
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.translate = void 0;
|
|
4
|
+
const string_1 = require("../types/string");
|
|
5
|
+
function translate(input) {
|
|
6
|
+
let val = typeof input.val === "string" ? input.val : input.val.get();
|
|
7
|
+
const from = typeof input.from === "string" ? input.from : input.from.get();
|
|
8
|
+
const to = typeof input.to === "string" ? input.to : input.to.get();
|
|
9
|
+
const fromSplit = from.split("");
|
|
10
|
+
const toSplit = to.split("");
|
|
11
|
+
for (let i = 0; i < fromSplit.length; i++) {
|
|
12
|
+
const reg = new RegExp(fromSplit[i], "g");
|
|
13
|
+
val = val.replace(reg, toSplit[i] || "");
|
|
14
|
+
}
|
|
15
|
+
return new string_1.String().set(val);
|
|
16
|
+
}
|
|
17
|
+
exports.translate = translate;
|
|
18
|
+
//# sourceMappingURL=translate.js.map
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.replace = void 0;
|
|
4
4
|
function replace(input) {
|
|
5
5
|
let temp = input.target.get();
|
|
6
|
+
const ignoreCase = input.ignoringCase === true ? "i" : "";
|
|
6
7
|
let search = "";
|
|
7
8
|
let found = false;
|
|
8
9
|
if (input.of) {
|
|
@@ -11,13 +12,16 @@ function replace(input) {
|
|
|
11
12
|
throw "REPLACE, zero length input";
|
|
12
13
|
}
|
|
13
14
|
found = temp.indexOf(search) >= 0;
|
|
15
|
+
if (ignoreCase.length > 0) {
|
|
16
|
+
search = new RegExp(search, ignoreCase);
|
|
17
|
+
}
|
|
14
18
|
}
|
|
15
19
|
else if (input.regex) {
|
|
16
20
|
if (input.regex.get().length === 0 && input.all === true) {
|
|
17
21
|
throw "REPLACE, zero length input";
|
|
18
22
|
}
|
|
19
23
|
found = temp.match(search) !== null;
|
|
20
|
-
search = new RegExp(input.regex.get());
|
|
24
|
+
search = new RegExp(input.regex.get(), ignoreCase);
|
|
21
25
|
}
|
|
22
26
|
let replace = "";
|
|
23
27
|
if (typeof input.with === "string") {
|
|
@@ -28,7 +32,7 @@ function replace(input) {
|
|
|
28
32
|
}
|
|
29
33
|
if (input.all === true) {
|
|
30
34
|
if (input.regex) {
|
|
31
|
-
temp = temp.replace(new RegExp(input.regex.get(), "g"), replace);
|
|
35
|
+
temp = temp.replace(new RegExp(input.regex.get(), "g" + ignoreCase), replace);
|
|
32
36
|
}
|
|
33
37
|
else {
|
|
34
38
|
while (temp.replace(search, replace) !== temp) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/runtime",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.19",
|
|
4
4
|
"description": "Transpiler - Runtime",
|
|
5
5
|
"main": "build/src/index.js",
|
|
6
6
|
"typings": "build/src/index.d.ts",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"@types/mocha": "^9.1.1",
|
|
33
33
|
"@types/sql.js": "^1.4.3",
|
|
34
34
|
"chai": "^4.3.6",
|
|
35
|
-
"mocha": "^
|
|
35
|
+
"mocha": "^10.0.0",
|
|
36
36
|
"source-map-support": "^0.5.21",
|
|
37
37
|
"typescript": "^4.6.4"
|
|
38
38
|
}
|