tapjs/tap-parser

patch: avoid buffer() warning

Closed this issue · 2 comments

Hi,

Could you apply this patch:

commit 729896839052e98a07c71a9088a9f5ccce1b2700
Author: Bastien Roucariès <rouca@debian.org>
Date:   Mon Jan 7 00:17:20 2019 +0100

    Avoid buffer() warning

diff --git a/index.js b/index.js
index 43a0417..49eb90f 100644
--- a/index.js
+++ b/index.js
@@ -323,7 +323,7 @@ class Parser extends MiniPass {
       return
 
     if (typeof encoding === 'string' && encoding !== 'utf8')
-      chunk = new Buffer(chunk, encoding)
+      chunk = new Buffer.from(chunk, encoding)
 
     if (Buffer.isBuffer(chunk))
       chunk += ''
diff --git a/test/basic.js b/test/basic.js
index 58110b1..cf7b847 100644
--- a/test/basic.js
+++ b/test/basic.js
@@ -14,13 +14,13 @@ t.test('end() can take chunk', function (t) {
   })
   t.test('encoding', function (t) {
     var p = new Parser()
-    p.end(new Buffer('1..0\n').toString('hex'), 'hex',  t.end)
+    p.end(new Buffer.from('1..0\n').toString('hex'), 'hex',  t.end)
   })
 })
 
 t.test('takes a buffer just fine', function (t) {
   var p = new Parser(theEnd)
-  p.write(new Buffer('TAP version 13\n'))
+  p.write(new Buffer.from('TAP version 13\n'))
 
   var calledme = false
   function callme () {

Would you mind opening a PR?

Fixed by 1734727