diff options
author | Florrie <towerofnix@gmail.com> | 2018-05-29 09:59:01 -0300 |
---|---|---|
committer | Florrie <towerofnix@gmail.com> | 2018-05-29 09:59:01 -0300 |
commit | 7c28e5c072ca27e6f2fc4a488c32718514aad924 (patch) | |
tree | 2af00ef680fd9bde46c7b9b8dc0ab9eb890d705a /index.js | |
parent | b64a14b761a38da13b81370828a2d5e9ad68c330 (diff) |
Move cache stuff to downloaders.js
Diffstat (limited to 'index.js')
-rw-r--r-- | index.js | 32 |
1 files changed, 2 insertions, 30 deletions
diff --git a/index.js b/index.js index 6edbd01..a3b4b9f 100644 --- a/index.js +++ b/index.js @@ -5,36 +5,8 @@ const { getDownloaderFor } = require('./downloaders') const EventEmitter = require('events') class InternalApp extends EventEmitter { - constructor() { - super() - - // downloadCache [downloaderFunction] [downloaderArg] - this.downloadCache = new Map() - } - - async download(arg) { - const downloader = getDownloaderFor(arg) - if (this.downloadCache.has(downloader)) { - const category = this.downloadCache.get(downloader) - if (category.hasOwnProperty(arg)) { - return category[arg] - } - } - - const ret = await this.downloadIgnoringCache(arg) - - if (!this.downloadCache.has(downloader)) { - this.downloadCache.set(downloader, {}) - } - - this.downloadCache.get(downloader)[arg] = ret - - return ret - } - - downloadIgnoringCache(arg) { - const downloader = getDownloaderFor(arg) - return downloader(arg) + download(arg) { + return getDownloaderFor(arg)(arg) } } |