@abaplint/runtime 2.0.4 → 2.0.7

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
@@ -1,5 +1,6 @@
1
+ import { DecFloat34, Float } from "../types";
1
2
  import { ICharacter } from "../types/_character";
2
3
  import { INumeric } from "../types/_numeric";
3
4
  export declare function frac(input: {
4
5
  val: number | string | ICharacter | INumeric;
5
- }): number;
6
+ }): number | Float | DecFloat34;
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.frac = void 0;
4
+ /* eslint-disable radix */
5
+ const types_1 = require("../types");
4
6
  function frac(input) {
5
7
  let num_in = undefined;
6
8
  let ret = 0;
@@ -11,6 +13,10 @@ function frac(input) {
11
13
  else if (typeof input.val === "string") {
12
14
  num_in = parseFloat(input.val);
13
15
  }
16
+ else if (input.val instanceof types_1.DecFloat34
17
+ || input.val instanceof types_1.Float) {
18
+ num_in = input.val.getRaw();
19
+ }
14
20
  else {
15
21
  num_in = parseFloat(input.val.get().toString());
16
22
  }
@@ -21,7 +27,15 @@ function frac(input) {
21
27
  }
22
28
  ret = parseFloat(pre + numSplit[1]);
23
29
  }
24
- return ret;
30
+ if (input.val instanceof types_1.DecFloat34) {
31
+ return new types_1.DecFloat34().set(ret);
32
+ }
33
+ else if (input.val instanceof types_1.Float) {
34
+ return new types_1.Float().set(ret);
35
+ }
36
+ else {
37
+ return ret;
38
+ }
25
39
  }
26
40
  exports.frac = frac;
27
41
  //# sourceMappingURL=frac.js.map
@@ -27,8 +27,13 @@ function replace(input) {
27
27
  replace = input.with.get();
28
28
  }
29
29
  if (input.all === true) {
30
- while (temp.replace(search, replace) !== temp) {
31
- temp = temp.replace(search, replace);
30
+ if (input.regex) {
31
+ temp = temp.replace(new RegExp(input.regex.get(), "g"), replace);
32
+ }
33
+ else {
34
+ while (temp.replace(search, replace) !== temp) {
35
+ temp = temp.replace(search, replace);
36
+ }
32
37
  }
33
38
  }
34
39
  else {
@@ -2,6 +2,7 @@ import { ICharacter } from "../types/_character";
2
2
  import { INumeric } from "../types/_numeric";
3
3
  export interface IShiftOptions {
4
4
  deletingLeading?: string | ICharacter;
5
+ deletingTrailing?: string | ICharacter;
5
6
  places?: INumeric;
6
7
  to?: ICharacter | string;
7
8
  direction?: "LEFT" | "RIGHT";
@@ -2,9 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.shift = void 0;
4
4
  function shift(target, options) {
5
- if ((options === null || options === void 0 ? void 0 : options.direction) === "RIGHT") {
6
- throw "SHIFT, RIGHT todo";
7
- }
8
5
  if ((options === null || options === void 0 ? void 0 : options.mode) === "BYTE") {
9
6
  shift_byte_mode(target, options);
10
7
  }
@@ -25,6 +22,15 @@ function shift_character_mode(target, options) {
25
22
  value = value.substr(1);
26
23
  }
27
24
  }
25
+ else if (options === null || options === void 0 ? void 0 : options.deletingTrailing) {
26
+ let trailing = options.deletingTrailing;
27
+ if (typeof trailing !== "string") {
28
+ trailing = trailing.get();
29
+ }
30
+ if (value.endsWith(trailing)) {
31
+ value = " ".repeat(trailing.length) + value.substring(0, value.length - trailing.length);
32
+ }
33
+ }
28
34
  else if (options === null || options === void 0 ? void 0 : options.places) {
29
35
  const p = options.places.get();
30
36
  if (options.circular) {
package/package.json CHANGED
@@ -1,39 +1,39 @@
1
- {
2
- "name": "@abaplint/runtime",
3
- "version": "2.0.4",
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.0",
32
- "@types/mocha": "^9.1.0",
33
- "@types/sql.js": "^1.4.3",
34
- "chai": "^4.3.6",
35
- "mocha": "^9.2.2",
36
- "source-map-support": "^0.5.21",
37
- "typescript": "^4.6.3"
38
- }
39
- }
1
+ {
2
+ "name": "@abaplint/runtime",
3
+ "version": "2.0.7",
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.0",
32
+ "@types/mocha": "^9.1.0",
33
+ "@types/sql.js": "^1.4.3",
34
+ "chai": "^4.3.6",
35
+ "mocha": "^9.2.2",
36
+ "source-map-support": "^0.5.21",
37
+ "typescript": "^4.6.3"
38
+ }
39
+ }