Browse Source

Only set cache if it's undefined

Otherwise we waste time setting up NodeCache which may get overwritten by a custom cache option.
xo
Luke Childs 8 years ago
parent
commit
f05cf3f0d4
  1. 4
      src/index.js

4
src/index.js

@ -10,7 +10,6 @@ class Onionoo {
// Set default options
this.options = Object.assign({}, {
cache: new NodeCache(),
baseUrl: 'https://onionoo.torproject.org',
endpoints: [
'summary',
@ -21,6 +20,9 @@ class Onionoo {
'uptime'
]
}, options);
if(typeof this.options.cache == 'undefined') {
this.options.cache = new NodeCache();
}
// Return object containing endpoint methods
return this.options.endpoints.reduce((onionoo, endpoint) => {

Loading…
Cancel
Save