Git Product home page Git Product logo

weyder-package's Introduction

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 :^)

weyder-package's People

Contributors

devorein avatar enfayz avatar neodein avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.