@abaplint/runtime 1.8.26 → 1.8.29

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,8 +1,12 @@
1
1
  import { FieldSymbol, Table, TableRowType } from "../types";
2
+ import { ICharacter } from "../types/_character";
3
+ import { INumeric } from "../types/_numeric";
2
4
  export interface IAppendOptions {
3
5
  source: TableRowType;
4
6
  target: Table;
5
7
  lines?: boolean;
6
8
  assigning?: FieldSymbol;
9
+ from?: ICharacter | INumeric;
10
+ to?: ICharacter | INumeric;
7
11
  }
8
12
  export declare function append(input: IAppendOptions): void;
@@ -4,8 +4,21 @@ exports.append = void 0;
4
4
  const types_1 = require("../types");
5
5
  function append(input) {
6
6
  if (input.lines === true && input.source instanceof types_1.Table) {
7
+ let from = 1;
8
+ if (input.from) {
9
+ from = parseInt(input.from.get() + "", 10);
10
+ }
11
+ let to = input.source.array().length;
12
+ if (input.to) {
13
+ to = parseInt(input.to.get() + "", 10);
14
+ }
15
+ let index = 1;
7
16
  for (const a of input.source.array()) {
17
+ if (index < from || index > to) {
18
+ continue;
19
+ }
8
20
  input.target.append(a);
21
+ index++;
9
22
  }
10
23
  }
11
24
  else {
@@ -1,2 +1,10 @@
1
1
  import { ICharacter } from "../types/_character";
2
- export declare function replace(input: ICharacter, all: boolean, s: ICharacter | string, r: ICharacter | string): void;
2
+ export declare type replaceInput = {
3
+ target: ICharacter;
4
+ sectionLength?: ICharacter;
5
+ regex?: ICharacter;
6
+ all: boolean;
7
+ with: ICharacter;
8
+ of: ICharacter;
9
+ };
10
+ export declare function replace(input: replaceInput): void;
@@ -1,27 +1,32 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.replace = void 0;
4
- function replace(input, all, s, r) {
5
- let temp = input.get();
4
+ function replace(input) {
5
+ let temp = input.target.get();
6
6
  let search = "";
7
- if (typeof s === "string") {
8
- search = s;
7
+ let found = false;
8
+ if (input.of) {
9
+ search = input.of.get();
10
+ if (search.length === 0 && input.all === true) {
11
+ throw "REPLACE, zero length input";
12
+ }
13
+ found = temp.indexOf(search) >= 0;
9
14
  }
10
- else {
11
- search = s.get();
15
+ else if (input.regex) {
16
+ if (input.regex.get().length === 0 && input.all === true) {
17
+ throw "REPLACE, zero length input";
18
+ }
19
+ found = temp.match(search) !== null;
20
+ search = new RegExp(input.regex.get());
12
21
  }
13
22
  let replace = "";
14
- if (typeof r === "string") {
15
- replace = r;
23
+ if (typeof input.with === "string") {
24
+ replace = input.with;
16
25
  }
17
26
  else {
18
- replace = r.get();
27
+ replace = input.with.get();
19
28
  }
20
- const found = temp.indexOf(search) >= 0;
21
- if (all === true) {
22
- if (search.length === 0) {
23
- throw "REPLACE, zero length input";
24
- }
29
+ if (input.all === true) {
25
30
  while (temp.replace(search, replace) !== temp) {
26
31
  temp = temp.replace(search, replace);
27
32
  }
@@ -32,7 +37,7 @@ function replace(input, all, s, r) {
32
37
  const subrc = found ? 0 : 4;
33
38
  // @ts-ignore
34
39
  abap.builtin.sy.get().subrc.set(subrc);
35
- input.set(temp);
40
+ input.target.set(temp);
36
41
  }
37
42
  exports.replace = replace;
38
43
  //# sourceMappingURL=replace.js.map
package/package.json CHANGED
@@ -1,42 +1,42 @@
1
- {
2
- "name": "@abaplint/runtime",
3
- "version": "1.8.26",
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:minor": "npm --no-git-tag-version version minor && rm -rf build && npm install && npm run test && npm publish --access public",
14
- "publish:patch": "npm --no-git-tag-version version patch && rm -rf build && npm install && npm run test && npm publish --access public",
15
- "test": "npm run compile && mocha"
16
- },
17
- "mocha": {
18
- "recursive": true,
19
- "reporter": "progress",
20
- "spec": "build/test/**/*.js",
21
- "require": "source-map-support/register"
22
- },
23
- "keywords": [
24
- "ABAP",
25
- "abaplint"
26
- ],
27
- "author": "abaplint",
28
- "license": "MIT",
29
- "dependencies": {
30
- "hdb": "^0.19.1",
31
- "sql.js": "^1.6.2"
32
- },
33
- "devDependencies": {
34
- "@types/chai": "^4.3.0",
35
- "@types/mocha": "^9.1.0",
36
- "@types/sql.js": "^1.4.3",
37
- "chai": "^4.3.6",
38
- "mocha": "^9.2.2",
39
- "source-map-support": "^0.5.21",
40
- "typescript": "^4.6.3"
41
- }
42
- }
1
+ {
2
+ "name": "@abaplint/runtime",
3
+ "version": "1.8.29",
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:minor": "npm --no-git-tag-version version minor && rm -rf build && npm install && npm run test && npm publish --access public",
14
+ "publish:patch": "npm --no-git-tag-version version patch && rm -rf build && npm install && npm run test && npm publish --access public",
15
+ "test": "npm run compile && mocha"
16
+ },
17
+ "mocha": {
18
+ "recursive": true,
19
+ "reporter": "progress",
20
+ "spec": "build/test/**/*.js",
21
+ "require": "source-map-support/register"
22
+ },
23
+ "keywords": [
24
+ "ABAP",
25
+ "abaplint"
26
+ ],
27
+ "author": "abaplint",
28
+ "license": "MIT",
29
+ "dependencies": {
30
+ "hdb": "^0.19.1",
31
+ "sql.js": "^1.6.2"
32
+ },
33
+ "devDependencies": {
34
+ "@types/chai": "^4.3.0",
35
+ "@types/mocha": "^9.1.0",
36
+ "@types/sql.js": "^1.4.3",
37
+ "chai": "^4.3.6",
38
+ "mocha": "^9.2.2",
39
+ "source-map-support": "^0.5.21",
40
+ "typescript": "^4.6.3"
41
+ }
42
+ }