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

use Buffer.from if available #42

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ARitz-Cracker
Copy link

new Buffer is deprecated, so Buffer.from should be used if it's available

new Buffer is deprecated
@addaleax
Copy link

This would be very nice to have :) @creationix?

@creationix
Copy link
Owner

This is great, but there is no need to check every time the function is called. Instead of having the indirection that checks at runtime every time the function is called, simply set the function.

// Use Buffer.from directly if it exists.  Otherwise, create a version of the constructor that works like a function.
const bufferFrom = Buffer.from ? Buffer.from : (...args) => new Buffer(...args);

@adminy
Copy link

adminy commented Oct 27, 2023

ok, but can this be addressed? its been 2 years now

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.

4 participants