Implementation of the Luhn checksum algorithm, see http://en.wikipedia.org/wiki/Luhn_algorithm
First argument should be a number or a string composed of digits only. Second argument is optional. If second argument evaluates to true, the return value is the concatenation of the first argument and its Luhn checksum. Otherwise the return value is a boolean indicating if the first arguments checksum digit is valid.
Doh, you are right @tsaniel.
Have a fix, but need to update annotated version so will just put it in the comment here for now:
function(b,y,t,e,s,u){s=0;u=y?1:2;for(t=(b=b+'').length;t--;){e=b[t]*(u^=3);s+=e-(e>9?9:0)}t=10-(s%10||10);return y?b+t:!t}
And yes, that is 1 byte shorter than the broken version