Skip to content

Commit

Permalink
slightly different strategy to determine isNode
Browse files Browse the repository at this point in the history
  • Loading branch information
HenrikJoreteg committed Jun 27, 2013
1 parent 6310d95 commit f7264a2
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions andlog.js
@@ -1,9 +1,8 @@
// follow @HenrikJoreteg and @andyet if you like this ;)
(function (window) {
var global = global || window,
ls = global && global.localStorage,
out = {},
inNode = !ls;
(function () {
var inNode = typeof window === 'undefined',
ls = !inNode && window.localStorage,
out = {};

if (inNode) {
module.exports = console;
Expand All @@ -16,7 +15,7 @@
var methods = "assert,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,markTimeline,profile,profileEnd,time,timeEnd,trace,warn".split(","),
l = methods.length,
fn = function () {};

while (l--) {
out[methods[l]] = fn;
}
Expand All @@ -26,4 +25,4 @@
} else {
window.console = out;
}
})(this);
})();

0 comments on commit f7264a2

Please sign in to comment.