fix: Ensure passed Id filters get applied on top of maybe link filter (#7182)
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
import { arrayIntersection } from "../array-intersection"
|
||||
|
||||
describe("arrayIntersection", function () {
|
||||
it("should return the intersection between two arrays", function () {
|
||||
const output = arrayIntersection(["foo", "bar"], ["bar", "baz"])
|
||||
expect(output).toEqual(["bar"])
|
||||
})
|
||||
|
||||
it("should return an empty array if there is no intersection", function () {
|
||||
const output = arrayIntersection(["bar", "baz"], ["foo", "boo"])
|
||||
expect(output).toEqual([])
|
||||
})
|
||||
|
||||
it("should return an all items when the arrays are equivalent", function () {
|
||||
const output = arrayIntersection(["bar", "baz"], ["baz", "bar"])
|
||||
expect(output).toEqual(["baz", "bar"])
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,17 @@
|
||||
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)
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
export * from "./alter-columns-helper"
|
||||
export * from "./array-difference"
|
||||
export * from "./array-intersection"
|
||||
export * from "./build-query"
|
||||
export * from "./camel-to-snake-case"
|
||||
export * from "./container"
|
||||
|
||||
Reference in New Issue
Block a user