npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@andrearizzello/weather_lib

v6.1.1

Published

A simple weather library

Downloads

16

Readme

Weather library for the Vente-Privee project

Minimal library for weather forecasts

Installation:

This is a Node.js module and can be found on the NPM registry.

Installation is done using the npm install command:

$ npm i @andrearizzello/weather_lib

Features:

  • Easy to use library
  • Get weather forecast information based on:
    1. City ID (check HERE for the list)
    2. City Name
    3. Coordinates
  • Possibility to get more specific/advanced information
  • Possibility of obtaining up to 5 days of forecasts

Quick Start:

const Weather = require('@andrearizzello/weather_lib');

let weathObj = new Weather('YOUR_API_KEY');

weathObj.getCurrentWeatherByName('Paris', 'FR', false, 1)
	.then(result => console.log("CURR BY NAME\n", result), reason => console.log(reason));

Expected output (test case)

Output

In-depth documentation:

At the moment the library has 2 main functions:

  • One to get the current weather
  • One to get the forecast for the next 5 days

These functions are used as follows:

// ############################ CURRENT WEATHER ###################################

weathObj.getCurrentWeatherByID(2968815, true, 0)
    .then(result => console.log("CURR BY ID\n", result), reason => console.log(reason));

weathObj.getCurrentWeatherByName("Paris", "FR", true, 0)
    .then(result => console.log("CURR BY NAME\n", result), reason => console.log(reason));

weathObj.getCurrentWeatherByCoords(48.8566, 2.3515, true, 0)
    .then(result => console.log("CURR BY COORDS\n", result), reason => console.log(reason));

// ############################ FORECAST WEATHER #################################

weathObj.getForecastByID(2968815, new Date('02/03/2019 9:00'), true, 0)
    .then(result => console.log("FORECAST BY ID\n", result), reason => console.log(reason));

weathObj.getForecastByName("Paris", 'FR', new Date('02/03/2019 9:00'), true, 0)
    .then(result => console.log("FORECAST BY NAME\n", result), reason => console.log(reason));

weathObj.getForecastByCoords(48.8566, 2.3515, new Date("02/03/2019 9:00"), true, 0)
    .then(result => console.log("FORECAST BY COORDS\n", result), reason => console.log(reason));
  • getCurrentWeatherByID accepts at least 1 argument, the ID of the city you want to get the weather, the other 2 arguments are used if you want to get additional data.

  • getCurrentWeatherByName accepts at least 2 arguments, the name of the city and the country, the other 2 arguments are again used if you want to get additional data.

  • getCurrentWeatherByCoords accepts at least 2 arguments, latitude and longitude respectively, the other 2 arguments are used to get additional data.

  • getForecastByID accepts at least 2 arguments, the ID of the city, the date and time (the latter if necessary) at which you wish to obtain the forecasts, the last two arguments, as before, are used to get additional data.

  • getForecastByName accepts at least 3 arguments, the name of the city, the country, the date and time (the latter if necessary) at which you wish to obtain the forecast, the last two arguments, are used to get additional data.

  • getForecastByCoords accepts at least 3 arguments, latitude and longitude respectively and also date and time (the latter if necessary) at which you wish to obtain the forecast, the last two arguments, as before, are used to get additional data.

A better explainded documentation of each function can be also found inside the code files.

Tests:

Tests are included in the library, you can find them in the tests folder, if you want to run them just use:

npm test

Keep in mind that you need to set the env variable process.env.APIKEY with your key if you want to run the tests

Here is an example: