@flesh-and-blood/search
A fuse.js-based search engine for Flesh and Blood cards.
Installation
npm i @flesh-and-blood/search @flesh-and-blood/types
@flesh-and-blood/types is a peer dependency: install it alongside this package
Usage
import Searcher from "@flesh-and-blood/search";
import { cards, releases } from "@flesh-and-blood/cards";
const searcher = new Searcher(cards, { releases });
const { searchResults } = searcher.search("rhinar go again");
new Searcher(cards, { releases }), or{ index }to share a catalogue index built withgetCatalogueIndex(cards, releases)index.getHero(name)resolves any name a player writes for a hero to its key, the wayl:andsp:do;index.getHeroMatches(name)answers every hero the name fits, each with a hero card, for a name several heroes hold;index.getByRole(CardRole.Hero)lists every hero card, andindex.getHeroCardsByFormat(format)the hero cards legal in a format; filter either oncard.heroPoolfor one hero pool.getHeroFilterValue(heroCard)writes thel:filter for a hero card- A hero name several heroes hold is reported in
unresolvedFiltersas{ reason: "ambiguous", values, candidates }, each candidate a hero card's name .search(text)→SearchResults:{ searchResults: SearchCard[], appliedFilters, keywords, attributes }
Data-only modules are available as subpath imports (handy for lazy-loaded UI like a search-bar dropdown):
import { shorthands } from "@flesh-and-blood/search/shorthands";
What's included
- Default export:
Searcher, the search engine - Types:
SearchResults,SearchCard - Data modules (subpath imports):
shorthands,memes - Filter, exclusion and helper utilities (
filters,exclusions,legality,helpers,constants,related)
Working with this project
npm run build # build:esm (per-file ESM) + build:cjs (bundled) + tsc declarations
npm test # vitest
Uses @flesh-and-blood/cards (file:../cards) as a dev dependency for tests.