-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from 10play/fix-font-example
Fix Font Example
- Loading branch information
Showing
6 changed files
with
48 additions
and
25 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
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './useKeyboard'; | ||
export * from './uniqueBy'; |
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,15 @@ | ||
export function uniqueBy<T, K extends keyof T>( | ||
items: T[], | ||
keyOrFn: K | ((item: T) => any) | ||
): T[] { | ||
const keyFn = | ||
typeof keyOrFn === 'function' ? keyOrFn : (item: T) => item[keyOrFn]; | ||
const seen = new Map<any, T>(); | ||
items.forEach((item) => { | ||
const key = keyFn(item); | ||
if (!seen.has(key)) { | ||
seen.set(key, item); | ||
} | ||
}); | ||
return Array.from(seen.values()); | ||
} |
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
Empty file.