From 7e9835dd80a560f4b5a33fa770411efeccfdaaec Mon Sep 17 00:00:00 2001 From: Etienne Lemay Date: Fri, 22 Jul 2016 16:04:30 -0400 Subject: [PATCH] utils#intersect --- src/utils/index.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/utils/index.js b/src/utils/index.js index 0d3c036..32ee325 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -67,4 +67,16 @@ function getData(emoji, skin, sheetURL) { return emojiData } -export { getData, getSanitizedData } +function intersect(a, b) { + var aSet = new Set(a), + bSet = new Set(b), + intersection = null + + intersection = new Set( + [...aSet].filter(x => bSet.has(x)) + ) + + return Array.from(intersection) +} + +export { getData, getSanitizedData, intersect }