Skip to content

Commit

Permalink
better options
Browse files Browse the repository at this point in the history
  • Loading branch information
Kathund committed Aug 22, 2024
1 parent c3fac33 commit e27d3e9
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions src/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ class Client {

constructor(key: string, options?: ClientOptions) {
this.key = key;
this.parasOptions(options);
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 @@ -72,17 +72,15 @@ class Client {
if (this.rateLimit.interval) clearInterval(this.rateLimit.interval);
}

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
};
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;
}
}

Expand Down

0 comments on commit e27d3e9

Please sign in to comment.