]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - shared/core-utils/common/array.ts
Fix server lint
[github/Chocobozzz/PeerTube.git] / shared / core-utils / common / array.ts
index 9e326a5aa7590e4ab0dea051f240e2c4272a57c1..e1b422165c00b0c884fe42f83a51c249b76be7fe 100644 (file)
@@ -8,6 +8,20 @@ function findCommonElement <T> (array1: T[], array2: T[]) {
   return null
 }
 
+// Avoid conflict with other toArray() functions
+function arrayify <T> (element: T | T[]) {
+  if (Array.isArray(element)) return element
+
+  return [ element ]
+}
+
+// Avoid conflict with other uniq() functions
+function uniqify <T> (elements: T[]) {
+  return Array.from(new Set(elements))
+}
+
 export {
-  findCommonElement
+  uniqify,
+  findCommonElement,
+  arrayify
 }