mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-06-05 06:40:35 +08:00
Here is the code for the two functions of iban@1.3.0: https://github.com/arhs/iban.js/blob/master/iban.js#L359 /** * Convert an IBAN to a BBAN. * * @param iban * @param {String} [separator] the separator to use between the blocks of the BBAN, defaults to ' ' * @returns {string|*} */ exports.toBBAN = function(iban, separator){ if (typeof separator == 'undefined'){ separator = ' '; } iban = electronicFormat(iban); var countryStructure = countries[iban.slice(0,2)]; if (!countryStructure) { throw new Error('No country with code ' + iban.slice(0,2)); } return countryStructure.toBBAN(iban, separator); }; exports.printFormat = function(iban, separator){ if (typeof separator == 'undefined'){ separator = ' '; } return electronicFormat(iban).replace(EVERY_FOUR_CHARS, "$1" + separator); };
63 lines
2.0 KiB
TypeScript
63 lines
2.0 KiB
TypeScript
// Type definitions for iban.js 0.0.5
|
|
// Project: https://github.com/arhs/iban.js/
|
|
// Definitions by: Cyril Schumacher <https://github.com/cyrilschumacher>
|
|
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
|
|
/**
|
|
* @summary Interface for {@link IBAN} object.
|
|
* @author Cyril Schumacher
|
|
* @version 1.0
|
|
*/
|
|
interface IBANStatic {
|
|
/**
|
|
* @summary Returns the IBAN in a electronic format.
|
|
* @param {string} iban The IBAN to convert.
|
|
* @param {string} The IBAN in electronic format.
|
|
*/
|
|
electronicFormat(iban: string): string;
|
|
|
|
/**
|
|
* @summary Convert the passed BBAN to an IBAN for this country specification.
|
|
* @param {string} countryCode The country of the BBAN.
|
|
* @param {string} bban The BBAN to convert to IBAN.
|
|
* @returns {string} The IBAN.
|
|
*/
|
|
fromBBAN(countryCode: string, bban: string): string;
|
|
|
|
/**
|
|
* @summary Check if the passed iban is valid according to this specification.
|
|
* @param {string} iban The iban to validate.
|
|
* @returns {boolean} True if valid, false otherwise.
|
|
*/
|
|
isValid(iban: string): boolean;
|
|
|
|
/**
|
|
* @summary Check of the passed BBAN is valid.
|
|
* @param {string} countryCode The country of the BBAN.
|
|
* @param {string} bban The BBAN to validate.
|
|
* @returns {boolean} True if valid, false otherwise.
|
|
*/
|
|
isValidBBAN(countryCode: string, bban: string): boolean;
|
|
|
|
/**
|
|
* @summary Returns the IBAN in a print format.
|
|
* @param {string} iban The IBAN to convert.
|
|
* @param {string} separator The separator to use between IBAN blocks, defaults to ' '.
|
|
*/
|
|
printFormat(iban: string, separator?: string): string;
|
|
|
|
/**
|
|
* @summary Convert the passed IBAN to a country-specific BBAN.
|
|
* @param {string} iban The IBAN to convert.
|
|
* @param {string} separator The separator to use between BBAN blocks, defaults to ' '.
|
|
* @returns {string} The BBAN
|
|
*/
|
|
toBBAN(iban: string, separator?: string): string;
|
|
}
|
|
|
|
declare var IBAN: IBANStatic;
|
|
|
|
declare module 'iban' {
|
|
export = IBAN;
|
|
}
|