2.0.0 • Published 3 years ago
refined-text-search v2.0.0
Installation
yarn add refined-text-search
Usage
import { tokenize, match } from 'refined-text-search'
// Tokenize a search query
const tokens = tokenize('"Hello World" my dear -"how are you" -horrible oh')
// -> [
// {term: 'how are you', exclude: true},
// {term: 'horrible', exclude: true},
// {term: 'hello world'},
// {term: 'my'},
// {term: 'dear'},
// {term: 'oh'}
// ]
// See if a tokenized query matches a string
const b = match(tokens, 'HeLLo World. My dear oh dear...')
// -> true
const b = match(tokens, 'HeLLo World.')
// -> false
const c = match(tokens, 'HeLLo World. My dear oh dear... What a horrible night.')
// -> false
Contributors
Thanks goes to these wonderful people (emoji key):
This project follows the all-contributors specification. Contributions of any kind welcome!
License
MIT