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

base-reporter

v0.2.0

Published

Base application smart plugin for caching data and adding and running custom report functions.

Downloads

2

Readme

base-reporter NPM version NPM downloads Build Status

Base application smart plugin for caching data and adding and running custom report functions.

Install

Install with npm:

$ npm install base-reporter --save

Usage

var reporter = require('base-reporter');

API

reporter

Exposes smart plugin for adding a reporter instance to a base application.

Params

  • config {Object}: Configuration object.
  • returns {Function}: Plugin function to use with app.use

Example

app.use(reporter());

.reporter.middleware

Creates a middleware function that can be used with application middleware methods.

Params

  • fn {String|Function}: Pass a property string or function that will create a middleware function. Defaults to files.
  • returns {Function}: Function that can be used as a middleware function.

Example

// Default middleware will cache all files on the `reporter.files` array (can be accessed in report functions):
app.preWrite(/./, app.reporter.middleware());

// Pass a custom property string to cache files on another property:
app.preWrite(/./, app.reporter.middleware('templates'));

// Pass a custom function that creates the middleware function. The function will take the reporter instance:
app.preWrite(/./, app.reporter.middleware(function(reporter) {
  var counter = 0;
  return function(file, next) {
    reporter.union('files', file);
    reporter.set('counter', ++counter);
    next():
  };
}));

.reporter.add

Add a report function to the reporter with the given name. Function may take the reporter instance and options as parameters.

Params

  • name {String}: Name of the reporter
  • fn {Function}: report function to run when .reporter.report(name) is called.
  • returns {Object} this: to enable chaining

Example

app.reporter.add('basic', function(reporter, options) {
  console.log(this.files);
});

.reporter.report

Run a registered report function with the given options.

Params

  • name {String}: Name of the report to run.
  • returns {Object} this: to enable chaining

Example

app.reporter.report('basic', {foo: 'bar'});
//=> file1.js,file2.js,file3.js

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Building docs

Generate readme and API documentation with verb:

$ npm install verb && npm run docs

Or, if verb is installed globally:

$ verb

Running tests

Install dev dependencies:

$ npm install -d && npm test

Author

Brian Woodward

License

Copyright © 2016, Brian Woodward. Released under the MIT license.


This file was generated by verb, v0.9.0, on June 16, 2016.