diff --git a/package.json b/package.json
index 8b23447..194665a 100644
--- a/package.json
+++ b/package.json
@@ -72,6 +72,7 @@
"jquery": "^3.1.1",
"jsbn": "^1.1.0",
"jsrsasign": "^7.1.0",
+ "lodash": "^4.17.4",
"moment": "^2.17.1",
"moment-timezone": "^0.5.11",
"sladex-blowfish": "^0.8.1",
diff --git a/src/core/config/Categories.js b/src/core/config/Categories.js
index da0c9f0..bfadfca 100755
--- a/src/core/config/Categories.js
+++ b/src/core/config/Categories.js
@@ -181,6 +181,9 @@ const Categories = [
"Parse UNIX file permissions",
"Swap endianness",
"Parse colour code",
+ "To Snake case",
+ "To Camel case",
+ "To Kebab case",
]
},
{
diff --git a/src/core/config/OperationConfig.js b/src/core/config/OperationConfig.js
index ca6bdbb..fa2f5c0 100755
--- a/src/core/config/OperationConfig.js
+++ b/src/core/config/OperationConfig.js
@@ -3249,6 +3249,48 @@ const OperationConfig = {
},
]
},
+ "To Snake case": {
+ description: [
+ "Converts the input string to snake case.",
+ "
",
+ "Snake case is all lower case with underscores as word boundaries.",
+ "
",
+ "e.g. this_is_snake_case",
+ ].join("\n"),
+ run: StrUtils.runToSnakeCase,
+ inputType: "string",
+ outputType: "string",
+ args: [
+ ]
+ },
+ "To Camel case": {
+ description: [
+ "Converts the input string to camel case.",
+ "
",
+ "Camel case is all lower case except letters after word boundaries which are uppercase.",
+ "
",
+ "e.g. thisIsCamelCase",
+ ].join("\n"),
+ run: StrUtils.runToCamelCase,
+ inputType: "string",
+ outputType: "string",
+ args: [
+ ]
+ },
+ "To Kebab case": {
+ description: [
+ "Converts the input string to kebab case.",
+ "
",
+ "Kebab case is all lower case with dashes as word boundaries.",
+ "
",
+ "e.g. this-is-kebab-case",
+ ].join("\n"),
+ run: StrUtils.runToKebabCase,
+ inputType: "string",
+ outputType: "string",
+ args: [
+ ]
+ },
};
export default OperationConfig;
diff --git a/src/core/operations/StrUtils.js b/src/core/operations/StrUtils.js
index 00d2c56..1c7ca9c 100755
--- a/src/core/operations/StrUtils.js
+++ b/src/core/operations/StrUtils.js
@@ -1,3 +1,5 @@
+import {camelCase, kebabCase, snakeCase} from "lodash";
+
import Utils from "../Utils.js";
import * as JsDiff from "diff";
@@ -593,6 +595,44 @@ const StrUtils = {
return output;
},
+
+ /**
+ * Converts to snake_case.
+ *
+ * @param {string} input
+ * @param {Object[]} args
+ * @returns {string}
+ *
+ */
+ runToSnakeCase(input, args) {
+ return snakeCase(input);
+ },
+
+
+ /**
+ * Converts to camelCase.
+ *
+ * @param {string} input
+ * @param {Object[]} args
+ * @returns {string}
+ *
+ */
+ runToCamelCase(input, args) {
+ return camelCase(input);
+ },
+
+
+ /**
+ * Converts to kebab-case.
+ *
+ * @param {string} input
+ * @param {Object[]} args
+ * @returns {string}
+ *
+ */
+ runToKebabCase(input, args) {
+ return kebabCase(input);
+ },
};
export default StrUtils;