refined-text-search
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

refined-text-search

Tokenize a search query with refined options (like Google's) and match against a target.

Package Version Build Status Code Coverage

InstallationUsageContributorsLicense


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):


David Reeß

💻 📖 ⚠️

This project follows the all-contributors specification. Contributions of any kind welcome!

License

MIT

Package Sidebar

Install

npm i refined-text-search

Weekly Downloads

8

Version

2.0.0

License

MIT

Unpacked Size

46.8 kB

Total Files

26

Last publish

Collaborators

  • queicherius