dark-sky-api
Advanced tools
Comparing version 0.4.0 to 0.5.0
@@ -186,2 +186,28 @@ 'use strict'; | ||
/** | ||
* Get the whole kit and kaboodle - contains currently, minutely, hourly, daily, alerts, and flags unless excluded | ||
* daily and durrently are processed if returned | ||
* @param {string} excludesBlock - pass comma separated excludes | ||
*/ | ||
}, { | ||
key: 'loadItAll', | ||
value: function loadItAll(excludesBlock) { | ||
var _this4 = this; | ||
if (!this.initialized) { | ||
return this.loadPositionAsync().then(function (position) { | ||
return _this4.initialize(position).loadCurrent(); | ||
}); | ||
} | ||
return this.darkSkyApi.units(this._units).language(this._language).exclude(excludesBlock).get().then(function (data) { | ||
!data.currently ? null : data.currently = _this4.processWeatherItem(data.currently); | ||
!data.daily.data ? null : data.daily.data = data.daily.data.map(function (item) { | ||
return _this4.processWeatherItem(item); | ||
}); | ||
data.updatedDateTime = (0, _moment2.default)(); | ||
return data; | ||
}); | ||
} | ||
/** | ||
* Make response a bit more friendly | ||
@@ -363,2 +389,20 @@ * @param {object} item - item to process | ||
/** | ||
* Get the whole kit and kaboodle - contains currently, minutely, hourly, daily, alerts, and flags unless excluded | ||
* daily and currently are processed if returned | ||
* @param {string} excludesBlock - pass comma separated excludes | ||
* @param {object} [position] - if omitted api will use loadPositionAsync | ||
*/ | ||
}, { | ||
key: 'loadItAll', | ||
value: function loadItAll(excludesBlock, position) { | ||
this.initialize(); | ||
if (position) { | ||
return this._api.setPosition(position).loadItAll(excludesBlock); | ||
} else { | ||
return this._api.loadItAll(excludesBlock); | ||
} | ||
} | ||
/** | ||
@@ -365,0 +409,0 @@ * Return the us response units |
{ | ||
"name": "dark-sky-api", | ||
"version": "0.4.0", | ||
"version": "0.5.0", | ||
"description": "a simple and robust dark sky api service for client-side js", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -125,2 +125,15 @@ # dark-sky-api | ||
### Hourly, Minutely, Alerts, and Flags | ||
To retrieve any of these results use loadItAll with optional excludesBlock | ||
```javascript | ||
DarkSkyApi.loadItAll() | ||
.then(console.log); | ||
DarkSkyApi.loadItAll('daily,hourly,minutely,flags') // just return alerts | ||
DarkSkyApi.loadItAll(excludes, position); // explicit position is second argument | ||
``` | ||
### Initialization | ||
@@ -127,0 +140,0 @@ |
@@ -135,2 +135,25 @@ import darkSkySkeleton from 'dark-sky-skeleton'; | ||
/** | ||
* Get the whole kit and kaboodle - contains currently, minutely, hourly, daily, alerts, and flags unless excluded | ||
* daily and durrently are processed if returned | ||
* @param {string} excludesBlock - pass comma separated excludes | ||
*/ | ||
loadItAll(excludesBlock) { | ||
if (!this.initialized) { | ||
return this.loadPositionAsync() | ||
.then(position => this.initialize(position).loadCurrent()); | ||
} | ||
return this.darkSkyApi | ||
.units(this._units) | ||
.language(this._language) | ||
.exclude(excludesBlock) | ||
.get() | ||
.then((data) => { | ||
!data.currently ? null : data.currently = this.processWeatherItem(data.currently); | ||
!data.daily.data ? null : data.daily.data = data.daily.data.map(item => this.processWeatherItem(item)); | ||
data.updatedDateTime = moment(); | ||
return data; | ||
}); | ||
} | ||
/** | ||
* Make response a bit more friendly | ||
@@ -294,2 +317,19 @@ * @param {object} item - item to process | ||
/** | ||
* Get the whole kit and kaboodle - contains currently, minutely, hourly, daily, alerts, and flags unless excluded | ||
* daily and currently are processed if returned | ||
* @param {string} excludesBlock - pass comma separated excludes | ||
* @param {object} [position] - if omitted api will use loadPositionAsync | ||
*/ | ||
static loadItAll(excludesBlock, position) { | ||
this.initialize(); | ||
if (position) { | ||
return this._api | ||
.setPosition(position) | ||
.loadItAll(excludesBlock); | ||
} else { | ||
return this._api.loadItAll(excludesBlock); | ||
} | ||
} | ||
/** | ||
@@ -296,0 +336,0 @@ * Return the us response units |
38008
910
207