Last active
January 10, 2020 13:33
-
-
Save frivolta/bbb5e4255b43ab41862163aafc20e7a6 to your computer and use it in GitHub Desktop.
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
// Let's define our valueToFilter type | |
const filterArrayByValue = <T, P extends keyof T>( | |
items: T[], | |
propertyName: P, | |
valueToFilter: T[P] //Partial<T> | |
): T[] => { | |
return items.filter(item =>item[propertyName] === valueToFilter); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment