"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/node_modules/grim/lib/grim.js" (7 Feb 2017, 4799 Bytes) of archive /windows/misc/atom-windows.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Javascript source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 (function() {
    2   var Deprecation, Emitter, getRawStack, grim;
    3 
    4   Emitter = require('emissary').Emitter;
    5 
    6   Deprecation = require('./deprecation');
    7 
    8   if (global.__grim__ == null) {
    9     grim = global.__grim__ = {
   10       deprecations: {},
   11       includeDeprecatedAPIs: true,
   12       getDeprecations: function() {
   13         var deprecation, deprecations, deprecationsByLineNumber, deprecationsByPackage, fileName, lineNumber, packageName, _ref;
   14         deprecations = [];
   15         _ref = grim.deprecations;
   16         for (fileName in _ref) {
   17           deprecationsByLineNumber = _ref[fileName];
   18           for (lineNumber in deprecationsByLineNumber) {
   19             deprecationsByPackage = deprecationsByLineNumber[lineNumber];
   20             for (packageName in deprecationsByPackage) {
   21               deprecation = deprecationsByPackage[packageName];
   22               deprecations.push(deprecation);
   23             }
   24           }
   25         }
   26         return deprecations;
   27       },
   28       getDeprecationsLength: function() {
   29         return this.getDeprecations().length;
   30       },
   31       clearDeprecations: function() {
   32         grim.deprecations = {};
   33       },
   34       logDeprecations: function() {
   35         var deprecation, deprecations, _i, _len;
   36         deprecations = this.getDeprecations();
   37         deprecations.sort(function(a, b) {
   38           return b.getCallCount() - a.getCallCount();
   39         });
   40         console.warn("\nCalls to deprecated functions\n-----------------------------");
   41         for (_i = 0, _len = deprecations.length; _i < _len; _i++) {
   42           deprecation = deprecations[_i];
   43           console.warn("(" + (deprecation.getCallCount()) + ") " + (deprecation.getOriginName()) + " : " + (deprecation.getMessage()), deprecation);
   44         }
   45       },
   46       deprecate: function(message, metadata) {
   47         var deprecation, deprecationSite, error, fileName, lineNumber, originalStackTraceLimit, packageName, stack, _base, _base1, _base2, _ref, _ref1;
   48         originalStackTraceLimit = Error.stackTraceLimit;
   49         Error.stackTraceLimit = 7;
   50         error = new Error;
   51         Error.captureStackTrace(error);
   52         Error.stackTraceLimit = originalStackTraceLimit;
   53         stack = (_ref = typeof error.getRawStack === "function" ? error.getRawStack() : void 0) != null ? _ref : getRawStack(error);
   54         stack = stack.slice(1);
   55         deprecationSite = stack[0];
   56         fileName = deprecationSite.getFileName();
   57         lineNumber = deprecationSite.getLineNumber();
   58         packageName = (_ref1 = metadata != null ? metadata.packageName : void 0) != null ? _ref1 : "";
   59         if ((_base = grim.deprecations)[fileName] == null) {
   60           _base[fileName] = {};
   61         }
   62         if ((_base1 = grim.deprecations[fileName])[lineNumber] == null) {
   63           _base1[lineNumber] = {};
   64         }
   65         if ((_base2 = grim.deprecations[fileName][lineNumber])[packageName] == null) {
   66           _base2[packageName] = new Deprecation(message);
   67         }
   68         deprecation = grim.deprecations[fileName][lineNumber][packageName];
   69         deprecation.addStack(stack, metadata);
   70         grim.emit("updated", deprecation);
   71       },
   72       addSerializedDeprecation: function(serializedDeprecation) {
   73         var deprecation, fileName, lineNumber, message, packageName, stack, stacks, _base, _base1, _base2, _i, _len, _ref, _ref1, _ref2;
   74         deprecation = Deprecation.deserialize(serializedDeprecation);
   75         message = deprecation.getMessage();
   76         fileName = deprecation.fileName, lineNumber = deprecation.lineNumber;
   77         stacks = deprecation.getStacks();
   78         packageName = (_ref = (_ref1 = stacks[0]) != null ? (_ref2 = _ref1.metadata) != null ? _ref2.packageName : void 0 : void 0) != null ? _ref : "";
   79         if ((_base = grim.deprecations)[fileName] == null) {
   80           _base[fileName] = {};
   81         }
   82         if ((_base1 = grim.deprecations[fileName])[lineNumber] == null) {
   83           _base1[lineNumber] = {};
   84         }
   85         if ((_base2 = grim.deprecations[fileName][lineNumber])[packageName] == null) {
   86           _base2[packageName] = new Deprecation(message, fileName, lineNumber);
   87         }
   88         deprecation = grim.deprecations[fileName][lineNumber][packageName];
   89         for (_i = 0, _len = stacks.length; _i < _len; _i++) {
   90           stack = stacks[_i];
   91           deprecation.addStack(stack, stack.metadata);
   92         }
   93         grim.emit("updated", deprecation);
   94       }
   95     };
   96     Emitter.extend(grim);
   97   }
   98 
   99   getRawStack = function(error) {
  100     var originalPrepareStackTrace, result;
  101     originalPrepareStackTrace = Error.prepareStackTrace;
  102     Error.prepareStackTrace = function(error, stack) {
  103       return stack;
  104     };
  105     result = error.stack;
  106     Error.prepareStackTrace = originalPrepareStackTrace;
  107     return result;
  108   };
  109 
  110   module.exports = global.__grim__;
  111 
  112 }).call(this);