Here’s how I see it:
it’s kinda like TZData. A leap second is added every few years, and it is known in adwance when it will be added. So, right now there’s a 37 second difference between UTC and TAI. So, my hypothetical JS module would have a constant 37 to know that if two dates that I make calculations for are in 2020 I would move by 37.
If dates are in 2017, I would use 36.
So, in general it would be a lookup table inside the module, and the module would make appropriate calculations based on that table.
If a new leap second is announced (they pre-announce it 6 months before) I would expand the table and release an update.