Can now use convertUnit to round to 0 decimal places. #8

Merged
merged 1 commit into from Mar 15, 2012

Projects

Done in Geolib Development

2 participants

@josher19
Contributor
josher19 commented Mar 7, 2012

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 "".

@josher19 josher19 Can 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,
    geolib.convertUnit('mi', 5000*1000, 0) === 3106.856

Generally suggest using 
    arg = (null == arg ? DEFAULT : arg)
instead of
    arg = arg || DEFAULT
for giving default arguments.
0e90fd7
@manuelbieh manuelbieh merged commit 390e9d4 into manuelbieh:master Mar 15, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment