Just to add to this, there's another 'hack' for things like this - since you can add to the built-in classes in Espruino, it is possible to just extend Pin:
The gotcha here is that there's no storage for fields (like the interval's ID) in the Pin itself, so you'd have to store them elsewhere, like maybe in a closure:
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Just to add to this, there's another 'hack' for things like this - since you can add to the built-in classes in Espruino, it is possible to just extend
Pin
:The gotcha here is that there's no storage for fields (like the interval's ID) in the Pin itself, so you'd have to store them elsewhere, like maybe in a closure:
In reality it's maybe not as clean as @MaBe's suggestion, but it's an interesting thing to be aware of :)