1.0.4 • Published 2 years ago

luhn-tiny v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

luhn

A simple function to allow you to check whether a credit card number's checksum digit (or the trailing luhn checksum digit of any similar number such as a phone's IMEI) is correct.

Usage:

luhn('4111 1111 1111 1111')   // returns true
luhn('4111-1111-1111-1112')   // returns true
luhn(4111111111111)           // returns true
luhn(4111111111112)           // returns false

As you can see, it accepts a number or a string and ignores non-numeric characters in strings (e.g. spaces or dashes).

There's a ton of these functions out there, but I'm pretty sure this is the smallest and probably the fastest.

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago