@azure-tools/codegen
Advanced tools
Comparing version 2.1.232 to 2.2.234
@@ -14,2 +14,3 @@ export * from './exec'; | ||
export * from './media-types'; | ||
export * from './formatter'; | ||
//# sourceMappingURL=exports.d.ts.map |
@@ -19,2 +19,3 @@ "use strict"; | ||
__export(require("./media-types")); | ||
__export(require("./formatter")); | ||
//# sourceMappingURL=exports.js.map |
@@ -39,4 +39,2 @@ import { TextPossibilities } from './file-generator'; | ||
export declare function convert(num: number): Iterable<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; | ||
export declare function fixLeadingNumber(identifier: Array<string>): Array<string>; | ||
@@ -46,9 +44,4 @@ export declare function removeProhibitedPrefix(identifier: string, prohibitedPrefix: string, skipIdentifiers?: Array<string>): string; | ||
export declare function removeSequentialDuplicates(identifier: Iterable<string>): 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 pascalCase(identifier: string | Array<string>, removeDuplicates?: boolean): string; | ||
export declare function camelCase(identifier: string | Array<string>): string; | ||
export declare function getPascalIdentifier(name: string): string; | ||
@@ -55,0 +48,0 @@ export declare function escapeString(text: string | undefined): string; |
@@ -199,26 +199,2 @@ "use strict"; | ||
exports.convert = convert; | ||
function formatStyle(style, fallback) { | ||
switch (`${style}`.toLowerCase()) { | ||
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; | ||
} | ||
return fallback; | ||
} | ||
exports.formatStyle = formatStyle; | ||
function fixLeadingNumber(identifier) { | ||
@@ -265,38 +241,23 @@ if (identifier.length > 0 && /^\d+/.exec(identifier[0])) { | ||
exports.removeSequentialDuplicates = removeSequentialDuplicates; | ||
function applyFormat(normalizedContent, overrides = {}, separator = '', format = (s, i) => s) { | ||
return normalizedContent.map((each, index) => overrides[each.toLowerCase()] || format(each, index)).join(separator); | ||
function pascalCase(identifier, removeDuplicates = true) { | ||
return identifier === undefined ? '' : typeof identifier === 'string' ? | ||
pascalCase(fixLeadingNumber(deconstruct(identifier)), removeDuplicates) : | ||
(removeDuplicates ? [...removeSequentialDuplicates(identifier)] : identifier).map(each => each.capitalize()).join(''); | ||
} | ||
function kebabCase(identifier, removeDuplicates = true, overrides = {}) { | ||
return overrides[identifier] || applyFormat(normalize(identifier, removeDuplicates), overrides, '-'); | ||
} | ||
exports.kebabCase = kebabCase; | ||
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, overrides = {}) { | ||
return overrides[identifier] || applyFormat(normalize(identifier, removeDuplicates), overrides, '_', each => each.toUpperCase()); | ||
} | ||
exports.upperCase = upperCase; | ||
function normalize(identifier, removeDuplicates = true, overrides = {}) { | ||
if (!identifier || identifier.length === 0) { | ||
return ['']; | ||
exports.pascalCase = pascalCase; | ||
function camelCase(identifier) { | ||
if (typeof (identifier) === 'string') { | ||
return camelCase(fixLeadingNumber(deconstruct(identifier))); | ||
} | ||
return removeDuplicates ? removeSequentialDuplicates(fixLeadingNumber(deconstruct(identifier))) : fixLeadingNumber(deconstruct(identifier)); | ||
switch (identifier.length) { | ||
case 0: | ||
return ''; | ||
case 1: | ||
return identifier[0].uncapitalize(); | ||
} | ||
return `${identifier[0].uncapitalize()}${pascalCase(identifier.slice(1))}`; | ||
} | ||
exports.normalize = normalize; | ||
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, overrides = {}) { | ||
return overrides[identifier] || applyFormat(normalize(identifier, removeDuplicates), overrides, '', (each, index) => index ? each.capitalize() : each.uncapitalize()); | ||
} | ||
exports.camelCase = camelCase; | ||
function getPascalIdentifier(name) { | ||
return pascalCase(name); | ||
return pascalCase(fixLeadingNumber(deconstruct(name))); | ||
} | ||
@@ -303,0 +264,0 @@ exports.getPascalIdentifier = getPascalIdentifier; |
{ | ||
"name": "@azure-tools/codegen", | ||
"version": "2.1.232", | ||
"version": "2.2.234", | ||
"patchOffset": 100, | ||
@@ -51,4 +51,4 @@ "description": "Autorest Code generator common and base classes", | ||
"dependencies": { | ||
"@azure-tools/async-io": "~3.0.211", | ||
"@azure-tools/linq": "~3.1.217", | ||
"@azure-tools/async-io": "~3.0.212", | ||
"@azure-tools/linq": "~3.1.218", | ||
"js-yaml": "3.13.1", | ||
@@ -55,0 +55,0 @@ "semver": "^5.5.1", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
199632
68
2511
0
Updated@azure-tools/linq@~3.1.218