aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHolden Rohrer <hr@hrhr.dev>2020-01-24 15:34:10 -0500
committerHolden Rohrer <hr@hrhr.dev>2020-01-24 15:34:10 -0500
commit8cb88f2ccf8d4487af74ba5f6c9e81a7dc306c54 (patch)
tree695db8906bbff07e8518d12d3d5d6e52574e2ba7
parent46d56620c3ba385bdd41bc391c975e4934b4c82d (diff)
wwrap can be used for socket extension
-rw-r--r--utils/writewrap.js13
1 files changed, 6 insertions, 7 deletions
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;