JamesEggers1 / luhn

A JavaScript module of the luhn algorithm for Credit Card Validation that works with both client-side JavaScript and Node.js
MIT License
52 stars 20 forks source link

Strange usage #3

Closed LinusU closed 9 years ago

LinusU commented 10 years ago

Hi,

When using this module from Node.js it feels very strange to do require('luhn').luhn. All the other libraries is just require('name').

Please allow the following code to work:

var luhn = require('luhn');

luhn.validate('123456');
jazzzz commented 10 years ago

:+1:

JamesEggers1 commented 10 years ago

While it is a strange syntax, it is in place due to the module being able to be consumed client-side as well. At the time of development, there wasn't a better way. Going to do an update to address this soon.

LinusU commented 10 years ago

Nice, remember to follow semver when you change how to require it :)

JamesEggers1 commented 9 years ago

Been really behind and finally getting around to this. This will be a part of v1.1 or v2 shortly as there are other items changes coming with the client-side aspect of things too.

JamesEggers1 commented 9 years ago

Updated package to v2.0.0 which addresses this. The usage is now as follows:

var luhn = require("luhn");
var is_valid = luhn.validate("number");