-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: Native Contact Picker Properties (#14)
* feat: qr code improvements * apply pending connection events * chore: hide import contacts for now * fix: import native contact fixes and improvements * fix: phone number parsing for Google contacts * fix: contact properties intersection
- Loading branch information
1 parent
5217869
commit b737209
Showing
3 changed files
with
40 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
export function intersection<T>(a: T[], b: T[]): T[] { | ||
const setB = new Set(b) | ||
return a.filter((value) => setB.has(value)) | ||
} | ||
|
||
if (import.meta.vitest) { | ||
const { test, expect } = import.meta.vitest | ||
|
||
test('finds intersection of two arrays', () => { | ||
const arrA = [1, 2, 3, 4, 5] | ||
const arrB = [3, 4, 5, 6, 7] | ||
const expected = intersection(arrA, arrB) | ||
expect(expected).toEqual([3, 4, 5]) | ||
}) | ||
|
||
test('handles empty array', () => { | ||
const expectedA = intersection([1, 2], []) | ||
expect(expectedA).toEqual([]) | ||
|
||
const expectedB = intersection([], [1, 2, 3]) | ||
expect(expectedB).toEqual([]) | ||
}) | ||
|
||
test('maintains duplicates in first array', () => { | ||
const expected = intersection(['one', 'two', 'three', 'two', 'four'], ['two', 'four']) | ||
expect(expected).toEqual(['two', 'two', 'four']) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters