Socket
Socket
Sign inDemoInstall

fuse-immutable

Package Overview
Dependencies
1
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    fuse-immutable

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


Version published
Weekly downloads
460
increased by156.98%
Maintainers
1
Install size
1.39 MB
Created
Weekly downloads
 

Changelog

Source

Version 2.0.0

  • Modified search algorithm to search individual words AND the full string, computing the final score as a function of both. This yields better scoring accuracy (#41)
  • Changed exact substrings to not have a score of zero. That is searching for "hell" in "hello" will not yield a score of zero, while searching for "hello" will (#63)
  • Added verbose option, which will print to the console useful information, mostly for debugging
  • Improved code structure.
  • Added version information within Fuse itself
  • Added this Changelog (#64)
  • Added fallback when pattern length is greater than machine word length (i.e, > 32 characters) (#38)
  • Allowed results with a value of 0 to be returned (#73)

Readme

Source

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.

Keywords

FAQs

Last updated on 09 Jan 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc