Reduce b4a
usage and prefer the native Buffer
methods
#163
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The PR reduces some
b4a
usages:b4a.alloc
b4a.alloc
is just an alias ofBuffer.alloc
, see https://github.com/holepunchto/b4a/blob/5a6b328df1817977351208e1991b1fdfb4bfa529/index.js#L9-#L11b4a.concat
b4a.concat
is just an alias ofBuffer.concat
, see https://github.com/holepunchto/b4a/blob/5a6b328df1817977351208e1991b1fdfb4bfa529/index.js#L29-L31b4a.from
b4a.from
is just an alias ofBuffer.from
, see https://github.com/holepunchto/b4a/blob/5a6b328df1817977351208e1991b1fdfb4bfa529/index.js#L45-L47b4a.byteLength
b4a.byteLength
is just an alias ofBuffer.byteLength
, see https://github.com/holepunchto/b4a/blob/5a6b328df1817977351208e1991b1fdfb4bfa529/index.js#L21By replacing those
b4a
usage with Node.js built-inBuffer
, the PR improves performance (as those alias methods would create extra stacks), and makes it easier to transition to the Uint8Array in future PRs.The unit tests still pass after the changes.