@abaplint/runtime 1.8.22 → 1.8.25

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,6 +1,9 @@
1
1
  import { Integer } from "../types";
2
2
  import { ICharacter } from "../types/_character";
3
- export declare function count(input: {
4
- val: ICharacter | string;
5
- sub: ICharacter | string;
6
- }): Integer;
3
+ export declare type countInput = {
4
+ val: ICharacter;
5
+ sub: ICharacter;
6
+ regex?: ICharacter;
7
+ case?: ICharacter;
8
+ };
9
+ export declare function count(input: countInput): Integer;
@@ -1,14 +1,25 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.count = void 0;
4
+ const compare_1 = require("../compare");
4
5
  const types_1 = require("../types");
5
6
  function count(input) {
6
7
  let found = 0;
7
- const val = typeof input.val === "string" ? input.val : input.val.get();
8
- let sub = typeof input.sub === "string" ? input.sub : input.sub.get();
9
- sub = sub.replace(/\*/g, "\\*");
8
+ const val = input.val.get();
9
+ let reg = "";
10
+ if (input.sub) {
11
+ reg = input.sub.get();
12
+ reg = reg.replace(/\*/g, "\\*");
13
+ }
14
+ else if (input.regex) {
15
+ reg = input.regex.get();
16
+ }
17
+ let options = "g";
18
+ if (input.case && (0, compare_1.initial)(input.case)) {
19
+ options += "i";
20
+ }
10
21
  if (val !== "") {
11
- const res = val.match(new RegExp(sub, "g"));
22
+ const res = val.match(new RegExp(reg, options));
12
23
  if (res) {
13
24
  found = res.length;
14
25
  }
@@ -5,6 +5,7 @@ declare type options = {
5
5
  date?: string;
6
6
  time?: string;
7
7
  width?: number;
8
+ decimals?: number;
8
9
  };
9
10
  export declare function templateFormatting(source: ICharacter | INumeric, options: options): string;
10
11
  export {};
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.templateFormatting = void 0;
4
+ const types_1 = require("./types");
4
5
  function templateFormatting(source, options) {
5
6
  let text = source.get() + "";
6
7
  if (options.timestamp === "iso") {
@@ -13,7 +14,10 @@ function templateFormatting(source, options) {
13
14
  text = text.substr(0, 2) + ":" + text.substr(2, 2) + ":" + text.substr(4, 2);
14
15
  }
15
16
  if (options.width) {
16
- text = text.padEnd(options.width, " ");
17
+ text = text.trimEnd().padEnd(options.width, " ");
18
+ }
19
+ else if (options.decimals && source instanceof types_1.Integer) {
20
+ text = source.get() + "." + "".padEnd(options.decimals, "0");
17
21
  }
18
22
  return text;
19
23
  }
@@ -120,14 +120,24 @@ class Table {
120
120
  }
121
121
  ///////////////////////////
122
122
  getValue(item, cloneRow = true) {
123
+ // make sure to do conversion if needed
123
124
  if (typeof item === "number") {
124
- return new integer_1.Integer().set(item);
125
+ const tmp = (0, clone_1.clone)(this.getRowType());
126
+ tmp.set(new integer_1.Integer().set(item));
127
+ return tmp;
125
128
  }
126
129
  else if (typeof item === "string") {
127
- return new string_1.String().set(item);
130
+ const tmp = (0, clone_1.clone)(this.getRowType());
131
+ tmp.set(new string_1.String().set(item));
132
+ return tmp;
133
+ }
134
+ else if (cloneRow === true) {
135
+ const tmp = (0, clone_1.clone)(this.getRowType());
136
+ tmp.set(item);
137
+ return tmp;
128
138
  }
129
139
  else {
130
- return cloneRow === true ? (0, clone_1.clone)(item) : item;
140
+ return item;
131
141
  }
132
142
  }
133
143
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/runtime",
3
- "version": "1.8.22",
3
+ "version": "1.8.25",
4
4
  "description": "Transpiler - Runtime",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",
@@ -37,6 +37,6 @@
37
37
  "chai": "^4.3.6",
38
38
  "mocha": "^9.2.2",
39
39
  "source-map-support": "^0.5.21",
40
- "typescript": "^4.6.2"
40
+ "typescript": "^4.6.3"
41
41
  }
42
42
  }