/
dimamir
/
medusa
Обзор
Документация
Войти
/
dimamir
/
medusa
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
packages/core/utils/src/common/array-intersection.ts
17 строк
405 B
Adrien de Peretti
chore(): start moving some packages to the core directory (#7215)
03 май 2024, 14:37
Не верифицирован
03 май 2024, 14:37
bbccd64
Код
Авторство
О чём код?
type ArrayIntersectionElement = string | number export function arrayIntersection<TElement = ArrayIntersectionElement>( firstArray: TElement[], secondArray: TElement[] ): TElement[] { const firstArraySet = new Set(firstArray) const res = new Set<TElement>() secondArray.forEach((element) => { if (firstArraySet.has(element)) { res.add(element) } }) return Array.from(res) }