New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

weather-underground-node

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

weather-underground-node - npm Package Compare versions

Comparing version 0.5.0 to 1.0.0

28

lib/weather-underground-node.js

@@ -17,4 +17,6 @@ /* eslint-disable no-console */

that.chainedParams = [];
that.units = "units=m";
var format = "format=json";
var units = "units=m";
apikey = "apiKey=" + apikey;

@@ -168,2 +170,19 @@ if(debug !== true) debug = false;

/* UNITS OPTIONS */
that.InImperialUnits = function() {
this.units = "units=e";
return this;
};
that.InEnglishUnits = function() {
this.units = "units=e";
return this;
};
that.InMetricUnits = function() {
this.units = "units=m";
return this;
};
/**

@@ -190,3 +209,3 @@ * Performs the actual request

var otherParams = [units, format, apikey];
var otherParams = [that.units, format, apikey];
if(chain.indexOf("v3/location") !== -1) otherParams = [format, apikey];

@@ -199,3 +218,8 @@ var query = that.chainedParams.concat(otherParams);

var url = "https://api.weather.com" + chain + "?"+ query.join("&");
//reset vars to default for next request
that.chainedRequests = [];
that.chainedParams = [];
that.units = "units=m";
if(debug) {

@@ -202,0 +226,0 @@ console.log("#-------------------#");

2

package.json
{
"name": "weather-underground-node",
"version": "0.5.0",
"version": "1.0.0",
"main": "./lib/weather-underground-node.js",

@@ -5,0 +5,0 @@ "description": "Weather underground client for node.js - NEW 2019 API from The Weather Company (IBM) only for PWS owners",

@@ -62,3 +62,3 @@ # Weather underground client for node.js

console.log(response);
}
});
```

@@ -71,3 +71,3 @@

console.log(response);
}
});
```

@@ -80,3 +80,3 @@

console.log(response);
}
});
```

@@ -86,6 +86,10 @@ To get daily historic data:

```js
wunderground.PWSHistoryDaily("IROME228", "20190309").request(function (err, response) { console.log(response);
}
wunderground.PWSHistoryDaily("IROME228", "20190309").request(function (err, response) {
console.log(response);
});
```
## Units
Imperial/english units can be requested by adding `InImperialUnits()` or `InEnglishUnits()` to the chain. (default: Metric units)
## Running Unit Tests and Code coverage

@@ -92,0 +96,0 @@

@@ -53,3 +53,3 @@ /* eslint-disable no-unused-vars */

response.observations.should.is.Array();
response.observations[0].should.have.properties(["stationID", "softwareType", "country", "lat", "lon"]);
response.observations[0].should.have.properties(["stationID", "softwareType", "country", "lat", "lon", "metric"]);
response.observations[0].stationID.should.be.exactly("IROME228");

@@ -70,3 +70,3 @@ response.observations[0].country.should.be.exactly("IT");

response.observations.should.is.Array();
response.observations[0].should.have.properties(["stationID", "softwareType", "country", "lat", "lon"]);
response.observations[0].should.have.properties(["stationID", "softwareType", "country", "lat", "lon", "metric"]);
response.observations[0].stationID.should.be.exactly("IROME228");

@@ -80,2 +80,50 @@ response.observations[0].country.should.be.exactly("IT");

it("Request PWS conditions - in imperial units.", function (done) {
validApikey.should.be.true(apykeyMessage);
var wunderground = new WeatherUndergroundNode(apikey);
wunderground.PWSCurrentConditions("IROME228").InImperialUnits().request(function (err, response) {
response.should.have.property("observations");
response.observations.should.is.Array();
response.observations[0].should.have.properties(["stationID", "softwareType", "country", "lat", "lon", "imperial"]);
response.observations[0].stationID.should.be.exactly("IROME228");
response.observations[0].country.should.be.exactly("IT");
response.observations[0].softwareType.should.be.exactly("NodeRed");
done();
});
});
it("Request PWS conditions - in english units.", function (done) {
validApikey.should.be.true(apykeyMessage);
var wunderground = new WeatherUndergroundNode(apikey);
wunderground.PWSCurrentConditions("IROME228").InEnglishUnits().request(function (err, response) {
response.should.have.property("observations");
response.observations.should.is.Array();
response.observations[0].should.have.properties(["stationID", "softwareType", "country", "lat", "lon", "imperial"]);
response.observations[0].stationID.should.be.exactly("IROME228");
response.observations[0].country.should.be.exactly("IT");
response.observations[0].softwareType.should.be.exactly("NodeRed");
done();
});
});
it("Request PWS conditions - in metric units.", function (done) {
validApikey.should.be.true(apykeyMessage);
var wunderground = new WeatherUndergroundNode(apikey);
wunderground.PWSCurrentConditions("IROME228").InMetricUnits().request(function (err, response) {
response.should.have.property("observations");
response.observations.should.is.Array();
response.observations[0].should.have.properties(["stationID", "softwareType", "country", "lat", "lon", "metric"]);
response.observations[0].stationID.should.be.exactly("IROME228");
response.observations[0].country.should.be.exactly("IT");
response.observations[0].softwareType.should.be.exactly("NodeRed");
done();
});
});
it("Request PWS conditions - wrong key.", function (done) {

@@ -82,0 +130,0 @@

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