# RBE/filter + Rate Limit

**URL:** <https://discourse.nodered.org/t/rbe-filter-rate-limit/66882>\
**Category:** General\
**Tags:** function-node\
**Created:** [25 August 2022 08:36 UTC](https://discourse.nodered.org/t/rbe-filter-rate-limit/66882 "2022-08-25T08:36:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![GeorgeCastanza](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/georgecastanza/32/40766_2.png) [@GeorgeCastanza](https://discourse.nodered.org/u/GeorgeCastanza)\
**Post date:** [25 August 2022 08:36 UTC](https://discourse.nodered.org/t/rbe-filter-rate-limit/66882/1 "2022-08-25T08:36:42Z")

</div>

I've appreciated this code [here](https://discourse.nodered.org/t/combination-of-rate-limit-and-rbe-node/35034/15) from @Colin.

How would I go about comparing objects, for it seems that objects pass through the RBE + rate limit node without reference to the rate limit.

Here is the code:

```auto
const minInterval = 5000 // min interval between outputs, msec
const previous = context.get("previous") || {timestamp: 0}
const now = new Date().getTime()
if ( msg.payload == previous.value && (now - previous.timestamp) < minInterval )
{
    // same value as last one and too soon to send again, so send nothing
    msg = null
} else {
    previous.timestamp = now
    previous.value = msg.payload
    context.set("previous", previous)
}
return msg;

```

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [25 August 2022 12:49 UTC](https://discourse.nodered.org/t/rbe-filter-rate-limit/66882/2 "2022-08-25T12:49:09Z")

</div>

> [@GeorgeCastanza](#):
>
> `if ( msg.payload == previous.value &&`

Provided the payload is a reasonable simple object then this should work I think

`if ( JSON.stringify(msg.payload) === JSON.stringify(previous.value) && ...`

---

<div class="post-metadata">

**Author:** ![GeorgeCastanza](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/georgecastanza/32/40766_2.png) [@GeorgeCastanza](https://discourse.nodered.org/u/GeorgeCastanza)\
**Post date:** [25 August 2022 13:07 UTC](https://discourse.nodered.org/t/rbe-filter-rate-limit/66882/3 "2022-08-25T13:07:14Z")

</div>

Thanks Colin.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [24 October 2022 13:07 UTC](https://discourse.nodered.org/t/rbe-filter-rate-limit/66882/4 "2022-10-24T13:07:54Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
