From 8cb88f2ccf8d4487af74ba5f6c9e81a7dc306c54 Mon Sep 17 00:00:00 2001 From: Holden Rohrer Date: Fri, 24 Jan 2020 15:34:10 -0500 Subject: wwrap can be used for socket extension --- utils/writewrap.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'utils') diff --git a/utils/writewrap.js b/utils/writewrap.js index 3ca7ede..2e2ae07 100644 --- a/utils/writewrap.js +++ b/utils/writewrap.js @@ -1,12 +1,11 @@ // An EventEmitter wrapper for socket.js writes const EventEmitter = require('events'); -class wwrap extends EventEmitter{ - constructor(socket){ - super(); - socket.on('write', (acc) => { // Assumed that none are rejected because I've never seen it - for (let w of acc) this.emit(w); - }); - } +function wwrap(){ // should be called with wwrap.call(socket) + let self = this; + self.on('write', (acc) => { + for (let w of acc) this.emit(w); + }); } + module.exports = wwrap; -- cgit