1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
|
(function() {
var Deprecation, SourceMapCache;
SourceMapCache = {};
module.exports = Deprecation = (function() {
Deprecation.getFunctionNameFromCallsite = function(callsite) {};
Deprecation.deserialize = function(_arg) {
var deprecation, fileName, lineNumber, message, stack, stacks, _i, _len;
message = _arg.message, fileName = _arg.fileName, lineNumber = _arg.lineNumber, stacks = _arg.stacks;
deprecation = new Deprecation(message, fileName, lineNumber);
for (_i = 0, _len = stacks.length; _i < _len; _i++) {
stack = stacks[_i];
deprecation.addStack(stack, stack.metadata);
}
return deprecation;
};
function Deprecation(message, fileName, lineNumber) {
this.message = message;
this.fileName = fileName;
this.lineNumber = lineNumber;
this.callCount = 0;
this.stackCount = 0;
this.stacks = {};
this.stackCallCounts = {};
}
Deprecation.prototype.getFunctionNameFromCallsite = function(callsite) {
var _ref, _ref1, _ref2;
if (callsite.functionName != null) {
return callsite.functionName;
}
if (callsite.isToplevel()) {
return (_ref = callsite.getFunctionName()) != null ? _ref : '<unknown>';
} else {
if (callsite.isConstructor()) {
return "new " + (callsite.getFunctionName());
} else if (callsite.getMethodName() && !callsite.getFunctionName()) {
return callsite.getMethodName();
} else {
return "" + (callsite.getTypeName()) + "." + ((_ref1 = (_ref2 = callsite.getMethodName()) != null ? _ref2 : callsite.getFunctionName()) != null ? _ref1 : '<anonymous>');
}
}
};
Deprecation.prototype.getLocationFromCallsite = function(callsite) {
var column, fileName, line;
if (callsite.location != null) {
return callsite.location;
}
if (callsite.isNative()) {
return "native";
} else if (callsite.isEval()) {
return "eval at " + (this.getLocationFromCallsite(callsite.getEvalOrigin()));
} else {
fileName = callsite.getFileName();
line = callsite.getLineNumber();
column = callsite.getColumnNumber();
return "" + fileName + ":" + line + ":" + column;
}
};
Deprecation.prototype.getFileNameFromCallSite = function(callsite) {
var _ref;
return (_ref = callsite.fileName) != null ? _ref : callsite.getFileName();
};
Deprecation.prototype.getOriginName = function() {
return this.originName;
};
Deprecation.prototype.getMessage = function() {
return this.message;
};
Deprecation.prototype.getStacks = function() {
var location, parsedStack, parsedStacks, stack, _ref;
parsedStacks = [];
_ref = this.stacks;
for (location in _ref) {
stack = _ref[location];
parsedStack = this.parseStack(stack);
parsedStack.callCount = this.stackCallCounts[location];
parsedStack.metadata = stack.metadata;
parsedStacks.push(parsedStack);
}
return parsedStacks;
};
Deprecation.prototype.getStackCount = function() {
return this.stackCount;
};
Deprecation.prototype.getCallCount = function() {
return this.callCount;
};
Deprecation.prototype.addStack = function(stack, metadata) {
var callerLocation, _base, _base1;
if (this.originName == null) {
this.originName = this.getFunctionNameFromCallsite(stack[0]);
}
if (this.fileName == null) {
this.fileName = this.getFileNameFromCallSite(stack[0]);
}
if (this.lineNumber == null) {
this.lineNumber = typeof (_base = stack[0]).getLineNumber === "function" ? _base.getLineNumber() : void 0;
}
this.callCount++;
stack.metadata = metadata;
callerLocation = this.getLocationFromCallsite(stack[1]);
if (this.stacks[callerLocation] == null) {
this.stacks[callerLocation] = stack;
this.stackCount++;
}
if ((_base1 = this.stackCallCounts)[callerLocation] == null) {
_base1[callerLocation] = 0;
}
return this.stackCallCounts[callerLocation]++;
};
Deprecation.prototype.parseStack = function(stack) {
return stack.map((function(_this) {
return function(callsite) {
return {
functionName: _this.getFunctionNameFromCallsite(callsite),
location: _this.getLocationFromCallsite(callsite),
fileName: _this.getFileNameFromCallSite(callsite)
};
};
})(this));
};
Deprecation.prototype.serialize = function() {
return {
message: this.getMessage(),
lineNumber: this.lineNumber,
fileName: this.fileName,
stacks: this.getStacks()
};
};
return Deprecation;
})();
}).call(this);
|