From fd68ad9bde1956abfc0dd0aaa067586864e1dad6 Mon Sep 17 00:00:00 2001 From: "Lu[ke] Wilson" Date: Sun, 26 Jan 2025 16:08:54 +0000 Subject: [PATCH] add docs and allow arrays of aliases --- packages/superdough/superdough.mjs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/superdough/superdough.mjs b/packages/superdough/superdough.mjs index 8bf7804b..4cb2553a 100644 --- a/packages/superdough/superdough.mjs +++ b/packages/superdough/superdough.mjs @@ -24,13 +24,25 @@ export function aliasBankMap(aliasMap) { const soundDictionary = soundMap.get(); for (const key in soundDictionary) { const [bank, suffix] = key.split('_'); - if (aliasMap[bank]) { - soundDictionary[`${aliasMap[bank]}_${suffix}`] = soundDictionary[key]; + const aliasValue = aliasMap[bank]; + if (aliasValue) { + if (typeof aliasValue === 'string') { + soundDictionary[`${aliasValue}_${suffix}`] = soundDictionary[key]; + } else if (Array.isArray(aliasValue)) { + for (const alias of aliasValue) { + soundDictionary[`${alias}_${suffix}`] = soundDictionary[key]; + } + } } } soundMap.set({ ...soundDictionary }); } +/** + * Register an alias for a bank of sounds. Optionally accepts a map of banks to aliases. + * @param {string} bank - The bank to alias + * @param {string} alias - The alias to use for the bank + */ export function aliasBank(...args) { switch (args.length) { case 1: