JSPM

  • Created
  • Published
  • Downloads 1131460
  • Score
    100M100P100Q186906F
  • License ISC

Package Exports

  • fuzzysort

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (fuzzysort) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

fuzzysort

Fast javascript SublimeText-like fuzzy search for node or the browser.

Demo

Installation Node

const fuzzysort = require('fuzzysort')

Installation Browser

<script src="fuzzysort.js"></script>

Usage

fuzzysort.go(search, target)

fuzzysort.go('query', 'some string that contains my query.')
// {score: 0.059, highlighted: "some string that contains my <b>query</b>."}

fuzzysort.go('query', 'irrelevant string') // null

// exact match returns a score of 0. lower score is better
fuzzysort.go('query', 'query') // {score: 0, highlighted: "<b>query</b>"}

fuzzysort.goArray(search, targets)

fuzzysort.goArray('mr', ['Monitor.cpp', 'MeshRenderer.cpp'])
// [{score: 0.018, highlighted: "<b>M</b>esh<b>R</b>enderer.cpp"}
// ,{score: 6.009, highlighted: "<b>M</b>onito<b>r</b>.cpp"}]

fuzzysort.goArrayAsync

let promise = fuzzysort.goArrayAsync('mr', ['Monitor.cpp', 'MeshRenderer.cpp'])
promise.then(results => console.log(results))
if(invalidated) promise.cancel()
Options
  • fuzzysort.noMatchLimit = 100 If there's no match for a span this long, give up
  • fuzzysort.highlightMatches = true Turn this off if you don't care about highlighted
  • fuzzysort.highlightOpen = '<b>'
  • fuzzysort.highlightClose = '</b>'