Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

wundergrounded

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wundergrounded - npm Package Compare versions

Comparing version 0.1.3 to 0.1.4

example.js

39

lib/wundergrounded.js

@@ -146,4 +146,15 @@ 'use strict';

var apiEndpoint = function(service, query, callback) {
_requests.push(service);
var apiEndpoint = function(service, query, callback) {
var requestExists = function(request) {
for(var i = 0; i < _requests.length; i++) {
var _request = _requests[i];
if(_request === request) {
return true;
}
}
return false;
};
if(!requestExists(service)) {
_requests.push(service);
}
if(query && callback) {

@@ -169,7 +180,9 @@ request(query, callback);

else {
var doRequest = function() {
// Copy requests value and clear
var services = _requests;
_requests = [];
// Function that actually does the request... used later
var doRequest = function(_services, _query, _callback) {
// Generate URL
var url = 'http://api.wunderground.com/api/' + _apiKey + '/' + _requests.join('/') + '/q/' + query + '.json';
// Clear requests queue
_requests = [];
var url = 'http://api.wunderground.com/api/' + _apiKey + '/' + _services.join('/') + '/q/' + _query + '.json';
// Try to pull the data from the cache

@@ -180,3 +193,3 @@ if(_cache) {

if(_debug) log('[' + url + '] Returning cached response.');
callback(false, json);
_callback(false, json);
return this;

@@ -199,3 +212,3 @@ }

if(_debug) log('[' + url + '] Returning API response.');
callback(false, json);
_callback(false, json);
}

@@ -205,3 +218,3 @@ // If this is a sad-path response, return an error

if(_debug) log('[' + url + '] Request failed!');
callback(json, 'An error occurred while communicating with the Weather Underground API.');
_callback(json, 'An error occurred while communicating with the Weather Underground API.');
}

@@ -212,3 +225,3 @@ }

if(_debug) log('[' + url + '] Request failed!');
callback(error, 'Received an error when trying to connect to ' + url);
_callback(error, 'Received an error when trying to connect to ' + url);
}

@@ -221,3 +234,3 @@ });

if(!error) {
doRequest();
doRequest(services, query, callback);
}

@@ -228,3 +241,3 @@ });

else {
doRequest();
doRequest(services, query, callback);
}

@@ -276,2 +289,2 @@ }

};
};
{
"name": "wundergrounded",
"version": "0.1.3",
"version": "0.1.4",
"description": "",

@@ -5,0 +5,0 @@ "main": "lib/wundergrounded.js",

@@ -215,3 +215,4 @@ # Wundergrounded

* 0.1.4 Fixing race condition in limited requests
* 0.1.3 Minor updates to README
* 0.1.0 Initial release
* 0.1.3 Minor updates to README
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc