https://github.com/tolbon/luhn-ts
Simple and Fast Luhn's Algorithm in Typescript
https://github.com/tolbon/luhn-ts
hacktoberfest javascript luhn-algorithm node typescript
Last synced: 3 months ago
JSON representation
Simple and Fast Luhn's Algorithm in Typescript
- Host: GitHub
- URL: https://github.com/tolbon/luhn-ts
- Owner: tolbon
- Created: 2017-05-04T20:55:32.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2022-10-08T10:54:02.000Z (over 2 years ago)
- Last Synced: 2025-02-23T01:48:32.210Z (4 months ago)
- Topics: hacktoberfest, javascript, luhn-algorithm, node, typescript
- Language: JavaScript
- Homepage:
- Size: 64.5 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# luhn-ts
Luhn's Algorithm write in Typescript (already transpiled/compiled in lib folder)## Installation ##
```bash
npm install luhn-ts
# OR
yarn add luhn-ts
```#### Node.js ####
```javascript
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.
``````javascript
var luhn = require("luhn");
var checksum = luhn.computeCheckSumControl("497401423384552"); // should respond an array of checksum [3].
// because 497401423384552-3 is valid CreditCard Numbervar 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;
```