@azure-tools/codegen
Advanced tools
Comparing version 2.1.231 to 2.1.232
@@ -39,3 +39,3 @@ import { TextPossibilities } from './file-generator'; | ||
export declare function convert(num: number): Iterable<string>; | ||
export declare type formatter = ((identifier: string | string[], removeDuplicates?: boolean | undefined) => string); | ||
export declare type formatter = ((identifier: string | string[], removeDuplicates: boolean | undefined, overrides: Dictionary<string> | undefined) => string); | ||
export declare function formatStyle(style: any, fallback: formatter): formatter; | ||
@@ -46,8 +46,9 @@ export declare function fixLeadingNumber(identifier: Array<string>): Array<string>; | ||
export declare function removeSequentialDuplicates(identifier: Iterable<string>): string[]; | ||
export declare function kebabCase(identifier: string | Array<string>, removeDuplicates?: boolean): string; | ||
export declare function snakeCase(identifier: string | Array<string>, removeDuplicates?: boolean): string; | ||
export declare function upperCase(identifier: string | Array<string>, removeDuplicates?: boolean): string; | ||
export declare function normalize(identifier: string | Array<string>, removeDuplicates?: boolean): Array<string>; | ||
export declare function pascalCase(identifier: string | Array<string>, removeDuplicates?: boolean): string; | ||
export declare function camelCase(identifier: string | Array<string>, removeDuplicates?: boolean): string; | ||
export declare function kebabCase(identifier: string | Array<string>, removeDuplicates?: boolean, overrides?: Dictionary<string>): string; | ||
export declare function spaceCase(identifier: string | Array<string>, removeDuplicates?: boolean, overrides?: Dictionary<string>): string; | ||
export declare function snakeCase(identifier: string | Array<string>, removeDuplicates?: boolean, overrides?: Dictionary<string>): string; | ||
export declare function upperCase(identifier: string | Array<string>, removeDuplicates?: boolean, overrides?: Dictionary<string>): string; | ||
export declare function normalize(identifier: string | Array<string>, removeDuplicates?: boolean, overrides?: Dictionary<string>): Array<string>; | ||
export declare function pascalCase(identifier: string | Array<string>, removeDuplicates?: boolean, overrides?: Dictionary<string>): string; | ||
export declare function camelCase(identifier: string | Array<string>, removeDuplicates?: boolean, overrides?: Dictionary<string>): string; | ||
export declare function getPascalIdentifier(name: string): string; | ||
@@ -54,0 +55,0 @@ export declare function escapeString(text: string | undefined): string; |
@@ -202,7 +202,19 @@ "use strict"; | ||
case 'camelcase': | ||
case 'camel': | ||
return camelCase; | ||
case 'pascalcase': | ||
case 'pascal': | ||
return pascalCase; | ||
case 'snakecase': | ||
case 'snake': | ||
return snakeCase; | ||
case 'uppercase': | ||
case 'upper': | ||
return upperCase; | ||
case 'kebabcase': | ||
case 'kebab': | ||
return kebabCase; | ||
case 'spacecase': | ||
case 'space': | ||
return spaceCase; | ||
} | ||
@@ -253,15 +265,22 @@ return fallback; | ||
exports.removeSequentialDuplicates = removeSequentialDuplicates; | ||
function kebabCase(identifier, removeDuplicates = true) { | ||
return normalize(identifier, removeDuplicates).join('-'); | ||
function applyFormat(normalizedContent, overrides = {}, separator = '', format = (s, i) => s) { | ||
return normalizedContent.map((each, index) => overrides[each.toLowerCase()] || format(each, index)).join(separator); | ||
} | ||
function kebabCase(identifier, removeDuplicates = true, overrides = {}) { | ||
return overrides[identifier] || applyFormat(normalize(identifier, removeDuplicates), overrides, '-'); | ||
} | ||
exports.kebabCase = kebabCase; | ||
function snakeCase(identifier, removeDuplicates = true) { | ||
return normalize(identifier, removeDuplicates).join('_'); | ||
function spaceCase(identifier, removeDuplicates = true, overrides = {}) { | ||
return overrides[identifier] || applyFormat(normalize(identifier, removeDuplicates), overrides, ''); | ||
} | ||
exports.spaceCase = spaceCase; | ||
function snakeCase(identifier, removeDuplicates = true, overrides = {}) { | ||
return overrides[identifier] || applyFormat(normalize(identifier, removeDuplicates), overrides, '_'); | ||
} | ||
exports.snakeCase = snakeCase; | ||
function upperCase(identifier, removeDuplicates = true) { | ||
return normalize(identifier, removeDuplicates).join('_').toUpperCase(); | ||
function upperCase(identifier, removeDuplicates = true, overrides = {}) { | ||
return overrides[identifier] || applyFormat(normalize(identifier, removeDuplicates), overrides, '_', each => each.toUpperCase()); | ||
} | ||
exports.upperCase = upperCase; | ||
function normalize(identifier, removeDuplicates = true) { | ||
function normalize(identifier, removeDuplicates = true, overrides = {}) { | ||
if (!identifier || identifier.length === 0) { | ||
@@ -273,8 +292,8 @@ return ['']; | ||
exports.normalize = normalize; | ||
function pascalCase(identifier, removeDuplicates = true) { | ||
return normalize(identifier, removeDuplicates).map(each => each.capitalize()).join(''); | ||
function pascalCase(identifier, removeDuplicates = true, overrides = {}) { | ||
return overrides[identifier] || applyFormat(normalize(identifier, removeDuplicates), overrides, '', each => each.capitalize()); | ||
} | ||
exports.pascalCase = pascalCase; | ||
function camelCase(identifier, removeDuplicates = true) { | ||
return normalize(identifier, removeDuplicates).map((each, index) => index ? each.capitalize() : each.uncapitalize()).join(''); | ||
function camelCase(identifier, removeDuplicates = true, overrides = {}) { | ||
return overrides[identifier] || applyFormat(normalize(identifier, removeDuplicates), overrides, '', (each, index) => index ? each.capitalize() : each.uncapitalize()); | ||
} | ||
@@ -281,0 +300,0 @@ exports.camelCase = camelCase; |
{ | ||
"name": "@azure-tools/codegen", | ||
"version": "2.1.231", | ||
"version": "2.1.232", | ||
"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
197246
2488