rotemdan / lzutf8.js

A high-performance Javascript string compression library
MIT License
322 stars 26 forks source link

Deprecation warning #21

Open s7dhansh opened 5 years ago

s7dhansh commented 5 years ago
(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.
hxhieu commented 3 years ago

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

lz.compress(Buffer.from(str))
rotemdan commented 3 years ago

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 commented 3 years ago

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

The two calls are in:

There's a third call in:

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).