File tree Expand file tree Collapse file tree 4 files changed +22
-71
lines changed Expand file tree Collapse file tree 4 files changed +22
-71
lines changed Original file line number Diff line number Diff line change 3
3
4
4
* Drop support for Node.js 0.6
5
5
* Replace interal ` eval ` usage with ` Function ` constructor
6
+ * Use instance methods on ` process ` to check for listeners
6
7
7
8
1.1.2 / 2018-01-11
8
9
==================
Original file line number Diff line number Diff line change 8
8
* Module dependencies.
9
9
*/
10
10
11
- var eventListenerCount = require ( './lib/compat' ) . eventListenerCount
12
11
var relative = require ( 'path' ) . relative
13
12
14
13
/**
@@ -127,6 +126,26 @@ function depd (namespace) {
127
126
return deprecate
128
127
}
129
128
129
+ /**
130
+ * Determine if event emitter has listeners of a given type.
131
+ *
132
+ * The way to do this check is done three different ways in Node.js >= 0.8
133
+ * so this consolidates them into a minimal set using instance methods.
134
+ *
135
+ * @param {EventEmitter } emitter
136
+ * @param {string } type
137
+ * @returns {boolean }
138
+ * @private
139
+ */
140
+
141
+ function eehaslisteners ( emitter , type ) {
142
+ var count = typeof emitter . listenerCount !== 'function'
143
+ ? emitter . listeners ( type ) . length
144
+ : emitter . listenerCount ( type )
145
+
146
+ return count > 0
147
+ }
148
+
130
149
/**
131
150
* Determine if namespace is ignored.
132
151
*/
@@ -166,7 +185,7 @@ function istraced (namespace) {
166
185
*/
167
186
168
187
function log ( message , site ) {
169
- var haslisteners = eventListenerCount ( process , 'deprecation' ) !== 0
188
+ var haslisteners = eehaslisteners ( process , 'deprecation' )
170
189
171
190
// abort early if no destination
172
191
if ( ! haslisteners && this . _ignored ) {
Load Diff This file was deleted.
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments