Skip to content
/ luhn-ts Public

Simple and Fast Luhn's Algorithm in Typescript

Notifications You must be signed in to change notification settings

tolbon/luhn-ts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

luhn-ts

Luhn's Algorithm write in Typescript (already transpiled/compiled in lib folder)

Installation

npm install luhn-ts
# OR
yarn add luhn-ts

Node.js

var luhn = require("luhn");
var cleanCreditCardNumber = luhn.cleanProposed("41111-111-1111111 1"); // should respond "4111111111111111".

var is_valid = luhn.isLuhnValid(cleanCreditCardNumber); // should respond true.
var is_valid = luhn.isLuhnValid(cleanCreditCardNumber, 10); // exactly the same as before

//French society "Laposte" use luhn validation with a multiple of 5
var is_laposteSiret_valid = luhn.isLuhnValid("35600000000048", 5); // should respond true.
var luhn = require("luhn");
var checksum = luhn.computeCheckSumControl("497401423384552"); // should respond an array of checksum [3].
// because 497401423384552-3 is valid CreditCard Number

var checksum = luhn.computeCheckSumControl("3560000000004", 5); // should respond an array of checksum [3, 8].
// 3560000000004-3 is valid LuhnNumber Modulo 5;
// 3560000000004-8 is valid LuhnNumber Modulo 5;

About

Simple and Fast Luhn's Algorithm in Typescript

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published