In hex you use three or six digits to define a color. By replacing all six-digit colors with the closest color which can be expressed with three digits, we save 3 bytes each! Hooray!
http://www.w3.org/TR/CSS2/syndata.html#value-def-color
The three-digit RGB notation (#rgb) is converted into six-digit form (#rrggbb) by replicating digits, not by adding zeros.
Examples:
'00ff00' -> '0f0'
'34cf9d' -> '3c9'
If we want this to be completely non-destructive, we can only change #000000 to #000, #000011 to #001, ... #111111 to #111 ... #FFFFFF to #FFF, almost as in Subzey's first approach (which would go wrong on colors like #099330:
function(a){return a.replace(/(\w)\1(\w)\2(\w)\3/,"$1$2$3")}
But as we wanted to get the closest color (as is specified in the readme), the original approach (with function body reusal) works best.