@abaplint/runtime 2.0.18 → 2.0.21
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 +2 -2
- package/build/src/builtin/condense.d.ts +3 -0
- package/build/src/builtin/condense.js +16 -5
- package/build/src/builtin/index.d.ts +1 -0
- package/build/src/builtin/index.js +1 -0
- package/build/src/builtin/translate.d.ts +6 -0
- package/build/src/builtin/translate.js +20 -0
- package/package.json +39 -39
package/README.md
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
# @abaplint/runtime
|
|
2
|
-
|
|
1
|
+
# @abaplint/runtime
|
|
2
|
+
|
|
3
3
|
Runtime
|
|
@@ -3,4 +3,7 @@ import { ICharacter } from "../types/_character";
|
|
|
3
3
|
import { INumeric } from "../types/_numeric";
|
|
4
4
|
export declare function condense(input: {
|
|
5
5
|
val: ICharacter | INumeric | string;
|
|
6
|
+
from?: ICharacter | string;
|
|
7
|
+
to?: ICharacter | string;
|
|
8
|
+
del?: ICharacter | string;
|
|
6
9
|
}): String;
|
|
@@ -3,15 +3,26 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.condense = void 0;
|
|
4
4
|
const types_1 = require("../types");
|
|
5
5
|
function condense(input) {
|
|
6
|
-
let str = "";
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
let str = typeof input.val === "string" ? input.val : input.val.get().toString();
|
|
7
|
+
let from = " ";
|
|
8
|
+
if (input.from) {
|
|
9
|
+
from = typeof input.from === "string" ? input.from : input.from.get().toString();
|
|
9
10
|
}
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
let to = " ";
|
|
12
|
+
if (input.to) {
|
|
13
|
+
to = typeof input.to === "string" ? input.to : input.to.get().toString();
|
|
12
14
|
}
|
|
15
|
+
/*
|
|
16
|
+
let del = " ";
|
|
17
|
+
if (input.del) {
|
|
18
|
+
del = typeof input.del === "string" ? input.del : input.del.get().toString();
|
|
19
|
+
}
|
|
20
|
+
*/
|
|
13
21
|
str = str.replace(/ +$/, "");
|
|
14
22
|
str = str.replace(/^ +/, "");
|
|
23
|
+
for (const f of from.split("")) {
|
|
24
|
+
str = str.replace(new RegExp(f.replace(".", "\\."), "g"), to);
|
|
25
|
+
}
|
|
15
26
|
return new types_1.String().set(str.replace(/ {2,}/g, " "));
|
|
16
27
|
}
|
|
17
28
|
exports.condense = condense;
|
|
@@ -50,6 +50,7 @@ __exportStar(require("./tan"), exports);
|
|
|
50
50
|
__exportStar(require("./to_lower"), exports);
|
|
51
51
|
__exportStar(require("./to_mixed"), exports);
|
|
52
52
|
__exportStar(require("./to_upper"), exports);
|
|
53
|
+
__exportStar(require("./translate"), exports);
|
|
53
54
|
__exportStar(require("./trunc"), exports);
|
|
54
55
|
__exportStar(require("./xstrlen"), exports);
|
|
55
56
|
exports.abap_true = new types_1.Character({ length: 1, qualifiedName: "ABAP_BOOL" }).set("X");
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.translate = void 0;
|
|
4
|
+
const string_1 = require("../types/string");
|
|
5
|
+
function translate(input) {
|
|
6
|
+
let val = typeof input.val === "string" ? input.val : input.val.get();
|
|
7
|
+
const from = typeof input.from === "string" ? input.from : input.from.get();
|
|
8
|
+
const to = typeof input.to === "string" ? input.to : input.to.get();
|
|
9
|
+
const fromSplit = from.split("");
|
|
10
|
+
const toSplit = to.split("");
|
|
11
|
+
const chars = {};
|
|
12
|
+
for (let i = 0; i < fromSplit.length; i++) {
|
|
13
|
+
chars[fromSplit[i]] = toSplit[i] || "";
|
|
14
|
+
}
|
|
15
|
+
const reg = new RegExp("[" + from + "]", "g");
|
|
16
|
+
val = val.replace(reg, m => chars[m] || "");
|
|
17
|
+
return new string_1.String().set(val);
|
|
18
|
+
}
|
|
19
|
+
exports.translate = translate;
|
|
20
|
+
//# sourceMappingURL=translate.js.map
|
package/package.json
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@abaplint/runtime",
|
|
3
|
-
"version": "2.0.
|
|
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.1",
|
|
32
|
-
"@types/mocha": "^9.1.1",
|
|
33
|
-
"@types/sql.js": "^1.4.3",
|
|
34
|
-
"chai": "^4.3.6",
|
|
35
|
-
"mocha": "^10.0.0",
|
|
36
|
-
"source-map-support": "^0.5.21",
|
|
37
|
-
"typescript": "^4.6.4"
|
|
38
|
-
}
|
|
39
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@abaplint/runtime",
|
|
3
|
+
"version": "2.0.21",
|
|
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.1",
|
|
32
|
+
"@types/mocha": "^9.1.1",
|
|
33
|
+
"@types/sql.js": "^1.4.3",
|
|
34
|
+
"chai": "^4.3.6",
|
|
35
|
+
"mocha": "^10.0.0",
|
|
36
|
+
"source-map-support": "^0.5.21",
|
|
37
|
+
"typescript": "^4.6.4"
|
|
38
|
+
}
|
|
39
|
+
}
|