If one calls digitalRead the result (read: side-effect) is that the pin number is mutated. It ended up to always become 16 in my case in the calling closure. I added an argument to the result (function(pin, err, value)) and copied the initial pin number in a let to make sure it will not be changed outside of the method itself. This also allowed me to solve an issue with another library for node-red that depends on this library.
If one calls digitalRead the result (read: side-effect) is that the pin number is mutated. It ended up to always become 16 in my case in the calling closure. I added an argument to the result (function(pin, err, value)) and copied the initial pin number in a let to make sure it will not be changed outside of the method itself. This also allowed me to solve an issue with another library for node-red that depends on this library.