Skip to content
This repository was archived by the owner on Sep 9, 2024. It is now read-only.

Update the Buffer APIs #98

Merged
merged 1 commit into from
Jun 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ var LZ4 = require('lz4')
var data = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.'
data += data
// LZ4 can only work on Buffers
var input = new Buffer(data)
var input = Buffer.from(data)
// Initialize the output buffer to its maximum length based on the input data
var output = new Buffer( LZ4.encodeBound(input.length) )
var output = Buffer.alloc( LZ4.encodeBound(input.length) )

// block compression (no archive format)
var compressedSize = LZ4.encodeBlock(input, output)
Expand All @@ -49,7 +49,7 @@ output = output.slice(0, compressedSize)
console.log( "compressed data", output )

// block decompression (no archive format)
var uncompressed = new Buffer(input.length)
var uncompressed = Buffer.alloc(input.length)
var uncompressedSize = LZ4.decodeBlock(output, uncompressed)
uncompressed = uncompressed.slice(0, uncompressedSize)

Expand Down
6 changes: 3 additions & 3 deletions benchmark/bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ console.log('Input file:', inputFileName)

var input = fs.readFileSync(inputFileName)
var outputMaxSize = lz4.encodeBound(input.length)
var output = new Buffer(outputMaxSize)
var output = Buffer.alloc(outputMaxSize)

var decoded = new Buffer(input.length)
var encoded = new Buffer(outputMaxSize)
var decoded = Buffer.alloc(input.length)
var encoded = Buffer.alloc(outputMaxSize)
var n = lz4.encodeBlock(input, encoded)
encoded = encoded.slice(0, n)

Expand Down
Loading