After ESLint in TileSource

This commit is contained in:
Christian Paul 2017-12-23 00:07:23 -08:00
parent 1369140af4
commit 088b9a3b71

View File

@ -20,11 +20,7 @@ const config = require('./config');
let MBTiles = null; let MBTiles = null;
try { try {
MBTiles = require('mbtiles'); MBTiles = require('mbtiles');
} catch (err) {} } catch (err) {void 0;}
const cache = {};
const cacheSize = 16;
const cached = [];
const modes = { const modes = {
MBTiles: 1, MBTiles: 1,
@ -53,13 +49,13 @@ class TileSource {
} else if (this.source.endsWith('.mbtiles')) { } else if (this.source.endsWith('.mbtiles')) {
if (!MBTiles) { if (!MBTiles) {
throw new Error("MBTiles support must be installed with following command: 'npm install -g mbtiles'"); throw new Error('MBTiles support must be installed with following command: \'npm install -g mbtiles\'');
} }
this.mode = modes.MBTiles; this.mode = modes.MBTiles;
this.loadMBtils(source); this.loadMBtils(source);
} else { } else {
throw new Error("source type isn't supported yet"); throw new Error('source type isn\'t supported yet');
} }
} }
@ -81,10 +77,10 @@ class TileSource {
getTile(z, x, y) { getTile(z, x, y) {
if (!this.mode) { if (!this.mode) {
throw new Error("no TileSource defined"); throw new Error('no TileSource defined');
} }
const cached = this.cache[[z, x, y].join("-")]; const cached = this.cache[[z, x, y].join('-')];
if (cached) { if (cached) {
return Promise.resolve(cached); return Promise.resolve(cached);
} }
@ -172,7 +168,7 @@ class TileSource {
fs.mkdirSync(path); fs.mkdirSync(path);
return true; return true;
} catch (error) { } catch (error) {
return error.code === "EEXIST"; return error.code === 'EEXIST';
} }
} }
} }