Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: deprecation warning for new Buffer (#1905)
Co-authored-by: Filip Mösner <[email protected]>
- Loading branch information
e93286e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For some cases this commit still produces a deprecation warning.
I believe the fallback call should be
util.newBuffer(0)
, notnew this.buf.constructor(0)
In my case, the deprecation warning happens because I have built the library for ESM using rollup. This commit uses
util.Buffer
which in turn usesutil.inquire("buffer").Buffer
.util.inquire
uses a hiddenrequire
to test if module 'buffer' is available. However, therequire
method is not available under ESM, so under ESMutil.inquire
always fails, even for Node environments that have a native Buffer available.