@abaplint/runtime 2.11.80 → 2.11.82

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,3 +1,3 @@
1
1
  import { ICharacter } from "../types/_character";
2
2
  export declare const LINE_NOT_FOUND = "CX_SY_ITAB_LINE_NOT_FOUND";
3
- export declare function line_exists(callback: () => void): ICharacter;
3
+ export declare function line_exists(callback: () => Promise<void>): Promise<ICharacter>;
@@ -4,9 +4,9 @@ exports.LINE_NOT_FOUND = void 0;
4
4
  exports.line_exists = line_exists;
5
5
  const is_line_not_found_1 = require("../is_line_not_found");
6
6
  exports.LINE_NOT_FOUND = "CX_SY_ITAB_LINE_NOT_FOUND";
7
- function line_exists(callback) {
7
+ async function line_exists(callback) {
8
8
  try {
9
- callback();
9
+ await callback();
10
10
  }
11
11
  catch (error) {
12
12
  if ((0, is_line_not_found_1.isLineNotFound)(error)) {
@@ -1,2 +1,2 @@
1
1
  import { Integer } from "../types";
2
- export declare function line_index(callback: () => void): Integer;
2
+ export declare function line_index(callback: () => Promise<void>): Promise<Integer>;
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.line_index = line_index;
4
4
  const is_line_not_found_1 = require("../is_line_not_found");
5
5
  const operators_1 = require("../operators");
6
- function line_index(callback) {
6
+ async function line_index(callback) {
7
7
  try {
8
- callback();
8
+ await callback();
9
9
  }
10
10
  catch (error) {
11
11
  if ((0, is_line_not_found_1.isLineNotFound)(error)) {
@@ -3,8 +3,8 @@ import { ICharacter } from "../types/_character";
3
3
  import { INumeric } from "../types/_numeric";
4
4
  export interface ITableExpressionOptions {
5
5
  index?: INumeric | ICharacter | string | Integer | number;
6
- withKey?: (i: any) => boolean;
6
+ withKey?: (i: any) => Promise<boolean>;
7
7
  usesTableLine?: boolean;
8
8
  }
9
9
  export declare let foundIndex: number;
10
- export declare function tableExpression(source: Table | HashedTable, options: ITableExpressionOptions): any;
10
+ export declare function tableExpression(source: Table | HashedTable, options: ITableExpressionOptions): Promise<any>;
@@ -6,14 +6,14 @@ const read_table_1 = require("../statements/read_table");
6
6
  const throw_error_1 = require("../throw_error");
7
7
  const _parse_1 = require("./_parse");
8
8
  exports.foundIndex = 0;
9
- function tableExpression(source, options) {
9
+ async function tableExpression(source, options) {
10
10
  let found;
11
11
  if (options.index) {
12
12
  exports.foundIndex = (0, _parse_1.parse)(options.index) - 1;
13
13
  found = source.array()[exports.foundIndex];
14
14
  }
15
15
  else if (options.withKey) {
16
- const search = (0, read_table_1.searchWithKey)(source.array(), options.withKey, 0, options?.usesTableLine);
16
+ const search = await (0, read_table_1.searchWithKeyPromise)(source.array(), options.withKey, 0, options?.usesTableLine);
17
17
  found = search.found;
18
18
  exports.foundIndex = search.foundIndex;
19
19
  }
@@ -29,4 +29,8 @@ export declare function searchWithKey(arr: any, withKey: (i: any) => boolean, st
29
29
  found: any;
30
30
  foundIndex: number;
31
31
  };
32
+ export declare function searchWithKeyPromise(arr: any, withKey: (i: any) => Promise<boolean>, startIndex: number | undefined, usesTableLine: boolean | undefined): Promise<{
33
+ found: any;
34
+ foundIndex: number;
35
+ }>;
32
36
  export declare function readTable(table: Table | HashedTable | FieldSymbol, options?: IReadTableOptions): ReadTableReturn;
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.searchWithKey = searchWithKey;
4
+ exports.searchWithKeyPromise = searchWithKeyPromise;
4
5
  exports.readTable = readTable;
6
+ /* eslint-disable max-len */
5
7
  const binary_search_1 = require("../binary_search");
6
8
  const compare_1 = require("../compare");
7
9
  const types_1 = require("../types");
@@ -64,6 +66,29 @@ function searchWithKey(arr, withKey, startIndex = 0, usesTableLine) {
64
66
  foundIndex: 0,
65
67
  };
66
68
  }
69
+ async function searchWithKeyPromise(arr, withKey, startIndex = 0, usesTableLine) {
70
+ const isStructured = arr[0] instanceof types_1.Structure;
71
+ for (let index = startIndex; index < arr.length; index++) {
72
+ const a = arr[index];
73
+ let row = undefined;
74
+ if (usesTableLine === false && isStructured === true) {
75
+ row = a.get();
76
+ }
77
+ else {
78
+ row = isStructured ? { table_line: a, ...a.get() } : { table_line: a };
79
+ }
80
+ if (await withKey(row) === true) {
81
+ return {
82
+ found: a,
83
+ foundIndex: index + 1,
84
+ };
85
+ }
86
+ }
87
+ return {
88
+ found: undefined,
89
+ foundIndex: 0,
90
+ };
91
+ }
67
92
  /////////////////
68
93
  function readTable(table, options) {
69
94
  let found = undefined;
@@ -12,6 +12,7 @@ const sort_1 = require("../statements/sort");
12
12
  const character_1 = require("./character");
13
13
  const hex_1 = require("./hex");
14
14
  const hex_uint8_1 = require("./hex_uint8");
15
+ const move_corresponding_1 = require("../statements/move_corresponding");
15
16
  var TableAccessType;
16
17
  (function (TableAccessType) {
17
18
  TableAccessType["standard"] = "STANDARD";
@@ -497,7 +498,7 @@ class Table {
497
498
  return ref;
498
499
  }
499
500
  else {
500
- const val = this.cloneRow(item);
501
+ const val = this.cloneRow(item, true);
501
502
  this.value.push(val);
502
503
  return val;
503
504
  }
@@ -518,7 +519,7 @@ class Table {
518
519
  this.value.sort(compareFn);
519
520
  }
520
521
  ///////////////////////////
521
- cloneRow(item) {
522
+ cloneRow(item, corresponding = false) {
522
523
  // make sure to do conversion if needed
523
524
  if (typeof item === "number") {
524
525
  const tmp = this.getRowType().clone();
@@ -536,6 +537,11 @@ class Table {
536
537
  const val = item.clone();
537
538
  return val;
538
539
  }
540
+ else if (corresponding === true && this.isStructured === true && item instanceof structure_1.Structure) {
541
+ const tmp = this.getRowType().clone();
542
+ (0, move_corresponding_1.moveCorresponding)(item, tmp);
543
+ return tmp;
544
+ }
539
545
  else {
540
546
  const tmp = this.getRowType().clone();
541
547
  tmp.set(item);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/runtime",
3
- "version": "2.11.80",
3
+ "version": "2.11.82",
4
4
  "description": "Transpiler - Runtime",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",