forked from medigy/governance
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode.ts
More file actions
24 lines (22 loc) · 637 Bytes
/
Copy pathcode.ts
File metadata and controls
24 lines (22 loc) · 637 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import { inflect } from "./deps.ts";
export interface TypeScriptClassNameOptions {
readonly forceSuffix?: string;
readonly removeSuffixes?: string[];
}
export function typeScriptClassName(
iv: inflect.InflectableValue,
{ forceSuffix, removeSuffixes }: TypeScriptClassNameOptions,
): string {
let result = inflect.toPascalCase(iv);
if (removeSuffixes) {
for (const suffix of removeSuffixes) {
if (result.endsWith(suffix)) {
result = result.substr(0, result.length - suffix.length);
}
}
}
if (forceSuffix) {
if (!result.endsWith(forceSuffix)) result += forceSuffix;
}
return result;
}