@azure-tools/codegen
Advanced tools
Comparing version 2.2.243 to 2.2.244
@@ -15,2 +15,8 @@ "use strict"; | ||
} | ||
function wrap(prefix, postfix, style) { | ||
if (postfix || prefix) { | ||
return (i, r, o) => typeof i === 'string' && typeof (o) === 'object' ? o[i.toLowerCase()] || `${prefix}${style(i, r, o)}${postfix}` : `${prefix}${style(i, r, o)}${postfix}`; | ||
} | ||
return style; | ||
} | ||
function applyFormat(normalizedContent, overrides = {}, separator = '', formatter = (s, i) => s) { | ||
@@ -27,21 +33,28 @@ return normalizedContent.map((each, index) => overrides[each.toLowerCase()] || formatter(each, index)).join(separator); | ||
static select(style, fallback) { | ||
switch (`${style}`.toLowerCase()) { | ||
case 'camelcase': | ||
case 'camel': | ||
return Style.camel; | ||
case 'pascalcase': | ||
case 'pascal': | ||
return Style.pascal; | ||
case 'snakecase': | ||
case 'snake': | ||
return Style.snake; | ||
case 'uppercase': | ||
case 'upper': | ||
return Style.upper; | ||
case 'kebabcase': | ||
case 'kebab': | ||
return Style.kebab; | ||
case 'spacecase': | ||
case 'space': | ||
return Style.space; | ||
if (style) { | ||
const styles = /^([a-zA-Z0-9_]*?\+?)([a-zA-Z]+)(\+?[a-zA-Z0-9_]*)$/g.exec(style.replace(/\s*/g, '')); | ||
if (styles) { | ||
const prefix = styles[1] ? styles[1].substring(0, styles[1].length - 1) : ''; | ||
const postfix = styles[3] ? styles[3].substring(1) : ''; | ||
switch (styles[2]) { | ||
case 'camelcase': | ||
case 'camel': | ||
return wrap(prefix, postfix, Style.camel); | ||
case 'pascalcase': | ||
case 'pascal': | ||
return wrap(prefix, postfix, Style.pascal); | ||
case 'snakecase': | ||
case 'snake': | ||
return wrap(prefix, postfix, Style.snake); | ||
case 'uppercase': | ||
case 'upper': | ||
return wrap(prefix, postfix, Style.upper); | ||
case 'kebabcase': | ||
case 'kebab': | ||
return wrap(prefix, postfix, Style.kebab); | ||
case 'spacecase': | ||
case 'space': | ||
return wrap(prefix, postfix, Style.space); | ||
} | ||
} | ||
} | ||
@@ -48,0 +61,0 @@ return fallback; |
{ | ||
"name": "@azure-tools/codegen", | ||
"version": "2.2.243", | ||
"version": "2.2.244", | ||
"patchOffset": 100, | ||
@@ -5,0 +5,0 @@ "description": "Autorest Code generator common and base classes", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
204471
2573