0.7.12 • Published 4 years ago

@iosio/fuse-worker v0.7.12

Weekly downloads
32
License
MIT
Repository
-
Last release
4 years ago

@iosio/fuse-worker

Delegates fuse.js fuzzy search to a worker thread.

Installation

npm install @iosio/fuse-worker

Requires configuring your build system to copy the worker file from node_modules to the root of the build destination where the application is served from.

Copy path: 'node_modules/@iosio/fuse-worker/lib/fuse.worker.js'

(As of now, version 3.4.5 of fuse.js is bundled with the worker file)

Usage

To create a new fuse worker, import FuseWorker and call the factory function that creates and connects to a web worker.

import {FuseWorker} from '@iosio/fuse-worker';

const fuse = FuseWorker({
    workerURL: './path/to/fuse.worker.js', // defaults to './fuse.worker.js'.
    list: [], //optionally pass the list to perform the search in, or set the list using fuse.set({list}) .
    options: {}, //optionally merge options into the default fuse.js options config or use fuse.set({options}) .
})

fuse options: See https://fusejs.io/ for more info on fuse.js and the available options. The following is what exists as the default options.

let options = {
    shouldSort: true,
    minMatchCharLength: 1,
    findAllMatches: true,
    keys: ['name'],
    maxPatternLength: 50,
    threshold: 0.4,
    distance: 1000,
    location: 0,
    ...options //any options you pass will be merged in here
};

fuse.set As stated above, the list and options on the fuse worker instance may be updated by calling fuse.set

fuse.set({
    list: [...your_new_list_to_search_in],
    options: {...any_new_options}
});

fuse.search To perform a search, call fuse.search passing a string text value as the first argument and a callback function as the second argument.

fuse.search('some value to search for', (results) => {
    console.log('the results from fuse.js', results)
});
0.7.12

4 years ago

0.7.9

4 years ago

0.7.8

4 years ago

0.7.0

4 years ago

0.6.6

4 years ago

0.6.5

4 years ago

0.6.4

4 years ago

0.6.1

4 years ago

0.6.0

4 years ago

0.5.81

4 years ago

0.5.79

4 years ago

0.5.75

4 years ago

0.5.74

4 years ago

0.5.73

4 years ago

0.5.72

4 years ago

0.5.71

4 years ago

0.5.70

4 years ago

0.5.69

4 years ago

0.5.68

4 years ago

0.5.67

4 years ago

0.5.66

4 years ago

0.5.65

4 years ago

0.5.64

4 years ago

0.5.63

4 years ago