@abaplint/runtime 2.1.54 → 2.1.55
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/README.md
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
# @abaplint/runtime
|
|
2
|
-
|
|
1
|
+
# @abaplint/runtime
|
|
2
|
+
|
|
3
3
|
Runtime
|
|
@@ -9,4 +9,4 @@ export interface IDeleteInternalOptions {
|
|
|
9
9
|
from?: any;
|
|
10
10
|
to?: any;
|
|
11
11
|
}
|
|
12
|
-
export declare function deleteInternal(target: Table | FieldSymbol, options?: IDeleteInternalOptions): void
|
|
12
|
+
export declare function deleteInternal(target: Table | FieldSymbol, options?: IDeleteInternalOptions): Promise<void>;
|
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
3
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
4
|
+
var m = o[Symbol.asyncIterator], i;
|
|
5
|
+
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
6
|
+
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
7
|
+
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
8
|
+
};
|
|
2
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
10
|
exports.deleteInternal = void 0;
|
|
4
11
|
const types_1 = require("../types");
|
|
5
12
|
const compare_1 = require("../compare");
|
|
6
13
|
const loop_1 = require("./loop");
|
|
7
|
-
function deleteInternal(target, options) {
|
|
14
|
+
async function deleteInternal(target, options) {
|
|
15
|
+
var e_1, _a;
|
|
8
16
|
let prev = undefined;
|
|
9
17
|
let index = 0;
|
|
10
18
|
if (target instanceof types_1.FieldSymbol) {
|
|
@@ -31,45 +39,55 @@ function deleteInternal(target, options) {
|
|
|
31
39
|
return;
|
|
32
40
|
}
|
|
33
41
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if (options
|
|
40
|
-
|
|
42
|
+
try {
|
|
43
|
+
for (var _b = __asyncValues((0, loop_1.loop)(target)), _c; _c = await _b.next(), !_c.done;) {
|
|
44
|
+
const i = _c.value;
|
|
45
|
+
// @ts-ignore
|
|
46
|
+
index = abap.builtin.sy.get().tabix.get() - 1;
|
|
47
|
+
if (options === null || options === void 0 ? void 0 : options.where) {
|
|
48
|
+
const row = i instanceof types_1.Structure ? i.get() : { table_line: i };
|
|
49
|
+
if (options.where(row) === true) {
|
|
50
|
+
target.deleteIndex(index);
|
|
51
|
+
}
|
|
41
52
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
53
|
+
else if ((options === null || options === void 0 ? void 0 : options.adjacent) === true && prev !== undefined) {
|
|
54
|
+
if (options === null || options === void 0 ? void 0 : options.comparing) {
|
|
55
|
+
let match = false;
|
|
56
|
+
for (const compareField of options.comparing) {
|
|
57
|
+
match = (0, compare_1.eq)(prev.get()[compareField], i.get()[compareField]);
|
|
58
|
+
if (!match) {
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
if (match) {
|
|
63
|
+
target.deleteIndex(index);
|
|
50
64
|
}
|
|
51
65
|
}
|
|
52
|
-
if (
|
|
66
|
+
else if ((0, compare_1.eq)(prev, i) === true) {
|
|
53
67
|
target.deleteIndex(index);
|
|
54
68
|
}
|
|
55
69
|
}
|
|
56
|
-
else if ((0
|
|
70
|
+
else if ((options === null || options === void 0 ? void 0 : options.index) && options.index.get() === index) {
|
|
71
|
+
target.deleteIndex(options.index.get() - 1);
|
|
72
|
+
}
|
|
73
|
+
else if ((options === null || options === void 0 ? void 0 : options.fromValue) && (0, compare_1.eq)(options.fromValue, i)) {
|
|
57
74
|
target.deleteIndex(index);
|
|
58
75
|
}
|
|
76
|
+
else if ((options === null || options === void 0 ? void 0 : options.from) && options.from.get() <= index + 1) {
|
|
77
|
+
target.deleteIndex(index);
|
|
78
|
+
}
|
|
79
|
+
else if ((options === null || options === void 0 ? void 0 : options.to) && options.to.get() <= index + 1) {
|
|
80
|
+
target.deleteIndex(0);
|
|
81
|
+
}
|
|
82
|
+
prev = i;
|
|
59
83
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
else if ((options === null || options === void 0 ? void 0 : options.from) && options.from.get() <= index + 1) {
|
|
67
|
-
target.deleteIndex(index);
|
|
68
|
-
}
|
|
69
|
-
else if ((options === null || options === void 0 ? void 0 : options.to) && options.to.get() <= index + 1) {
|
|
70
|
-
target.deleteIndex(0);
|
|
84
|
+
}
|
|
85
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
86
|
+
finally {
|
|
87
|
+
try {
|
|
88
|
+
if (_c && !_c.done && (_a = _b.return)) await _a.call(_b);
|
|
71
89
|
}
|
|
72
|
-
|
|
90
|
+
finally { if (e_1) throw e_1.error; }
|
|
73
91
|
}
|
|
74
92
|
}
|
|
75
93
|
exports.deleteInternal = deleteInternal;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FieldSymbol, Integer, Table } from "../types";
|
|
2
2
|
export interface ILoopOptions {
|
|
3
|
-
where?: (i: any) => boolean
|
|
3
|
+
where?: (i: any) => Promise<boolean>;
|
|
4
4
|
from?: Integer;
|
|
5
5
|
to?: Integer;
|
|
6
6
|
}
|
|
7
|
-
export declare function loop(table: Table | FieldSymbol | undefined, options?: ILoopOptions):
|
|
7
|
+
export declare function loop(table: Table | FieldSymbol | undefined, options?: ILoopOptions): AsyncGenerator<any, void, unknown>;
|
|
@@ -1,54 +1,80 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
3
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
4
|
+
var m = o[Symbol.asyncIterator], i;
|
|
5
|
+
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
6
|
+
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
7
|
+
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
8
|
+
};
|
|
9
|
+
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
|
10
|
+
var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {
|
|
11
|
+
var i, p;
|
|
12
|
+
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
|
13
|
+
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
|
|
14
|
+
};
|
|
15
|
+
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
|
16
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
17
|
+
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
18
|
+
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
19
|
+
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
|
|
20
|
+
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
21
|
+
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
22
|
+
function fulfill(value) { resume("next", value); }
|
|
23
|
+
function reject(value) { resume("throw", value); }
|
|
24
|
+
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
25
|
+
};
|
|
2
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
27
|
exports.loop = void 0;
|
|
4
28
|
const types_1 = require("../types");
|
|
5
|
-
function
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const current = array[loopIndex.index];
|
|
32
|
-
if (options === null || options === void 0 ? void 0 : options.where) {
|
|
33
|
-
const row = isStructured ? current.get() : { table_line: current };
|
|
34
|
-
if (options.where(row) === false) {
|
|
35
|
-
loopIndex.index++;
|
|
36
|
-
continue;
|
|
29
|
+
function loop(table, options) {
|
|
30
|
+
return __asyncGenerator(this, arguments, function* loop_1() {
|
|
31
|
+
if (table === undefined) {
|
|
32
|
+
throw new Error("LOOP at undefined");
|
|
33
|
+
}
|
|
34
|
+
else if (table instanceof types_1.FieldSymbol) {
|
|
35
|
+
// @ts-ignore
|
|
36
|
+
yield __await(yield* __asyncDelegator(__asyncValues(loop(table.getPointer(), options))));
|
|
37
|
+
return yield __await(void 0);
|
|
38
|
+
}
|
|
39
|
+
const length = table.array().length;
|
|
40
|
+
if (length === 0) {
|
|
41
|
+
// @ts-ignore
|
|
42
|
+
abap.builtin.sy.get().subrc.set(4);
|
|
43
|
+
return yield __await(void 0);
|
|
44
|
+
}
|
|
45
|
+
const loopFrom = (options === null || options === void 0 ? void 0 : options.from) && (options === null || options === void 0 ? void 0 : options.from.get()) > 0 ? options.from.get() - 1 : 0;
|
|
46
|
+
let loopTo = (options === null || options === void 0 ? void 0 : options.to) && options.to.get() < length ? options.to.get() : length;
|
|
47
|
+
const loopIndex = table.startLoop(loopFrom);
|
|
48
|
+
let entered = false;
|
|
49
|
+
try {
|
|
50
|
+
const array = table.array();
|
|
51
|
+
const isStructured = array[0] instanceof types_1.Structure;
|
|
52
|
+
while (loopIndex.index < loopTo) {
|
|
53
|
+
if (loopIndex.index > array.length) {
|
|
54
|
+
break;
|
|
37
55
|
}
|
|
56
|
+
const current = array[loopIndex.index];
|
|
57
|
+
if (options === null || options === void 0 ? void 0 : options.where) {
|
|
58
|
+
const row = isStructured ? current.get() : { table_line: current };
|
|
59
|
+
if ((yield __await(options.where(row))) === false) {
|
|
60
|
+
loopIndex.index++;
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
// @ts-ignore
|
|
65
|
+
abap.builtin.sy.get().tabix.set(loopIndex.index + 1);
|
|
66
|
+
entered = true;
|
|
67
|
+
yield yield __await(current);
|
|
68
|
+
loopIndex.index++;
|
|
69
|
+
loopTo = (options === null || options === void 0 ? void 0 : options.to) && options.to.get() < array.length ? options.to.get() : array.length;
|
|
38
70
|
}
|
|
71
|
+
}
|
|
72
|
+
finally {
|
|
73
|
+
table.unregisterLoop(loopIndex);
|
|
39
74
|
// @ts-ignore
|
|
40
|
-
abap.builtin.sy.get().
|
|
41
|
-
entered = true;
|
|
42
|
-
yield current;
|
|
43
|
-
loopIndex.index++;
|
|
44
|
-
loopTo = (options === null || options === void 0 ? void 0 : options.to) && options.to.get() < array.length ? options.to.get() : array.length;
|
|
75
|
+
abap.builtin.sy.get().subrc.set(entered ? 0 : 4);
|
|
45
76
|
}
|
|
46
|
-
}
|
|
47
|
-
finally {
|
|
48
|
-
table.unregisterLoop(loopIndex);
|
|
49
|
-
// @ts-ignore
|
|
50
|
-
abap.builtin.sy.get().subrc.set(entered ? 0 : 4);
|
|
51
|
-
}
|
|
77
|
+
});
|
|
52
78
|
}
|
|
53
79
|
exports.loop = loop;
|
|
54
80
|
//# sourceMappingURL=loop.js.map
|
package/package.json
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@abaplint/runtime",
|
|
3
|
-
"version": "2.1.
|
|
4
|
-
"description": "Transpiler - Runtime",
|
|
5
|
-
"main": "build/src/index.js",
|
|
6
|
-
"typings": "build/src/index.d.ts",
|
|
7
|
-
"repository": {
|
|
8
|
-
"type": "git",
|
|
9
|
-
"url": "git+https://github.com/abaplint/transpiler.git"
|
|
10
|
-
},
|
|
11
|
-
"scripts": {
|
|
12
|
-
"compile": "tsc",
|
|
13
|
-
"publish:major": "npm --no-git-tag-version version major && rm -rf build && npm install && npm run test && npm publish --access public",
|
|
14
|
-
"publish:minor": "npm --no-git-tag-version version minor && rm -rf build && npm install && npm run test && npm publish --access public",
|
|
15
|
-
"publish:patch": "npm --no-git-tag-version version patch && rm -rf build && npm install && npm run test && npm publish --access public",
|
|
16
|
-
"test": "npm run compile && mocha"
|
|
17
|
-
},
|
|
18
|
-
"mocha": {
|
|
19
|
-
"recursive": true,
|
|
20
|
-
"reporter": "progress",
|
|
21
|
-
"spec": "build/test/**/*.js",
|
|
22
|
-
"require": "source-map-support/register"
|
|
23
|
-
},
|
|
24
|
-
"keywords": [
|
|
25
|
-
"ABAP",
|
|
26
|
-
"abaplint"
|
|
27
|
-
],
|
|
28
|
-
"author": "abaplint",
|
|
29
|
-
"license": "MIT",
|
|
30
|
-
"devDependencies": {
|
|
31
|
-
"@types/chai": "^4.3.3",
|
|
32
|
-
"@types/mocha": "^9.1.1",
|
|
33
|
-
"chai": "^4.3.6",
|
|
34
|
-
"mocha": "^10.0.0",
|
|
35
|
-
"source-map-support": "^0.5.21",
|
|
36
|
-
"typescript": "^4.8.
|
|
37
|
-
},
|
|
38
|
-
"dependencies": {
|
|
39
|
-
"temporal-polyfill": "^0.0.8"
|
|
40
|
-
}
|
|
41
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@abaplint/runtime",
|
|
3
|
+
"version": "2.1.55",
|
|
4
|
+
"description": "Transpiler - Runtime",
|
|
5
|
+
"main": "build/src/index.js",
|
|
6
|
+
"typings": "build/src/index.d.ts",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/abaplint/transpiler.git"
|
|
10
|
+
},
|
|
11
|
+
"scripts": {
|
|
12
|
+
"compile": "tsc",
|
|
13
|
+
"publish:major": "npm --no-git-tag-version version major && rm -rf build && npm install && npm run test && npm publish --access public",
|
|
14
|
+
"publish:minor": "npm --no-git-tag-version version minor && rm -rf build && npm install && npm run test && npm publish --access public",
|
|
15
|
+
"publish:patch": "npm --no-git-tag-version version patch && rm -rf build && npm install && npm run test && npm publish --access public",
|
|
16
|
+
"test": "npm run compile && mocha"
|
|
17
|
+
},
|
|
18
|
+
"mocha": {
|
|
19
|
+
"recursive": true,
|
|
20
|
+
"reporter": "progress",
|
|
21
|
+
"spec": "build/test/**/*.js",
|
|
22
|
+
"require": "source-map-support/register"
|
|
23
|
+
},
|
|
24
|
+
"keywords": [
|
|
25
|
+
"ABAP",
|
|
26
|
+
"abaplint"
|
|
27
|
+
],
|
|
28
|
+
"author": "abaplint",
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@types/chai": "^4.3.3",
|
|
32
|
+
"@types/mocha": "^9.1.1",
|
|
33
|
+
"chai": "^4.3.6",
|
|
34
|
+
"mocha": "^10.0.0",
|
|
35
|
+
"source-map-support": "^0.5.21",
|
|
36
|
+
"typescript": "^4.8.3"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"temporal-polyfill": "^0.0.8"
|
|
40
|
+
}
|
|
41
|
+
}
|