Socket
Book a DemoInstallSign in
Socket

fuzzr

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fuzzr

An incredibly fast fuzzy search utilizing rust compiled to wasm

latest
Source
npmnpm
Version
0.3.1
Version published
Maintainers
1
Created
Source

Fuzzr

Fuzzr is an incredibly fast fuzzy searcher compiled for browser use. This library is written in rust and utilizes the popular skim algorithm used in the skim command line search. The algorithm is provided by the fuzzy-matcher crate by lotabout. I merely provided the wasm bindings.

Usage

const Fuzzr = (await import('fuzzr')).Fuzzr

const collection = [
  { name: 'Apple' },
  { name: 'Orange' },
  { name: 'Pineapple' },
  { name: 'Pear' }
]

const fuzzr = new Fuzzr(collection, {
  surroundMatchesWith: ['<strong>', '</strong>'],
  // only necessary when not passing a collection of Strings:
  toString: ({ name }) => name,
})

fuzzr.search('Ale')
/*
[
  {
    item: { name: 'Apple' },
    score: 42,
    formatted: '<strong>A</strong>pp<strong>le</strong>'
  },
  {
    item: { name: 'Pineapple' },
    score: 42,
    formatted: 'Pine<strong>a</strong>pp<strong>le</strong>'
  }
]
*/

Results are ordered in descending order by score. If the score is equal, the order of the elements in the collection is preserved.

FAQs

Package last updated on 19 Jul 2020

Did you know?

Socket

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.