ibantools-germany
Version:
IBAN Validator and Generator for German Bank Accounts
88 lines (87 loc) • 2.8 kB
TypeScript
/**
* ibantools-germany
* Copyright (c) 2022-2026 Markus Baumer <markus@baumer.dev>
* SPDX-License-Identifier: MIT OR MPL-2.0
*/
/**
* Fill the account number with zeros from the left to get a 10 digits string
*/
export declare const paddedAccountNumber: (number: string) => string;
/**
* Get an array of digits for a number or string
*
* Example: 0118999 will return [0, 1, 1, 8, 9 ,9 ,9]
*/
export declare const getDigits: (numberOrString: number | string) => number[];
/**
* Get the sum of all numbers
*
* Example: [1,2,3] will return 6
*/
export declare const calculateSum: (numbers: number[]) => number;
/**
* Get cross sum of number
*
* Example: 17 will return 8, 146 will return 11
*/
export declare const calculateCrossSum: (number: number) => number;
/**
* Get cross sum of each number
*
* Example: [17, 146] will return [8, 11]
*/
export declare const calculateCrossSums: (numbers: number[]) => number[];
/**
* Get unit column of number
*
* Example: 94 will return 4, 236 will return 6
*/
export declare const getUnitFromNumber: (number: number) => number;
/**
* Get unit column of numbers
*
* Example: [94, 83] will return [4, 3]
*/
export declare const getUnitsFromNumbers: (numbers: number[]) => number[];
export type WeightType = "MULTIPLY" | "MULTIPLY_ADD";
/**
* Return an array of digits weighted. This can either be by
* multiplying the digits with the weight (default) or adding
* the weight to the digits or by multiplying and then adding
* the weight.
*
* Example: digits [1, 2 , 3 , 4] with weights [1, 2, 1, 2]
* will return
* [1, 4, 3, 8] with type MULTIPLY
* [2, 6, 4, 10] with type MULTIPLY_ADD
*/
export declare const weightDigits: (digits: number[], weights: number[], weightType?: WeightType) => number[];
/**
* Does the same as weightDigits() but uses the weight (left to right)
* on the digits (right to left)
*/
export declare const weightDigitsRTL: (digits: number[], weights: number[], weightType?: WeightType) => number[];
/**
* Calculates the modulo (remainder of division) and subtracts it from
* the minuend, returns difference and remainder.
*
* Example: Value 12 with divisor 10 and minuend 11 will return 9 (remainder of 12/10 = 2; 11-2 = 9)
*/
export declare const moduloDifference: (value: number, divisor: number, minuend: number) => {
difference: number;
remainder: number;
};
/**
* Get the difference to next half decade (5, 15, 25...).
*
* Example: Value 12 result is 3, value 6 is 9
*/
export declare const diffNextHalfDecade: (value: number) => number;
/**
* Checksum calculation method for IBAN
*/
export declare const modulo97: (value: string) => number;
/**
* Convert letters to digits (ASCII code minus 55)
*/
export declare const lettersToDigits: (string: string) => string;