cdigit
Version:
Collection of check digit algorithms implemented in JavaScript
35 lines (34 loc) • 1.11 kB
TypeScript
/**
* cdigit
*
* @copyright 2018-2021 LiosK
* @license (MIT OR Apache-2.0)
*/
import { Algo } from "./common";
/**
* Verhoeff algorithm implementation
*
* Note: There is not a firm consensus on the direction (left to right or right
* to left) in which a Verhoeff calculator scans numeric text to construct an
* input digit sequence. This implementation is hard coded to read a string from
* right to left and append the check digit at the rightmost position, which is
* a consistent behavior with other popular implementations. Reverse the input
* string before calling this class' methods if you need to interpret a string
* from left to right.
*/
declare class Verhoeff implements Algo {
name: string;
longName: string;
/** Verhoeff multiplication table */
private d;
/** Verhoeff permutation table */
private p;
/** Verhoeff inverse table */
private inv;
compute(num: string): string;
generate(num: string): string;
validate(num: string): boolean;
parse(num: string): [string, string];
}
export declare const verhoeff: Verhoeff;
export {};