@abaplint/runtime 2.13.29 → 2.13.31
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/replace.d.ts +6 -5
- package/build/src/builtin/replace.js +35 -22
- package/build/src/builtin/strlen.d.ts +2 -2
- package/build/src/builtin/strlen.js +16 -5
- package/build/src/builtin/substring_after.d.ts +2 -1
- package/build/src/builtin/substring_after.js +14 -3
- package/build/src/builtin/substring_before.d.ts +2 -1
- package/build/src/builtin/substring_before.js +16 -5
- package/build/src/builtin/to_lower.d.ts +2 -1
- package/build/src/builtin/to_lower.js +14 -3
- package/build/src/builtin/to_upper.d.ts +2 -1
- package/build/src/builtin/to_upper.js +14 -3
- package/build/src/builtin/translate.d.ts +2 -1
- package/build/src/builtin/translate.js +14 -3
- package/package.json +3 -3
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { ICharacter } from "../types/_character";
|
|
2
2
|
import { INumeric } from "../types/_numeric";
|
|
3
3
|
import { String } from "../types/string";
|
|
4
|
+
import { FieldSymbol } from "../types";
|
|
4
5
|
export interface IReplaceInput {
|
|
5
|
-
val: string | ICharacter;
|
|
6
|
-
sub?: string | ICharacter;
|
|
7
|
-
with?: string | ICharacter;
|
|
8
|
-
regex?: string | ICharacter;
|
|
9
|
-
pcre?: string | ICharacter;
|
|
6
|
+
val: string | ICharacter | FieldSymbol;
|
|
7
|
+
sub?: string | ICharacter | FieldSymbol;
|
|
8
|
+
with?: string | ICharacter | FieldSymbol;
|
|
9
|
+
regex?: string | ICharacter | FieldSymbol;
|
|
10
|
+
pcre?: string | ICharacter | FieldSymbol;
|
|
10
11
|
off?: INumeric;
|
|
11
12
|
len?: INumeric;
|
|
12
13
|
occ?: INumeric;
|
|
@@ -4,58 +4,71 @@ exports.replace = replace;
|
|
|
4
4
|
const string_1 = require("../types/string");
|
|
5
5
|
const abap_regex_1 = require("../abap_regex");
|
|
6
6
|
const types_1 = require("../types");
|
|
7
|
+
function dereference(input) {
|
|
8
|
+
if (input instanceof types_1.FieldSymbol) {
|
|
9
|
+
const pointer = input.getPointer();
|
|
10
|
+
if (pointer === undefined) {
|
|
11
|
+
throw new Error("GETWA_NOT_ASSIGNED");
|
|
12
|
+
}
|
|
13
|
+
return pointer;
|
|
14
|
+
}
|
|
15
|
+
return input;
|
|
16
|
+
}
|
|
7
17
|
function replace(input) {
|
|
18
|
+
const source = dereference(input.val);
|
|
19
|
+
const withSource = dereference(input.with);
|
|
20
|
+
const subSource = dereference(input.sub);
|
|
21
|
+
const regexInput = dereference(input.pcre || input.regex);
|
|
8
22
|
let val = undefined;
|
|
9
|
-
if (typeof
|
|
10
|
-
val =
|
|
23
|
+
if (typeof source === "string") {
|
|
24
|
+
val = source;
|
|
11
25
|
}
|
|
12
|
-
else if (
|
|
13
|
-
val =
|
|
26
|
+
else if (source instanceof types_1.Character) {
|
|
27
|
+
val = source.getTrimEnd();
|
|
14
28
|
}
|
|
15
29
|
else {
|
|
16
|
-
val =
|
|
30
|
+
val = source.get();
|
|
17
31
|
}
|
|
18
32
|
let wi = undefined;
|
|
19
|
-
if (typeof
|
|
20
|
-
wi =
|
|
33
|
+
if (typeof withSource === "string") {
|
|
34
|
+
wi = withSource;
|
|
21
35
|
}
|
|
22
|
-
else if (
|
|
23
|
-
wi =
|
|
36
|
+
else if (withSource instanceof types_1.Character) {
|
|
37
|
+
wi = withSource.getTrimEnd();
|
|
24
38
|
}
|
|
25
|
-
else if (
|
|
26
|
-
wi =
|
|
39
|
+
else if (withSource) {
|
|
40
|
+
wi = withSource.get();
|
|
27
41
|
}
|
|
28
42
|
let sub = undefined;
|
|
29
|
-
if (typeof
|
|
30
|
-
sub =
|
|
43
|
+
if (typeof subSource === "string") {
|
|
44
|
+
sub = subSource;
|
|
31
45
|
}
|
|
32
|
-
else if (
|
|
33
|
-
sub =
|
|
46
|
+
else if (subSource instanceof types_1.Character) {
|
|
47
|
+
sub = subSource.getTrimEnd();
|
|
34
48
|
}
|
|
35
|
-
else if (
|
|
36
|
-
sub =
|
|
49
|
+
else if (subSource) {
|
|
50
|
+
sub = subSource.get();
|
|
37
51
|
}
|
|
38
52
|
if (sub !== undefined) {
|
|
39
53
|
sub = abap_regex_1.ABAPRegExp.escapeRegExp(sub);
|
|
40
54
|
}
|
|
41
|
-
const regexInput = input.pcre || input.regex;
|
|
42
55
|
if (typeof regexInput === "string") {
|
|
43
56
|
sub = new RegExp(abap_regex_1.ABAPRegExp.convert(regexInput), "g");
|
|
44
57
|
}
|
|
45
58
|
else if (regexInput) {
|
|
46
59
|
sub = new RegExp(abap_regex_1.ABAPRegExp.convert(regexInput.get()), "g");
|
|
47
60
|
}
|
|
48
|
-
if (input.off && input.len && typeof
|
|
61
|
+
if (input.off && input.len && typeof source === "string") {
|
|
49
62
|
const offset = input.off.get();
|
|
50
63
|
const length = input.len.get();
|
|
51
64
|
val = val.substring(0, offset) + wi + val.substring(offset + length);
|
|
52
65
|
}
|
|
53
|
-
else if (input.off && input.len && !(typeof
|
|
66
|
+
else if (input.off && input.len && !(typeof source === "string")) {
|
|
54
67
|
const offset = input.off.get();
|
|
55
68
|
const length = input.len.get();
|
|
56
|
-
val =
|
|
69
|
+
val = source.getOffset({ offset: 0, length: offset }).get() +
|
|
57
70
|
wi +
|
|
58
|
-
|
|
71
|
+
source.getOffset({ offset: offset + length }).get();
|
|
59
72
|
}
|
|
60
73
|
else if (input.occ === undefined && sub && wi !== undefined) {
|
|
61
74
|
if (typeof sub === "string") {
|
|
@@ -4,15 +4,26 @@ exports.strlen = strlen;
|
|
|
4
4
|
const integer_factory_1 = require("../integer_factory");
|
|
5
5
|
const types_1 = require("../types");
|
|
6
6
|
function strlen(input) {
|
|
7
|
+
let source;
|
|
8
|
+
if (input.val instanceof types_1.FieldSymbol) {
|
|
9
|
+
const pointer = input.val.getPointer();
|
|
10
|
+
if (pointer === undefined) {
|
|
11
|
+
throw new Error("GETWA_NOT_ASSIGNED");
|
|
12
|
+
}
|
|
13
|
+
source = pointer;
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
source = input.val;
|
|
17
|
+
}
|
|
7
18
|
let str = "";
|
|
8
|
-
if (typeof
|
|
9
|
-
str =
|
|
19
|
+
if (typeof source === "string") {
|
|
20
|
+
str = source;
|
|
10
21
|
}
|
|
11
|
-
else if (
|
|
12
|
-
str =
|
|
22
|
+
else if (source instanceof types_1.Character) {
|
|
23
|
+
str = source.getTrimEnd();
|
|
13
24
|
}
|
|
14
25
|
else {
|
|
15
|
-
str =
|
|
26
|
+
str = source.get();
|
|
16
27
|
}
|
|
17
28
|
if (str.length <= 200) {
|
|
18
29
|
return integer_factory_1.IntegerFactory.get(str.length);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { FieldSymbol } from "../types";
|
|
1
2
|
import { ICharacter } from "../types/_character";
|
|
2
3
|
interface ISubstringAfterInput {
|
|
3
|
-
val: ICharacter | string;
|
|
4
|
+
val: ICharacter | FieldSymbol | string;
|
|
4
5
|
sub?: ICharacter | string;
|
|
5
6
|
regex?: ICharacter | string;
|
|
6
7
|
pcre?: ICharacter | string;
|
|
@@ -5,9 +5,20 @@ const abap_regex_1 = require("../abap_regex");
|
|
|
5
5
|
const types_1 = require("../types");
|
|
6
6
|
const string_1 = require("../types/string");
|
|
7
7
|
function substring_after(input) {
|
|
8
|
-
let
|
|
9
|
-
if (input.val instanceof types_1.
|
|
10
|
-
|
|
8
|
+
let source;
|
|
9
|
+
if (input.val instanceof types_1.FieldSymbol) {
|
|
10
|
+
const pointer = input.val.getPointer();
|
|
11
|
+
if (pointer === undefined) {
|
|
12
|
+
throw new Error("GETWA_NOT_ASSIGNED");
|
|
13
|
+
}
|
|
14
|
+
source = pointer;
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
source = input.val;
|
|
18
|
+
}
|
|
19
|
+
let val = typeof source === "string" ? source : source.get();
|
|
20
|
+
if (source instanceof types_1.Character) {
|
|
21
|
+
val = source.getTrimEnd();
|
|
11
22
|
}
|
|
12
23
|
let reg = "";
|
|
13
24
|
if (typeof input.regex === "string") {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { FieldSymbol } from "../types";
|
|
1
2
|
import { ICharacter } from "../types/_character";
|
|
2
3
|
export declare function substring_before(input: {
|
|
3
|
-
val: ICharacter | string;
|
|
4
|
+
val: ICharacter | FieldSymbol | string;
|
|
4
5
|
sub?: ICharacter | string;
|
|
5
6
|
regex?: ICharacter | string;
|
|
6
7
|
}): ICharacter;
|
|
@@ -5,15 +5,26 @@ const abap_regex_1 = require("../abap_regex");
|
|
|
5
5
|
const types_1 = require("../types");
|
|
6
6
|
const string_1 = require("../types/string");
|
|
7
7
|
function substring_before(input) {
|
|
8
|
+
let source;
|
|
9
|
+
if (input.val instanceof types_1.FieldSymbol) {
|
|
10
|
+
const pointer = input.val.getPointer();
|
|
11
|
+
if (pointer === undefined) {
|
|
12
|
+
throw new Error("GETWA_NOT_ASSIGNED");
|
|
13
|
+
}
|
|
14
|
+
source = pointer;
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
source = input.val;
|
|
18
|
+
}
|
|
8
19
|
let val = "";
|
|
9
|
-
if (typeof
|
|
10
|
-
val =
|
|
20
|
+
if (typeof source === "string") {
|
|
21
|
+
val = source;
|
|
11
22
|
}
|
|
12
|
-
else if (
|
|
13
|
-
val =
|
|
23
|
+
else if (source instanceof types_1.Character) {
|
|
24
|
+
val = source.getTrimEnd();
|
|
14
25
|
}
|
|
15
26
|
else {
|
|
16
|
-
val =
|
|
27
|
+
val = source.get();
|
|
17
28
|
}
|
|
18
29
|
let reg = "";
|
|
19
30
|
if (typeof input.regex === "string") {
|
|
@@ -3,9 +3,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.to_lower = to_lower;
|
|
4
4
|
const types_1 = require("../types");
|
|
5
5
|
function to_lower(input) {
|
|
6
|
-
|
|
7
|
-
if (input.val instanceof types_1.
|
|
8
|
-
|
|
6
|
+
let source;
|
|
7
|
+
if (input.val instanceof types_1.FieldSymbol) {
|
|
8
|
+
const pointer = input.val.getPointer();
|
|
9
|
+
if (pointer === undefined) {
|
|
10
|
+
throw new Error("GETWA_NOT_ASSIGNED");
|
|
11
|
+
}
|
|
12
|
+
source = pointer;
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
source = input.val;
|
|
16
|
+
}
|
|
17
|
+
const val = typeof source === "string" ? source : source.get();
|
|
18
|
+
if (source instanceof types_1.Character) {
|
|
19
|
+
return new types_1.Character(source.getLength()).set(val.toLowerCase());
|
|
9
20
|
}
|
|
10
21
|
else {
|
|
11
22
|
return new types_1.String().set(val.toLowerCase());
|
|
@@ -3,9 +3,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.to_upper = to_upper;
|
|
4
4
|
const types_1 = require("../types");
|
|
5
5
|
function to_upper(input) {
|
|
6
|
-
|
|
7
|
-
if (input.val instanceof types_1.
|
|
8
|
-
|
|
6
|
+
let source;
|
|
7
|
+
if (input.val instanceof types_1.FieldSymbol) {
|
|
8
|
+
const pointer = input.val.getPointer();
|
|
9
|
+
if (pointer === undefined) {
|
|
10
|
+
throw new Error("GETWA_NOT_ASSIGNED");
|
|
11
|
+
}
|
|
12
|
+
source = pointer;
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
source = input.val;
|
|
16
|
+
}
|
|
17
|
+
const val = typeof source === "string" ? source : source.get();
|
|
18
|
+
if (source instanceof types_1.Character) {
|
|
19
|
+
return new types_1.Character(source.getLength()).set(val.toUpperCase());
|
|
9
20
|
}
|
|
10
21
|
else {
|
|
11
22
|
return new types_1.String().set(val.toUpperCase());
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { FieldSymbol } from "../types";
|
|
1
2
|
import { ICharacter } from "../types/_character";
|
|
2
3
|
export declare function translate(input: {
|
|
3
4
|
val: ICharacter | string;
|
|
4
5
|
from: ICharacter | string;
|
|
5
|
-
to: ICharacter | string;
|
|
6
|
+
to: ICharacter | FieldSymbol | string;
|
|
6
7
|
}): ICharacter;
|
|
@@ -6,9 +6,20 @@ const string_1 = require("../types/string");
|
|
|
6
6
|
function translate(input) {
|
|
7
7
|
let val = typeof input.val === "string" ? input.val : input.val.get();
|
|
8
8
|
const from = typeof input.from === "string" ? input.from : input.from.get();
|
|
9
|
-
let
|
|
10
|
-
if (input.to instanceof types_1.
|
|
11
|
-
|
|
9
|
+
let toSource;
|
|
10
|
+
if (input.to instanceof types_1.FieldSymbol) {
|
|
11
|
+
const pointer = input.to.getPointer();
|
|
12
|
+
if (pointer === undefined) {
|
|
13
|
+
throw new Error("GETWA_NOT_ASSIGNED");
|
|
14
|
+
}
|
|
15
|
+
toSource = pointer;
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
toSource = input.to;
|
|
19
|
+
}
|
|
20
|
+
let to = typeof toSource === "string" ? toSource : toSource.get();
|
|
21
|
+
if (toSource instanceof types_1.Character) {
|
|
22
|
+
to = toSource.getTrimEnd();
|
|
12
23
|
}
|
|
13
24
|
const fromSplit = from.split("");
|
|
14
25
|
const toSplit = to.split("");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/runtime",
|
|
3
|
-
"version": "2.13.
|
|
3
|
+
"version": "2.13.31",
|
|
4
4
|
"description": "Transpiler - Runtime",
|
|
5
5
|
"main": "build/src/index.js",
|
|
6
6
|
"typings": "build/src/index.d.ts",
|
|
@@ -31,9 +31,9 @@
|
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@types/chai": "^4.3.20",
|
|
33
33
|
"@types/mocha": "^10.0.10",
|
|
34
|
-
"@types/node": "^24.
|
|
34
|
+
"@types/node": "^24.13.2",
|
|
35
35
|
"chai": "^4.5.0",
|
|
36
|
-
"mocha": "^11.7.
|
|
36
|
+
"mocha": "^11.7.6",
|
|
37
37
|
"source-map-support": "^0.5.21",
|
|
38
38
|
"typescript": "^6.0.3"
|
|
39
39
|
},
|