style: change inline ifs to code blocks

This commit is contained in:
Kamil Myśliwiec
2023-02-01 12:36:36 +01:00
parent 208d8ca184
commit f10c917b71

View File

@@ -11,19 +11,20 @@ export class MetadataScanner {
prototype: object | null, prototype: object | null,
callback: (name: string) => R, callback: (name: string) => R,
): R[] { ): R[] {
if (!prototype) return []; if (!prototype) {
return [];
}
const visitedNames = new Map<string, boolean>(); const visitedNames = new Map<string, boolean>();
const result: R[] = []; const result: R[] = [];
do { do {
for (const property of Object.getOwnPropertyNames(prototype)) { for (const property of Object.getOwnPropertyNames(prototype)) {
if (visitedNames.has(property)) continue; if (visitedNames.has(property)) {
continue;
}
visitedNames.set(property, true); visitedNames.set(property, true);
const descriptor = Object.getOwnPropertyDescriptor(prototype, property); const descriptor = Object.getOwnPropertyDescriptor(prototype, property);
if ( if (
descriptor.set || descriptor.set ||
descriptor.get || descriptor.get ||
@@ -34,7 +35,6 @@ export class MetadataScanner {
} }
const value = callback(property); const value = callback(property);
if (isNil(value)) { if (isNil(value)) {
continue; continue;
} }
@@ -52,19 +52,20 @@ export class MetadataScanner {
*getAllFilteredMethodNames( *getAllFilteredMethodNames(
prototype: object | null, prototype: object | null,
): IterableIterator<string> { ): IterableIterator<string> {
if (!prototype) return []; if (!prototype) {
return [];
}
const visitedNames = new Map<string, boolean>(); const visitedNames = new Map<string, boolean>();
const result: string[] = []; const result: string[] = [];
do { do {
for (const property of Object.getOwnPropertyNames(prototype)) { for (const property of Object.getOwnPropertyNames(prototype)) {
if (visitedNames.has(property)) continue; if (visitedNames.has(property)) {
continue;
}
visitedNames.set(property, true); visitedNames.set(property, true);
const descriptor = Object.getOwnPropertyDescriptor(prototype, property); const descriptor = Object.getOwnPropertyDescriptor(prototype, property);
if ( if (
descriptor.set || descriptor.set ||
descriptor.get || descriptor.get ||