Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid using global Buffer #338

Closed
wants to merge 1 commit into from
Closed

Avoid using global Buffer #338

wants to merge 1 commit into from

Conversation

jimmywarting
Copy link

@jimmywarting jimmywarting commented May 9, 2023

No description provided.

@mscdex
Copy link
Owner

mscdex commented May 9, 2023

Why?

@jimmywarting
Copy link
Author

jimmywarting commented May 9, 2023

trying to assume that it exist globally is problematic for bundlers. it needs to scan the code if one is using globalThis.buffer and needs to decide if it have to polyfill it or not.

While the Buffer class is available within the global scope, it is still recommended to explicitly reference it via an import or require statement.

  • it was once attempted to warn/deprecate access to globalThis.buffer by assigning it a deprecation warning getter function.

my own code can detect this kinds of patterns where ppl try to use globalThis.buffer and yours is one of them

@mscdex
Copy link
Owner

mscdex commented May 9, 2023

As far as linting goes, this project uses eslint and not xo. Attempting to support arbitrary linters and linting configurations doesn't make sense.

Regarding the aforementioned links and notes about deprecating global Buffer, that was only for ES modules. busboy is a CJS module.

@jimmywarting
Copy link
Author

In any case i think you should attempt to only use Uint8Array instead of the overhead Buffer if at all possible.

@mscdex
Copy link
Owner

mscdex commented May 9, 2023

In any case i think you should attempt to only use Uint8Array instead of the overhead Buffer if at all possible.

That's not very feasible considering:

  • This module utilizes Buffer-specific functionality
  • Node.js users are more accustomed to dealing with Buffers at this point
  • Working around the limitations of Uint8Array would not only require adding more code to polyfill functionality but it could also easily result in lower performance

@mscdex mscdex closed this May 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants