2.0.0 • Published 6 years ago

fuse-immutable v2.0.0

Weekly downloads
177
License
Apache-2.0
Repository
github
Last release
6 years ago

fuse-immutable

Lightweight fuzzy-search for Immutable.js (Based on Fuse.js by krisk)

Twitter URL

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'))
// List [
//   Map {
//    "title": "Jackson",
//    "author": "Steve Pearson",
//    "tags": List [ "Kevin Wong", "Victoria Adam", "John Smith" ]
//   }
//  ]

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.

2.0.0

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago