Skip to content

Commit ce8a662

Browse files
committed
Feedback applied.
1 parent c4062ff commit ce8a662

File tree

1 file changed

+7
-16
lines changed

1 file changed

+7
-16
lines changed

src/index.ts

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,12 @@ function emitDom() {
3131
const outputFolder = path.join(__SOURCE_DIRECTORY__, "../", "generated");
3232

3333
// ${name} will be substituted with the name of an interface
34-
const removeVerboseIntroductions: (RegExp | [RegExp, string])[] = [
34+
const removeVerboseIntroductions: [RegExp, string][] = [
3535
[/^(The|A) ${name} interface of (the\s*)*([a-z\s]+ API)(\\\'s)?/, 'An interface of the $3 '],
36-
/^(The|A) ${name} (interface|event|object) (is|represents|represent|describes|defines)?/,
37-
/^An object implementing the ${name} interface (is|represents|represent|describes|defines)/,
38-
/^The ${name} is an interface representing/,
39-
/^This type (is|represents|represent|describes|defines)?/,
40-
36+
[/^(The|A) ${name} (interface|event|object) (is|represents|represent|describes|defines)?/, ''],
37+
[/^An object implementing the ${name} interface (is|represents|represent|describes|defines)/, ''],
38+
[/^The ${name} is an interface representing/, ''],
39+
[/^This type (is|represents|represent|describes|defines)?/, ''],
4140
[/^The ([a-z\s]+ API(\\\'s)?) ${name} (represents|is|describes|defines)/, 'The $1 ']
4241
];
4342

@@ -90,17 +89,9 @@ function emitDom() {
9089

9190
function transformVerbosity(name: string, description: string): string {
9291
for (const regTemplate of removeVerboseIntroductions) {
93-
let template: string, replace: string;
94-
if (Array.isArray(regTemplate)) {
95-
template = regTemplate[0].source;
96-
replace = regTemplate[1];
97-
}
98-
else {
99-
template = regTemplate.source;
100-
replace = '';
101-
}
92+
const [{ source: template }, replace] = regTemplate;
10293

103-
const reg = new RegExp(template.replace(/\$\{name\}/g, name).replace(/\s+/, '\\s*') + '\\s*', 'i');
94+
const reg = new RegExp(template.replace(/\$\{name\}/g, name) + '\\s*', 'i');
10495
const product = description.replace(reg, replace);
10596
if (product !== description) {
10697
return product.charAt(0).toUpperCase() + product.slice(1);

0 commit comments

Comments
 (0)