Socket
Socket
Sign inDemoInstall

node-accuweather

Package Overview
Dependencies
75
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.3.1 to 1.4.0

dist/src/test.js

36

dist/src/index.js
'use strict';
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
var request = require('request-promise');

@@ -7,10 +9,16 @@

return function (API_KEY) {
var baseUrl = 'http://dataservice.accuweather.com';
// Gets the AccuWeather-specific location key so that a query can be made to get the weather
var getLocationKey = function getLocationKey(query) {
var params = {
url: 'http://dataservice.accuweather.com/locations/v1/cities/autocomplete',
qs: { apikey: API_KEY, q: query }
url: baseUrl + '/locations/v1/cities/autocomplete',
qs: { apikey: API_KEY, q: query },
json: true
};
return request(params).then(function (body) {
return JSON.parse(body)[0].Key;
return request(params).then(function (_ref) {
var _ref2 = _slicedToArray(_ref, 1),
body = _ref2[0];
return body.Key;
}).catch(function (err) {

@@ -24,10 +32,16 @@ console.error(err);

var params = {
url: 'http://dataservice.accuweather.com/currentconditions/v1/' + key,
qs: { apikey: API_KEY, details: true }
url: baseUrl + '/currentconditions/v1/' + key,
qs: { apikey: API_KEY, details: true },
json: true
};
return request(params);
}).then(function (body) {
}).then(function (_ref3) {
var _ref4 = _slicedToArray(_ref3, 1),
body = _ref4[0];
return {
Temperature: JSON.parse(body)[0].Temperature.Imperial.Value,
RealFeel: JSON.parse(body)[0].RealFeelTemperature.Imperial.Value
Summary: body.WeatherText,
Temperature: body.Temperature.Imperial.Value,
RealFeel: body.RealFeelTemperature.Imperial.Value,
Precipitation: body.Precip1hr.Imperial
};

@@ -40,4 +54,4 @@ }).catch(function (err) {

return {
getLocationKey: getLocationKey,
getNowWeatherAndRealFeel: getNowWeatherAndRealFeel };
getNowWeatherAndRealFeel: getNowWeatherAndRealFeel
};
};

@@ -44,0 +58,0 @@ };

{
"name": "node-accuweather",
"version": "1.3.1",
"version": "1.4.0",
"description": "An node wrapper for the AccuWeather API",

@@ -5,0 +5,0 @@ "main": "dist/src/index.js",

@@ -5,11 +5,14 @@ const request = require('request-promise')

return (API_KEY) => {
const baseUrl = 'http://dataservice.accuweather.com'
// Gets the AccuWeather-specific location key so that a query can be made to get the weather
const getLocationKey = (query) => {
const params = {
url: 'http://dataservice.accuweather.com/locations/v1/cities/autocomplete',
qs: {apikey: API_KEY, q: query}
url: baseUrl + '/locations/v1/cities/autocomplete',
qs: {apikey: API_KEY, q: query},
json: true
}
return request(params)
.then(body => {
return(JSON.parse(body)[0].Key)
.then(([body,]) => {
return body.Key
})

@@ -25,11 +28,14 @@ .catch(err => {

const params = {
url: 'http://dataservice.accuweather.com/currentconditions/v1/' + key,
qs: {apikey: API_KEY, details: true}
url: baseUrl + '/currentconditions/v1/' + key,
qs: {apikey: API_KEY, details: true},
json: true
}
return request(params)
})
.then(body => {
.then(([body,]) => {
return {
Temperature: JSON.parse(body)[0].Temperature.Imperial.Value,
RealFeel: JSON.parse(body)[0].RealFeelTemperature.Imperial.Value
Summary: body.WeatherText,
Temperature: body.Temperature.Imperial.Value,
RealFeel: body.RealFeelTemperature.Imperial.Value,
Precipitation: body.Precip1hr.Imperial
}

@@ -43,4 +49,4 @@ })

return {
getLocationKey: getLocationKey,
getNowWeatherAndRealFeel: getNowWeatherAndRealFeel }
getNowWeatherAndRealFeel: getNowWeatherAndRealFeel
}
}

@@ -47,0 +53,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc