TileRequestHandler.prototype.use = function(plugin) { if (!plugin) returnthis; // ...简化后的代码 if (plugin.reshook) returnthis._registerResponseHook(plugin); };
TileRequestHandler.prototype._registerResponseHook = function(plugin) { var id = "reshook#" + this.responseHooks.length; if (!plugin) thrownewError("Falsy value passed to registerResponseHook()"); if (typeof plugin.reshook !== "function") thrownewError( "Attempted to register a response hook with no reshook() method" ); this.responseHooks.push({ id: id, plugin: plugin }); returnthis; };