MCPcopy
hub / github.com/sequelize/sequelize-auto / recase

Function recase

src/types.ts:208–231  ·  view source on GitHub ↗
(opt: CaseOption | CaseFileOption | undefined, val: string | null, singular = false)

Source from the content-addressed store, hash-verified

206
207/** Change casing of val string according to opt [c|l|o|p|u] */
208export function recase(opt: CaseOption | CaseFileOption | undefined, val: string | null, singular = false) {
209 if (singular && val) {
210 val = singularize(val);
211 }
212 if (!opt || opt === 'o' || !val) {
213 return val || ''; // original
214 }
215 if (opt === 'c') {
216 return _.camelCase(val);
217 }
218 if (opt === 'k') {
219 return _.kebabCase(val);
220 }
221 if (opt === 'l') {
222 return _.snakeCase(val);
223 }
224 if (opt === 'p') {
225 return _.upperFirst(_.camelCase(val));
226 }
227 if (opt === 'u') {
228 return _.snakeCase(val).toUpperCase();
229 }
230 return val;
231}
232
233const tsNames = ["DataTypes", "Model", "Optional", "Sequelize"];
234export function makeTableName(opt: CaseOption | undefined, tableNameOrig: string | null, singular = false, lang = "es5") {

Callers 15

createFileMethod · 0.90
createAssociationsMethod · 0.90
createTsInitStringMethod · 0.90
createES5InitStringMethod · 0.90
createESMInitStringMethod · 0.90
addRelationMethod · 0.90
getAliasMethod · 0.90
getChildAliasMethod · 0.90
generateTextMethod · 0.90
addFieldMethod · 0.90
addTypeScriptFieldsMethod · 0.90
isTimestampFieldMethod · 0.90

Calls 1

singularizeFunction · 0.85

Tested by

no test coverage detected