You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This pull request aims to implement the node Buffer class to the best of my ability. I know we were flip-flopping on this a while ago, and instead of just opening an issue about Buffer support (and being ungreatful,) I thought I should pick up and learn how it works so I can personally do something about it.
Notes:
We can only implement one of the constructors, I chose new Buffer(size: i32) to be consistent with AS
Checklist:
new Buffer(size); (deprecated in node, but required for new Uint8Array constructor)
Class Method: Buffer.alloc(size[, fill[, encoding]])
Class Method: Buffer.allocUnsafe(size)
Class Method: Buffer.allocUnsafeSlow(size)
Class Method: Buffer.byteLength(string[, encoding])
Class Method: Buffer.compare(buf1, buf2)
Class Method: Buffer.concat(list[, totalLength])
Class Method: Buffer.from(ArrayBufferView)
Class Method: Buffer.from(arrayBuffer[, byteOffset[, length]])
This method should probably skip byteOffset and length properties
Class Method: Buffer.from(string[, encoding])
This method could use the encoding parameter Buffer.from("str", "encoding")
I'm generally in favor of adding a Buffer class (and other node APIs), just not sure if the node API implementations should live in its own module, like "@assemblyscript/std-node". If it doesn't, we might run into situations where sometimes the normal JS API is used in a PR, and sometimes the node API is used, so it will be hard to split that again at a later point. Also, having it directly in stdlib increases initial parse times because it'd add additional classes to the global scope (so it must parse to know the globals), like Buffer or an implementation of process, which would be unnecessary if someone doesn't plan to use it.
Nonetheless, due to its expected importance my suggestion is to make it an official AS repo so everyone can contribute and we can maintain. Wdyt? :)
Closed in favor of standardizing the node apis in its own repo. Just waiting on @dcodeIO to make the repo.
This file contains hidden or 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
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.
This pull request aims to implement the node
Bufferclass to the best of my ability. I know we were flip-flopping on this a while ago, and instead of just opening an issue aboutBuffersupport (and being ungreatful,) I thought I should pick up and learn how it works so I can personally do something about it.Notes:
new Buffer(size: i32)to be consistent with ASChecklist:
new Buffer(size);(deprecated in node, but required for new Uint8Array constructor)Buffer.from("str", "encoding")