Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Fuse.js is a powerful, lightweight fuzzy-search library, with zero dependencies. It provides a simple way to perform approximate string matching (fuzzy searching) by searching for patterns in text, which is useful for implementing features like search-as-you-type, autocomplete, and other search-related functionalities.
Simple Search
This feature allows you to perform a simple fuzzy search on a list of items. The code sample demonstrates searching for the term 'old man' in an array of book titles.
const Fuse = require('fuse.js');
const books = [{ title: 'Old Man's War' }, { title: 'The Lock Artist' }];
const fuse = new Fuse(books, { keys: ['title'] });
const result = fuse.search('old man');
Weighted Search
This feature allows you to perform a search where each field can have a different weight, affecting the relevance of search results. The code sample demonstrates a weighted search where the author field has a higher weight than the title.
const Fuse = require('fuse.js');
const books = [{ title: 'Old Man's War', author: 'John Scalzi' }, { title: 'The Lock Artist', author: 'Steve Hamilton' }];
const fuse = new Fuse(books, { keys: [{ name: 'title', weight: 0.3 }, { name: 'author', weight: 0.7 }] });
const result = fuse.search('john');
Extended Search
This feature allows you to use an extended search syntax to perform searches that include logical operators. The code sample demonstrates searching for items that do not include the word 'lock'.
const Fuse = require('fuse.js');
const books = [{ title: 'Old Man's War' }, { title: 'The Lock Artist' }];
const options = { includeMatches: true, useExtendedSearch: true };
const fuse = new Fuse(books, options);
const result = fuse.search('!lock');
Algolia is a hosted search engine capable of delivering real-time results from the first keystroke. It's more feature-rich and includes a complete search API compared to the client-side library Fuse.js. However, it requires setting up an account and is not a purely client-side solution.
Lunr.js is a small, full-text search library for use in the browser. It indexes data ahead of time and provides a simple search interface. Lunr.js is more suited for smaller datasets and static websites, whereas Fuse.js does not require pre-indexing and can handle dynamic content better.
Elasticlunr.js is a lightweight full-text search engine in JavaScript for browser search and offline search. It is based on lunr.js but provides more flexibility and is faster. Compared to Fuse.js, Elasticlunr.js requires pre-indexing and is more suitable for static content.
Fuse.js is a lightweight fuzzy-search, in JavaScript, with zero dependencies.
To checkout out live examples and docs, visit fusejs.io.
NPM
NPM is the recommended installation method. It pairs nicely with a CommonJS module bundler such as Webpack or Browserify.
# latest stable
$ npm install --save fuse.js
CDN
Available on cdnjs (see the latest version on the Releases page).
Code should be run through Standard Format.
Before submitting a pull request, please add relevant tests in test/index.js
, and execute them via npm test
.
FAQs
Lightweight fuzzy-search
The npm package fuse.js receives a total of 1,246,124 weekly downloads. As such, fuse.js popularity was classified as popular.
We found that fuse.js demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.