-
-
Notifications
You must be signed in to change notification settings - Fork 34
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
Change to replace Buffer
with Uint8Array
#85
Conversation
Previously, this project depended on Node’s buffer. This commit changes that: it replaces that support with `Uint8Array`. In most cases, this will be fine, because the Node `Buffer` class subclasses `Uint8Array`. However, there are differences in which encodings are supported when turning this binary data into a string, and there are differences in how methods work.
What encodings are no longer supported? |
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.
I take it this would be SemVer major?
Are there changes which will be needed in unified?
new VFile(Buffer.from('bar')).toString(), | ||
'bar', | ||
'buffer: should return the internal value' | ||
new VFile(Buffer.from([0xef, 0xbb, 0xbf, 0x61, 0x62, 0x63])).toString(), |
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.
does this mean buffer from string is no longer supported, and only hex can be used?
This is indeed semver major!
depends on how chrome/node/etc is built, see also https://github.com/vfile/vfile/pull/85/files#diff-92bbac9a308cd5fcf9db165841f2d90ce981baddcb2b1e26cfff170929af3bd1R614, so typically everything is supported, but some Node-isms like
nope, those are fine! This just updated the 2 tests to be more clear by using bytes and actually different encodings, instead of already unicode strings So it’s mostly going to be fine! |
Initial checklist
Description of changes
Previously, this project depended on Node’s buffer. This commit changes that: it replaces that support with
Uint8Array
. In most cases, this will be fine, because the NodeBuffer
class subclassesUint8Array
.However, there are differences in which encodings are supported when turning this binary data into a string, and there are differences in how methods work.