Socket
Socket
Sign inDemoInstall

openweather-api-node

Package Overview
Dependencies
2
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.4.0 to 1.4.1

2

package.json
{
"name": "openweather-api-node",
"version": "1.4.0",
"version": "1.4.1",
"description": "Simple Node.js package that makes it easy to work with OpenWeather API",

@@ -5,0 +5,0 @@ "main": "src/index.js",

@@ -336,3 +336,3 @@ /**

async #evaluateLocationByName(name, key) {
let response = await this.#fetch(`${API_ENDPOINT}${GEO_PATH}direct?q=${name}&limit=1&appid=${key}`)
let response = await this.#fetch(`${API_ENDPOINT}${GEO_PATH}direct?q=${encodeURIComponent(name)}&limit=1&appid=${encodeURIComponent(key)}`)
let data = response.data

@@ -363,3 +363,3 @@ if (data.length == 0) throw new Error("Unknown location name: " + name)

if (typeof lat === "number" && typeof lon === "number" && -90 <= lat && lat <= 90 && -180 <= lon && lon <= 180) {
return { lat: lat, lon: lon }
return { lat, lon }
} else {

@@ -384,3 +384,3 @@ throw new Error("Wrong coordinates")

async #evaluateLocationByZipCode(zipCode, key) {
let response = await this.#fetch(`${API_ENDPOINT}${GEO_PATH}zip?zip=${zipCode}&appid=${key}`)
let response = await this.#fetch(`${API_ENDPOINT}${GEO_PATH}zip?zip=${encodeURIComponent(zipCode)}&appid=${encodeURIComponent(key)}`)
let data = response.data

@@ -402,3 +402,3 @@ return {

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}`)
let response = await this.#fetch(`${API_ENDPOINT}${GEO_PATH}reverse?lat=${options.coordinates.lat}&lon=${options.coordinates.lon}&limit=1&appid=${encodeURIComponent(options.key)}`)
let data = response.data

@@ -418,3 +418,3 @@ return data.length ? data[0] : null

options = await this.#parseOptions(options)
let response = await this.#fetch(`${API_ENDPOINT}${GEO_PATH}direct?q=${query}&limit=5&appid=${options.key}`)
let response = await this.#fetch(`${API_ENDPOINT}${GEO_PATH}direct?q=${encodeURIComponent(query)}&limit=5&appid=${encodeURIComponent(options.key)}`)
let data = response.data

@@ -704,3 +704,3 @@ return data

async #uncacheLocation(key) { // necessary for some setters to be synchronous
if (this.#globalOptions.coordinates.lat && this.#globalOptions.coordinates.lon) return // ! what if lat or lon = 0 ?
if (typeof this.#globalOptions.coordinates.lat == "number" && typeof this.#globalOptions.coordinates.lon == "number") return

@@ -707,0 +707,0 @@ key = this.#globalOptions.key ?? key

@@ -23,4 +23,4 @@ const fs = require("fs")

it("gets all locations", async () => {
let locations = await weather.getAllLocations("London")
assert(locations.length == 5)
let locations = await weather.getAllLocations("Lousã")
assert(locations.length > 0)
})

@@ -27,0 +27,0 @@

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc