UNPKG

verhoeff-algorithm

Version:

A TypeScript implementation of the Verhoeff algorithm.

51 lines (32 loc) 1.04 kB
# Verhoeff Algorithm Validator A simple TypeScript implementation of the Verhoeff algorithm for checksum validation. ## Installation You can install this package using npm: ```sh npm install verhoeff-algorithm ``` ## Usage ### Import the module #### In TypeScript: ```ts import { isValidVerhoeff } from "verhoeff-algorithm"; ``` #### In JavaScript: ```js const { isValidVerhoeff } = require("verhoeff-algorithm"); ``` ### Validate a number ```ts const number = "12345"; if (isValidVerhoeff(number)) { console.log("Valid Verhoeff number"); } else { console.log("Invalid Verhoeff number"); } ``` ## How It Works The Verhoeff algorithm is a checksum formula for error detection. It ensures that a given numeric value follows a specific checksum pattern. This package provides a function to verify whether a number passes the Verhoeff validation. ## License This project is licensed under the MIT License. ## Author Created by [npdevind](https://github.com/npdevind).