nationstates.js
Version:
A wrapper to interact with the NationStates API.
100 lines (99 loc) • 3.48 kB
TypeScript
/**
* ⚠️ Deprecated! Use Client instead.
* Required for all other classes. Defines the configuration of the wrapper and is used to enforce rate limits and user agents.
* @example const api = new client('Testlandia');
*/
export declare class API {
static readonly version: string;
private _userAgent;
private _rateLimit;
protected static _lastRequestMs: number;
/**
* Instance must be instantiated with a user agent string. Setting a custom rate limit is optional.
* @param {string} userAgent
* @param {number} rateLimit
*/
constructor(userAgent: string, rateLimit?: number);
/**
* Retrieves the user agent string.
* @example console.log(api.userAgent);
*/
get userAgent(): string;
/**
* Sets the user agent. Verifies the parameter length if less than three, is alphanumeric,
* does not end in an empty space, and is a string.
* @example api.userAgent = 'Testlandia';
* @param {string} userAgent
*/
set userAgent(userAgent: string);
/**
* Returns the current rate limit as a number.
* @example console.log(api.rateLimit);
*/
get rateLimit(): number;
/**
* Set the rateLimit of the instance. Verifies that the input is a number and is >= 650.
* @example api.rateLimit = 1500;
* @param {number} ms - The number of milliseconds to set the rateLimit to.
*/
set rateLimit(ms: number);
/**
* Returns the last request time in milliseconds. Used to enforce rate limits.
* @example console.log(api.lastRequestMs);
*/
get lastRequestMs(): number;
/**
* ❌⚠️ DO NOT USE unless you kow what you're doing.
* Set the time of the last request in milliseconds.
* @example api.lastRequestMs = Date.now();
* @param ms
*/
set lastRequestMs(ms: number);
}
export declare class Client {
static readonly version: string;
private _userAgent;
private _rateLimit;
protected static _lastRequestMs: number;
/**
* Instance must be instantiated with a user agent string. Setting a custom rate limit is optional.
* @param {string} userAgent
* @param {number} rateLimit
*/
constructor(userAgent: string, rateLimit?: number);
/**
* Retrieves the user agent string.
* @example console.log(api.userAgent);
*/
get userAgent(): string;
/**
* Sets the user agent. Verifies the parameter length if less than three, is alphanumeric,
* does not end in an empty space, and is a string.
* @example api.userAgent = 'Testlandia';
* @param {string} userAgent
*/
set userAgent(userAgent: string);
/**
* Returns the current rate limit as a number.
* @example console.log(api.rateLimit);
*/
get rateLimit(): number;
/**
* Set the rateLimit of the instance. Verifies that the input is a number and is >= 650.
* @example api.rateLimit = 1500;
* @param {number} ms - The number of milliseconds to set the rateLimit to.
*/
set rateLimit(ms: number);
/**
* Returns the last request time in milliseconds. Used to enforce rate limits.
* @example console.log(api.lastRequestMs);
*/
get lastRequestMs(): number;
/**
* ❌⚠️ DO NOT USE unless you kow what you're doing.
* Set the time of the last request in milliseconds.
* @example api.lastRequestMs = Date.now();
* @param ms
*/
set lastRequestMs(ms: number);
}