Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
forecast-query
Advanced tools
Readme
Queryable typescript API for weather information from openweathermap
This project allows one to create a query in order to find out about a weather in certain location. Queries are promise-based and will only execute when the query is complete. This package provider information on everything from pressure, to rain, to weather/weather icons and descriptions in chosen language. Package will select which api it should call based on the parameters of query.
const weather = forecast(key).around(50.08804, 14.42076);
await writeWeatherWithDate(weather);
weather.yesterday();
await writeWeatherWithDate(weather);
weather.hour(3);
await writeWeatherWithDate(weather);
weather.hour(17);
await writeWeatherWithDate(weather);
weather.today();
await writeWeatherWithDate(weather);
weather.hour(19);
await writeWeatherWithDate(weather);
weather.tomorrow();
await writeWeatherWithDate(weather);
weather.hour(12);
await writeWeatherWithDate(weather);
weather.dayAfterTomorrow();
await writeWeatherWithDate(weather);
This example only uses two requests, the rest of information is obtained from stored values from api.
const load = forecast(apiKey, true).in(524901).at(new Date(fakeDate), tenDaysAhead).fetch(global.fetch); // gets data from .at(date) by us zipcode
expect(await load.wind('speed')).toBe(4.1);
expect(await load.wind('degree')).toBe(249);
// sunny(), cloudy(), is(), ashy() and other methods can be used to get description of weather at set time
expect((await load.sunny())?.description).toBe('sky is clear');
With subscribers used, there is a greater attention to speedy delivery, which might mean some requests will not be cached. If you need cached requests with an array of weather results, please see the example below this one.
forecast(key).around(50.08804, 14.42076)
.subscribe(async (from, _, cast) => {
weatherList.push({
date: from,
clouds: await cast.clouds() || 0,
rain: await cast.rain() || 0,
weather: (await cast.is())?.description || '',
});
})
.yesterday()
.hour(3)
.hour(17)
.today()
.hour(19)
.tomorrow()
.hour(12)
.dayAfterTomorrow()
.clearSubscribers();
console.log(weatherList.sort((a, b) => a.date.getTime() - b.date.getTime()));
Stop emptying cache after failed fetch. Add .list function to allow users to iterate over wide variety of results. .list allows you to specify a certain condition and get results across a wide range of dates with just one or two lines. All of the functions of usual weather api will return an array of results with dates appended to them.
const list = forecast(key)
.around(50.08804, 14.42076)
.at(today, fourDaysLater)
.list('hour');
console.log(await list.clouds());
console.log(await list.percipitation('rain'));
console.log(await list.cloudy()); // This will fetch the description of the clouds outside from today to 4 days later date, with every-hour updates.
Can now use .geo() to access user location on devices supporting navigator.geolocation.getCurrentPosition.
In case of server-side use, you can define your own getCurrentPosition callback.
Fix a bug where time machine is called with invalid date
If you find any bugs, or have ideas about improving this package, please file in a task or a pull request :) .
FAQs
Queryable typescript API for weather information from openweathermap, no dependencies
The npm package forecast-query receives a total of 8 weekly downloads. As such, forecast-query popularity was classified as not popular.
We found that forecast-query 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.