openweather-apis
Advanced tools
Comparing version 3.3.5 to 4.0.0
37
index.js
@@ -0,1 +1,2 @@ | ||
/*jshint esversion: 6,node: true,-W041: false */ | ||
// weather.js - APIs for openweathermap.org | ||
@@ -29,3 +30,3 @@ (function(){ | ||
config.city = encodeURIComponent(city.toLowerCase()); | ||
} | ||
}; | ||
@@ -139,3 +140,3 @@ weather.setCoordinate = function(latitude, longitude){ | ||
}); | ||
}; | ||
} | ||
@@ -146,3 +147,3 @@ function getPres(callback){ | ||
}); | ||
}; | ||
} | ||
@@ -153,3 +154,3 @@ function getTemp(callback){ | ||
}); | ||
}; | ||
} | ||
@@ -160,3 +161,3 @@ function getHum(callback){ | ||
}); | ||
}; | ||
} | ||
@@ -167,3 +168,3 @@ function getDesc(callback){ | ||
}); | ||
}; | ||
} | ||
@@ -193,3 +194,3 @@ function getSmart(callback){ | ||
}); | ||
}; | ||
} | ||
@@ -204,23 +205,23 @@ function getCoordinate(){ | ||
return coordinateQuery; | ||
}; | ||
} | ||
function buildPath(){ | ||
return '/data/2.5/weather?' + getCoordinate() + '&units=' + config.units + '&lang=' + config.lan + '&mode=json&APPID=' + config.APPID; | ||
}; | ||
} | ||
function buildPathForecast(){ | ||
return '/data/2.5/forecast?' + getCoordinate() + '&units=' + config.units + '&lang=' + config.lan + '&mode=json&APPID=' + config.APPID; | ||
}; | ||
} | ||
function buildPathForecastForDays(days){ | ||
return '/data/2.5/forecast/daily?' + getCoordinate() + '&cnt=' + days + '&units=' + config.units + '&lang=' + config.lan + '&mode=json&APPID=' + config.APPID; | ||
}; | ||
} | ||
function buildPathForecastForHours(hours) { | ||
return '/data/2.5/forecast/hour?' + getCoordinate() + '&cnt=' + hours + '&units=' + config.units + '&lang=' + config.lan + '&mode=json&APPID=' + config.APPID; | ||
}; | ||
} | ||
function getData(url, callback, tries){ | ||
options.path = url; | ||
http.get(options, function(res){ | ||
var conn = http.get(options, function(res){ | ||
var chunks = ''; | ||
@@ -239,5 +240,5 @@ res.on('data', function(chunk) { | ||
try{ | ||
parsed = JSON.parse(chunks) | ||
parsed = JSON.parse(chunks); | ||
}catch(e){ | ||
parsed = {error:e} | ||
parsed = {error:e}; | ||
} | ||
@@ -252,4 +253,8 @@ | ||
}); | ||
}; | ||
conn.on('error', function(err){ | ||
return callback(err, null); | ||
}); | ||
} | ||
})(); |
{ | ||
"name": "openweather-apis", | ||
"version": "3.3.5", | ||
"version": "4.0.0", | ||
"description": "Simple APIs to use with OpenWeatherMap.org free servicies, request a APPID on http://openweathermap.org/appid and start!", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -23,2 +23,3 @@ # openweather-apis | ||
+ Version 3.3.0 get the rain in present in getSmartJSON | ||
+ Version 4.0.0 Fix unhandled exception #26 | ||
@@ -25,0 +26,0 @@ ## Installation |
326
182
26396
10