Skip to content

Commit

Permalink
Use Buffer.from() in the documentation
Browse files Browse the repository at this point in the history
Use `Buffer.from()` instead of `new Buffer()` because the Buffer constructor is deprecated.
  • Loading branch information
nwoltman authored Oct 23, 2018
1 parent 270e5f5 commit c768eb8
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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'))
```
Expand Down

0 comments on commit c768eb8

Please sign in to comment.