lzutf8.js icon indicating copy to clipboard operation
lzutf8.js copied to clipboard

Deprecation warning

Open s7dhansh opened this issue 7 years ago • 3 comments

(node:1) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.

s7dhansh avatar Dec 15 '18 09:12 s7dhansh

FYI, this can be worked around by creating the Buffer before hand instead of passing in the raw string

lz.compress(Buffer.from(str))

hxhieu avatar Jan 15 '21 10:01 hxhieu

Thanks for the reports. I apologize for not being very responsive. The library has been semi-maintained for a while. I will see what is needed to fix the issue.

rotemdan avatar Jan 15 '21 10:01 rotemdan

I've made this commit that changes two calls to Buffer() to Buffer.from():

The two calls are in:

  • Base64.ts
  • UTF8.ts

There's a third call in:

  • BufferTools.ts

That I did not modify, as it's in a conditional branch that shouldn't be executed on modern versions of Node.

Testing on latest node seem to pass. However this breaks on versions before 10, which I guess is okay.

I've publishd on npm (version 0.5.8).

rotemdan avatar Jan 15 '21 11:01 rotemdan