js-luhn

0.0.3 • Public • Published

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

License

ISC

Package Sidebar

Install

npm i js-luhn

Weekly Downloads

1

Version

0.0.3

License

ISC

Unpacked Size

21.6 kB

Total Files

6

Last publish

Collaborators

  • marisnb