debug-proxy
Advanced tools
Comparing version 0.1.1 to 0.1.2
@@ -1,6 +0,5 @@ | ||
/* jshint browser:true, node:true */ | ||
/* jshint browser:true, node:true, unused:true */ | ||
'use strict'; | ||
var loading = false; | ||
var loaded = false; | ||
var listeners = []; | ||
@@ -10,3 +9,3 @@ var debug; | ||
function enableDebugging() { | ||
var loading = true; | ||
loading = true; | ||
require.ensure(['debug'], function(require) { | ||
@@ -41,15 +40,8 @@ debug = require('debug'); | ||
module.exports = function debugProxy(namespace) { | ||
function debugProxy(namespace) { | ||
var backend; | ||
if (debug) { | ||
return debug(namespace); | ||
} | ||
listeners.push(function() { | ||
backend = debug(namespace); | ||
}); | ||
return function() { | ||
var fn = function() { | ||
if (backend) { | ||
// Backend is loaded, just use it | ||
backend.apply(backend, arguments); | ||
@@ -60,6 +52,25 @@ } else if(loading) { | ||
listeners.push(function() { | ||
backend.apply(backend, arguments); | ||
backend.apply(backend, args); | ||
}); | ||
} | ||
}; | ||
listeners.push(function() { | ||
// Backend has been loaded, switch to it | ||
backend = debug(namespace); | ||
fn.enabled = backend.enabled; | ||
}); | ||
fn.enabled = loading; // Technically this isn't totally correct as debug may filter | ||
// this level out once the backend has started | ||
return fn; | ||
} | ||
module.exports = function(namespace) { | ||
if (debug) { | ||
return debug(namespace); | ||
} | ||
return debugProxy(namespace); | ||
}; |
{ | ||
"name": "debug-proxy", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "Client side proxy for visionmedia/debug to allow delayed loading", | ||
@@ -5,0 +5,0 @@ "main": "sync-debug.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3043
63