Commit f44a7acc authored by Diegodlh's avatar Diegodlh
Browse files

use destructuring for options parameter

parent 10ecdbb9
......@@ -183,19 +183,10 @@ export class TemplateConfiguration extends DomainConfiguration<
async translateWith(
target: Webpage,
paths: string[],
options: {
useFallback?: boolean;
preferSamePath?: boolean;
tryAllTemplates?: boolean;
}
{ useFallback = true, preferSamePath = true, tryAllTemplates = false } = {}
): Promise<TemplateOutput[]> {
// defaults
if (options.useFallback === undefined) options.useFallback = true;
if (options.preferSamePath === undefined) options.preferSamePath = true;
if (options.tryAllTemplates === undefined) options.tryAllTemplates = false;
const templates: BaseTranslationTemplate[] = this.get(paths);
if (options.preferSamePath) {
if (preferSamePath) {
const targetPathTemplateIndex = templates.findIndex(
(template) => template.path === target.path
);
......@@ -206,12 +197,12 @@ export class TemplateConfiguration extends DomainConfiguration<
}
}
if (options.useFallback && this._fallback) {
if (useFallback && this._fallback) {
templates.push(this._fallback);
}
let outputs: TemplateOutput[];
if (options.tryAllTemplates) {
if (tryAllTemplates) {
outputs = await Promise.all(
templates.map((template) => template.translate(target))
);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment