Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.10.19: implement from_mixed() #1469

Merged
merged 4 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"link:database-pg": "cd packages/database-pg && npm link @abaplint/runtime",
"link:database-snowflake": "cd packages/database-snowflake && npm link @abaplint/runtime",
"link:cli": "cd packages/cli && npm link --force && npm link @abaplint/transpiler",
"docker:start": "docker compose -f test/stack.yml up -d",
"docker:stop": "docker compose -f test/stack.yml down",
"docker:start": "docker compose -p transpiler -f test/stack.yml up -d",
"docker:stop": "docker compose -p transpiler -f test/stack.yml down -v",
"lint": "eslint packages/**/*.ts --format unix"
},
"repository": {
Expand Down Expand Up @@ -186,7 +186,7 @@
},
"homepage": "https://github.com/abaplint/transpiler_poc#readme",
"devDependencies": {
"@abaplint/core": "^2.113.7",
"@abaplint/core": "^2.113.8",
"@types/chai": "^4.3.19",
"@types/mocha": "^10.0.7",
"@types/node": "^22.5.4",
Expand All @@ -206,6 +206,6 @@
"source-map-support": "^0.5.21",
"sql.js": "^1.11.0",
"temporal-polyfill": "^0.2.5",
"typescript": "^5.5.4"
"typescript": "^5.6.2"
}
}
36 changes: 18 additions & 18 deletions packages/cli/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@abaplint/transpiler-cli",
"version": "2.10.18",
"version": "2.10.19",
"description": "Transpiler - Command Line Interface",
"funding": "https://github.com/sponsors/larshp",
"bin": {
Expand All @@ -26,12 +26,12 @@
"author": "abaplint",
"license": "MIT",
"devDependencies": {
"@abaplint/transpiler": "^2.10.18",
"@abaplint/transpiler": "^2.10.19",
"@types/glob": "^8.1.0",
"glob": "=7.2.0",
"@types/progress": "^2.0.7",
"@types/node": "^22.5.4",
"@abaplint/core": "^2.113.7",
"@abaplint/core": "^2.113.8",
"progress": "^2.0.3",
"webpack": "^5.94.0",
"webpack-cli": "^5.1.4",
Expand Down
18 changes: 9 additions & 9 deletions packages/runtime/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/runtime/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@abaplint/runtime",
"version": "2.10.18",
"version": "2.10.19",
"description": "Transpiler - Runtime",
"main": "build/src/index.js",
"typings": "build/src/index.d.ts",
Expand Down Expand Up @@ -34,7 +34,7 @@
"chai": "^4.5.0",
"mocha": "^10.7.3",
"source-map-support": "^0.5.21",
"typescript": "^5.5.4"
"typescript": "^5.6.2"
},
"dependencies": {
"temporal-polyfill": "^0.2.5"
Expand Down
40 changes: 40 additions & 0 deletions packages/runtime/src/builtin/from_mixed.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/* eslint-disable @typescript-eslint/ban-types */
import {throwError} from "../throw_error";
import {String} from "../types";
import {ICharacter} from "../types/_character";
import {INumeric} from "../types/_numeric";

export function from_mixed(input: {
val: ICharacter | string,
sep?: ICharacter | string,
case?: ICharacter | string,
min?: INumeric | number }): String {

let sep = input.sep;
if (sep === undefined) {
sep = "_";
}
if (typeof sep !== "string") {
sep = sep.get();
}
if (sep.length === 0) {
throwError("CX_SY_STRG_PAR_VAL");
}

const min = 1;
if (min < 0) {
throwError("CX_SY_STRG_PAR_VAL");
}

let val = input.val;
if (typeof val !== "string") {
val = val.get();
}

// todo: handle "case" and "min" ?

const regex = new RegExp(/([A-Z])/, "g");
val = val.substring(0, 1) + val.substring(1).replace(regex, "_$1");

return new String().set(val.toUpperCase());
}
3 changes: 2 additions & 1 deletion packages/runtime/src/builtin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export * from "./escape";
export * from "./find";
export * from "./floor";
export * from "./frac";
export * from "./from_mixed";
export * from "./insert";
export * from "./ipow";
export * from "./lines";
Expand All @@ -26,8 +27,8 @@ export * from "./replace";
export * from "./reverse";
export * from "./round";
export * from "./segment";
export * from "./shift_right";
export * from "./shift_left";
export * from "./shift_right";
export * from "./sign";
export * from "./sin";
export * from "./sqrt";
Expand Down
Loading