Skip to content

Commit

Permalink
Updates to structure
Browse files Browse the repository at this point in the history
  • Loading branch information
David Koblas committed May 3, 2019
1 parent 00d6e1f commit 6f0f553
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 30 deletions.
10 changes: 5 additions & 5 deletions src/iban.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ export class IBAN {
}

/**
* IBAN Validation testing [iban-js API compatability]
* IBAN Validation testing [iban-js API compatibility]
*
* @param {string} iban
* @returns {boolean} true if the value is a valid IBAN
Expand All @@ -273,7 +273,7 @@ export class IBAN {
}

/**
* Convert an IBAN to a formatted BBAN - with validation[iban-js API compatability]
* Convert an IBAN to a formatted BBAN - with validation[iban-js API compatibility]
*
* @param {string} iban
* @param {String} [separator] the separator to use between the blocks of the BBAN, defaults to ' '
Expand Down Expand Up @@ -306,7 +306,7 @@ export class IBAN {
}

/**
* Check the validity of the passed BBAN. [iban-js API compatability]
* Check the validity of the passed BBAN. [iban-js API compatibility]
*
* @param countryCode the country of the BBAN
* @param bban the BBAN to check the validity of
Expand All @@ -321,7 +321,7 @@ export class IBAN {
}

/**
* Standard print format of an IBAN, no validation is performed [iban-js API compatability]
* Standard print format of an IBAN, no validation is performed [iban-js API compatibility]
*
* @param iban
* @param separator optional (default ' ')
Expand All @@ -332,7 +332,7 @@ export class IBAN {
}

/**
* Electronic format of the IBAN, no validation is performed. [iban-js API compatability]
* Electronic format of the IBAN, no validation is performed. [iban-js API compatibility]
*
* @param iban
* @param separator
Expand Down
10 changes: 5 additions & 5 deletions src/ibanUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,9 @@ export function replaceCheckDigit(iban: string, checkDigit: string): string {
*/
export function toFormattedString(
iban: string,
seperator: string = " ",
separator: string = " ",
): string {
return iban.replace(/(.{4})/g, `$1${seperator}`).trim();
return iban.replace(/(.{4})/g, `$1${separator}`).trim();
}

/* Returns formatted version of BBAN from IBAN.
Expand All @@ -270,7 +270,7 @@ export function toFormattedString(
*/
export function toFormattedStringBBAN(
iban: string,
seperator: string = " ",
separator: string = " ",
): string {
const structure = getBbanStructure(iban);

Expand All @@ -283,11 +283,11 @@ export function toFormattedStringBBAN(
(acc, part) => {
const value = structure.extractValue(bban, part.getPartType());

return acc.concat(value || "", part.trailingSeperator ? seperator : "");
return acc.concat(value || "", part.trailingSeparator ? separator : "");
},
[] as string[],
);
parts.pop(); // Don't care about last seperator
parts.pop(); // Don't care about last separator

return parts.join("");
}
Expand Down
38 changes: 19 additions & 19 deletions src/structurePart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,128 +56,128 @@ export class BbanStructurePart {
private entryType: PartType;
private characterType: CharacterType;
private length: number;
trailingSeperator: boolean;
trailingSeparator: boolean;
generate: GenerateValue;
hasGenerator: boolean;

private constructor(
entryType: PartType,
characterType: CharacterType,
length: number,
trailingSeperator: boolean,
trailingSeparator: boolean,
generate?: GenerateValue,
) {
this.entryType = entryType;
this.characterType = characterType;
this.length = length;
this.generate = generate || this.defaultGenerator;
this.hasGenerator = !!generate;
this.trailingSeperator = trailingSeperator;
this.trailingSeparator = trailingSeparator;
}

static bankCode(
length: number,
characterType: CharacterType,
trailingSeperator: boolean = true,
trailingSeparator: boolean = true,
): BbanStructurePart {
return new BbanStructurePart(
PartType.BANK_CODE,
characterType,
length,
trailingSeperator,
trailingSeparator,
);
}

static branchCode(
length: number,
characterType: CharacterType,
trailingSeperator: boolean = true,
trailingSeparator: boolean = true,
): BbanStructurePart {
return new BbanStructurePart(
PartType.BRANCH_CODE,
characterType,
length,
trailingSeperator,
trailingSeparator,
);
}

static accountNumber(
length: number,
characterType: CharacterType,
trailingSeperator: boolean = true,
trailingSeparator: boolean = true,
): BbanStructurePart {
return new BbanStructurePart(
PartType.ACCOUNT_NUMBER,
characterType,
length,
trailingSeperator,
trailingSeparator,
);
}

static nationalCheckDigit(
length: number,
characterType: CharacterType,
generate?: GenerateValue,
trailingSeperator: boolean = false,
trailingSeparator: boolean = false,
): BbanStructurePart {
return new BbanStructurePart(
PartType.NATIONAL_CHECK_DIGIT,
characterType,
length,
trailingSeperator,
trailingSeparator,
generate,
);
}

static accountType(
length: number,
characterType: CharacterType,
trailingSeperator: boolean = false,
trailingSeparator: boolean = false,
): BbanStructurePart {
return new BbanStructurePart(
PartType.ACCOUNT_TYPE,
characterType,
length,
trailingSeperator,
trailingSeparator,
);
}

static currencyType(
length: number,
characterType: CharacterType,
trailingSeperator: boolean = false,
trailingSeparator: boolean = false,
): BbanStructurePart {
return new BbanStructurePart(
PartType.CURRENCY_TYPE,
characterType,
length,
trailingSeperator,
trailingSeparator,
);
}

static ownerAccountNumber(
length: number,
characterType: CharacterType,
trailingSeperator: boolean = true,
trailingSeparator: boolean = true,
): BbanStructurePart {
return new BbanStructurePart(
PartType.OWNER_ACCOUNT_NUMBER,
characterType,
length,
trailingSeperator,
trailingSeparator,
);
}

static identificationNumber(
length: number,
characterType: CharacterType,
trailingSeperator: boolean = true,
trailingSeparator: boolean = true,
): BbanStructurePart {
return new BbanStructurePart(
PartType.IDENTIFICATION_NUMBER,
characterType,
length,
trailingSeperator,
trailingSeparator,
);
}

Expand Down
2 changes: 1 addition & 1 deletion test/iban.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,7 @@ describe("IBAN", () => {
});
});

describe("iban-js compatability", () => {
describe("iban-js compatibility", () => {
it("printFormat", () => {
expect(IBAN.printFormat("FR1420041010050500013M02606")).toBe(
"FR14 2004 1010 0505 0001 3M02 606",
Expand Down

0 comments on commit 6f0f553

Please sign in to comment.