Skip to content

Commit

Permalink
Add assertions to DictionaryCoder
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucas Wojciechowski committed Mar 31, 2016
1 parent 7b61aa9 commit 2bca561
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions js/source/worker_tile.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ WorkerTile.prototype.parse = function(data, layers, actor, rawTileData, callback
if (layer.minzoom && this.zoom < layer.minzoom) continue;
if (layer.maxzoom && this.zoom >= layer.maxzoom) continue;
if (layer.layout && layer.layout.visibility === 'none') continue;
if (data.layers && !data.layers[layer['source-layer']]) continue;

bucket = Bucket.create({
layer: layer,
Expand Down
4 changes: 4 additions & 0 deletions js/util/dictionary_coder.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict';

var assert = require('assert');

module.exports = DictionaryCoder;

function DictionaryCoder(strings) {
Expand All @@ -13,9 +15,11 @@ function DictionaryCoder(strings) {
}

DictionaryCoder.prototype.encode = function(string) {
assert(string in this._stringToNumber);
return this._stringToNumber[string];
};

DictionaryCoder.prototype.decode = function(n) {
assert(n < this._numberToString.length);
return this._numberToString[n];
};

0 comments on commit 2bca561

Please sign in to comment.