Tiny, fast fuzzy ⚡️earch for React applications
Live demo https://use-command-score.vercel.app
npm install use-command-score
import { useCommandScore } from "use-command-score";
useCommandScore(needle, haystack, options);
Search array of strings
useCommandScore("vsc", ["Vim", "Google chrome", "Visual studio code"]); // ['Visual studio code']
Search array of objects & limit result Live demo
useCommandScore("hger", movies, {
limit: 3,
keys: ["title", "meta.actors", "meta.director"]
});
useCommandScore(needle, haystack, options)
Search query
Type: string
Required: true
Array of items to search
Type: Array<T>
Required: true
Type: object
Required: false
Object key paths in haystack
. The value of the key paths will be matched against needle
Type: Array<string>
Required: false
const data = [
{ name: "a", address: { code: "123" } },
{ name: "b", address: { code: "456" } }
];
useCommandScore("4", data, { keys: ["name", "address.code"] });
Limits the total results returned
Type: number
Required: false
useCommandScore(needle, haystack, { limit: 5 });