File tree Expand file tree Collapse file tree 1 file changed +15
-8
lines changed Expand file tree Collapse file tree 1 file changed +15
-8
lines changed Original file line number Diff line number Diff line change 77 */
88
99var EventEmitter = function ( events ) {
10- this . events = events || [ ] ;
10+ var that = this ;
11+ that . _events = events || [ ] ;
1112} ;
1213EventEmitter . prototype . emit = function ( type ) {
1314 var that = this ;
15+ that . _verifyType ( type ) ;
16+ if ( that . _nuked ) return ;
17+
1418 var args = Array . prototype . slice . call ( arguments , 1 ) ;
15- if ( ! that . nuked && that [ 'on' + type ] ) {
19+ if ( that [ 'on' + type ] ) {
1620 that [ 'on' + type ] . apply ( that , args ) ;
1721 }
18- if ( utils . arrIndexOf ( that . events , type ) === - 1 ) {
22+ } ;
23+ EventEmitter . prototype . _verifyType = function ( type ) {
24+ var that = this ;
25+ if ( utils . arrIndexOf ( that . _events , type ) === - 1 ) {
1926 utils . log ( 'Event ' + JSON . stringify ( type ) +
20- ' not listed ' + JSON . stringify ( that . events ) +
27+ ' not listed ' + JSON . stringify ( that . _events ) +
2128 ' in ' + that ) ;
2229 }
2330} ;
2431
25- EventEmitter . prototype . nuke = function ( type ) {
32+ EventEmitter . prototype . nuke = function ( ) {
2633 var that = this ;
27- that . nuked = true ;
28- for ( var i = 0 ; i < that . events . length ; i ++ ) {
29- delete that [ that . events [ i ] ] ;
34+ that . _nuked = true ;
35+ for ( var i = 0 ; i < that . _events . length ; i ++ ) {
36+ delete that [ that . _events [ i ] ] ;
3037 }
3138} ;
You can’t perform that action at this time.
0 commit comments