No need to steal this, I would guess that a “limiter” is what is wanted here, and there are plenty of algorithms available. It won’t take away from the dynamics of the audio either, it will merely cap the loudest parts so that one isn’t exceedingly loud while the next is normal.
The readme actually explains the algorithm used: https://github.com/xoxorwr/pw-loudness-eq#the-limiter