-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Showing
1 changed file
with
8 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.