@@ -109,12 +109,12 @@ printStackTrace.implementation.prototype = {
109109 */
110110 instrumentFunction : function ( context , functionName , callback ) {
111111 context = context || window ;
112- context [ '_old' + functionName ] = context [ functionName ] ;
113- context [ functionName ] = function ( ) {
114- callback . call ( this , printStackTrace ( ) ) ;
115- return context [ '_old' + functionName ] . apply ( this , arguments ) ;
112+ var original = context [ functionName ] ;
113+ context [ functionName ] = function instrumented ( ) {
114+ callback . call ( this , printStackTrace ( ) . slice ( 4 ) ) ;
115+ return context [ functionName ] . _instrumented . apply ( this , arguments ) ;
116116 } ;
117- context [ functionName ] . _instrumented = true ;
117+ context [ functionName ] . _instrumented = original ;
118118 } ,
119119
120120 /**
@@ -128,8 +128,8 @@ printStackTrace.implementation.prototype = {
128128 deinstrumentFunction : function ( context , functionName ) {
129129 if ( context [ functionName ] . constructor === Function &&
130130 context [ functionName ] . _instrumented &&
131- context [ '_old' + functionName ] . constructor === Function ) {
132- context [ functionName ] = context [ '_old' + functionName ] ;
131+ context [ functionName ] . _instrumented . constructor === Function ) {
132+ context [ functionName ] = context [ functionName ] . _instrumented ;
133133 }
134134 } ,
135135
@@ -140,7 +140,11 @@ printStackTrace.implementation.prototype = {
140140 * @return Array<String> of function calls, files and line numbers
141141 */
142142 chrome : function ( e ) {
143- return e . stack . replace ( / ^ [ ^ \( ] + ?[ \n $ ] / gm, '' ) . replace ( / ^ \s + a t \s + / gm, '' ) . replace ( / ^ O b j e c t .< a n o n y m o u s > \s * \( / gm, '{anonymous}()@' ) . split ( '\n' ) ;
143+ //return e.stack.replace(/^[^\(]+?[\n$]/gm, '').replace(/^\s+at\s+/gm, '').replace(/^Object.<anonymous>\s*\(/gm, '{anonymous}()@').split('\n');
144+ return e . stack . replace ( / ^ \S [ ^ \( ] + ?[ \n $ ] / gm, '' ) .
145+ replace ( / ^ \s + a t \s + / gm, '' ) .
146+ replace ( / ^ ( [ ^ \( ] + ?) ( [ \n $ ] ) / gm, '{anonymous}()@$1$2' ) .
147+ replace ( / ^ O b j e c t .< a n o n y m o u s > \s * \( ( [ ^ \) ] + ) \) / gm, '{anonymous}()@$1' ) . split ( '\n' ) ;
144148 } ,
145149
146150 /**
0 commit comments