From fdbf0a561ed43d4699169fa347799951b600b20c Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Wed, 15 Dec 2021 17:06:07 +0100 Subject: [PATCH] docs:add custom module merger example --- resources/docs/docs/custom-module/examples.md | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/resources/docs/docs/custom-module/examples.md b/resources/docs/docs/custom-module/examples.md index 884b491c..5fa3eb3e 100644 --- a/resources/docs/docs/custom-module/examples.md +++ b/resources/docs/docs/custom-module/examples.md @@ -362,3 +362,45 @@ module.exports = { } ``` + +## Custom module merger +```js +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 + } +} +```