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

statto-backend

v0.3.0

Published

An abstract statto-backend which provides common tests.

Downloads

5

Readme

statto-backend

An abstract statto-backend which provides common tests.

Synopsis

Imagine that you'd like to implement a backend using a database called 'FreshDB'.

var util = require('util')
var stattoBackend = require('statto-backend')

function StattoBackendFreshDB() {
    // ... implementation details ...
}

util.inherits(StattoBackendFreshDB, stattoBackend.StattoBackendAbstract)

Who is this package for?

This package should be used by developers writing a new backend for statto. For implementation examples, please see the following packages:

All of these packages also pass the test suite contained in this package. Again see these other projects for further details.

Implementing a Backend

Many functions within a backend are implemented (naively) by the stattoBackend.StattoBackendAbstract class. This means two things:

  1. You only have to implement a few functions to get a fully working backend
  2. You can rely on the abstract class to implement the rest of the interface properly

However:

  1. You may want to implement more methods so that you can make efficiency gains that the database affords you

Methods

To get a fully working interface using the stattoBackend.StattoBackendAbstract class, you just need to implement:

  • .addRaw(raw, callback) - should store the raw stats into the datastore
    • raw - the raw stats emitted by the statto server
    • callback - the callback to which any error is passed, no other data
  • .getRaws(date, callback) - should retrieve all raw stats stored for this timestamp
    • date - a date or ts for which records should be retrieved (where ts ~~ 2015-04-04T00:53:15.000Z)
    • callback - a fn(err, rawArray) which is called back with an array of stats for this timestamp
  • .setStats(stats, callback) - should store the processed stats into the datastore
    • stats - the processed stats created from all the raw stats for the same timestamp
    • callback - the callback to which any error is passed, no other data
  • .getStats(date, callback) - should retrieve the processed stats stored for this timestamp
    • date - a date or ts for which records should be retrieved (where ts ~~ 2015-04-04T00:53:15.000Z)
    • callback - a fn(err, stats) which is called back with the stats for this timestamp

Methods implemented by stattoBackend.StattoBackendAbstract:

  • .getStats(date, callback) - should retrieve the merged stats for this timestamp
    • date - a date or ts for which the stats record should be retrieved (where ts ~~ 2015-04-04T00:53:15.000Z)
    • callback - a fn(err, stats) which is called back with the stats for this timestamp

Author

Written by Andrew Chilton - Twitter.

Written for Tynio.

License

The MIT License (MIT). Copyright 2015 Tynio Ltd.

(Ends)