@abaplint/runtime 2.11.62 → 2.11.63

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.
@@ -0,0 +1,5 @@
1
+ import { Character, String } from "./types";
2
+ import { ICharacter } from "./types/_character";
3
+ import { INumeric } from "./types/_numeric";
4
+ export declare function alphaOut(source: ICharacter | INumeric): string;
5
+ export declare function alphaIn(source: ICharacter | INumeric | String, context: Character | String | undefined): string;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.alphaOut = alphaOut;
4
+ exports.alphaIn = alphaIn;
5
+ const types_1 = require("./types");
6
+ function alphaOut(source) {
7
+ const txt = source.get() + "";
8
+ return txt.replace(/^0+/, "");
9
+ }
10
+ function alphaIn(source, context) {
11
+ let txt = source.get() + "";
12
+ if (context === undefined) {
13
+ throw new Error("alphaIn, context is undefined");
14
+ }
15
+ if (txt.match(/^[0-9 ]+$/) === null) {
16
+ // contains letters
17
+ return txt;
18
+ }
19
+ let length = 0;
20
+ if (context instanceof types_1.String && source instanceof types_1.String) {
21
+ return txt;
22
+ }
23
+ else if (context instanceof types_1.Character) {
24
+ length = context.getLength();
25
+ }
26
+ else if (source instanceof types_1.Character) {
27
+ length = source.getLength();
28
+ }
29
+ txt = txt.trimEnd();
30
+ return txt.padStart(length, "0");
31
+ }
32
+ //# sourceMappingURL=alpha.js.map
@@ -20,6 +20,7 @@ import { CharacterFactory } from "./character_factory";
20
20
  import { ABAPEventing } from "./abap_eventing";
21
21
  import { isLineNotFound } from "./is_line_not_found";
22
22
  import { parametersCall } from "./parameters_call";
23
+ import { alphaIn, alphaOut } from "./alpha";
23
24
  export { RFC, types, DB, MemoryConsole };
24
25
  export type RuntimeDatabaseOptions = {
25
26
  schemaPrefix?: string;
@@ -77,6 +78,8 @@ export declare class ABAP {
77
78
  dynamicCallLookup: typeof dynamicCallLookup;
78
79
  parametersCall: typeof parametersCall;
79
80
  eventing: ABAPEventing;
81
+ alphaOut: typeof alphaOut;
82
+ alphaIn: typeof alphaIn;
80
83
  IntegerFactory: typeof IntegerFactory;
81
84
  CharacterFactory: typeof CharacterFactory;
82
85
  readonly context: Context;
@@ -27,6 +27,7 @@ const character_factory_1 = require("./character_factory");
27
27
  const abap_eventing_1 = require("./abap_eventing");
28
28
  const is_line_not_found_1 = require("./is_line_not_found");
29
29
  const parameters_call_1 = require("./parameters_call");
30
+ const alpha_1 = require("./alpha");
30
31
  class ABAP {
31
32
  // global objects
32
33
  Classes = {};
@@ -57,6 +58,8 @@ class ABAP {
57
58
  dynamicCallLookup = dynamic_call_lookup_1.dynamicCallLookup;
58
59
  parametersCall = parameters_call_1.parametersCall;
59
60
  eventing = new abap_eventing_1.ABAPEventing();
61
+ alphaOut = alpha_1.alphaOut;
62
+ alphaIn = alpha_1.alphaIn;
60
63
  IntegerFactory = integer_factory_1.IntegerFactory;
61
64
  CharacterFactory = character_factory_1.CharacterFactory;
62
65
  context;
@@ -9,6 +9,8 @@ type options = {
9
9
  decimals?: number;
10
10
  currency?: any;
11
11
  style?: any;
12
+ alpha?: "out" | "in";
13
+ alphaInContext?: any;
12
14
  align?: "left" | "right";
13
15
  };
14
16
  export declare function templateFormatting(source: ICharacter | INumeric, options?: options): string;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.templateFormatting = templateFormatting;
4
+ const alpha_1 = require("./alpha");
4
5
  const types_1 = require("./types");
5
6
  function templateFormatting(source, options) {
6
7
  let text = "";
@@ -52,6 +53,12 @@ function templateFormatting(source, options) {
52
53
  else {
53
54
  text = source.get() + "";
54
55
  }
56
+ if (options?.alpha === "out") {
57
+ text = (0, alpha_1.alphaOut)(source);
58
+ }
59
+ else if (options?.alpha === "in") {
60
+ text = (0, alpha_1.alphaIn)(source, options.alphaInContext);
61
+ }
55
62
  if (options) {
56
63
  if (options.currency !== undefined) {
57
64
  throw "template formatting with currency not supported";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/runtime",
3
- "version": "2.11.62",
3
+ "version": "2.11.63",
4
4
  "description": "Transpiler - Runtime",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",
@@ -32,7 +32,7 @@
32
32
  "@types/chai": "^4.3.20",
33
33
  "@types/mocha": "^10.0.10",
34
34
  "chai": "^4.5.0",
35
- "mocha": "^11.7.1",
35
+ "mocha": "^11.7.2",
36
36
  "source-map-support": "^0.5.21",
37
37
  "typescript": "^5.9.2"
38
38
  },