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

waterlevels.client

v2.1.1

Published

There are two ways to use this library.

Downloads

29

Readme

Usage

There are two ways to use this library.

1. Node.js

As a node module, you can simply require the package. Passing the process global object allows the program to load AWS_REGION and AWS_BUCKET from your configured environment variables.

Configure your environment variables

export AWS_REGION=eu-west-1
export AWS_BUCKET=tc2-waterlevels.sync

Use require or import to obtain and configure your client object

(require)

var client = require( "waterlevels.client" ).default( process );

await client.listProviders(); // => [ "waterlevel.ie" ];

(ES6)

import clientFactory from "waterlevels.client";
const client = clientFactory( process );

await client.listProviders(); // => [ "waterlevel.ie" ];

2. Browser

In the browser you need to pass the configuration details by hand as shown below

(ES6 e.g. webpack)

import clientFactory from "waterlevels.client";
const config = { env: { AWS_REGION: "eu-west-1", AWS_BUCKET: "tc2-waterlevels.sync" } };
const client = clientFactory( config );

await client.listProviders(); // => [ "waterlevel.ie" ]

API

listProviders

Return a list of data providers for which data has been gathered in the waterlevels.sync store.

Returns Array<string>

Example

await client.listProviders(); // => [ "waterlevel.ie" ]

listDays

Return a list of days for which data is stored for a particular provider. Optionally including a range of dates to query.

Parameters

  • provider string
  • startDay string (optional)
  • endDay string (optional)

Returns Array<string>

Example

await client.listDays( "waterlevel.ie", "2019-01-01", "2019-06-30" );
/*
[
  '2019-02-14',
  '2019-02-19',
  '2019-03-07',
  '2019-06-17',
  '2019-06-18',
  '2019-06-19',
  '2019-06-20',
  '2019-06-22',
  '2019-06-23'
]
*/

getData

Returns all the data from a particular provider on a particular day

Parameters:

  • provider string
  • day string

Returns: Array<object>

Example

await client.getData( "waterlevel.ie", "2019-02-19" )
/*
[
  {
    id: '/0000036091/0001/2340',
    name: 'Ballinacur',
    date: '2019-02-19T18:45:00.000Z',
    coordinates: [ -7.693641, 54.056571 ],
    value: 1.374,
    extractionId: 'waterlevel.ie-1561299150483'
  },
  {
    id: '/0000036091/OD/2341',
    name: 'Ballinacur',
    date: '2019-02-19T18:45:00.000Z',
    coordinates: [ -7.693641, 54.056571 ],
    value: 53.041,
    extractionId: 'waterlevel.ie-1561299150483'
  },
  {
    id: '/0000036091/0003/2343',
    name: 'Ballinacur',
    date: '2019-02-19T18:30:00.000Z',
    coordinates: [ -7.693641, 54.056571 ],
    value: 11.03,
    extractionId: 'waterlevel.ie-1561299150483'
  },
  {
    id: '/0000036091/0002/2342',
    name: 'Ballinacur',
    date: '2019-02-19T18:30:00.000Z',
    coordinates: [ -7.693641, 54.056571 ],
    value: 8.497,
    extractionId: 'waterlevel.ie-1561299150483'
  }
]
*/

getExtraction

Gets the raw extraction data used to create a given data item

Parameters:

  • extractionId string

Returns: string

Example

const data = await client.getData( "waterlevel.ie", "2019-02-19" );

// get extractionId from first data item
const extractionId = data[ 0 ].extractionId;

// get raw extract
const extract = await client.getExtract( extractionId );
/*
"{"crs":4326,"type":"FeatureCollection","features":[{"geometry":{"type":"Point","coordinates":[-8.238554,53.361687]},"type":"Feature","id":990,"properties":{"url":"/0000026007/0002/","csv_file":"/data/month/26007_0002.csv","station.name":"Bellagill","value":16.16,"datetime":"2019-06-23 14:00:00+00:00","sensor.ref":"0002","station.ref":"0000026007","station.region_id":2,"err_code":99}},{"geometry":{"type":"Point","coordinates":[-8.238554,53.361687]},"type":"Feature","id":841,"properties":{"url":"/ . . .
*/