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

jw-weather

v2.1.2

Published

Reader for various weather APIs

Downloads

26

Readme

jw-weather

Module for reading weather data from various public APIs.

Currently supports:

  • DarkSky (at least until Apple shuts it down...)
  • AccuWeather
  • OpenWeatherMap
  • ~~Weather UnderGround~~ (API depriciated)

The goal is to create a weather module that returns a standardized weather object regardless of the API used. This serves a few purposes:

  1. Being able to seamlessly transition to another service in case the API is depreciated. Which is why this project was started, and is already happening again with the DarkSky API.
  2. Being able to switch to another service if costs or needs change.
  3. Being able to use more then one service simultaneously to increase the frequency that you are able to query the APIs since the providers limit allowed queries for a given license.

Because reason #1 is the main purpose of this module certain features that are nice to have but differ between services have been omitted. For example AccuWeather allows you to specify a zipcode for your location but DarkSky doesn't, so even though using the zipcode might be preferable vs. the latitude/longitude, that capability has been removed because it would make the usage incompatible between services.

Sample use in Node.js:

var jw-weather = require('jw-weather');

var boston = new jw-weather.service({
    provider: 'darksky',
    key: '0123456789abcdef9876543210fedcba', //this is a fake key
    latitude: 42.3601,
    longitude: -71.0589
});

boston.update(function(err) {
    if (err) {
        console.log('ERROR: ' + err);
    } else {
        console.log('Temp: ' + boston.temp);
    }     
});

The weather object currently includes:

  • lastUpdate (When the update was run locally)
  • forecastTime (The actual forecast time from the the provider)
  • temp
  • feelsLike
  • humidity
  • currentCondition
  • An icon name/number
  • sunrise
  • sunset
  • A 5-day forecast (Accuweather does not forecast humidity)

Startup options:

  • provider: string, 'darksky' || 'accuweather' || 'openweathermap'
  • key: string, provided by weather service
  • latitude: number
  • longitude: number
  • celsius: boolean (default=false, i.e. fahrenheit)

List of Functions:

  • update(callback(err))

    Updates the weather object with the latest forecast. Returns an error message or null when the update is complete.

  • fullWeather()

    Returns an object representing the full standardized weather data

List of Properties:

  • raw: The raw API response from the provider
  • lastUpdate: The last time the weather object was updated
  • forecastTime: The time of the forecast
  • temp: The current temperature
  • humidity: The current humidity
  • currentCondition: A text description of the current condition
  • icon: An icon number
  • feelsLike: The "Real Feel" temperature
  • sunrise: Sunrise time
  • sunset: Sunset time
  • forecast: A 5-day forecast

Review demo.js for example use.