diff --git a/src/BrailleBuffer.js b/src/BrailleBuffer.js index d4ffd41..3d41253 100644 --- a/src/BrailleBuffer.js +++ b/src/BrailleBuffer.js @@ -113,9 +113,8 @@ export default class BrailleBuffer { } //TODO Optimize this part - var i, k; const results = []; - for (i = k = 1; k <= 255; i = ++k) { + for (let i = 1; i <= 255; i++) { const braille = (i & 7) + ((i & 56) << 1) + ((i & 64) >> 3) + (i & 128); results.push(this.asciiToBraille[i] = masks.reduce((function(best, mask) { const covered = utils.population(mask.mask & braille); diff --git a/src/Canvas.js b/src/Canvas.js index 5ede330..d4ca0b4 100644 --- a/src/Canvas.js +++ b/src/Canvas.js @@ -163,9 +163,8 @@ export default class Canvas { const b = this._bresenham(pointA, pointC); const c = this._bresenham(pointA, pointB); - const points = a.concat(b).concat(c).filter((point) => { - var ref; - return (0 <= (ref = point.y) && ref < this.height); + const points = a.concat(b).concat(c).filter(({y}) => { + return 0 <= y && y < this.height; }).sort(function(a, b) { if (a.y === b.y) { return a.x - b.x; diff --git a/src/Styler.js b/src/Styler.js index 551c822..4425727 100644 --- a/src/Styler.js +++ b/src/Styler.js @@ -13,7 +13,6 @@ export default class Styler { constructor(style) { this.styleById = {}; this.styleByLayer = {}; - var base, name; this.styleName = style.name; if (style.constants) { this._replaceConstants(style.constants, style.layers); @@ -30,10 +29,7 @@ export default class Styler { layer.appliesTo = this._compileFilter(layer.filter); - //TODO Better translation of: @styleByLayer[style['source-layer']] ?= [] - if ((base = this.styleByLayer)[name = layer['source-layer']] == null) { - base[name] = []; - } + this.styleByLayer[layer['source-layer']] ??= []; this.styleByLayer[layer['source-layer']].push(layer); this.styleById[layer.id] = layer; } diff --git a/src/Tile.js b/src/Tile.js index ea99360..cca3942 100644 --- a/src/Tile.js +++ b/src/Tile.js @@ -18,14 +18,10 @@ export default class Tile { this.styler = styler; } - load(buffer) { - return this._unzipIfNeeded(buffer).then((buffer) => { - return this._loadTile(buffer); - }).then(() => { - return this._loadLayers(); - }).then(() => { - return this; - }); + async load(buffer) { + const unzippedBuffer = await this._unzipIfNeeded(buffer); + await this._loadTile(unzippedBuffer); + await this._loadLayers(); } _loadTile(buffer) { diff --git a/src/TileSource.js b/src/TileSource.js index 97c6023..153921e 100644 --- a/src/TileSource.js +++ b/src/TileSource.js @@ -133,12 +133,13 @@ export default class TileSource { }); } - _createTile(z, x, y, buffer) { + async _createTile(z, x, y, buffer) { const name = [z, x, y].join('-'); this.cached.push(name); const tile = this.cache[name] = new Tile(this.styler); - return tile.load(buffer); + await tile.load(buffer); + return tile; } _initPersistence() {