Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A minimal tilelive source.
"use strict";
/**
* Note:
*
* setImmediate(callback, null, {});
*
* is shorthand for:
*
* setImmediate(function() {
* return callback(null, {});
* });
*
* (setImmediate() is used to preserve the contract that these are async calls;
* if your output is the result of an async call, it's not necessary.)
*/
/**
* A minimal tilelive source.
*/
module.exports = function(tilelive, options) {
var Minimal = function(uri, callback) {
return setImmediate(callback, null, this);
};
Minimal.prototype.getTile = function(z, x, y, callback) {
return setImmediate(callback, null, JSON.stringify({
hello: "world"
}), {
"Content-Type": "application/json"
});
};
Minimal.prototype.getInfo = function(callback) {
return setImmediate(callback, null, {});
};
Minimal.prototype.close = function(callback) {
return callback && setImmediate(callback);
};
Minimal.registerProtocols = function(tilelive) {
tilelive.protocols["minimal:"] = Minimal;
};
Minimal.registerProtocols(tilelive);
return Minimal;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment