Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 49be0e4

Browse files
authored
fix: avoid new Buffer usage (jpeg-js#73)
1 parent d2323c1 commit 49be0e4

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

lib/decoder.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1100,7 +1100,7 @@ function decode(jpegData, userOpts = {}) {
11001100
exifBuffer: decoder.exifBuffer,
11011101
data: opts.useTArray ?
11021102
new Uint8Array(bytesNeeded) :
1103-
new Buffer(bytesNeeded)
1103+
Buffer.alloc(bytesNeeded)
11041104
};
11051105
if(decoder.comments.length > 0) {
11061106
image["comments"] = decoder.comments;

lib/encoder.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Basic GUI blocking jpeg encoder
3636
*/
3737

3838
var btoa = btoa || function(buf) {
39-
return new Buffer(buf).toString('base64');
39+
return Buffer.from(buf).toString('base64');
4040
};
4141

4242
function JPEGEncoder(quality) {
@@ -714,7 +714,7 @@ function JPEGEncoder(quality) {
714714
writeWord(0xFFD9); //EOI
715715

716716
if (typeof module === 'undefined') return new Uint8Array(byteout);
717-
return new Buffer(byteout);
717+
return Buffer.from(byteout);
718718

719719
var jpegDataUri = 'data:image/jpeg;base64,' + btoa(byteout.join(''));
720720

0 commit comments

Comments
 (0)