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

weyder

v2.1.4

Published

A simple weather package that takes advantage of the darksky and mapbox api

Downloads

4

Readme

Weyder

1. Installation

npm install weyder

2. Using weyder

const weyder = require('weyder') // OR
const {geoCode,foreCast,setAccessToken,setWeatherDataSpan} = require('weyder');

Exported values overview

  • geoCode (location) => [ latitude,longitude ]
  • foreCast ([ latitude,longitude ]) => weather Information
  • setAccessToken ("mapbox" || "darksky", mapbox_token || darksky_token)
  • setWeatherDataSpan ({"currently" || "minutely" || "daily": boolean})

setAccessToken

This function is used to set the access token of mapbox and darksky endpoints

Create a free darksky and mapbox account, copy your own access token and pass the api name and access token to setAccessToken

setAccessToken("darksky","your_DarkSky_AccessToken")
setAccessToken("mapbox","your_MapBox_AccessToken")

setWeatherDataSpan

Use this function and set appropriate time span to get the more information from the api.

Object properties currently, minutely, hourly, daily, value <boolean>

setWeatherDataSpan({
    'currently': true,
    'minutely': false,
    'daily': true
})

The above sets

  • currently = true,
  • minutely = false,
  • hourly = false,
  • daily = true

3. Necessary Resources

NOTE: To undestand what currently, hourly, daily holds, visit https://darksky.net/dev/docs#data-point

Here's a snapshot of currently

currently_data

Here's a snapshot of hourly

hourly_data

Here's a snapshot of daily

daily_data

4. Basic Usage

Using the api (async/await style)

const getWeatherData = async (location) =>{
    const geocode = await geoCode(location)
    const forecast = await foreCast(geocode)
    console.log(forecast)
}
getWeatherData("Austin")
// Output
// {
//     currently: [...],
//     hourly: [...]
//     daily: [...],
// }

Using the api (promises style)

geoCode('Austin')
.then(geocode => foreCast(geocode))
.then(forecast => {
    console.log(forecast);
})
.catch(e=>{
    console.log(e);
})

// Output
// {
//     currently: [...],
//     hourly: [...]
//     daily: [...],
// }

Using the api (callbacks style)

geoCode("Austin",(err,geocode)=>{
    if(err) return err
    foreCast(geocode,(err,forecast)=>{
        if(err) return err
        console.log(forecast)
    })
})

// Output
// {
//     currently: [...],
//     hourly: [...]
//     daily: [...],
// }

5. Total Usage

const {geoCode,foreCast,setAccessToken,setWeatherDataSpan} = require('weyder');

setAccessToken("darksky","your_DarkSky_AccessToken")
setAccessToken("mapbox","your_MapBox_AccessToken")

setWeatherDataSpan({
    'currently': true,
    'minutely': false,
    'daily': true
})

geoCode('Austin')
.then(geocode => foreCast(geocode))
.then(forecast => {
    console.log(forecast);
})
.catch(e=>{
    console.log(e);
})

// Output
// {
//     currently: [...],
//     hourly: [...]
//     daily: [...],
// }

TODO:

  1. Still thinking :^)