@abaplint/runtime 2.3.107 → 2.3.109
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.
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.find = void 0;
|
|
4
|
+
const throw_error_1 = require("../throw_error");
|
|
4
5
|
const types_1 = require("../types");
|
|
5
6
|
function find(input) {
|
|
6
|
-
var _a, _b, _c, _d;
|
|
7
|
-
|
|
7
|
+
var _a, _b, _c, _d, _e;
|
|
8
|
+
let val = typeof input.val === "string" ? input.val : input.val.get();
|
|
9
|
+
if (input.len !== undefined) {
|
|
10
|
+
throw "transpiler find(), todo len";
|
|
11
|
+
}
|
|
8
12
|
if (input.regex) {
|
|
13
|
+
if (input.off !== undefined) {
|
|
14
|
+
throw "transpiler find(), todo off regex";
|
|
15
|
+
}
|
|
9
16
|
const caseInput = typeof input.case === "string" ? input.case : (_a = input.case) === null || _a === void 0 ? void 0 : _a.get();
|
|
10
17
|
const regex = typeof input.regex === "string" ? input.regex : input.regex.get();
|
|
11
18
|
const flags = caseInput !== "X" ? "i" : "";
|
|
@@ -20,8 +27,30 @@ function find(input) {
|
|
|
20
27
|
}
|
|
21
28
|
else {
|
|
22
29
|
const sub = typeof input.sub === "string" ? input.sub : (_c = input.sub) === null || _c === void 0 ? void 0 : _c.get();
|
|
23
|
-
|
|
24
|
-
|
|
30
|
+
let off = typeof input.off === "number" ? input.off : ((_d = input.off) === null || _d === void 0 ? void 0 : _d.get()) || 0;
|
|
31
|
+
let occ = typeof input.occ === "number" ? input.occ : (_e = input.occ) === null || _e === void 0 ? void 0 : _e.get();
|
|
32
|
+
if (occ === 0) {
|
|
33
|
+
(0, throw_error_1.throwError)("CX_SY_STRG_PAR_VAL");
|
|
34
|
+
}
|
|
35
|
+
else if (occ === undefined) {
|
|
36
|
+
occ = 1;
|
|
37
|
+
}
|
|
38
|
+
let negative = false;
|
|
39
|
+
if (occ < 0) {
|
|
40
|
+
negative = true;
|
|
41
|
+
val = val.split("").reverse().join("");
|
|
42
|
+
occ = Math.abs(occ);
|
|
43
|
+
}
|
|
44
|
+
let found = -1;
|
|
45
|
+
for (let i = 0; i < occ; i++) {
|
|
46
|
+
found = val.indexOf(sub || "", off);
|
|
47
|
+
if (found >= 0) {
|
|
48
|
+
off = found + 1;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (negative === true && found >= 0) {
|
|
52
|
+
found = val.length - found - 1;
|
|
53
|
+
}
|
|
25
54
|
return new types_1.Integer().set(found);
|
|
26
55
|
}
|
|
27
56
|
}
|