Created
September 27, 2019 17:24
-
-
Save benjamincharity/3fadc64850891f174df8bd46d1137ba6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
public queryStates(query: string): State[] { | |
query = query.toLowerCase(); | |
if (query) { | |
const letters = query.split('').map(l => `${l}.*`).join(''); | |
const regex = new RegExp(letters, 'ig'); | |
return this.states.filter(s => !!s.name.match(regex)); | |
} else { | |
// if no query, return first 10 states | |
return STATES.slice(0, 10); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment