@abaplint/runtime 1.8.24 → 1.8.27
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.
- package/build/src/builtin/count.d.ts +7 -4
- package/build/src/builtin/count.js +15 -4
- package/build/src/statements/find.d.ts +1 -1
- package/build/src/statements/find.js +24 -13
- package/build/src/statements/replace.d.ts +9 -1
- package/build/src/statements/replace.js +20 -15
- package/build/src/template_formatting.d.ts +1 -0
- package/build/src/template_formatting.js +4 -0
- package/package.json +2 -2
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { Integer } from "../types";
|
|
2
2
|
import { ICharacter } from "../types/_character";
|
|
3
|
-
export declare
|
|
4
|
-
val: ICharacter
|
|
5
|
-
sub: ICharacter
|
|
6
|
-
|
|
3
|
+
export declare type countInput = {
|
|
4
|
+
val: ICharacter;
|
|
5
|
+
sub: ICharacter;
|
|
6
|
+
regex?: ICharacter;
|
|
7
|
+
case?: ICharacter;
|
|
8
|
+
};
|
|
9
|
+
export declare function count(input: countInput): Integer;
|
|
@@ -1,14 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.count = void 0;
|
|
4
|
+
const compare_1 = require("../compare");
|
|
4
5
|
const types_1 = require("../types");
|
|
5
6
|
function count(input) {
|
|
6
7
|
let found = 0;
|
|
7
|
-
const val =
|
|
8
|
-
let
|
|
9
|
-
|
|
8
|
+
const val = input.val.get();
|
|
9
|
+
let reg = "";
|
|
10
|
+
if (input.sub) {
|
|
11
|
+
reg = input.sub.get();
|
|
12
|
+
reg = reg.replace(/\*/g, "\\*");
|
|
13
|
+
}
|
|
14
|
+
else if (input.regex) {
|
|
15
|
+
reg = input.regex.get();
|
|
16
|
+
}
|
|
17
|
+
let options = "g";
|
|
18
|
+
if (input.case && (0, compare_1.initial)(input.case)) {
|
|
19
|
+
options += "i";
|
|
20
|
+
}
|
|
10
21
|
if (val !== "") {
|
|
11
|
-
const res = val.match(new RegExp(
|
|
22
|
+
const res = val.match(new RegExp(reg, options));
|
|
12
23
|
if (res) {
|
|
13
24
|
found = res.length;
|
|
14
25
|
}
|
|
@@ -14,4 +14,4 @@ export interface IFindOptions {
|
|
|
14
14
|
ignoringCase?: boolean;
|
|
15
15
|
submatches?: ICharacter[];
|
|
16
16
|
}
|
|
17
|
-
export declare function find(input: ICharacter |
|
|
17
|
+
export declare function find(input: ICharacter | Table, options: IFindOptions): void;
|
|
@@ -4,10 +4,6 @@ exports.find = void 0;
|
|
|
4
4
|
const types_1 = require("../types");
|
|
5
5
|
function find(input, options) {
|
|
6
6
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
7
|
-
let i = input;
|
|
8
|
-
if (typeof i !== "string") {
|
|
9
|
-
i = i.get();
|
|
10
|
-
}
|
|
11
7
|
let sectionOffset = (_a = options.sectionOffset) === null || _a === void 0 ? void 0 : _a.get();
|
|
12
8
|
if (sectionOffset && options.byteMode) {
|
|
13
9
|
sectionOffset = sectionOffset * 2;
|
|
@@ -49,16 +45,31 @@ function find(input, options) {
|
|
|
49
45
|
else {
|
|
50
46
|
throw "FIND, runtime, no input";
|
|
51
47
|
}
|
|
52
|
-
if (sectionOffset) {
|
|
53
|
-
i = i.substr(sectionOffset);
|
|
54
|
-
}
|
|
55
|
-
let temp;
|
|
56
48
|
const matches = [];
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
49
|
+
if (input instanceof types_1.Table) {
|
|
50
|
+
for (const blah of input.array()) {
|
|
51
|
+
let temp;
|
|
52
|
+
// eslint-disable-next-line no-cond-assign
|
|
53
|
+
while (temp = s.exec(blah.get())) {
|
|
54
|
+
matches.push(temp);
|
|
55
|
+
if (options.first === true) {
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
let blah = input.get();
|
|
63
|
+
if (sectionOffset) {
|
|
64
|
+
blah = blah.substr(sectionOffset);
|
|
65
|
+
}
|
|
66
|
+
let temp;
|
|
67
|
+
// eslint-disable-next-line no-cond-assign
|
|
68
|
+
while (temp = s.exec(blah)) {
|
|
69
|
+
matches.push(temp);
|
|
70
|
+
if (options.first === true) {
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
62
73
|
}
|
|
63
74
|
}
|
|
64
75
|
if (options.submatches) {
|
|
@@ -1,2 +1,10 @@
|
|
|
1
1
|
import { ICharacter } from "../types/_character";
|
|
2
|
-
export declare
|
|
2
|
+
export declare type replaceInput = {
|
|
3
|
+
target: ICharacter;
|
|
4
|
+
sectionLength?: ICharacter;
|
|
5
|
+
regex?: ICharacter;
|
|
6
|
+
all: boolean;
|
|
7
|
+
with: ICharacter;
|
|
8
|
+
of: ICharacter;
|
|
9
|
+
};
|
|
10
|
+
export declare function replace(input: replaceInput): void;
|
|
@@ -1,27 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.replace = void 0;
|
|
4
|
-
function replace(input
|
|
5
|
-
let temp = input.get();
|
|
4
|
+
function replace(input) {
|
|
5
|
+
let temp = input.target.get();
|
|
6
6
|
let search = "";
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
let found = false;
|
|
8
|
+
if (input.of) {
|
|
9
|
+
search = input.of.get();
|
|
10
|
+
if (search.length === 0 && input.all === true) {
|
|
11
|
+
throw "REPLACE, zero length input";
|
|
12
|
+
}
|
|
13
|
+
found = temp.indexOf(search) >= 0;
|
|
9
14
|
}
|
|
10
|
-
else {
|
|
11
|
-
|
|
15
|
+
else if (input.regex) {
|
|
16
|
+
if (input.regex.get().length === 0 && input.all === true) {
|
|
17
|
+
throw "REPLACE, zero length input";
|
|
18
|
+
}
|
|
19
|
+
found = temp.match(search) !== null;
|
|
20
|
+
search = new RegExp(input.regex.get());
|
|
12
21
|
}
|
|
13
22
|
let replace = "";
|
|
14
|
-
if (typeof
|
|
15
|
-
replace =
|
|
23
|
+
if (typeof input.with === "string") {
|
|
24
|
+
replace = input.with;
|
|
16
25
|
}
|
|
17
26
|
else {
|
|
18
|
-
replace =
|
|
27
|
+
replace = input.with.get();
|
|
19
28
|
}
|
|
20
|
-
|
|
21
|
-
if (all === true) {
|
|
22
|
-
if (search.length === 0) {
|
|
23
|
-
throw "REPLACE, zero length input";
|
|
24
|
-
}
|
|
29
|
+
if (input.all === true) {
|
|
25
30
|
while (temp.replace(search, replace) !== temp) {
|
|
26
31
|
temp = temp.replace(search, replace);
|
|
27
32
|
}
|
|
@@ -32,7 +37,7 @@ function replace(input, all, s, r) {
|
|
|
32
37
|
const subrc = found ? 0 : 4;
|
|
33
38
|
// @ts-ignore
|
|
34
39
|
abap.builtin.sy.get().subrc.set(subrc);
|
|
35
|
-
input.set(temp);
|
|
40
|
+
input.target.set(temp);
|
|
36
41
|
}
|
|
37
42
|
exports.replace = replace;
|
|
38
43
|
//# sourceMappingURL=replace.js.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.templateFormatting = void 0;
|
|
4
|
+
const types_1 = require("./types");
|
|
4
5
|
function templateFormatting(source, options) {
|
|
5
6
|
let text = source.get() + "";
|
|
6
7
|
if (options.timestamp === "iso") {
|
|
@@ -15,6 +16,9 @@ function templateFormatting(source, options) {
|
|
|
15
16
|
if (options.width) {
|
|
16
17
|
text = text.trimEnd().padEnd(options.width, " ");
|
|
17
18
|
}
|
|
19
|
+
else if (options.decimals && source instanceof types_1.Integer) {
|
|
20
|
+
text = source.get() + "." + "".padEnd(options.decimals, "0");
|
|
21
|
+
}
|
|
18
22
|
return text;
|
|
19
23
|
}
|
|
20
24
|
exports.templateFormatting = templateFormatting;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/runtime",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.27",
|
|
4
4
|
"description": "Transpiler - Runtime",
|
|
5
5
|
"main": "build/src/index.js",
|
|
6
6
|
"typings": "build/src/index.d.ts",
|
|
@@ -37,6 +37,6 @@
|
|
|
37
37
|
"chai": "^4.3.6",
|
|
38
38
|
"mocha": "^9.2.2",
|
|
39
39
|
"source-map-support": "^0.5.21",
|
|
40
|
-
"typescript": "^4.6.
|
|
40
|
+
"typescript": "^4.6.3"
|
|
41
41
|
}
|
|
42
42
|
}
|