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

hertz-timer

v1.0.1

Published

A basic event trigger and recording library

Downloads

11

Readme

#NODE hertz-timer - A basic event trigger and recording library

Ever need to trigger a event for testing purposes... but not just a twenty times per second? You're looking for something that can behave like in a more random fashion? hertz-timer comprises a number of claases to help.

hertz-timer.generator

The generator is the core of hertz-time. It invokes the supplied callback with the following controls:

  • Minimum hertz (hertz = times per second)
  • Maximum hertz
  • Hertz variation (minus up-to how many per variation phase)
  • Variation change every x ms (if calculated every cycle, you get a very flat average very quickly)
  • Stop time (how long to run for)
  • Stop count (how many cycles to run)
  • Wake cycle (how long to pause when stopped before checking to see if it should run again)

hertz-timer.counter

An associated helper function for recording events happening X times per second (both can be used independently). The only control is to control how many seconds are stored,

##Example

For a full example, please see https://github.com/kw77/hertz-timer-demo


// Define the callback to run 100-200 times per second
var tick = 0; function demo(){
tick++;
if(tick%100 == 0) process.stdout.write('.')

var hertzTimer = require('../index.js');
var hertzCounter = new hertzTimer.counter(10);
var config = {
    hertzCounter: hertzCounter,
    callback: demo,
    stopTime: 10000,
    active: true,
    minHertz: 100,
    maxHertz: 200,
    stopCount: null,
    wakeCycle: 1000,
    variationEvery: 1000,
    hertzVariation: 100
};
var generator = new hertzTimer.generator(config);
generator.on('complete',function(){ console.log('Cycles complete\n' ); }); 
generator.on('started', function(){ console.log('New cycles started'); });
generator.on('stopped', function(){ console.log('Cycles stopped'); });

##License CC-BY-SA