nmccready / angular-simple-logger

Basic logger with level logging which can also be independent.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

angular-simple-logger is polluting the global namespace with local variables

Lavan opened this issue · comments

While looking at #13 I also noticed that many local variables in this package are accessible globally.

In the following method both key and val become global variables.

    _isValidLogObject = function(logObject) {
      var isValid;
      isValid = false;
      if (!logObject) {
        return isValid;
      }
      for (key in _fns) {
        val = _fns[key];
        isValid = (logObject[val] != null) && typeof logObject[val] === 'function';
        if (!isValid) {
          break;
        }
      }
      return isValid;
    };

As the default settings for CoffeeScript seems to be to generate local variables (with var statements) and from what I can see you haven't specified any strange options, I have no idea how it ends up like this here.

Which version? The new releases are wrapped in a closure.

The meteor version.

Does meteor use CommonJS, if so I can point it to the index.js version. Also which release can you make an example showing the global variable problem? I can test against that. Or better yet add specs to test the specific release and check for globals.

Apparently I must be seeing things/be too tired. Well, actually I didn't step far enough out of your code to see that the "pollution" actually didn't occur. The calling module ALSO had variables called key and val which caused me into thinking your code was the culprit. Meh, sorry about that.

TY for digging deeper.