fuse-immutable
Lightweight fuzzy-search for Immutable.js (Based on Fuse.js by krisk)
Table of Contents
How is this different than Fuse.js?
The obvious difference is that it works with Immutable.js data. Instead of an array for your list
argument, pass in an Immutable.List.
One other key difference is the results when using tokenize
and matchAllTokens
together. Fuse.js will return items that have a single value that matches all tokens. fuse-immutable returns items where each token can be found somewhere in the item.
import { fromJS } from 'immutable'
import Fuse from 'fuse-immutable'
const list = fromJS([{
title: 'Jackson',
author: 'Steve Pearson',
tags: ['Kevin Wong', 'Victoria Adam', 'John Smith']
}, {
title: 'The life of Jane',
author: 'John Smith',
tags: ['Jane', 'Jackson', 'Sam']
}, {
title: 'The life of John',
author: 'Jane Wong',
tags: ['Victoria Adam', 'John Pearson']
}])
const options = {
threshold: 0,
tokenize: true,
matchAllTokens: true,
}
const fuse = new Fuse(list, options)
console.log(fuse.search('Jackson Wong'))
Contributing
Coding conventions
Code should be run through Standard Format.
Testing
Before submitting a pull request, please add relevant tests in test/index.js
, and execute them via npm test
.