Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.