Skip to content

Commit

Permalink
2.0.0 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
evanshortiss committed May 25, 2017
1 parent f7cf0a0 commit 79ce93d
Show file tree
Hide file tree
Showing 7 changed files with 348 additions and 678 deletions.
16 changes: 14 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,20 @@

Dates use DD/MM/YYYY format.

## 2.0.0 - 24/05/17
* Increase performance by approximately 10x due to use of `pixl-xml` and
improved algorithm for getting weather nodes.
* Simplify codebase.
* Update JSON output format to be closer to the original XML content. This gives
users of this module more flexibility and information but is a breaking change.
* Add `getValidTimes` function.
* Fix security `request` and `qs` module vulnerabilities by updating to `yr.no-interface@1.0.1`.

# 1.0.0 26/04/2017
## 1.0.1 - 28/04/2017
* Mitigate security vulnerabilities.
* Use new yr.no-interface@1.0.0 internally.

## 1.0.0 - 27/04/2017
* Change to Promise based interface.
* Make the module a factory function.
* Use `pixl-xml` to increase XML parsing speed and lower memory usage. Yay for
Expand All @@ -13,5 +25,5 @@ better performance!
passing the current timestamp. Simplifies API footprint.


# < 1.0.0
## < 1.0.0
* Undocumented. Sorry.
97 changes: 75 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,40 +74,93 @@ many time formats will work, but a millisecond timestamp or ISO formatted date
string are both ideal options to use use.

### LocationForecast.getXml()
Returns the XML string that the locationforecast API returned.
Returns the raw XML string that the `locationforecast` API returned.

### LocationForecast.getJson()
Returns the JSON representation of a locationforecast response.
Returns the JSON representation of the entire `locationforecast` response.

### LocationForecast.getFirstDateInPayload()
Returns the first date string that is available in the data returned from the
locationforecast call.

### LocationForecast.getValidTimes()
Returns an Array of ISO timestamps that represent points in time that we have
weather data for.


## Weather JSON Format
Format is somewhat inspired by that of the
[forecast.io](https://developer.forecast.io/) service.

Some fields will be undefined depending on the weather conditions. Always
verify the field you need exists by using `data.hasOwnProperty('fog')`
or similar techniques.
verify the field you need exists, e.g use `data.hasOwnProperty('fog')` or
similar techniques.

```js
```json
{
icon: 'PARTLYCLOUD',
to: '2013-11-15T18:00:00Z',
from: '2013-11-15T12:00:00Z',
rain: '0.0 mm',
temperature: '9.7 celcius',
windDirection: { deg: '220.2', name: 'SW' },
windSpeed: { mps: '2.7', beaufort: '2', name: 'Svak vind' },
humidity: '27.9 percent',
pressure: '1021.0 hPa',
cloudiness: '0.0%',
fog: '0.0%',
lowClouds: '0.0%',
mediumClouds: '0.0%',
highClouds: '0.0%',
dewpointTemperature: '-8.3 celcius'
"datatype": "forecast",
"from": "2017-04-18T03:00:00Z",
"to": "2017-04-18T03:00:00Z",
"icon": "PartlyCloud",
"rain": "0.0 mm",
"altitude": "0",
"latitude": "59.8940",
"longitude": "10.6450",
"temperature": {
"id": "TTT",
"unit": "celsius",
"value": "-0.9"
},
"windDirection": {
"id": "dd",
"deg": "14.6",
"name": "N"
},
"windSpeed": {
"id": "ff",
"mps": "1.5",
"beaufort": "1",
"name": "Flau vind"
},
"windGust": {
"id": "ff_gust",
"mps": "2.4"
},
"humidity": {
"value": "78.3",
"unit": "percent"
},
"pressure": {
"id": "pr",
"unit": "hPa",
"value": "1030.1"
},
"cloudiness": {
"id": "NN",
"percent": "15.4"
},
"fog": {
"id": "FOG",
"percent": "0.0"
},
"lowClouds": {
"id": "LOW",
"percent": "15.4"
},
"mediumClouds": {
"id": "MEDIUM",
"percent": "0.8"
},
"highClouds": {
"id": "HIGH",
"percent": "0.0"
},
"dewpointTemperature": {
"id": "TD",
"unit": "celsius",
"value": "-4.5"
}
}
```

## CHANGELOG

Can be found [at this link](https://github.com/evanshortiss/yr.no-forecast/blob/master/CHANGELOG.md ).
40 changes: 40 additions & 0 deletions benchmark/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
'use strict';

const Benchmark = require('benchmark');
const suite = new Benchmark.Suite;
const readFileSync = require('fs').readFileSync;
const join = require('path').join;
const sinon = require('sinon');
const yrno = {
locationforecast: sinon.stub().yields(
null,
readFileSync(join(__dirname, '../fixtures/weather-response-oslo.xml'), 'utf8')
)
};
const forecast = require('proxyquire')('../index.js', {
'yr.no-interface': sinon.stub().returns(yrno)
});

suite
.add(
'#getFiveDaySummary',
(deffered) => {
forecast().getWeather()
.then((weather) => weather.getFiveDaySummary())
.then(() => deffered.resolve());
},
{defer: true}
)
.add(
'#getForecastForTime',
(deffered) => {
forecast().getWeather()
.then((weather) => weather.getFiveDaySummary())
.then(() => deffered.resolve());
},
{defer: true}
)
.on('cycle', function(event) {
console.log(String(event.target));
})
.run();

0 comments on commit 79ce93d

Please sign in to comment.