mtgql
v5.0.5
Published
query language for searching magic: the gathering cards
Downloads
1,186
Readme
mtgql-js
magic: the gathering query language library, javascript edition
Installation
npm install --save mtgqlUsage
import { QueryRunner, Card, DataProvider, MemoryDataProvider } from "mtgql";
// often loaded from scryfall bulk data
const cards: Card[] = [...];
// provides external data like cubes, sets, blocks, and tags
const dataProvider: DataProvider = new MemoryDataProvider();
// Use a query runner object when you already have a list of card data
const queryRunner = QueryRunner.fromCardList({ corpus: cards, dataProvider });
try {
const cards: Card[] = await queryRunner.search("t:creature c:ur")
} catch (searchError) {
// handle search errors
}
// Use a pre-compiled function for streams of card data
const filterFunction = await QueryRunner.singleCardFilter("t:creature")
...
const matchesFilter: boolean = filterFunction(card);Development
Prerequisites
- Java 11 or later is needed for openapi-generator
- node and npm
git clone https://git.sr.ht/~asks/mtgql
cd mtgql-js
npm install
# see package.json for build subcommands
npm run build