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
Support adding files with iterators as well #346
Comments
Another thing why generators would be good is if you used Abstract Chunk Store
|
Anything simpler just as a function that returns a promise that resolves the hole file would help reduce the memory as for how it is now. Right now node buffer is the only thing that can request more data when it needs it Gods have for lazy loading something // now function can return either a promise or simply `new Blob`
if(typeof data == 'function')
Promise.resolve(data()).then(data => do something) |
I'm working on an other fix to reduce the memory usage but this one will definitively follow ! |
Any progress? |
Not yet. |
realized a while back that nodes streams are iterable. and web streams are going to be iterable too some day. That will mean you can remove all node/browser specifics hacks and just use the iterable api if (!ReadableStream.prototype[Symbol.asyncIterator]) {
ReadableStream.prototype[Symbol.asyncIterator] = async function* () {
const reader = this.getReader()
while (1) {
const chunk = await reader.read()
if (chunk.done) return chunk.value
yield chunk.value
}
}
}
res = await fetch('something')
for await (chunk of res) {
// {value: uint8array, done: boolean}
} (part of my cross-js guideline for writing cross platform codes) |
so the supported data could be:
String/ArrayBuffer/Uint8Array/Buffer/Blob/Promise/Nodejs stream/generator & iterator
The text was updated successfully, but these errors were encountered: