manuelbieh/Geolib — pull request #8 by josher19 (2012-03-07 07:27:12+00:00)
Title: Can now use convertUnit to round to 0 decimal places.

Nice library! I found a minor bug where convertUnit does not allow one to round to 0 decimal places. Fixed in this pull request.

Can now use **convertUnit** to round to 0 decimal places:

geolib.convertUnit('mi', 5000*1000, 0) === 3107

and

geolib.convertUnit('mi', 5000*1000) === 3106.856

while before it was incorrectly being rounded to 4 places instead of 0:

geolib.convertUnit('mi', 5000*1000, 0) === 3106.856

I generally recommend using

arg = (null == arg ? DEFAULT : arg);

instead of

arg = arg || DEFAULT;

for giving default arguments in Javascript because that way you get the default for `null` and `undefined` items while keeping "falsy" items such as `0`, `false`, and `""`.