1.0.3 • Published 7 years ago

ok-text-search v1.0.3

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

OK Text Search NPM version Build status

A module for searching for text. Useful if you need to search a large piece of text for multiple strings.

Don't know if it's the fastest but it's OK. It's quite small (3k uncompressed), doesn't have any dependencies so should work in the browser fine. It's worth checking if something like this is the best fit for you as with a low amount of phrases and a small piece of text to search indexOf is often faster.

npm install ok-text-search
import OKTextSearch from 'ok-text-search';

const textSearch= new OKTextSearch(['something','another thing']);
textSearch.add('yet another thing');

textSearch.build();

const results = textSearch.exec('Lorem ipsum dolor something, consectetur adipiscing elit. In sem felis, tincidunt vitae orci et, ornare malesuada ante. Cras ultrices interdum leo id imperdiet. Lorem ipsum dolor sit amet, consectetur adipiscing elit.');
//[{index:18, text:'something'}]

If you'd like to check performance there is a simple benchmarking script.

npm run benchmark