![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
darkskyjs-lite
Advanced tools
A promise-based wrapper for requesting weather data from DarkSky.net
A javascript api for darksky.net
This is a smaller version of DarkSkyJS that only deals with current (the currently
endpoint) weather conditions, rather than the hourly
and daily
ones.
The purpose of this version is to reduce the file size of the library and remove the dependencies, specifically:
This package is designed to provide:
It differs from the original library in three ways:
14/10/2019 In v0.1.0 there's improved error checking for the PROXY_SCRIPT URL - Invalid URLs now return warning. The response JSON is also checked for validity.
The following data points have been added since 29/07/2017:
The following data points were added when first published on NPM
If you haven't already, create a developer account here https://darksky.net/dev/.
It is recommended you install via NPM where dependencies will be loaded automatically.
npm install darkskyjs
darkskyjs is configured to work with both AMD and CJS applications.
If you're using Webpack, Browserify or some other CJS module loader simply require the module like so
var Darksky = require('darkskyjs');
or using ES6 import, like so
import Darksky from 'darkskyjs'
and use the Darksky
constructor like so:
var darkSky = new DarkSky()
You can then use the method listed below to retrieve location specific weather data.
getCurrentConditions
If you're using Require.JS you will need to download momentjs and es6-promise.
A server side proxy is required for this to work. So create a file that will contain your key and be careful not to commit it to a public code base.
Here's an example PHP one. Replace the value of $api_key with your valid key.
<?php
// File Name: proxy.php
$api_key = 'b962d5ee80be5293a234b69fb975629c';
$API_ENDPOINT = 'https://api.darksky.net/forecast/';
$url = $API_ENDPOINT . $api_key . '/';
if(!isset($_GET['url'])) die();
$url = $url . $_GET['url'];
$url = file_get_contents($url);
print_r($url);
darkskyjs can handle multiple location requests. Simply pass in an array of requests (to one of the three methods listed above) to get data for multiple locations.
Each request must comprise of two key/value pairs: latitude
and longitude
. Optionally you can pass in a place name as a reference which will be returned should the request be successful e.g.
[{latitude: 51.507351, longitude: -0.127758, name: 'London'}]
If you don't pass an array it will create one for you, but it's best to do so for consistency and to avoid confusion as an array is what you'll get back.
This API returns a set of functions that allow you to access the raw data, rather then the raw data itself. Each function is named in exactly the same way as its respective data point e.g. ozone()
will return the value for ozone
.
getCurrentConditions
returns an array of condition arrays. Each array represents one of locations you requested data for.
In order to match the locations that were supplied with what's returned it is recommended that the name
property be used. A callback is then used to supply the returned data. For example:
darkSky.getCurrentConditions(
[
// location object(s)
{
latitude: 51.507351,
longitude: -0.127758,
name: 'London'
}
],
// callback
function(conditions) {
for (var i = 0, length = conditions.length; i < length; i++) {
if (conditions[i].name === 'London') {
console.log(conditions[i].cloudCover());
}
}
}
);
This package has no dependencies
Add a method for retrieving alerts
FAQs
A promise-based wrapper for requesting weather data from DarkSky.net
The npm package darkskyjs-lite receives a total of 9 weekly downloads. As such, darkskyjs-lite popularity was classified as not popular.
We found that darkskyjs-lite demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.