@flesh-and-blood /搜索
一、 fuse.js的搜索引擎 血肉之躯 卡片。
安装
npm i @flesh-and-blood/search @flesh-and-blood/types
@flesh-and-blood/types 是一个 同行的依赖:与这个包一起安装
使用
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 }),或者{ index }共享目录索引 建立与getCatalogueIndex(cards, releases)index.getHero(name)解析玩家为英雄写的任何名字到它的键l:和sp:做;index.getHeroMatches(name)回答每个英雄的名字,每个英雄卡, 为了一个名字,几个英雄坚守;index.getByRole(CardRole.Hero)列出每个英雄卡牌,和index.getHeroCardsByFormat(format)英雄卡牌合法的格式;过滤器任意开启card.heroPool一个英雄池。getHeroFilterValue(heroCard)写l:筛选英雄卡- 几个英雄持有的英雄名被报告
unresolvedFilters作为{ reason: "ambiguous", values, candidates },每位候选人都有一张英雄牌的名字 .search(text)→SearchResults:{ searchResults: SearchCard[], appliedFilters, keywords, attributes }
只有数据的模块可以作为子路径导入(方便于惰性加载的UI,如搜索栏下拉):
import { shorthands } from "@flesh-and-blood/search/shorthands";
包括什么
- 默认导出:
Searcher,搜索引擎 - 类型:
SearchResults,SearchCard - 数据模块(子路径导入):
shorthands,memes - 筛选、排除和辅助工具(
filters,exclusions,legality,helpers,constants,related)
参与这个项目
npm run build # build:esm (per-file ESM) + build:cjs (bundled) + tsc declarations
npm test # vitest
用途 @flesh-and-blood/cards (file:../cards)作为测试的开发依赖项。