@@ -507,6 +507,11 @@ if (typeof JSON !== 'object') {
507
507
*
508
508
* http://www.twitter.com/hij1nx
509
509
*
510
+ * Version: 2013-09-17
511
+ * GitHub SHA: 3caacce662998d7903d368b0c0f847f259cae0f7
512
+ * https://github.com/hij1nx/EventEmitter2
513
+ * Diff this version to master: https://github.com/hij1nx/EventEmitter2/compare/3caacce662998d7903d368b0c0f847f259cae0f7...master
514
+ *
510
515
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
511
516
* documentation files (the 'Software'), to deal in the Software without restriction, including without limitation
512
517
* the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
@@ -520,29 +525,39 @@ if (typeof JSON !== 'object') {
520
525
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
521
526
*
522
527
*/
523
- ! function ( exports , undefined ) {
528
+ ; ! function ( exports , undefined ) {
524
529
525
530
var isArray = Array . isArray ? Array . isArray : function _isArray ( obj ) {
526
531
return Object . prototype . toString . call ( obj ) === "[object Array]" ;
527
532
} ;
528
533
var defaultMaxListeners = 10 ;
529
534
530
535
function init ( ) {
531
- this . _events = new Object ;
536
+ this . _events = { } ;
537
+ if ( this . _conf ) {
538
+ configure . call ( this , this . _conf ) ;
539
+ }
532
540
}
533
541
534
542
function configure ( conf ) {
535
543
if ( conf ) {
544
+
545
+ this . _conf = conf ;
546
+
536
547
conf . delimiter && ( this . delimiter = conf . delimiter ) ;
548
+ conf . maxListeners && ( this . _events . maxListeners = conf . maxListeners ) ;
537
549
conf . wildcard && ( this . wildcard = conf . wildcard ) ;
550
+ conf . newListener && ( this . newListener = conf . newListener ) ;
551
+
538
552
if ( this . wildcard ) {
539
- this . listenerTree = new Object ;
553
+ this . listenerTree = { } ;
540
554
}
541
555
}
542
556
}
543
557
544
558
function EventEmitter ( conf ) {
545
- this . _events = new Object ;
559
+ this . _events = { } ;
560
+ this . newListener = false ;
546
561
configure . call ( this , conf ) ;
547
562
}
548
563
@@ -621,15 +636,15 @@ if (typeof JSON !== 'object') {
621
636
//
622
637
searchListenerTree ( handlers , type , xTree , i + 1 ) ;
623
638
}
624
-
639
+
625
640
xxTree = tree [ '**' ] ;
626
641
if ( xxTree ) {
627
642
if ( i < typeLength ) {
628
643
if ( xxTree . _listeners ) {
629
644
// If we have a listener on a '**', it will catch all, so add its handler.
630
645
searchListenerTree ( handlers , type , xxTree , typeLength ) ;
631
646
}
632
-
647
+
633
648
// Build arrays of matching next branches and others.
634
649
for ( branch in xxTree ) {
635
650
if ( branch !== '_listeners' && xxTree . hasOwnProperty ( branch ) ) {
@@ -660,7 +675,7 @@ if (typeof JSON !== 'object') {
660
675
function growListenerTree ( type , listener ) {
661
676
662
677
type = typeof type === 'string' ? type . split ( this . delimiter ) : type . slice ( ) ;
663
-
678
+
664
679
//
665
680
// Looks for two consecutive '**', if so, don't add the event at all.
666
681
//
@@ -676,7 +691,7 @@ if (typeof JSON !== 'object') {
676
691
while ( name ) {
677
692
678
693
if ( ! tree [ name ] ) {
679
- tree [ name ] = new Object ;
694
+ tree [ name ] = { } ;
680
695
}
681
696
682
697
tree = tree [ name ] ;
@@ -696,7 +711,7 @@ if (typeof JSON !== 'object') {
696
711
if ( ! tree . _listeners . warned ) {
697
712
698
713
var m = defaultMaxListeners ;
699
-
714
+
700
715
if ( typeof this . _events . maxListeners !== 'undefined' ) {
701
716
m = this . _events . maxListeners ;
702
717
}
@@ -717,7 +732,7 @@ if (typeof JSON !== 'object') {
717
732
name = type . shift ( ) ;
718
733
}
719
734
return true ;
720
- } ;
735
+ }
721
736
722
737
// By default EventEmitters will print a warning if more than
723
738
// 10 listeners are added to it. This is a useful default which
@@ -731,6 +746,8 @@ if (typeof JSON !== 'object') {
731
746
EventEmitter . prototype . setMaxListeners = function ( n ) {
732
747
this . _events || init . call ( this ) ;
733
748
this . _events . maxListeners = n ;
749
+ if ( ! this . _conf ) this . _conf = { } ;
750
+ this . _conf . maxListeners = n ;
734
751
} ;
735
752
736
753
EventEmitter . prototype . event = '' ;
@@ -752,7 +769,7 @@ if (typeof JSON !== 'object') {
752
769
self . off ( event , listener ) ;
753
770
}
754
771
fn . apply ( this , arguments ) ;
755
- } ;
772
+ }
756
773
757
774
listener . _origin = fn ;
758
775
@@ -762,11 +779,12 @@ if (typeof JSON !== 'object') {
762
779
} ;
763
780
764
781
EventEmitter . prototype . emit = function ( ) {
782
+
765
783
this . _events || init . call ( this ) ;
766
784
767
785
var type = arguments [ 0 ] ;
768
786
769
- if ( type === 'newListener' ) {
787
+ if ( type === 'newListener' && ! this . newListener ) {
770
788
if ( ! this . _events . newListener ) { return false ; }
771
789
}
772
790
@@ -783,9 +801,9 @@ if (typeof JSON !== 'object') {
783
801
784
802
// If there is no 'error' event listener then throw.
785
803
if ( type === 'error' ) {
786
-
787
- if ( ! this . _all &&
788
- ! this . _events . error &&
804
+
805
+ if ( ! this . _all &&
806
+ ! this . _events . error &&
789
807
! ( this . wildcard && this . listenerTree . error ) ) {
790
808
791
809
if ( arguments [ 1 ] instanceof Error ) {
@@ -849,7 +867,7 @@ if (typeof JSON !== 'object') {
849
867
} ;
850
868
851
869
EventEmitter . prototype . on = function ( type , listener ) {
852
-
870
+
853
871
if ( typeof type === 'function' ) {
854
872
this . onAny ( type ) ;
855
873
return this ;
@@ -885,7 +903,7 @@ if (typeof JSON !== 'object') {
885
903
if ( ! this . _events [ type ] . warned ) {
886
904
887
905
var m = defaultMaxListeners ;
888
-
906
+
889
907
if ( typeof this . _events . maxListeners !== 'undefined' ) {
890
908
m = this . _events . maxListeners ;
891
909
}
@@ -956,11 +974,11 @@ if (typeof JSON !== 'object') {
956
974
}
957
975
958
976
if ( position < 0 ) {
959
- return this ;
977
+ continue ;
960
978
}
961
979
962
980
if ( this . wildcard ) {
963
- leaf . _listeners . splice ( position , 1 )
981
+ leaf . _listeners . splice ( position , 1 ) ;
964
982
}
965
983
else {
966
984
this . _events [ type ] . splice ( position , 1 ) ;
@@ -974,6 +992,7 @@ if (typeof JSON !== 'object') {
974
992
delete this . _events [ type ] ;
975
993
}
976
994
}
995
+ return this ;
977
996
}
978
997
else if ( handlers === listener ||
979
998
( handlers . listener && handlers . listener === listener ) ||
@@ -1058,7 +1077,7 @@ if (typeof JSON !== 'object') {
1058
1077
1059
1078
} ;
1060
1079
1061
- // if (typeof define === 'function' && define.amd) {
1080
+ // if (typeof define === 'function' && define.amd) {
1062
1081
// define('EventEmitter2', [], function() {
1063
1082
// return EventEmitter;
1064
1083
// });
@@ -1068,8 +1087,9 @@ if (typeof JSON !== 'object') {
1068
1087
1069
1088
} ( typeof process !== 'undefined' && typeof process . title !== 'undefined' && typeof exports !== 'undefined' ? exports : window ) ;
1070
1089
1090
+
1071
1091
/*!
1072
- * F2 v1.3.1 10-15 -2013
1092
+ * F2 v1.4.0 10-17 -2013
1073
1093
* Copyright (c) 2013 Markit On Demand, Inc. http://www.openf2.org
1074
1094
*
1075
1095
* "F2" is licensed under the Apache License, Version 2.0 (the "License");
0 commit comments