search-worker

Simple fast text search that utilizes a web worker

Usage no npm install needed!

<script type="module">
  import searchWorker from 'https://cdn.skypack.dev/search-worker';
</script>

README

search-worker

Simple fast AF text search that utilizes a web worker.

This module delegates searching long lists of text to a worker thread, greatly increasing performance.

Uses "greenlet" as a dependency for inline worker threading.

Fork or clone this repo and to try out searching through 20,000+ items with no lag.

Installation

npm install search-worker

Usage


import { SearchWorker } from 'search-worker';

const originalList = [
  { name: 'lorem', foo: 'bar' },
  { name: 'ipsum', foo: 'baz' },
  { name: 'dolor', foo: 'buz' },
];

const options = { keys: ['name', 'foo'] };
// or const options = { keys: 'name,foo' };

let searchList = SearchWorker(
  originalList,
  options // you can omit these options if you are searching an array of strings ex: ['lorem','ipsum']
);

searchList('lorem')
  .then(updatedList => {
    console.log(updatedList) // [{name:'lorem', foo: 'bar'}]
  });

See the demo in this repo for usage with p/react

License