Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow parser to handle some missing fields (costs, forces, categories… #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/Parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class Parser {
}

private toCostArray(
bsCosts: Array<{ cost: BSCost[] } | { costLimit: BSCost[] } | string>,
bsCosts: Array<{ cost: BSCost[] } | { costLimit: BSCost[] } | string> = [],
additionalCosts: CalculatedCosts = {
[CostType.PTS]: 0,
[CostType.PL]: 0,
Expand Down Expand Up @@ -111,7 +111,7 @@ class Parser {
return costs;
}

private toForceArray(bsForces: Array<{ force: BSForce[] } | string>): Force[] {
private toForceArray(bsForces: Array<{ force: BSForce[] } | string> = []): Force[] {
const forces: Force[] = [];

bsForces.forEach((bsForces) => {
Expand Down Expand Up @@ -151,7 +151,7 @@ class Parser {
return publications;
}

private toCategoryArray(bsCategories: Array<{ category: BSCategory[] } | string>): Category[] {
private toCategoryArray(bsCategories: Array<{ category: BSCategory[] } | string> = []): Category[] {
const categories: Category[] = [];
bsCategories.forEach((bsCategories) => {
if (isBSCategory(bsCategories)) {
Expand All @@ -167,7 +167,7 @@ class Parser {
return categories;
}

private toRuleArray(bsRules: Array<{ rule: BSRule[] } | string>): Rule[] {
private toRuleArray(bsRules: Array<{ rule: BSRule[] } | string> = []): Rule[] {
const rules: Rule[] = [];

bsRules.forEach((bsRules) => {
Expand All @@ -184,7 +184,7 @@ class Parser {
return rules;
}

private toSelectionArray(bsSelections: Array<{ selection: BSSelection[] } | string>): Selection[] {
private toSelectionArray(bsSelections: Array<{ selection: BSSelection[] } | string> = []): Selection[] {
const selections: Selection[] = [];
bsSelections.forEach((bsSelections) => {
if (isBSSelection(bsSelections)) {
Expand All @@ -210,7 +210,7 @@ class Parser {
return selections;
}

private toProfileArray(bsProfiles: Array<{ profile: BSProfile<BSCharacteristic>[] } | string>): Profile<TypeName>[] {
private toProfileArray(bsProfiles: Array<{ profile: BSProfile<BSCharacteristic>[] } | string> = []): Profile<TypeName>[] {
const profiles: Profile<TypeName>[] = [];
bsProfiles.forEach((bsProfiles) => {
if (isBSProfile(bsProfiles)) {
Expand Down
Loading