Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

grim

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grim - npm Package Compare versions

Comparing version 0.8.0 to 0.9.0

lib/deprecation.js

70

lib/grim.js
(function() {
var Emitter, grim, _;
var Deprecation, Emitter, grim, _;

@@ -8,27 +8,24 @@ _ = require('underscore-plus');

global.__grimlog__ = {};
Deprecation = require('./deprecation');
global.__grimDeprecations__ = [];
grim = {
getLog: function() {
return global.__grimlog__;
getDeprecations: function() {
return _.clone(global.__grimDeprecations__);
},
clearLog: function() {
return global.__grimlog__ = {};
clearDeprecations: function() {
return global.__grimDeprecations__ = [];
},
logDeprecationWarnings: function() {
var metadata, method, warnings, _i, _len, _ref, _ref1, _results;
warnings = [];
_ref = grim.getLog();
for (method in _ref) {
metadata = _ref[method];
warnings.push([method, metadata]);
}
warnings.sort(function(a, b) {
return b[1].count - a[1].count;
logDeprecations: function() {
var deprecation, deprecations, _i, _len, _results;
deprecations = grim.getDeprecations();
deprecations.sort(function(a, b) {
return b.getCallCount() - a.getCallCount();
});
console.warn("\nCalls to deprecated functions\n-----------------------------");
_results = [];
for (_i = 0, _len = warnings.length; _i < _len; _i++) {
_ref1 = warnings[_i], method = _ref1[0], metadata = _ref1[1];
_results.push(console.warn("(" + metadata.count + ") " + method + " : " + metadata.message, metadata));
for (_i = 0, _len = deprecations.length; _i < _len; _i++) {
deprecation = deprecations[_i];
_results.push(console.warn("(" + (deprecation.getCallCount()) + ") " + (deprecation.getOriginName()) + " : " + (deprecation.getMessage()), deprecation));
}

@@ -38,29 +35,12 @@ return _results;

deprecate: function(message) {
var all, count, e, metadata, method, stackLines, trace, x, _base, _ref;
try {
throw new Error("Deprecated Method");
} catch (_error) {
e = _error;
stackLines = e.stack.split("\n");
_ref = stackLines[2].match(/^\s*at\s*(\S+)/), all = _ref[0], method = _ref[1];
var deprecation, methodName, stack;
stack = Deprecation.generateStack().slice(1);
methodName = Deprecation.getFunctionNameFromCallsite(stack[0]);
if (!(deprecation = global.__grimDeprecations__.find(function(d) {
return d.getOriginName() === methodName;
}))) {
deprecation = new Deprecation(message);
global.__grimDeprecations__.push(deprecation);
}
metadata = (_base = grim.getLog())[method] != null ? _base[method] : _base[method] = {
message: message,
count: 0,
stackTraces: []
};
metadata.count++;
x = _.find(metadata.stackTraces, function(_arg) {
var count, trace;
trace = _arg[0], count = _arg[1];
return trace === e.stack;
});
if (x) {
trace = x[0], count = x[1];
}
if (trace == null) {
trace = e.stack;
count = 0;
}
metadata.stackTraces.push([trace, count++]);
deprecation.addStack(stack);
return grim.emit("updated");

@@ -67,0 +47,0 @@ }

{
"name": "grim",
"version": "0.8.0",
"version": "0.9.0",
"description": "Log usage of deprecated methods",

@@ -5,0 +5,0 @@ "main": "./lib/grim",

@@ -1,3 +0,3 @@

# grim
# Grim [![Build Status](https://magnum.travis-ci.com/atom/grim.svg?token=wKV9hrS79m2qMyqpNvUo&branch=master)](https://travis-ci.org/atom/grim)
Log usage of deprecated methods
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc