Skip to content

Commit 662a766

Browse files
committed
Replace removeListener() with off()
1 parent 042d3e2 commit 662a766

File tree

3 files changed

+4
-10
lines changed

3 files changed

+4
-10
lines changed

src/main.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,7 @@ const stopLogging = function(listeners) {
5454
}
5555

5656
const removeListener = function({ eventListener, name }) {
57-
// TODO: use `process.off()` instead of `process.removeListener()`
58-
// after dropping Node.js <10 support
59-
process.removeListener(name, eventListener)
57+
process.off(name, eventListener)
6058
}
6159

6260
// We do not use `export default` because Babel transpiles it in a way that

src/warnings.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const removeWarningListener = function() {
1212
}
1313

1414
// This will be a noop if `init()` is called several times
15-
process.removeListener('warning', warningListener)
15+
process.off('warning', warningListener)
1616
}
1717

1818
// When this module is undone, Node.js default `warning` listener is restored

test/main/init.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,7 @@ each(EVENTS, ({ title }, { eventName, emit, defaultLevel }) => {
5555

5656
stopLogging()
5757

58-
// TODO: use `process.off()` instead of `process.removeListener()`
59-
// after dropping Node.js <10 support
60-
process.removeListener(eventName, processHandler)
58+
process.off(eventName, processHandler)
6159
},
6260
)
6361

@@ -77,8 +75,6 @@ each(EVENTS, ({ title }, { eventName, emit, defaultLevel }) => {
7775

7876
stopLogging()
7977

80-
// TODO: use `process.off()` instead of `process.removeListener()`
81-
// after dropping Node.js <10 support
82-
process.removeListener(eventName, processHandler)
78+
process.off(eventName, processHandler)
8379
})
8480
})

0 commit comments

Comments
 (0)