@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 with getCatalogueIndex(cards, releases)
index.resolveHeroName(name) resolves any name a player writes for a hero to the character
and hero pools it names, or to every candidate when the name is ambiguous;
index.getByRole(CardRole.Hero) lists every hero card, and
index.getHeroCardsByFormat(format) the hero cards legal in a format; filter either on
card.heroPool for one hero pool.
getHeroFilterValue(heroCard) writes the l: filter for a hero card
- A hero name several heroes hold is reported in
unresolvedFilters as
{ 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 # tsc (per-file ESM + declarations), then build:cjs (bundled)
npm test # vitest
Uses the workspace's @flesh-and-blood/cards as a dev dependency for tests.