Class: DumpRequest

nationscript/requests/dump~DumpRequest()

Superclass for all specialised request classes interacting with Daily Data Dumps, including archived ones.

Constructor

new DumpRequest()

Members

(protected) directory :string

Path to the directory where fetched Data Dumps are saved to locally.

Type:
  • string
Default Value:
  • './nsdumps/'

(protected) filter :Factory.FactoryDecider.<any>

Filter function to use for this request.

Type:
  • Factory.FactoryDecider.<any>

Methods

(static) setDirectory(dir) → {void}

Sets the directory to keep local copies of fetched Data Dumps in.

Parameters:
Name Type Description
dir string

Path to the desired directory

Throws:

if dir isn't a valid string

Type
TypeError
Returns:
Type
void

(abstract, protected) getFilePath() → {string}

Returns:

Path to the file which to save the local Dump copy as

Type
string

(async) getStream() → {Promise.<zlib.Gunzip>}

Gets the raw readable stream of the queried Dump data. The original stream - depending on the DumpMode used, either from the local Dump copy or the remote copy on the NationStates servers - is pipe()d first through a write stream to the local file, if necessary, and in any case will finally be pipe()d through a zlib.Gunzip stream, which is the ultimate return value.

Returns:

Stream of the fetched data, if found

Type
Promise.<zlib.Gunzip>

(async) send() → {Promise.<Array.<object>>}

Executes this request according to the set DumpMode.

Returns:

All parsed objects satisfying the filter

Type
Promise.<Array.<object>>

setFilter(filter) → {this}

Configure the filter function to apply to newly parsed objects. While parsing objects from the Dump XML, the filter function is called for each new object; if it returns true, the object is kept, otherwise it is discarded.

Parameters:
Name Type Description
filter Factory.FactoryDecider.<any>

Filter to use

Returns:

The request, for chaining

Type
this

setMode(mode) → {this}

Configure this request to use the specified DumpMode.

Parameters:
Name Type Description
mode number

Mode to use

Returns:

The request, for chaining

Type
this