From 4739ebb0acf231a314eb1b0d8fd2a4b56192464b Mon Sep 17 00:00:00 2001 From: Ashok Date: Sat, 24 Mar 2018 17:57:57 +0530 Subject: [PATCH] add string support for connection.write --- lib/connection.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/connection.js b/lib/connection.js index f443a1c..c681c92 100644 --- a/lib/connection.js +++ b/lib/connection.js @@ -159,6 +159,7 @@ class Connection extends events.EventEmitter { } write (data, len, cb) { + if (typeof data === 'string') data = Buffer.from(data) if (typeof len === 'function') this._write(data, data.length, len) else if (!len) this._write(data, data.length, cb || noop) else this._write(data, len, cb || noop)