Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fuzzyContains = (text, search) => {
- debugger
- if (!text)
- return false
- if (!search)
- return true
- search = search.toLowerCase()
- text = text.toString().toLowerCase()
- let previousLetterPosition = -1
- return search.split('').every(s => {
- debugger
- previousLetterPosition = text.indexOf(s, previousLetterPosition + 1)
- return previousLetterPosition !== -1
- })
- }
- handleSearch = search => {
- const {data} = this.state
- debugger
- let filteredData = data.filter(x => Object.keys(x).some(key => {
- debugger
- this.fuzzyContains(x[`<mark>${key}<mark/>`], search)}))
- this.setState({filteredData, search})
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement