UNPKG

@konfirm/iso7064

Version:

ISO/IEC 7064:2003 - Check character systems

169 lines (163 loc) 3.82 kB
import { Alphabet } from '@konfirm/alphabet'; export { Alphabet } from '@konfirm/alphabet'; type ISO7064Options = { algorithm: string; designation: number; radix: number; modulus: number; double: boolean; indices: Alphabet; alphabet: Alphabet; }; /** * Implement the common ISO 7064 implementation mechanics * * @class ISO7064 */ declare abstract class ISO7064 { constructor(options?: Partial<ISO7064Options>); /** * The algorithm name * * @readonly * @memberof ISO7064 */ get algorithm(): string; /** * The specification name * * @readonly * @memberof ISO7064 */ get specification(): string; /** * The designation (always 0, except for the Modulus implementations) * * @readonly * @memberof ISO7064 */ get designation(): number; /** * The alphabet of allowed characters and from which to obtain the indices * * @readonly * @memberof ISO7064 */ get indices(): Alphabet; /** * The checksum alphabet * * @readonly * @memberof ISO7064 */ get alphabet(): Alphabet; /** * The modulus * * @readonly * @memberof ISO7064 */ get modulus(): number; /** * The radix * * @readonly * @memberof ISO7064 */ get radix(): number; /** * Does the checksum consist of double digits * * @readonly * @memberof ISO7064 */ get double(): boolean; /** * Normalize input, removing any character not allowed in the input * * @param {string} input * @returns {string} normalized * @memberof ISO7064 */ normalize(input: string): string; /** * Calculate the checksum for input * * @param {string} input * @returns {string} checksum * @memberof ISO7064 */ checksum(input: string): string; /** * Validate the input * * @param {string} input * @returns {boolean} valid * @memberof ISO7064 */ validate(input: string): boolean; /** * Generate the normalized output including the checksum * * @param {string} input * @returns {string} generated * @memberof ISO7064 */ generate(input: string): string; /** * Create a new instance based on the current settings with optional overrides * * @param {object} options * @returns * @memberof ISO7064 */ factory(options?: {}): any; } /** * Pure checksum calculation implementation * * @class PureISO7064 * @extends {ISO7064} */ declare class PureISO7064 extends ISO7064 { /** * Creates an instance of PureISO7064 * * @param {*} options * @memberof PureISO7064 */ constructor(options?: Partial<ISO7064Options>); /** * Calculate the checksum for input * * @param {string} input * @returns {string} checksum * @memberof PureISO7064 */ checksum(input: string): string; } /** * Hybrid checksum calculation implementation * * @class HybridISO7064 * @extends {ISO7064} */ declare class HybridISO7064 extends ISO7064 { /** * Calculate the checksum for input * * @param {string} input * @returns {string} checksum * @memberof HybridISO7064 */ checksum(input: string): string; } declare const Mod11_2: PureISO7064; declare const Mod37_2: PureISO7064; declare const Mod97_10: PureISO7064; declare const Mod661_26: PureISO7064; declare const Mod1271_36: PureISO7064; declare const Mod11_10: HybridISO7064; declare const Mod27_26: HybridISO7064; declare const Mod37_36: HybridISO7064; export { HybridISO7064, ISO7064, Mod11_10, Mod11_2, Mod1271_36, Mod27_26, Mod37_2, Mod37_36, Mod661_26, Mod97_10, PureISO7064 };