@abaplint/runtime 2.13.83 → 2.13.84

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.
@@ -0,0 +1,11 @@
1
+ import { Integer } from "../types";
2
+ import { ICharacter } from "../types/_character";
3
+ import { INumeric } from "../types/_numeric";
4
+ export interface IFindAnyNotOfInput {
5
+ val: ICharacter | string;
6
+ sub: ICharacter | string;
7
+ off?: INumeric | number;
8
+ len?: INumeric | number;
9
+ occ?: INumeric | number;
10
+ }
11
+ export declare function find_any_not_of(input: IFindAnyNotOfInput): Integer;
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.find_any_not_of = find_any_not_of;
4
+ const types_1 = require("../types");
5
+ const throw_error_1 = require("../throw_error");
6
+ function find_any_not_of(input) {
7
+ const val = typeof input.val === "string" ? input.val : input.val.get();
8
+ const sub = typeof input.sub === "string" ? input.sub : input.sub.get();
9
+ const off = typeof input.off === "number" ? input.off : input.off?.get() || 0;
10
+ const len = typeof input.len === "number" ? input.len : input.len?.get();
11
+ let occ = typeof input.occ === "number" ? input.occ : input.occ?.get();
12
+ if (occ === 0) {
13
+ (0, throw_error_1.throwError)("CX_SY_STRG_PAR_VAL");
14
+ }
15
+ else if (occ === undefined) {
16
+ occ = 1;
17
+ }
18
+ if (off < 0 || off > val.length) {
19
+ (0, throw_error_1.throwError)("CX_SY_RANGE_OUT_OF_BOUNDS");
20
+ }
21
+ if (len !== undefined && (len < 0 || off + len > val.length)) {
22
+ (0, throw_error_1.throwError)("CX_SY_RANGE_OUT_OF_BOUNDS");
23
+ }
24
+ const end = len === undefined ? val.length : off + len;
25
+ const characters = new Set(sub.split(""));
26
+ let remaining = Math.abs(occ);
27
+ if (occ > 0) {
28
+ for (let i = off; i < end; i++) {
29
+ if (!characters.has(val.charAt(i)) && --remaining === 0) {
30
+ return new types_1.Integer().set(i);
31
+ }
32
+ }
33
+ }
34
+ else {
35
+ for (let i = end - 1; i >= off; i--) {
36
+ if (!characters.has(val.charAt(i)) && --remaining === 0) {
37
+ return new types_1.Integer().set(i);
38
+ }
39
+ }
40
+ }
41
+ return new types_1.Integer().set(-1);
42
+ }
43
+ //# sourceMappingURL=find_any_not_of.js.map
@@ -0,0 +1,11 @@
1
+ import { Integer } from "../types";
2
+ import { ICharacter } from "../types/_character";
3
+ import { INumeric } from "../types/_numeric";
4
+ export interface IFindAnyOfInput {
5
+ val: ICharacter | string;
6
+ sub: ICharacter | string;
7
+ off?: INumeric | number;
8
+ len?: INumeric | number;
9
+ occ?: INumeric | number;
10
+ }
11
+ export declare function find_any_of(input: IFindAnyOfInput): Integer;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.find_any_of = find_any_of;
4
+ const types_1 = require("../types");
5
+ const throw_error_1 = require("../throw_error");
6
+ function find_any_of(input) {
7
+ const val = typeof input.val === "string" ? input.val : input.val.get();
8
+ const sub = typeof input.sub === "string" ? input.sub : input.sub.get();
9
+ const off = typeof input.off === "number" ? input.off : input.off?.get() || 0;
10
+ const len = typeof input.len === "number" ? input.len : input.len?.get();
11
+ let occ = typeof input.occ === "number" ? input.occ : input.occ?.get();
12
+ if (occ === 0) {
13
+ (0, throw_error_1.throwError)("CX_SY_STRG_PAR_VAL");
14
+ }
15
+ else if (occ === undefined) {
16
+ occ = 1;
17
+ }
18
+ if (off < 0 || off > val.length) {
19
+ (0, throw_error_1.throwError)("CX_SY_RANGE_OUT_OF_BOUNDS");
20
+ }
21
+ if (len !== undefined && (len < 0 || off + len > val.length)) {
22
+ (0, throw_error_1.throwError)("CX_SY_RANGE_OUT_OF_BOUNDS");
23
+ }
24
+ if (sub === "") {
25
+ return new types_1.Integer().set(-1);
26
+ }
27
+ const end = len === undefined ? val.length : off + len;
28
+ const characters = new Set(sub.split(""));
29
+ let remaining = Math.abs(occ);
30
+ if (occ > 0) {
31
+ for (let i = off; i < end; i++) {
32
+ if (characters.has(val.charAt(i)) && --remaining === 0) {
33
+ return new types_1.Integer().set(i);
34
+ }
35
+ }
36
+ }
37
+ else {
38
+ for (let i = end - 1; i >= off; i--) {
39
+ if (characters.has(val.charAt(i)) && --remaining === 0) {
40
+ return new types_1.Integer().set(i);
41
+ }
42
+ }
43
+ }
44
+ return new types_1.Integer().set(-1);
45
+ }
46
+ //# sourceMappingURL=find_any_of.js.map
@@ -15,6 +15,8 @@ export * from "./count";
15
15
  export * from "./escape";
16
16
  export * from "./exp";
17
17
  export * from "./find";
18
+ export * from "./find_any_not_of";
19
+ export * from "./find_any_of";
18
20
  export * from "./floor";
19
21
  export * from "./frac";
20
22
  export * from "./from_mixed";
@@ -32,6 +32,8 @@ __exportStar(require("./count"), exports);
32
32
  __exportStar(require("./escape"), exports);
33
33
  __exportStar(require("./exp"), exports);
34
34
  __exportStar(require("./find"), exports);
35
+ __exportStar(require("./find_any_not_of"), exports);
36
+ __exportStar(require("./find_any_of"), exports);
35
37
  __exportStar(require("./floor"), exports);
36
38
  __exportStar(require("./frac"), exports);
37
39
  __exportStar(require("./from_mixed"), exports);
@@ -12,7 +12,12 @@ function find(input, options) {
12
12
  let s = "";
13
13
  if (options.find) {
14
14
  s = options.find;
15
- if (typeof s !== "string") {
15
+ if (s instanceof types_1.Character) {
16
+ // trailing blanks are ignored for fixed length character typed operands,
17
+ // note that text string operands keep them
18
+ s = s.getTrimEnd();
19
+ }
20
+ else if (typeof s !== "string") {
16
21
  s = s.get();
17
22
  }
18
23
  if (s === "") {
@@ -23,7 +23,9 @@ class XString {
23
23
  }
24
24
  set(value) {
25
25
  if (typeof value === "string") {
26
- this.value = value;
26
+ // the input is interpreted as hexadecimal digits, the conversion stops at
27
+ // the first character which is not an uppercase hex digit
28
+ this.value = /^[0-9A-F]*/.exec(value)?.[0] || "";
27
29
  if (this.value.length % 2 === 1) {
28
30
  this.value = this.value + "0";
29
31
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/runtime",
3
- "version": "2.13.83",
3
+ "version": "2.13.84",
4
4
  "description": "Transpiler - Runtime",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",