@@ -36,27 +36,30 @@ tape('once', function (t) {
3636 t . end ( )
3737} )
3838
39- tape ( 'prepend once' , function ( t ) {
40- var target = new events . EventEmitter ( )
41- var proxy = new EventProxy ( target )
42- var count = 0
43- target . addListener ( 'hello' , function ( ) {
44- count += 1
45- } )
46- proxy . addListener ( 'hello' , function ( ) {
47- count += 2
48- } )
49- var addResult = proxy . prependOnceListener ( 'hello' , function ( data ) {
50- t . equals ( count , 1 , 'event called once, before the listeners on proxy, after the listeners on target' )
51- t . equals ( data , 'world' , 'data passed through' )
52- count += 1
39+ // Node 4 compatibility
40+ if ( events . EventEmitter . prototype . prependOnceListener ) {
41+ tape ( 'prepend once' , function ( t ) {
42+ var target = new events . EventEmitter ( )
43+ var proxy = new EventProxy ( target )
44+ var count = 0
45+ target . addListener ( 'hello' , function ( ) {
46+ count += 1
47+ } )
48+ proxy . addListener ( 'hello' , function ( ) {
49+ count += 2
50+ } )
51+ var addResult = proxy . prependOnceListener ( 'hello' , function ( data ) {
52+ t . equals ( count , 1 , 'event called once, before the listeners on proxy, after the listeners on target' )
53+ t . equals ( data , 'world' , 'data passed through' )
54+ count += 1
55+ } )
56+ t . equals ( addResult , proxy , 'Result of prepend once is proxy instance' )
57+ target . emit ( 'hello' , 'world' )
58+ target . emit ( 'hello' , 'mundo' )
59+ t . equals ( count , 7 )
60+ t . end ( )
5361 } )
54- t . equals ( addResult , proxy , 'Result of prepend once is proxy instance' )
55- target . emit ( 'hello' , 'world' )
56- target . emit ( 'hello' , 'mundo' )
57- t . equals ( count , 7 )
58- t . end ( )
59- } )
62+ }
6063
6164tape ( 'remove all listeners' , function ( t ) {
6265 var target = new events . EventEmitter ( )
0 commit comments