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

warni

v0.0.2

Published

A helper to count alerts and send warnings or alerts not on every event.

Downloads

51

Readme

warni

Build Status Windows Tests Dependency Status NPM version

A helper to count alerts and send warnings or alerts not on every event.

NPM

Install

  npm install warni

Initialize

	var warnings = new Warni( { warn: 2, alert: 5, resend: 10 } );
	
	// listen to warnings
	warnings.on( "warning", function( data, count ){
		// generate your warning by sending it via Mail, Slack, HTTP or just log it to the console.
		console.warning( "WARNING! Got `" + count + "` issues of `" + data.title + "`\n" + data.details  )
	});
	
	// listen to alerts
	warnings.on( "alert", function( data, count ){
		// generate your warning by sending it via Mail, Slack, HTTP or just log it to the console.
		console.error( "ERROR! Got `" + count + "` issues of `" + data.title + "`\n" + data.details  )
	});
	
	// listen to the event until the ok was called.
	warnings.on( "ok", function( data, count ){
		// generate your warning by sending it via Mail, Slack, HTTP or just log it to the console.
		console.error( "OK! Back to normal operation after `" + count + "` issues of `" + data.title + "`\n" + data.details  )
	});
	
	// generate some issues
	for (idx = i = 0; i <= 110; idx = ++i) {
		warnings.issue( { title: "Huuuaaahhh 👻 an Error ...", details: "Just Testing ;-) with index " + idx } )
	}
	// by the configuration above th following events will be fired at index:
	// - idx=2: a warning event 
	// - idx=5: the first alert
	// - idx=50: the second alert (a resend)
	// - idx=100: the third alert (a resend)
	
	
	// if everthing is operating normal you should call
	warnings.ok( { title: "OK 👍🏼", details: "Relax ... 🍹" } )
	

Config-Options

  • warn : ( Number optional: default = 2 ) Number of .issue() calls needed to send a warning event. A warning event will only fired once between an ok() and an alert event.
  • alert : ( Number optional: default = 5 ) Alert of .issue() calls to send a alert event
  • alert : ( Number optional: default = 10 ) Resend a new alert event after x alert events. So only do the next alert event after alert * resend calls of .issue()

Methods

.issue( [data] )

Report a problem.

Arguments

  • data : ( Any optional ) Additional data to describe the issue within your event handlers

Return

( Warni ): The instance itself for chaining

.ok( [data] )

Tell Warni everything is ok and reset the issue counter if needed.

Arguments

  • data : ( Any optional ) Additional data to describe the issue within your event handlers

Return

( Warni ): The instance itself for chaining

Events

warning

An early warning, that something is fishy ;-). This is triggered once after .issue() iwas called config.warn times.

Arguments

  • data : ( Any ) The latest issue data you passed to .issue(data)
  • count : ( Number ) The count of issues called until now.

alert

Generate an alert. This is triggered if .issue() was called for config.alert or config.alert * config.resend times.

Arguments

  • data : ( Any ) The latest issue data you passed to .issue(data)
  • count : ( Number ) The count of issues called until now.

ok

Reported issues is gone. Triggered when .ok(data) was called after a warning event was triggered.

Arguments

  • data : ( Any ) The latest issue data you passed to .issue(data)
  • count : ( Number ) The count of issues before the .ok() was called.

Todos/Ideas

  • define a time in seconds until the next alert resend is allowed. With an increase of the time with every alert.

Testing

The tests are based on the mocha.js framework with should.js as assertaion lib. To start the test just call

	npm test

or

	grunt test

If you want to be more precice use the mocha cli

	mocha -R nyan -t 1337 test/main.js

Docker-Tests

If you want to test your module against multiple node versions you can use the docker tests.

Preparation

	# make sure you installed all dependencies
	npm install
	# build the files
	grunt build

Run

To run the tests through the defined versions run the following command:

	dockertests/run.sh

Release History

|Version|Date|Description| |:--:|:--:|:--| |0.0.2|2016-6-24|Added docs and return itself on ok and issue| |0.0.1|2016-6-23|Initial version|

NPM

Initially Generated with generator-mpnodemodule

The MIT License (MIT)

Copyright © 2016 M. Peter, http://www.tcs.de

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.