]>
git.r.bdr.sh - rbdr/dotfiles/blob - atom/packages/ex-mode/node_modules/event-kit/node_modules/grim/lib/grim.js
eee1d91cffb8fbd5bd003bd9db1d378f3992e3cc
2 var Deprecation
, Emitter
, grim
, _
;
4 _
= require('underscore-plus');
6 Emitter
= require('emissary').Emitter
;
8 Deprecation
= require('./deprecation');
10 if (global
.__grim__
== null) {
11 grim
= global
.__grim__
= {
13 maxDeprecationCallCount: function() {
16 getDeprecations: function() {
17 return _
.clone(grim
.grimDeprecations
);
19 getDeprecationsLength: function() {
20 return grim
.grimDeprecations
.length
;
22 clearDeprecations: function() {
23 return grim
.grimDeprecations
= [];
25 logDeprecations: function() {
26 var deprecation
, deprecations
, _i
, _len
, _results
;
27 deprecations
= grim
.getDeprecations();
28 deprecations
.sort(function(a
, b
) {
29 return b
.getCallCount() - a
.getCallCount();
31 console
.warn("\nCalls to deprecated functions\n-----------------------------");
33 for (_i
= 0, _len
= deprecations
.length
; _i
< _len
; _i
++) {
34 deprecation
= deprecations
[_i
];
35 _results
.push(console
.warn("(" + (deprecation
.getCallCount()) + ") " + (deprecation
.getOriginName()) + " : " + (deprecation
.getMessage()), deprecation
));
39 deprecate: function(message
) {
40 var deprecation
, deprecations
, methodName
, stack
;
41 stack
= Deprecation
.generateStack().slice(1);
42 methodName
= Deprecation
.getFunctionNameFromCallsite(stack
[0]);
43 deprecations
= grim
.grimDeprecations
;
44 if (!(deprecation
= _
.find(deprecations
, function(d
) {
45 return d
.getOriginName() === methodName
;
47 deprecation
= new Deprecation(message
);
48 grim
.grimDeprecations
.push(deprecation
);
50 if (deprecation
.getCallCount() < grim
.maxDeprecationCallCount()) {
51 deprecation
.addStack(stack
);
52 return grim
.emit("updated", deprecation
);
59 module
.exports
= global
.__grim__
;