Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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.
  • Loading branch information...
commit 0e90fd77f2688f8b214d4095a80d8b3c863f5461 1 parent e6deabd
josher19 josher19 authored
Showing with 3 additions and 2 deletions.
  1. +3 −2 geolib.js
5 geolib.js
View
@@ -510,7 +510,8 @@
* Converts a distance from meters to km, mm, cm, mi, ft, in or yd
*
* @param string Format to be converted in
- * @param float Distance
+ * @param float Distance in meters
+ * @param float Decimal places for rounding (default: 4)
* @return float Converted distance
*/
convertUnit: function(unit, distance, round) {
@@ -527,7 +528,7 @@
}
unit = unit || 'm';
- round = round || 4;
+ round = (null == round ? 4 : round);
switch(unit) {
Please sign in to comment.
Something went wrong with that request. Please try again.