Skip to content
This repository has been archived by the owner on Dec 11, 2024. It is now read-only.

Commit

Permalink
options fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Kathund committed Aug 22, 2024
1 parent ac0ccdf commit 1660539
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ class Client {
declare interval: NodeJS.Timeout;
constructor(key: string, options?: ClientOptions) {
this.key = key;
this.parasOptions(options);
this.errors = new Errors();
if (!this.key.length) throw new Error(this.errors.NO_API_KEY);
this.options = this.parasOptions(options);
this.requests = new Requests(this);
this.cacheHandler = new CacheHandler(this);
this.updater = new Updater(this);
Expand Down Expand Up @@ -64,15 +65,17 @@ class Client {
if (this.rateLimit.interval) clearInterval(this.rateLimit.interval);
}

private parasOptions(options?: ClientOptions) {
this.options.cache = options?.cache ?? true;
this.options.cacheTime = options?.cacheTime ?? 300;
this.options.cacheMaxKeys = options?.cacheMaxKeys ?? -1;
this.options.cacheCheckPeriod = options?.cacheCheckPeriod ?? 180;
this.options.rateLimit = options?.rateLimit ?? 'AUTO';
this.options.silent = options?.silent ?? false;
this.options.checkForUpdates = options?.checkForUpdates ?? true;
this.options.checkForUpdatesInterval = options?.checkForUpdatesInterval ?? 60;
private parasOptions(options?: ClientOptions): ClientOptions {
return {
cache: options?.cache ?? true,
cacheTime: options?.cacheTime ?? 300,
cacheMaxKeys: options?.cacheMaxKeys ?? -1,
cacheCheckPeriod: options?.cacheCheckPeriod ?? 180,
rateLimit: options?.rateLimit ?? 'AUTO',
silent: options?.silent ?? false,
checkForUpdates: options?.checkForUpdates ?? true,
checkForUpdatesInterval: options?.checkForUpdatesInterval ?? 60
};
}
}

Expand Down

0 comments on commit 1660539

Please sign in to comment.