-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Add deno.Buffer #1121
Add deno.Buffer #1121
Conversation
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.
Async generators are a thing and while not part of the GoLang API, implementing a [Symbol.asnycIterator]()
would allow:
async function f() {
for await (const x of denoBuffer) {
console.log(x);
}
}
Which relates to my other comments about having a more JavaScripty API.
@kitsonk Regarding async iterators, there was a lengthy discussion a few months ago about whether My conclusion was that it was overloading concerns and it would be better to provide a utility function for transforming any
In particular, it's imperative that users are able to provide memory for the |
Hi, I am not a go expert, what is the difference with ArrayBuffer ? |
My only feedback would be
Or just an object with the |
Functionally it conforms to the Deno's |
@GrosSacASac This is a Buffer that can grow. You can read() and write() from it. One situation where you might want to do this, is if you wanted to, say, buffer up an http response so it can be parsed: import { dial, Buffer, copy, stdout } from "deno";
dial("tcp", "google.com:80").then((conn) => {
let buf = new Buffer();
buf.writeString("GET / HTTP/1.1\r\n\r\n");
copy(conn, buf);
copy(stdout, conn);
}); |
@bartlomieju Ideally in the async iterator case we would allocate in Rust and pass it over to V8... This isn't implemented tho. So just allocate |
while (true) { | ||
try { | ||
const i = this._grow(MIN_READ); | ||
this._reslice(i); |
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 really have trouble following what's going on here...
Do not confuse this with Node's Buffer. This is a direct port of Go's bytes.ByteBuffer - it allows buffering of Reader objects.
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 am not so sure how this is going to be used and whether it belongs in Deno.
But ok let's see where it goes.
- Performance and stability improvements on all platforms. - Add repl (denoland#998) - Add deno.Buffer (denoland#1121) - Support cargo check (denoland#1128) - Upgrade Rust crates and Flatbuffers. (denoland#1145, denoland#1127) - Add helper to turn deno.Reader into async iterator (denoland#1130) - Add ability to load JSON as modules (denoland#1065) - Add deno.resources() (denoland#1119) - Add application/x-typescript mime type support (denoland#1111)
- Performance and stability improvements on all platforms. - Add repl (#998) - Add deno.Buffer (#1121) - Support cargo check (#1128) - Upgrade Rust crates and Flatbuffers. (#1145, #1127) - Add helper to turn deno.Reader into async iterator (#1130) - Add ability to load JSON as modules (#1065) - Add deno.resources() (#1119) - Add application/x-typescript mime type support (#1111)
Do not confuse this with Node's Buffer. This is a direct port of Go's
bytes.ByteBuffer - it allows buffering of Reader objects.