X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=shared%2Fcore-utils%2Fcommon%2Farray.ts;h=95393c731107eab04d5e51cf318ce6db47f293c5;hb=e3d6c6434f570f77c0532f86c82f78bcafb399ec;hp=9e326a5aa7590e4ab0dea051f240e2c4272a57c1;hpb=c3edc5b074aa4bb1861ed0a94d3713808e87170f;p=github%2FChocobozzz%2FPeerTube.git diff --git a/shared/core-utils/common/array.ts b/shared/core-utils/common/array.ts index 9e326a5aa..95393c731 100644 --- a/shared/core-utils/common/array.ts +++ b/shared/core-utils/common/array.ts @@ -8,6 +8,14 @@ function findCommonElement (array1: T[], array2: T[]) { return null } +// Avoid conflict with other toArray() functions +function arrayify (element: T | T[]) { + if (Array.isArray(element)) return element + + return [ element ] +} + export { - findCommonElement + findCommonElement, + arrayify }