@abaplint/runtime 1.8.25 → 1.8.28

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,8 +1,12 @@
1
1
  import { FieldSymbol, Table, TableRowType } from "../types";
2
+ import { ICharacter } from "../types/_character";
3
+ import { INumeric } from "../types/_numeric";
2
4
  export interface IAppendOptions {
3
5
  source: TableRowType;
4
6
  target: Table;
5
7
  lines?: boolean;
6
8
  assigning?: FieldSymbol;
9
+ from?: ICharacter | INumeric;
10
+ to?: ICharacter | INumeric;
7
11
  }
8
12
  export declare function append(input: IAppendOptions): void;
@@ -4,8 +4,21 @@ exports.append = void 0;
4
4
  const types_1 = require("../types");
5
5
  function append(input) {
6
6
  if (input.lines === true && input.source instanceof types_1.Table) {
7
+ let from = 1;
8
+ if (input.from) {
9
+ from = parseInt(input.from.get() + "", 10);
10
+ }
11
+ let to = input.source.array().length;
12
+ if (input.to) {
13
+ to = parseInt(input.to.get() + "", 10);
14
+ }
15
+ let index = 1;
7
16
  for (const a of input.source.array()) {
17
+ if (index < from || index > to) {
18
+ continue;
19
+ }
8
20
  input.target.append(a);
21
+ index++;
9
22
  }
10
23
  }
11
24
  else {
@@ -14,4 +14,4 @@ export interface IFindOptions {
14
14
  ignoringCase?: boolean;
15
15
  submatches?: ICharacter[];
16
16
  }
17
- export declare function find(input: ICharacter | string, options: IFindOptions): void;
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
- // eslint-disable-next-line no-cond-assign
58
- while (temp = s.exec(i)) {
59
- matches.push(temp);
60
- if (options.first === true) {
61
- break;
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 function replace(input: ICharacter, all: boolean, s: ICharacter | string, r: ICharacter | string): void;
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, all, s, r) {
5
- let temp = input.get();
4
+ function replace(input) {
5
+ let temp = input.target.get();
6
6
  let search = "";
7
- if (typeof s === "string") {
8
- search = s;
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
- search = s.get();
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 r === "string") {
15
- replace = r;
23
+ if (typeof input.with === "string") {
24
+ replace = input.with;
16
25
  }
17
26
  else {
18
- replace = r.get();
27
+ replace = input.with.get();
19
28
  }
20
- const found = temp.indexOf(search) >= 0;
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/runtime",
3
- "version": "1.8.25",
3
+ "version": "1.8.28",
4
4
  "description": "Transpiler - Runtime",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",