diff --git a/lib/mbtiles.js b/lib/mbtiles.js index 8dab716..d667b1c 100644 --- a/lib/mbtiles.js +++ b/lib/mbtiles.js @@ -101,6 +101,8 @@ MBTiles.prototype._exists = function(table, callback) { }; // DB integrity check. +// +// - @param {Function(err)} callback MBTiles.prototype._integrity = function(callback) { if (typeof callback !== 'function') callback = noop; @@ -108,12 +110,13 @@ MBTiles.prototype._integrity = function(callback) { if (!(row && row.integrity_check && row.integrity_check === 'ok')) { return callback(new Error('Corrupted database.')); } else { - return callback(null, true); + return callback(null); } }); }; // Setup schema, indices, views for a new mbtiles database. +// - @param {Function(err)} callback MBTiles.prototype._setup = function(callback) { var mbtiles = this; mbtiles._exists('tiles', function(err, exists) { @@ -130,7 +133,7 @@ MBTiles.prototype._setup = function(callback) { // - @param {Number} z tile z coordinate. // - @param {Number} x tile x coordinate. // - @param {Number} y tile y coordinate. -// - @param {Function} callback +// - @param {Function(err, grid, headers)} callback MBTiles.prototype.getTile = function(z, x, y, callback) { if (typeof callback !== 'function') throw new Error('Callback needed'); if (!this.open) return callback(new Error('MBTiles not yet loaded')); @@ -163,7 +166,7 @@ MBTiles.prototype.getTile = function(z, x, y, callback) { // - @param {Number} z tile z coordinate // - @param {Number} x tile x coordinate // - @param {Number} y tile y coordinate -// - @param {Function} callback +// - @param {Function(err, grid)} callback MBTiles.prototype.getGrid = function(z, x, y, callback) { if (typeof callback !== 'function') throw new Error('Callback needed'); if (!this.open) return callback(new Error('MBTiles not yet loaded')); @@ -226,9 +229,10 @@ MBTiles.prototype._metadata = function(key, callback) { }); }; -// Extend `MBTiles` class with an `info` method for retrieving metadata and -// performing fallback queries if certain keys (like `bounds`, `minzoom`, -// `maxzoom`) have not been provided. +// Obtain metadata from the database. Performing fallback queries if certain +// keys(like `bounds`, `minzoom`, `maxzoom`) have not been provided. +// +// - @param {Function(err, data)} callback MBTiles.prototype.getInfo = function(callback) { if (typeof callback !== 'function') throw new Error('Callback needed'); if (!this.open) return callback(new Error('MBTiles not yet loaded')); @@ -338,7 +342,7 @@ MBTiles.prototype.getInfo = function(callback) { // Puts the MBTiles tilestore into write mode. // -// - @param {Function} callback +// - @param {Function(err)} callback MBTiles.prototype.startWriting = function(callback) { if (typeof callback !== 'function') throw new Error('Callback needed'); if (!this.open) return callback(new Error('MBTiles not yet loaded')); @@ -364,7 +368,7 @@ MBTiles.prototype.startWriting = function(callback) { // (private) Commits the cached changes to the database. // -// - @param {Function} callback +// - @param {Function(err)} callback MBTiles.prototype._commit = function(callback) { var mbtiles = this; mbtiles._db.serialize(function() { @@ -453,7 +457,7 @@ MBTiles.prototype._commit = function(callback) { // Leaves write mode. // -// - @param {Function} callback +// - @param {Function(err)} callback MBTiles.prototype.stopWriting = function(callback) { if (typeof callback !== 'function') throw new Error('Callback needed'); if (!this.open) return callback(new Error('MBTiles not yet loaded')); @@ -476,7 +480,7 @@ MBTiles.prototype.stopWriting = function(callback) { // - @param {Number} x tile x coordinate // - @param {Number} y tile y coordinate // - @param {Buffer} buffer tile image data -// - @param {Function} callback +// - @param {Function(err)} callback MBTiles.prototype.putTile = function(z, x, y, data, callback) { if (typeof callback !== 'function') throw new Error('Callback needed'); if (!this.open) return callback(new Error('MBTiles not yet loaded')); @@ -509,7 +513,7 @@ MBTiles.prototype.putTile = function(z, x, y, data, callback) { // - @param {Number} x grid x coordinate // - @param {Number} y grid y coordinate // - @param {Object} data grid object -// - @param {Function} callback +// - @param {Function(err)} callback MBTiles.prototype.putGrid = function(z, x, y, data, callback) { if (typeof callback !== 'function') throw new Error('Callback needed'); if (!this.open) return callback(new Error('MBTiles not yet loaded'));