openweather-api-node
Advanced tools
Comparing version 1.1.1 to 1.1.2
46
index.js
@@ -61,6 +61,6 @@ const SUP_LANGS = [ | ||
const currentFormatter = require("./formaters/current-formatter"), | ||
minutelyFormatter = require("./formaters/minutely-formatter"), | ||
hourlyFormatter = require("./formaters/hourly-formatter"), | ||
dailyFormatter = require("./formaters/daily-formatter") | ||
const currentParser = require("./parsers/current-parser"), | ||
minutelyParser = require("./parsers/minutely-parser"), | ||
hourlyParser = require("./parsers/hourly-parser"), | ||
dailyParser = require("./parsers/daily-parser") | ||
@@ -287,3 +287,3 @@ class OpenWeatherAPI { | ||
await this.#uncacheLocation() | ||
options = await this.#formatOptions(options) | ||
options = await this.#parseOptions(options) | ||
let response = await this.#fetch(`${API_ENDPOINT}${GEO_PATH}reverse?lat=${options.coordinates.lat}&lon=${options.coordinates.lon}&limit=1&appid=${options.key}`) | ||
@@ -304,6 +304,6 @@ let data = response.data | ||
await this.#uncacheLocation() | ||
options = await this.#formatOptions(options) | ||
options = await this.#parseOptions(options) | ||
let response = await this.#fetch(this.#createURL(options, "alerts,minutely,hourly,daily")) | ||
let data = response.data | ||
return currentFormatter(data) | ||
return currentParser(data) | ||
} | ||
@@ -320,6 +320,6 @@ | ||
await this.#uncacheLocation() | ||
options = await this.#formatOptions(options) | ||
options = await this.#parseOptions(options) | ||
let response = await this.#fetch(this.#createURL(options, "alerts,current,hourly,daily")) | ||
let data = response.data | ||
return minutelyFormatter(data, limit) | ||
return minutelyParser(data, limit) | ||
} | ||
@@ -336,6 +336,6 @@ | ||
await this.#uncacheLocation() | ||
options = await this.#formatOptions(options) | ||
options = await this.#parseOptions(options) | ||
let response = await this.#fetch(this.#createURL(options, "alerts,current,minutely,daily")) | ||
let data = response.data | ||
return hourlyFormatter(data, limit) | ||
return hourlyParser(data, limit) | ||
} | ||
@@ -352,3 +352,3 @@ | ||
await this.#uncacheLocation() | ||
options = await this.#formatOptions(options) | ||
options = await this.#parseOptions(options) | ||
let response = await this.#fetch(this.#createURL(options, "alerts,current,minutely,hourly")) | ||
@@ -358,3 +358,3 @@ let data = response.data | ||
data.daily.shift() | ||
return dailyFormatter(data, limit) | ||
return dailyParser(data, limit) | ||
} | ||
@@ -380,3 +380,3 @@ | ||
await this.#uncacheLocation() | ||
options = await this.#formatOptions(options) | ||
options = await this.#parseOptions(options) | ||
let response = await this.#fetch(this.#createURL(options, "current,minutely,hourly,daily")) | ||
@@ -395,3 +395,3 @@ let data = response.data | ||
await this.#uncacheLocation() | ||
options = await this.#formatOptions(options) | ||
options = await this.#parseOptions(options) | ||
let response = await this.#fetch(this.#createURL(options)) | ||
@@ -404,6 +404,6 @@ let data = response.data | ||
timezone_offset: data.timezone_offset, | ||
current: currentFormatter(data), | ||
minutely: minutelyFormatter(data, Number.POSITIVE_INFINITY), | ||
hourly: hourlyFormatter(data, Number.POSITIVE_INFINITY), | ||
daily: dailyFormatter(data, Number.POSITIVE_INFINITY), | ||
current: currentParser(data), | ||
minutely: minutelyParser(data, Number.POSITIVE_INFINITY), | ||
hourly: hourlyParser(data, Number.POSITIVE_INFINITY), | ||
daily: dailyParser(data, Number.POSITIVE_INFINITY), | ||
alerts: data.alerts | ||
@@ -422,3 +422,3 @@ } | ||
dt = Math.round(new Date(dt).getTime() / 1000) | ||
options = await this.#formatOptions(options) | ||
options = await this.#parseOptions(options) | ||
let response = await this.#fetch(this.#createURL(options, false, dt)) | ||
@@ -431,4 +431,4 @@ let data = response.data | ||
timezone_offset: data.timezone_offset, | ||
current: currentFormatter(data), | ||
hourly: hourlyFormatter(data, Number.POSITIVE_INFINITY) | ||
current: currentParser(data), | ||
hourly: hourlyParser(data, Number.POSITIVE_INFINITY) | ||
} | ||
@@ -493,3 +493,3 @@ } | ||
async #formatOptions(options) { | ||
async #parseOptions(options) { | ||
if ( | ||
@@ -496,0 +496,0 @@ !(typeof options === "object") || |
{ | ||
"name": "openweather-api-node", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "Simple Node.js package that makes it easy to work with OpenWeather API", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -1,10 +0,31 @@ | ||
# openweather-api-node ☁️ | ||
![version](https://img.shields.io/npm/v/openweather-api-node?style=flat-square) | ||
![issues](https://img.shields.io/github/issues-raw/loloToster/openweather-api-node?style=flat-square) | ||
![license](https://img.shields.io/badge/license-MIT-blue?style=flat-square) | ||
<br> | ||
<br> | ||
<p align="center"> | ||
<img src="logo/logo.png" alt="logo" width="65%"> | ||
</p> | ||
<br> | ||
<p align="center"> | ||
Simple package that makes it easy to work with OpenWeather API. | ||
</p> | ||
<br> | ||
<p align="center"> | ||
<a href="https://npmjs.org/package/openweather-api-node"> | ||
<img src="https://img.shields.io/npm/v/openweather-api-node?style=flat-square" alt="Version"> | ||
</a> | ||
<a href="https://npmjs.org/package/openweather-api-node"> | ||
<img src="https://img.shields.io/npm/dt/openweather-api-node?style=flat-square" alt="Version"> | ||
</a> | ||
<a href="https://npmjs.org/package/openweather-api-node"> | ||
<img src="https://img.shields.io/github/issues-raw/loloToster/openweather-api-node?style=flat-square" alt="Issues"> | ||
</a> | ||
<a href="https://github.com/loloToster/openweather-api-node/blob/master/LICENSE"> | ||
<img src="https://img.shields.io/badge/license-MIT-blue?style=flat-square" alt="License"> | ||
</a> | ||
![NPM](https://nodei.co/npm/openweather-api-node.png?compact=true) | ||
</p> | ||
Simple Node.js package that makes it easy to work with OpenWeather API. | ||
# About | ||
This package is a wrapper for OpenWeather API. If you want to learn how to use this package check out examples in *examples* folder. The only thing that you need to get started is API key if you don't have one go to [OpenWeatherMap website](https://openweathermap.org/) and get it. For now this package supports only a part of the API but we are planning on adding more features like: air pollution, maps and all the other stuff that is available for free in OpenWeatherMap API. | ||
Currently Supported APIs: | ||
@@ -15,5 +36,8 @@ * Weather (from OneCall) | ||
If you want to learn how to use this package check out examples in *examples* folder. The only thing that you need to get started is API key if you don't have one go to [OpenWeatherMap website](https://openweathermap.org/) and get it. For now this package supports only a part of the API but we are planning on adding more features like: air pollution, maps and all the other stuff that is available for free in OpenWeatherMap API. | ||
# Installation | ||
``` | ||
npm i openweather-api-node | ||
``` | ||
## Simple Example | ||
# Simple Example | ||
```js | ||
@@ -40,3 +64,3 @@ const OpenWeatherAPI = require("openweather-api-node") | ||
## Table of Contents | ||
# Docs | ||
@@ -64,3 +88,3 @@ * [Methods][methods] | ||
* [mergeWeathers][mrgweathers] | ||
* [Unique features of this package][features] | ||
* [Models][models] | ||
* [Options][opt] | ||
@@ -492,3 +516,3 @@ * [Weather Object][wobj] | ||
# Unique features of this package | ||
# Models | ||
@@ -594,5 +618,5 @@ ## Options | ||
``` | ||
**API does not specify every value in every call so some of those values might be `undefined` for example daily weather object wont have weather.temp.cur!** | ||
**⚠️ API does not specify every value in every call so some of those values might be `undefined` for example daily weather object won't have weather.temp.cur!** | ||
[features]: #unique-features-of-this-package | ||
[models]: #models | ||
[opt]: #options | ||
@@ -599,0 +623,0 @@ [wobj]: #weather-object |
@@ -19,3 +19,3 @@ const fs = require("fs") | ||
let location = await weather.getLocation() | ||
assert(location.name === "New York City") | ||
assert(location.name.toLowerCase().includes("new york")) | ||
}) | ||
@@ -22,0 +22,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
65376
19
640