@abaplint/runtime 2.4.9 → 2.4.10

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.
@@ -34,6 +34,7 @@ export declare class Table {
34
34
  private readonly loops;
35
35
  private readonly options;
36
36
  private readonly qualifiedName;
37
+ private readonly isStructured;
37
38
  private secondaryIndexes;
38
39
  constructor(rowType: TableRowType, options?: ITableOptions, qualifiedName?: string);
39
40
  getKeyByName(name: string): ITableKey | undefined;
@@ -49,7 +50,7 @@ export declare class Table {
49
50
  getHeader(): TableRowType;
50
51
  insertIndex(item: TableRowType, index: number): TableRowType;
51
52
  deleteIndex(index: number): void;
52
- append(item: TableRowType, cloneRow?: boolean): FieldSymbol | DataReference | TableRowType;
53
+ append(item: TableRowType): FieldSymbol | DataReference | TableRowType;
53
54
  appendInitial(): TableRowType;
54
55
  sort(compareFn: (a: TableRowType, b: TableRowType) => number): void;
55
56
  private getValue;
@@ -4,6 +4,7 @@ exports.Table = exports.LoopIndex = exports.TableAccessType = void 0;
4
4
  const integer_1 = require("./integer");
5
5
  const string_1 = require("./string");
6
6
  const clone_1 = require("../clone");
7
+ const structure_1 = require("./structure");
7
8
  const field_symbol_1 = require("./field_symbol");
8
9
  const data_reference_1 = require("./data_reference");
9
10
  const insert_internal_1 = require("../statements/insert_internal");
@@ -29,6 +30,7 @@ class Table {
29
30
  this.loops = new Set();
30
31
  this.rowType = rowType;
31
32
  this.options = options;
33
+ this.isStructured = rowType instanceof structure_1.Structure;
32
34
  if ((options === null || options === void 0 ? void 0 : options.withHeader) === true) {
33
35
  this.header = (0, clone_1.clone)(this.rowType);
34
36
  }
@@ -147,7 +149,7 @@ class Table {
147
149
  }
148
150
  }
149
151
  }
150
- append(item, cloneRow = true) {
152
+ append(item) {
151
153
  this.secondaryIndexes = {};
152
154
  if (item instanceof field_symbol_1.FieldSymbol) {
153
155
  const p = item.getPointer();
@@ -164,11 +166,9 @@ class Table {
164
166
  return ref;
165
167
  }
166
168
  else {
167
- const val = this.getValue(item, cloneRow);
168
- const p = (0, clone_1.clone)(this.rowType);
169
- p.set(val);
170
- this.value.push(p);
171
- return p;
169
+ const val = this.getValue(item);
170
+ this.value.push(val);
171
+ return val;
172
172
  }
173
173
  }
174
174
  appendInitial() {
@@ -183,7 +183,7 @@ class Table {
183
183
  this.value.sort(compareFn);
184
184
  }
185
185
  ///////////////////////////
186
- getValue(item, cloneRow = true) {
186
+ getValue(item) {
187
187
  // make sure to do conversion if needed
188
188
  if (typeof item === "number") {
189
189
  const tmp = (0, clone_1.clone)(this.getRowType());
@@ -194,15 +194,19 @@ class Table {
194
194
  const tmp = (0, clone_1.clone)(this.getRowType());
195
195
  tmp.set(new string_1.String().set(item));
196
196
  return tmp;
197
+ // @ts-ignore
198
+ // eslint-disable-next-line max-len
199
+ }
200
+ else if (this.isStructured === true && item.getQualifiedName && this.rowType.getQualifiedName && item.getQualifiedName() === this.rowType.getQualifiedName()) {
201
+ // types match, so no need to do conversions, just clone the item
202
+ const val = (0, clone_1.clone)(item);
203
+ return val;
197
204
  }
198
- else if (cloneRow === true) {
205
+ else {
199
206
  const tmp = (0, clone_1.clone)(this.getRowType());
200
207
  tmp.set(item);
201
208
  return tmp;
202
209
  }
203
- else {
204
- return item;
205
- }
206
210
  }
207
211
  }
208
212
  exports.Table = Table;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/runtime",
3
- "version": "2.4.9",
3
+ "version": "2.4.10",
4
4
  "description": "Transpiler - Runtime",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",
@@ -36,6 +36,6 @@
36
36
  "typescript": "^4.8.4"
37
37
  },
38
38
  "dependencies": {
39
- "temporal-polyfill": "^0.0.8"
39
+ "temporal-polyfill": "^0.1.0"
40
40
  }
41
41
  }