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

noaa-stormevents

v0.1.7

Published

Parses the https://www.ncei.noaa.gov/pub/data/swdi/stormevents/csvfiles/ list of events and caches the results in a .cache directory. Provides an interator that you can use for getting the JSON. Errors are caught and ignored (typically CSV errors that pre

Downloads

15

Readme

NOAA Storm Events

Parses the https://www.ncei.noaa.gov/pub/data/swdi/stormevents/csvfiles/ list of events and caches the results in a .cache directory. Provides an interator that you can use for getting the JSON. Errors are caught and ignored (typically CSV errors that prevent JSON parsing).

Example:

import NOAAStormEvents from 'noaa-stormevents';

async function NOAA() {
	for await (const result of NOAAStormEvents()) {
		console.log(result);
	}
}

NOAA();

Note:
Commonjs exports are named. e.g.:

const { NOAAStormEvents } = require('noaa-stormevents');

Options

NOAAStormEvents takes one object parameter with the following properties:

  • type
    Type can be one of 'details', 'locations', or 'fatalities'. Supply null to loop over everything.

  • suppressLogs
    If you supply true, stdout logging will be suppressed.

  • onlyNew
    Uses the cache as a reference and ignores anything already downloaded or in the history info report

  • cacher
    Pass an object as this property and every function inside Info can be replaced. Useful if you want the history to be saved in a database instead of a filesystem.

getCacheFiles.setCachePath will allow you to change the cache path from .cache to any dir of your choosing. Must be set before running any of the other functions, otherwise .cache will be used/created.

Exports

In addition to the default export, you also have access to the following:

  • DownloadFiles
  • ExtractCacheFiles
  • getCacheFiles
  • PullLinks
  • WriteJSON
  • Info

Useage would follow this pattern:

const links = await PullLinks();
await DownloadFiles(links, suppressLogs);

await ExtractCacheFiles();

const files = await WriteJSON(type, suppressLogs);

getCacheFiles will only return the StormEvents_ files regardless of other files present in the .cache directory.

Repeated running of the function will not overwrite old files and will update with any changes made to https://www.ncei.noaa.gov/pub/data/swdi/stormevents/csvfiles/ while providing the same results.

If your filesystem is ephemeral, you can pass Info.replace(x) where x will be an object whose keys will replace the functions. You can replace all or some of the functions within to modify the storing and retrieval of the json cache. The filesystem must be used for the csv/json conversion.