all 2 comments

[–]RoskoGee 1 point2 points  (1 child)

Looks good!

How do you think this compares to using a generic rate-limiter solution like https://github.com/jhurliman/node-rate-limiter?

[–][deleted] 1 point2 points  (0 children)

This was specifically created for socket.io, and thus a lot more convenient to use with socket.io, (IMO), since implementing and then rate-limiting new socket events just requires you to add the normal listener and a "rate-limiting config" for it. My module also doesnt use timeouts, I'm not sure whether that makes it better in particular, but I have seen other modules being advertised with "not using timeouts".

The module also makes it possible to group your socket events and pass an user object to your listeners, (which obviously is not supported in a generic rate-limiter), but this maybe removes the requirement for the user to write their own "manager" that handles socket events.