### Prerelease Publishing Source: https://github.com/nozbe/microfuzz/blob/main/PUBLISHING.md Publishes the project as a prerelease using the 'next' tag. Requires updating the version and pushing tags. ```bash yarn ci:check yarn build # update changelog&readme npm version 1.1.1-1 # publish as prerelease npm publish --tag next git push && git push --tags ``` -------------------------------- ### Normal Publishing Source: https://github.com/nozbe/microfuzz/blob/main/PUBLISHING.md Publishes the project as a stable release. Requires updating the version and pushing tags. ```bash # publish normally npm publish git push && git push --tags ``` -------------------------------- ### Basic Fuzzy Search with Plain JS Source: https://github.com/nozbe/microfuzz/blob/main/README.md Initialize fuzzy search with a list of strings. The returned function takes a query text and returns sorted, matching items. ```javascript import createFuzzySearch from '@nozbe/microfuzz' const list = [/* an array of strings to fuzzy search */] const fuzzySearch = createFuzzySearch(list) // Run this whenever search term changes // Only matching items will be returned, sorted by how well they match `queryText` const results = fuzzySearch(queryText) ``` -------------------------------- ### Update Documentation Source: https://github.com/nozbe/microfuzz/blob/main/PUBLISHING.md Updates the project documentation by merging the main branch into gh-pages, building the demo, and committing the result. ```bash # update docs git checkout gh-pages git merge main cd demo && yarn gh-pages # commit result and push ``` -------------------------------- ### Fuzzy Search Strategy Configuration Source: https://github.com/nozbe/microfuzz/blob/main/README.md Control the fuzziness of the search by selecting from different strategies: 'off' for exact matching, 'smart' for default behavior, or 'aggressive' for unrestricted fuzzy matching. ```javascript // You can optionally pass `{ strategy: }` parameter to `createFuzzySearch` / `useFuzzySearchList`: // - 'off' - no fuzzy search, only matches if item contains query (or contains query words in any order) // - 'smart' - (default) matches letters in order, but poor quality matches are ignored // - 'aggressive' - matches letters in order with no restrictions (classic fuzzy search) ``` -------------------------------- ### Fuzzy Search with React Hooks Source: https://github.com/nozbe/microfuzz/blob/main/README.md Utilize the `useFuzzySearchList` hook for memoized fuzzy search in React applications. It simplifies integration and provides results with highlighting information. ```javascript import { useFuzzySearchList, Highlight } from '@nozbe/microfuzz/react' // `useFuzzySearchList` simply wraps `createFuzzySearch` with memoization built in // NOTE: For best performance, `getText` and `mapResultItem` should be memoized by user const filteredList = useFuzzySearchList({ list, // If `queryText` is blank, `list` is returned in whole queryText, // optional `getText` or `key`, same as with `createFuzzySearch` getText: (item) => [item.name], // arbitrary mapping function, takes `FuzzyResult` as input mapResultItem: ({ item, score, matches: [highlightRanges] }) => ({ item, highlightRanges }) }) // Render `filteredList`'s labels with matching characters highlighted filteredList.map(({ item, highlightRanges }) => ( )) ``` -------------------------------- ### Fuzzy Search on Object Properties Source: https://github.com/nozbe/microfuzz/blob/main/README.md Configure fuzzy search to operate on specific properties of objects within the list, or to extract text from complex nested structures. ```javascript const fuzzySearch = createFuzzySearch(list, { // search by `name` property key: 'name', // search by `description.text` property getText: (item) => [item.description.text], // search by multiple properties: getText: (item) => [item.name, item.description.text] }) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.