@abaplint/runtime 1.8.24 → 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") {
@@ -15,6 +16,9 @@ function templateFormatting(source, options) {
15
16
  if (options.width) {
16
17
  text = text.trimEnd().padEnd(options.width, " ");
17
18
  }
19
+ else if (options.decimals && source instanceof types_1.Integer) {
20
+ text = source.get() + "." + "".padEnd(options.decimals, "0");
21
+ }
18
22
  return text;
19
23
  }
20
24
  exports.templateFormatting = templateFormatting;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/runtime",
3
- "version": "1.8.24",
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
  }