refactor: simplify returns

Signed-off-by: Sayak Mukhopadhyay <mukhopadhyaysayak@gmail.com>
This commit is contained in:
Sayak Mukhopadhyay
2022-12-28 22:03:19 +05:30
parent 74eed91f5b
commit bfd1161dcf
+5 -9
View File
@@ -290,17 +290,13 @@ export class ConfigReader implements Config {
if (typeof value === 'boolean' || value === undefined) {
return value;
}
let boolean;
if (/^(?:y|yes|true|1|on)$/i.test(value as string) || value === 1) {
boolean = true;
} else if (/^(?:n|no|false|0|off)$/i.test(value as string) || value === 0) {
boolean = false;
} else {
throw new Error(
errors.convert(this.fullKey(key), this.context, 'boolean'),
);
return true;
}
return boolean;
if (/^(?:n|no|false|0|off)$/i.test(value as string) || value === 0) {
return false;
}
throw new Error(errors.convert(this.fullKey(key), this.context, 'boolean'));
}
/** {@inheritdoc Config.getString} */