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-throttle

v0.1.7

Published

A Node-RED node to throttle down passed through message amount.

Downloads

628

Readme

node-red-contrib-throttle

GitHub version NPM version Dependencies Status

A Node-RED node to throttle down outgoing messages.


Table of Contents


Install

Run the following command in your Node-RED user directory - typically ~/.node-red:

npm install node-red-contrib-throttle

Usage

A simple node to throttle down passed through message amount. Just insert the throttle node in between two others, and the passed through message amount can be limited by different parameters. Every other messages will be dropped.

By Time

Limits the passed through messages by a given amount of time.
For example: setting the node to 10 seconds means, that only one message in ten seconds will be forwarded.

By Count

Limits the passed through messages by a given count.
For example: setting the node to a count of 5 means, that only every fifth message will be forwarded.

By Block Size

Limits the passed through messages by a given block size. The counter will be reset when a message with msg.reset was received.
For example: setting the node to a block size of 5 means, that only the first five messages will be forwarded.

By Reset

Will only pass through a single message, when a message with msg.reset was received before.

Example Flows

Simple examples showing how to use the throttle and it's output.

Example by Time

example1.png

[{"id":"81be4802.e74478","type":"function","z":"8a25646f.9d541","name":"info msg","func":"msg.payload = \"injected\";\nreturn msg;","outputs":1,"noerr":0,"x":800,"y":60,"wires":[["789ee5ac.32e214"]]},{"id":"789ee5ac.32e214","type":"debug","z":"8a25646f.9d541","name":"output","active":true,"console":"false","complete":"payload","x":950,"y":80,"wires":[]},{"id":"99fbadf5.9b42e8","type":"throttle","z":"8a25646f.9d541","name":"","throttleType":"time","timeLimit":"3","timeLimitType":"seconds","countLimit":"3","blockSize":0,"locked":false,"x":800,"y":100,"wires":[["789ee5ac.32e214"]]},{"id":"681f30ee.8f3598","type":"inject","z":"8a25646f.9d541","name":"inject","topic":"","payload":"!!! PASSED THROUGH !!!","payloadType":"str","repeat":"","crontab":"","once":false,"x":650,"y":80,"wires":[["99fbadf5.9b42e8","81be4802.e74478"]]}]

Example by Count

example2.png

[{"id":"a3d7f710.99f97","type":"debug","z":"8a25646f.9d541","name":"output","active":true,"console":"false","complete":"payload","x":950,"y":200,"wires":[]},{"id":"e2c6599a.0b5c98","type":"function","z":"8a25646f.9d541","name":"info msg","func":"msg.payload = \"injected\";\nreturn msg;","outputs":1,"noerr":0,"x":800,"y":180,"wires":[["a3d7f710.99f97"]]},{"id":"8a2c177f.24e0c8","type":"throttle","z":"8a25646f.9d541","name":"","throttleType":"count","timeLimit":"10","timeLimitType":"seconds","countLimit":"3","blockSize":0,"locked":false,"x":800,"y":220,"wires":[["a3d7f710.99f97"]]},{"id":"836ebd21.ad25","type":"inject","z":"8a25646f.9d541","name":"inject","topic":"","payload":"!!! PASSED THROUGH !!!","payloadType":"str","repeat":"","crontab":"","once":false,"x":650,"y":200,"wires":[["8a2c177f.24e0c8","e2c6599a.0b5c98"]]}]

Example by Block Size

example3.png

[{"id":"32aac7a2.1c4d2","type":"function","z":"8a25646f.9d541","name":"info msg","func":"msg.payload = \"injected\";\nreturn msg;","outputs":1,"noerr":0,"x":800,"y":300,"wires":[["cc05fc6b.4e2598"]]},{"id":"ad1cf860.9c085","type":"throttle","z":"8a25646f.9d541","name":"","throttleType":"block","timeLimit":"10","timeLimitType":"seconds","countLimit":"3","blockSize":"3","locked":false,"x":800,"y":340,"wires":[["cc05fc6b.4e2598"]]},{"id":"8925c66d.9381d8","type":"inject","z":"8a25646f.9d541","name":"inject","topic":"","payload":"!!! PASSED THROUGH !!!","payloadType":"str","repeat":"","crontab":"","once":false,"x":490,"y":320,"wires":[["ad1cf860.9c085","32aac7a2.1c4d2"]]},{"id":"8a84f4e3.491f18","type":"inject","z":"8a25646f.9d541","name":"reset","topic":"","payload":"reset","payloadType":"str","repeat":"","crontab":"","once":false,"x":490,"y":380,"wires":[["c83fa727.0f0b3"]]},{"id":"c83fa727.0f0b3","type":"function","z":"8a25646f.9d541","name":"reset msg","func":"msg.reset = true;\nreturn msg;","outputs":1,"noerr":0,"x":620,"y":380,"wires":[["ad1cf860.9c085","cc05fc6b.4e2598"]]},{"id":"cc05fc6b.4e2598","type":"debug","z":"8a25646f.9d541","name":"output","active":true,"console":"false","complete":"payload","x":970,"y":380,"wires":[]}]

Example by Reset

example4.png

[{"id":"4e11480f.2fad28","type":"function","z":"8a25646f.9d541","name":"info msg","func":"msg.payload = \"injected\";\nreturn msg;","outputs":1,"noerr":0,"x":800,"y":460,"wires":[["c1d324bd.d2feb8"]]},{"id":"50915215.704714","type":"throttle","z":"8a25646f.9d541","name":"","throttleType":"reset","timeLimit":"10","timeLimitType":"seconds","countLimit":"3","blockSize":0,"locked":false,"x":800,"y":500,"wires":[["c1d324bd.d2feb8"]]},{"id":"4ba961e0.c018c8","type":"inject","z":"8a25646f.9d541","name":"inject","topic":"","payload":"!!! PASSED THROUGH !!!","payloadType":"str","repeat":"","crontab":"","once":false,"x":490,"y":480,"wires":[["50915215.704714","4e11480f.2fad28"]]},{"id":"f786e09d.1cdfa","type":"inject","z":"8a25646f.9d541","name":"reset","topic":"","payload":"reset","payloadType":"str","repeat":"","crontab":"","once":false,"x":490,"y":540,"wires":[["bbf770bd.df0768"]]},{"id":"bbf770bd.df0768","type":"function","z":"8a25646f.9d541","name":"reset msg","func":"msg.reset = true;\nreturn msg;","outputs":1,"noerr":0,"x":620,"y":540,"wires":[["50915215.704714","c1d324bd.d2feb8"]]},{"id":"c1d324bd.d2feb8","type":"debug","z":"8a25646f.9d541","name":"output","active":true,"console":"false","complete":"payload","x":970,"y":540,"wires":[]}]

Bugs / Feature request

Please report bugs and feel free to ask for new features directly on GitHub.

License

This project is licensed under Apache 2.0 license.

Donation

You like to support me?
You appreciate my work?
You use it in commercial projects?

Feel free to make a little donation! :wink: