From c768eb81ffd83a15aade35765f0fd563cc1b0b13 Mon Sep 17 00:00:00 2001 From: Nathan Woltman Date: Tue, 23 Oct 2018 11:12:29 -0400 Subject: [PATCH] Use Buffer.from() in the documentation Use `Buffer.from()` instead of `new Buffer()` because the Buffer constructor is deprecated. --- README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 5f2b341..131f5e3 100644 --- a/README.md +++ b/README.md @@ -15,11 +15,11 @@ The original buffers are kept intact and copies are only done as necessary. Any const BufferList = require('bl') var bl = new BufferList() -bl.append(new Buffer('abcd')) -bl.append(new Buffer('efg')) +bl.append(Buffer.from('abcd')) +bl.append(Buffer.from('efg')) bl.append('hi') // bl will also accept & convert Strings -bl.append(new Buffer('j')) -bl.append(new Buffer([ 0x3, 0x4 ])) +bl.append(Buffer.from('j')) +bl.append(Buffer.from([ 0x3, 0x4 ])) console.log(bl.length) // 12 @@ -72,10 +72,10 @@ const BufferList = require('bl') , fs = require('fs') var bl = new BufferList() -bl.append(new Buffer('abcd')) -bl.append(new Buffer('efg')) -bl.append(new Buffer('hi')) -bl.append(new Buffer('j')) +bl.append(Buffer.from('abcd')) +bl.append(Buffer.from('efg')) +bl.append(Buffer.from('hi')) +bl.append(Buffer.from('j')) bl.pipe(fs.createWriteStream('gibberish.txt')) ```