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

node-red-contrib-timed-counter

v0.1.0

Published

A Node-RED node that counts messages received in a specified limit

Downloads

664

Readme

node-red-contrib-timed-counter

A node that counts messages received in a specified time limit.

This node counts incoming messages while they are received in a configured time limit. When the first message comes in, a countdown timer is started. When subsequent messages arrive within the time limit the counter is incremented, so the first message gets msg.count == 1, the next msg.count == 2, and so on. When the time limit is reached, the counter is reset.

It can be configured in a couple of different ways. Firstly, it can be programmed with a fixed timeout, so it only counts within a time limit from the first message received (in a chain). Alternatively, a non-fixed timeout will result in each subsequent message resetting the time limit but not the counter; so if messages continue to be received by a certain frequency, the timer will be restarted but the count kept. This allows messages to be counted without limit, as long as they keep coming in fast enough.

It can also be configured to allow the messages to come through (with their counts added) as they are received, or whether to withhold them and just send the last one. This is to allow for a single message to represent all of the messages in a chain. For example, if detecting a double- or triple-click of a button to determine an alternative function, the first click might not be desired if immediately followed by a second click.

So, for a typical mouse single-, double- and triple-click detector, set the time limit to 350 milliseconds or so, untick "Fixed timeout", and tick "Final message only". The message that is eventually received will have a msg.count value equal to 1, 2, 3, or more. A switch node or a function node may be used to decide how to process them.

If a message with msg.reset set, then the timer and count will be reset. If "Final message only" is set, this reset message will be lost; if it isn't set then the reset message will flow through.

It can also be configured to apply a single timer and count for all received messages, or have a separate one for each topic. This could be accomplished using a flow, but the "Count per-topic" option makes this simpler.