debug-fabulous 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -10,9 +10,9 @@ Wrapper / Extension around [visionmedia's debug](https://github.com/visionmedia/
10
10
 
11
11
  ## Why would I consider using this library?
12
12
 
13
- One on the main utilities added to this library is lazy log level evaluation. This allows whatever log strings to only be created and evaluated if a log level is active. This can considerably reduce the amount of memory used in logging when you are not using.
13
+ The main utilities added to this library is lazy log level evaluation. This allows whatever logged strings to only be created and evaluated if a log level is active. This can considerably reduce the amount of memory used in logging when you are not using.
14
14
 
15
- This is important as this results in no-excuse for not using logging in your applications for performance reasons.
15
+ With this in mind, there are no excuses to not log anything and everything as performance can be kept in check easily (via log levels).
16
16
 
17
17
  ### Proof
18
18
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "debug-fabulous",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "visionmedia debug extensions rolled into one",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/src/lazy-eval.js CHANGED
@@ -16,28 +16,24 @@ function _resolveOutput(func, bindThis) {
16
16
  objectAssign(wrapped, func);
17
17
 
18
18
  return wrapped;
19
- };
20
-
19
+ }
21
20
 
22
21
  function wrapEval(_debug) {
23
-
24
22
  var debugOrig = _debug;
25
- var noop = function(){};
26
23
 
27
24
  function debug(namespace) {
28
-
25
+ function noop() {}
29
26
  var instance = debugOrig(namespace);
30
-
31
- // if we're not enabled then don't attempt to log anything
32
- // if a debug namespace wraps its debug in a closure then it never allocates anything but the function itself
33
- if (!instance.enabled){
27
+ /*
28
+ If we're not enabled then don't attempt to log anything.
29
+ Therefore when a debug namespace wraps its debug in a
30
+ closure then it never allocates anything but the function itself
31
+ */
32
+ if (!instance.enabled) {
34
33
  objectAssign(noop, instance);
35
- instance = noop;
36
- }
37
- else {
38
- instance = _resolveOutput(instance);
34
+ return noop;
39
35
  }
40
- return instance;
36
+ return _resolveOutput(instance);
41
37
  }
42
38
 
43
39
  var debugMemoized = memoize(debug);
package/src/spawn.js CHANGED
@@ -1,5 +1,4 @@
1
1
  function spawnFactory(_namespace, _debugFabFactory) {
2
- var memoize = require('memoizee');
3
2
  var namespace = _namespace || '';
4
3
  var debugFabFactory = _debugFabFactory;
5
4
 
@@ -7,6 +6,13 @@ function spawnFactory(_namespace, _debugFabFactory) {
7
6
  debugFabFactory = require('./debugFabFactory')();
8
7
  }
9
8
 
9
+ function spawn(ns) {
10
+ // this is this.debug (from Debugger)
11
+ var dbg = new Debugger(this.namespace, ns);
12
+
13
+ return dbg.debug;
14
+ };
15
+
10
16
  function Debugger(_base, _ns){
11
17
  var base = _base || '';
12
18
  var ns = _ns || '';
@@ -15,17 +21,9 @@ function spawnFactory(_namespace, _debugFabFactory) {
15
21
  var debug = debugFabFactory(newNs);
16
22
 
17
23
  this.debug = debug;
18
- this.debug.spawn = this.spawn;
24
+ this.debug.spawn = spawn;
19
25
  }
20
26
 
21
- Debugger.prototype.spawn = function(ns) {
22
- var dbg = new Debugger(this.namespace, ns);
23
-
24
- return dbg.debug;
25
- };
26
-
27
- Debugger.prototype.spawn = memoize(Debugger.prototype.spawn);
28
-
29
27
  var rootDebug = (new Debugger(namespace)).debug;
30
28
 
31
29
  return rootDebug;