Add operations To {Snake,Camel,Kebab} case

feature-extract-files
toby 2017-04-29 13:42:07 -04:00
parent 31e5d785fe
commit d5def01a9d
4 changed files with 86 additions and 0 deletions

View File

@ -72,6 +72,7 @@
"jquery": "^3.1.1", "jquery": "^3.1.1",
"jsbn": "^1.1.0", "jsbn": "^1.1.0",
"jsrsasign": "^7.1.0", "jsrsasign": "^7.1.0",
"lodash": "^4.17.4",
"moment": "^2.17.1", "moment": "^2.17.1",
"moment-timezone": "^0.5.11", "moment-timezone": "^0.5.11",
"sladex-blowfish": "^0.8.1", "sladex-blowfish": "^0.8.1",

View File

@ -181,6 +181,9 @@ const Categories = [
"Parse UNIX file permissions", "Parse UNIX file permissions",
"Swap endianness", "Swap endianness",
"Parse colour code", "Parse colour code",
"To Snake case",
"To Camel case",
"To Kebab case",
] ]
}, },
{ {

View File

@ -3249,6 +3249,48 @@ const OperationConfig = {
}, },
] ]
}, },
"To Snake case": {
description: [
"Converts the input string to snake case.",
"<br><br>",
"Snake case is all lower case with underscores as word boundaries.",
"<br><br>",
"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.",
"<br><br>",
"Camel case is all lower case except letters after word boundaries which are uppercase.",
"<br><br>",
"e.g. thisIsCamelCase",
].join("\n"),
run: StrUtils.runToCamelCase,
inputType: "string",
outputType: "string",
args: [
]
},
"To Kebab case": {
description: [
"Converts the input string to kebab case.",
"<br><br>",
"Kebab case is all lower case with dashes as word boundaries.",
"<br><br>",
"e.g. this-is-kebab-case",
].join("\n"),
run: StrUtils.runToKebabCase,
inputType: "string",
outputType: "string",
args: [
]
},
}; };
export default OperationConfig; export default OperationConfig;

View File

@ -1,3 +1,5 @@
import {camelCase, kebabCase, snakeCase} from "lodash";
import Utils from "../Utils.js"; import Utils from "../Utils.js";
import * as JsDiff from "diff"; import * as JsDiff from "diff";
@ -593,6 +595,44 @@ const StrUtils = {
return output; 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; export default StrUtils;