Adding to Custom Module

How do you add to an existing Custom Module?

I am trying to add this code to my existing Custom Module. https://openstagecontrol.discourse.group/t/tap-for-tempo-button/196/2

If I simply copy/paste the new code at the end of the existing code, it breaks the previous instructions. I think it's better (easier) for me to add this new code to the existing code, as I don't know enough yet to create Submodules.

Any help will be greatly appreciated!

Multiple assignations to the module.exports variable won't work, you need to modify the functions defined in this object (oscInFilter, oscOutFilter, etc) so that all the desired instructions are followed. There is no automatic merging procedure but its possible to write a custom module that does it:

var submodules = [
    require('./custom_modA.js'),
    require('./custom_modB.js'),
    // etc
]


module.exports = {
    init: function(){
        for (var m of submodules) {
            if (m.init) m.init()
        }
    },
    unload: function(){
        for (var m of submodules) {
            if (m.unload) m.unload()
        }
    },
    oscInFilter: function(data){

        for (var m of submodules) {
            if (m.oscInFilter) data = m.oscInFilter(data)
            if (!data) return
        }

        return data

    },
    oscOutFilter: function(data){

        for (var m of submodules) {
            if (m.oscOutFilter) data = m.oscOutFilter(data)
            if (!data) return
        }

        return data
    }
}

(I'll add the example to the docs)

Wow! Thank you so much - this works perfectly!