Interface Reader
get compressed(): boolean;
get filepath(): string;
get meta(): Readonly<CardDB.File.Metadata>;
asStream(options?: CardDB.Stream.StreamOptions): AsyncIterable<Card>;
diff(
comparison: CardDB.Stream.Reader,
streamOptions?: CardDB.Stream.StreamOptions,
): Promise<CardDB.Stream.Diff>;
getAll(): Promise<Card[]>;
getQuantityMap(
options?: CardDB.Stream.StreamOptions,
logger?: BasicLogger,
): Promise<Map<string, number>>;
isCardExportable(card: Card): boolean;
isCardGroup(card: Card, group: keyof MetadataGroups<string[]>): boolean;
}
Index
Accessors
Methods
Accessors
compressed
- get compressed(): boolean
Returns boolean
Whether backing CardDB is compressed.
filepath
- get filepath(): string
Returns string
The associated filepath.
meta
Methods
asStream
Parameters
Optionaloptions: CardDB.Stream.StreamOptionsOptional options.
Returns AsyncIterable<Card>
Asynchronous iterator over validated card entries.
diff
- diff(
comparison: CardDB.Stream.Reader,
streamOptions?: CardDB.Stream.StreamOptions,
): Promise<CardDB.Stream.Diff>Computes a quantity-based diff between this card stream and a comparison card stream instance.
Cards are compared using a composite identity key (
scryfall_id + foil + lang) via uniqueCardKey so that physically distinct printings are treated independently.The diff is asymmetric:
thiscard stream instance is treated as the baseline card pool.comparisonis treated as the comparison target.
The result captures:
- cards newly added in
comparison. - cards removed since
baseline. - cards whose quantities changed between the two CardStreams.
This function is intentionally card-data–light. It operates only on identity keys and quantities. Any card metadata required for reporting should be collected in a subsequent streaming pass.
Parameters
Returns Promise<CardDB.Stream.Diff>
CardStreamDiff object.
getAll
getQuantityMap
- getQuantityMap(
options?: CardDB.Stream.StreamOptions,
logger?: BasicLogger,
): Promise<Map<string, number>>Builds a quantity map for cards in this card stream.
Cards are grouped by their composite identity key (
scryfall_id + foil + lang), and the quantities of matching entries are summed.This method is streaming and memory-efficient: it does not retain card objects, only identity keys and aggregated quantities.
The returned map is suitable for:
- diff operations
- export coalescing
- analytics and reporting
Parameters
Optionaloptions: CardDB.Stream.StreamOptionsOptional stream selection options.
Optionallogger: BasicLoggerOptional logging.
Returns Promise<Map<string, number>>
A map of unique card identity keys to total quantities.
isCardExportable
Verifies that the card is not part of a non-exportable group. Presently all groups are non-exportable. IE
decks,externalorproxy.Parameters
- card: Card
Returns boolean
Whether card can be exported.
isCardGroup
Checks the meta external file names for a card file name match.
Parameters
- card: Card
- group: keyof MetadataGroups<string[]>
External card group to test for inclusion.
Returns boolean
Whether card is part of given group.
Stream the card data in the DB asynchronously.