Skip to content

Commit

Permalink
Use Buffer.from instead of deprecated new Buffer
Browse files Browse the repository at this point in the history
Fixes kaitai-io#27

Declare minimum supported node version as 6 according to
https://nodejs.org/en/docs/guides/buffer-constructor-deprecation/#variant-1
  • Loading branch information
Mingun committed Jul 13, 2023
1 parent bc3d1cf commit e2f988b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 1 addition & 2 deletions KaitaiStream.js
Original file line number Diff line number Diff line change
Expand Up @@ -622,8 +622,7 @@ KaitaiStream.bytesToStr = function(arr, encoding) {
case 'ucs-2':
case 'utf16le':
case 'utf-16le':
return new Buffer(arr).toString(encoding);
break;
return Buffer.from(arr).toString(encoding);
default:
// unsupported encoding, we'll have to resort to iconv-lite
if (typeof KaitaiStream.iconvlite === 'undefined')
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
"devDependencies": {
"jest": "^28.1.3"
},
"engines": {
"node": ">=6.0.0"
},
"keywords": [
"binary",
"file",
Expand Down

0 comments on commit e2f988b

Please sign in to comment.