Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fuzzysort

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fuzzysort

Fast SublimeText-like fuzzy search for JavaScript

  • 3.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
274K
increased by22.19%
Maintainers
1
Weekly downloads
 
Created

What is fuzzysort?

Fuzzysort is a fast and powerful fuzzy search library for JavaScript. It allows you to perform fuzzy searching on arrays of strings or objects, providing ranked results based on their similarity to the search query.

What are fuzzysort's main functionalities?

Basic Fuzzy Search

This feature allows you to perform a basic fuzzy search on an array of strings. The results are ranked based on their similarity to the search query 'twl'.

const fuzzysort = require('fuzzysort');
const results = fuzzysort.go('twl', ['twilight', 'twelve', 'two', 'towel']);
console.log(results.map(result => result.target));

Fuzzy Search on Objects

This feature allows you to perform a fuzzy search on an array of objects. The 'key' option specifies which property of the objects to search within.

const fuzzysort = require('fuzzysort');
const books = [
  {title: 'The Great Gatsby'},
  {title: 'The Grapes of Wrath'},
  {title: 'Great Expectations'}
];
const results = fuzzysort.go('grt', books, {key: 'title'});
console.log(results.map(result => result.obj.title));

Highlighting Matches

This feature allows you to highlight the matching parts of the search results. The 'highlight' function wraps the matching parts with the specified HTML tags.

const fuzzysort = require('fuzzysort');
const results = fuzzysort.go('grt', ['The Great Gatsby', 'The Grapes of Wrath', 'Great Expectations']);
results.forEach(result => {
  console.log(fuzzysort.highlight(result, '<b>', '</b>'));
});

Other packages similar to fuzzysort

Keywords

FAQs

Package last updated on 14 Oct 2024

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

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc