Use blocked scoped variables
In addition to using const and let, this also upgrades our linter config and removes lint (mostly whitespace).
This commit is contained in:
@@ -16,24 +16,24 @@ import PriorityQueue from './structs/PriorityQueue.js';
|
||||
* Function called on each tile change event.
|
||||
* @struct
|
||||
*/
|
||||
var TileQueue = function(tilePriorityFunction, tileChangeCallback) {
|
||||
const TileQueue = function(tilePriorityFunction, tileChangeCallback) {
|
||||
|
||||
PriorityQueue.call(
|
||||
this,
|
||||
/**
|
||||
this,
|
||||
/**
|
||||
* @param {Array} element Element.
|
||||
* @return {number} Priority.
|
||||
*/
|
||||
function(element) {
|
||||
return tilePriorityFunction.apply(null, element);
|
||||
},
|
||||
/**
|
||||
function(element) {
|
||||
return tilePriorityFunction.apply(null, element);
|
||||
},
|
||||
/**
|
||||
* @param {Array} element Element.
|
||||
* @return {string} Key.
|
||||
*/
|
||||
function(element) {
|
||||
return /** @type {ol.Tile} */ (element[0]).getKey();
|
||||
});
|
||||
function(element) {
|
||||
return /** @type {ol.Tile} */ (element[0]).getKey();
|
||||
});
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -62,11 +62,11 @@ inherits(TileQueue, PriorityQueue);
|
||||
* @inheritDoc
|
||||
*/
|
||||
TileQueue.prototype.enqueue = function(element) {
|
||||
var added = PriorityQueue.prototype.enqueue.call(this, element);
|
||||
const added = PriorityQueue.prototype.enqueue.call(this, element);
|
||||
if (added) {
|
||||
var tile = element[0];
|
||||
const tile = element[0];
|
||||
_ol_events_.listen(tile, EventType.CHANGE,
|
||||
this.handleTileChange, this);
|
||||
this.handleTileChange, this);
|
||||
}
|
||||
return added;
|
||||
};
|
||||
@@ -85,13 +85,13 @@ TileQueue.prototype.getTilesLoading = function() {
|
||||
* @protected
|
||||
*/
|
||||
TileQueue.prototype.handleTileChange = function(event) {
|
||||
var tile = /** @type {ol.Tile} */ (event.target);
|
||||
var state = tile.getState();
|
||||
const tile = /** @type {ol.Tile} */ (event.target);
|
||||
const state = tile.getState();
|
||||
if (state === TileState.LOADED || state === TileState.ERROR ||
|
||||
state === TileState.EMPTY || state === TileState.ABORT) {
|
||||
_ol_events_.unlisten(tile, EventType.CHANGE,
|
||||
this.handleTileChange, this);
|
||||
var tileKey = tile.getKey();
|
||||
this.handleTileChange, this);
|
||||
const tileKey = tile.getKey();
|
||||
if (tileKey in this.tilesLoadingKeys_) {
|
||||
delete this.tilesLoadingKeys_[tileKey];
|
||||
--this.tilesLoading_;
|
||||
@@ -106,9 +106,9 @@ TileQueue.prototype.handleTileChange = function(event) {
|
||||
* @param {number} maxNewLoads Maximum number of new tiles to load.
|
||||
*/
|
||||
TileQueue.prototype.loadMoreTiles = function(maxTotalLoading, maxNewLoads) {
|
||||
var newLoads = 0;
|
||||
var abortedTiles = false;
|
||||
var state, tile, tileKey;
|
||||
let newLoads = 0;
|
||||
let abortedTiles = false;
|
||||
let state, tile, tileKey;
|
||||
while (this.tilesLoading_ < maxTotalLoading && newLoads < maxNewLoads &&
|
||||
this.getCount() > 0) {
|
||||
tile = /** @type {ol.Tile} */ (this.dequeue()[0]);
|
||||
|
||||
Reference in New Issue
Block a user