diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-03-16 00:07:57 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-03-16 00:07:57 +0300 |
commit | 512177dcc7369c6c3f4ae54cc8a0abcb73828f71 (patch) | |
tree | 3ceb4aba221a235c570f6f7e5398b88a381e3ead /app/assets/javascripts/lib | |
parent | 7f08e6916d8259a8ed1549cb54460f0b746d9d8b (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/lib')
-rw-r--r-- | app/assets/javascripts/lib/utils/array_utility.js | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/app/assets/javascripts/lib/utils/array_utility.js b/app/assets/javascripts/lib/utils/array_utility.js index 197e7790ed7..04f9cb1cdb5 100644 --- a/app/assets/javascripts/lib/utils/array_utility.js +++ b/app/assets/javascripts/lib/utils/array_utility.js @@ -18,3 +18,13 @@ export const swapArrayItems = (array, leftIndex = 0, rightIndex = 0) => { copy[rightIndex] = temp; return copy; }; + +/** + * Return an array with all duplicate items from the given array + * + * @param {Array} array - The source array + * @returns {Array} new array with all duplicate items + */ +export const getDuplicateItemsFromArray = (array) => [ + ...new Set(array.filter((value, index) => array.indexOf(value) !== index)), +]; |