MTG Spoilers
A module for getting the latest Magic the Gathering spoilers as they become available.
Installation
npm install mtg-spoilers --save
Usage
The first argument is the set code, and the second argument is an options object with one required property, onNewSpoilers
, a function to be called with an array of new cards when they become available. The card objects are scryfall-client
Card objects.
var pollForSpoilers =
options.iteration
By default, it will check for new cards every fifteen minutes. You can override this behavior by passing a number in milliseconds to iteration
in the options object.
options.timeout
By default, it will automatically stop checking for new cards after 24 hours of no new spoilers. You can override this behavior by passing a number in milliseconds to timeout
in the options object.
If you only want the polling to stop by manually calling cancel
on the handler, pass Inifinity
for the value of timeout
.
options.onTimeout
An optional function that will be called when the polling times out. Will not fire when calling cancel
on the handler.
options.scryfallClientOptions
Under the hood, mtg-spoilers
uses scryfall-client
to make requests to the Scryfall API. Configuration for the client can be passed as options.scryfallClientOptions
.
Testing
npm test