js-luhn
v0.0.3
Published
A js luhn algorithm for validating credit cards
Downloads
12
Maintainers
Readme
js-luhn
A JavaScript module of the luhn algorithm for Credit Card Validation that works with both client-side JavaScript and Node.js.
A js-luhn algorithm for validating credit cards
Getting Started
Installation
npm install js-luhn --save
How to use
Integration
import luhn from "js-luhn"; // Javascript
const stats = require('js-luhn'); ; // Node Js
API Documentation
Luhn(data)
Returns the Boolean value in a given data.
import luhn from "js-luhn";
// '4242424242424242'
if(luhn('4242424242424242')) { // return boolean
... // your code here
}
// '4242 4242 4242 4242'
if(luhn('4242 4242 4242 4242')) { // return boolean
... // your code here
}
// 378282246310005
if(luhn(378282246310005)) { // return boolean
... // your code here
}
Running Tests
To run the test suite first install the development dependencies:
npm install
then run the tests:
node test