1
0
Fork 0

feat(shared): Added nsMerge method to utils

This commit is contained in:
Joost De Cock 2023-05-22 19:51:47 +02:00
parent 08400fd523
commit 6ba43940b0

View file

@ -243,3 +243,14 @@ export const validateTld = (email) => {
if (tlds.indexOf(tld) === -1) return tld
else return true
}
export const nsMerge = (...args) => {
const ns = new Set()
for (const arg of args) {
if (typeof arg === 'string') ns.add(arg)
else if (Array.isArray(arg)) ns.add(nsMerge(...arg))
else console.log('Unexpected namespect type:', { arg })
}
return [...ns]
}