All Projects → jhawthorn → Fzy.js

jhawthorn / Fzy.js

Licence: mit
A javascript port of fzy's scoring algorithm. As seen on GitHub.com!

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Fzy.js

Awgo
Go library for Alfred 3 + 4 workflows
Stars: ✭ 556 (+578.05%)
Mutual labels:  fuzzy-search, fuzzy
Flexsearch
Next-Generation full text search library for Browser and Node.js
Stars: ✭ 8,108 (+9787.8%)
Mutual labels:  fuzzy-search, fuzzy
Fuzzy
Go library that provides fuzzy string matching optimized for filenames and code symbols in the style of Sublime Text, VSCode, IntelliJ IDEA et al.
Stars: ✭ 979 (+1093.9%)
Mutual labels:  fuzzy-search, fuzzy
Fzy
🔍 A simple, fast fuzzy finder for the terminal
Stars: ✭ 2,295 (+2698.78%)
Mutual labels:  fuzzy-search, fuzzy
string-similarity-js
Lightweight string similarity function for javascript
Stars: ✭ 29 (-64.63%)
Mutual labels:  fuzzy-search, fuzzy
Tntsearch
A fully featured full text search engine written in PHP
Stars: ✭ 2,693 (+3184.15%)
Mutual labels:  fuzzy-search, fuzzy
Leaderf
An efficient fuzzy finder that helps to locate files, buffers, mrus, gtags, etc. on the fly for both vim and neovim.
Stars: ✭ 1,733 (+2013.41%)
Mutual labels:  fuzzy-search, fuzzy
Fz
Cli shell plugin, the missing fuzzy tab completion feature of z jump around command.
Stars: ✭ 359 (+337.8%)
Mutual labels:  fuzzy-search, fuzzy
Alfred Fuzzy
Fuzzy search helper for Alfred 3+ workflows
Stars: ✭ 67 (-18.29%)
Mutual labels:  fuzzy-search, fuzzy
Ugrep
🔍NEW ugrep v3.1: ultra fast grep with interactive query UI and fuzzy search: search file systems, source code, text, binary files, archives (cpio/tar/pax/zip), compressed files (gz/Z/bz2/lzma/xz/lz4), documents and more. A faster, user-friendly and compatible grep replacement.
Stars: ✭ 626 (+663.41%)
Mutual labels:  fuzzy-search
Fuzzysearch
🐷 Tiny and fast fuzzy search in Go
Stars: ✭ 602 (+634.15%)
Mutual labels:  fuzzy-search
Typesense
Fast, typo tolerant, fuzzy search engine for building delightful search experiences ⚡ 🔍 ✨ An Open Source alternative to Algolia and an Easier-to-Use alternative to ElasticSearch.
Stars: ✭ 8,644 (+10441.46%)
Mutual labels:  fuzzy-search
Fontpreview
Highly customizable and minimal font previewer written in bash
Stars: ✭ 661 (+706.1%)
Mutual labels:  fuzzy-search
Fuzzy C Means
A simple python implementation of Fuzzy C-means algorithm.
Stars: ✭ 40 (-51.22%)
Mutual labels:  fuzzy
Fuzzy Swift
🔍 simple and fast fuzzy string matching in Swift
Stars: ✭ 61 (-25.61%)
Mutual labels:  fuzzy
Cassandra Lucene Index
Lucene based secondary indexes for Cassandra
Stars: ✭ 584 (+612.2%)
Mutual labels:  fuzzy-search
Suggest
Top-k Approximate String Matching.
Stars: ✭ 50 (-39.02%)
Mutual labels:  fuzzy-search
Pysoc.js
😎 Simple gsoc data scraper, search for any keyword and instantly get data about the orgs that match your search criteria, use filters to sort and analyse the data, uses fuzzy-searching to improve user-search experience
Stars: ✭ 35 (-57.32%)
Mutual labels:  fuzzy-search
Broot
A new way to see and navigate directory trees : https://dystroy.org/broot
Stars: ✭ 6,362 (+7658.54%)
Mutual labels:  fuzzy-search
Inquirer Checkbox Plus Prompt
Checkbox with autocomplete and other additions for Inquirer
Stars: ✭ 25 (-69.51%)
Mutual labels:  fuzzy-search

fzy.js

A javascript port of fzy's fuzzy finder scoring algorithm

Try it out online!

CI status Build Size 0 Dependencies

Installation

npm i --save fzy.js

Usage

score(needle, haystack)

var fzy = require('fzy.js')

fzy.score("amuser", "app/models/user.rb")     // 5.595
fzy.score("amuser", "app/models/customer.rb") // 3.655

positions(needle, haystack)

fzy.positions("amuser", "app/models/user.rb")     // [ 0, 4, 11, 12, 13, 14 ]
fzy.positions("amuser", "app/models/customer.rb") // [ 0, 4, 12, 13, 17, 18 ]

NB: score and positions must be called with matching needle and haystack, doing otherwise is undefined. The caller needs to check that there is a match. See the full example below for a way to do this check.

Full Example

var { sortBy, escapeRegExp } = require("lodash");
var fzy = require("fzy.js");

// List of candidate strings
// Often generated by something like require("glob")("**/*")
var list = [
	"app/models/user.rb",
	"app/models/order.rb",
	"app/models/customer.rb"
];

// Usually this is input from the user
var query = "amuser";

// fzy.js doesn't implement filtering, only scoring, but it is simple enough with a regexp
var regex = new RegExp(query.split('').map(escapeRegExp).join(".*"));
list = list.filter((s) => s.match(regex));

// Sort by fzy's scoring, descending (higher scores are better matches)
list = sortBy(list, (s) => -fzy.score(query, s));

// Select only the first 10 results
list.slice(0, 10);

// Print out our results with matched positions
list.forEach((s) => {
	var padded = "";
	var p = fzy.positions(query, s);
	for(var i = 0; i < query.length; i++) {
		padded = padded.padEnd(p[i], ' ') + query[i];
	}

	console.log(s);
	console.log(padded);
	console.log("");
});

// Output:
//
// app/models/user.rb
// a   m      user
//
// app/models/customer.rb
// a   m       us   er

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].