From f05cf3f0d49f25fcfde9ac172c0643f17ce1d8ff Mon Sep 17 00:00:00 2001 From: Luke Childs Date: Thu, 15 Dec 2016 19:07:01 +0700 Subject: [PATCH] Only set cache if it's undefined Otherwise we waste time setting up NodeCache which may get overwritten by a custom cache option. --- src/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 5553cb7..ccd3d52 100644 --- a/src/index.js +++ b/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) => {