]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - shared/core-utils/common/array.ts
Add bulk action on following/followers
[github/Chocobozzz/PeerTube.git] / shared / core-utils / common / array.ts
index 9e326a5aa7590e4ab0dea051f240e2c4272a57c1..95393c731107eab04d5e51cf318ce6db47f293c5 100644 (file)
@@ -8,6 +8,14 @@ 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 ]
+}
+
 export {
-  findCommonElement
+  findCommonElement,
+  arrayify
 }