Comments (2)
I was just looking at this part of your code, and was considering this question. I came to the conclusion there would be no benefit. You create a Node stream with createWriteStream
but then immediately async iterate over it (using yield *
). Adding the stream.Readable.toWeb
wrapper there would just be overhead that got immediately discarded.
A more aggressive change might be to change BlobDataItem.prototype.stream
from being an async generator to returning a web stream. But since BlobDataItem
is an internal class, I don't see what the benefit in doing that would be, either.
from fetch-blob.
yup, it will just be unnecessary overhead.
the better solution would be to wait for nodejs/node#40606 to be fixed so it would be possible to go direct from file to whatwg stream, the extra overhead of converting it to buffer/node:stream/iterator/uint8array is not worth it...
the best solution would be to get rid of the toIterator entirely so that it never touches the main thread so that we could do something like this instead:
function concatenateReadables(readables) {
const ts = new TransformStream();
let promise = Promise.resolve();
for (const readable of readables) {
promise = promise.then(
() => readable.pipeTo(ts.writable, { preventClose: true }),
reason => {
return Promise.all([
ts.writable.abort(reason),
readable.cancel(reason)
]);
}
);
}
promise.then(() => ts.writable.close(),
reason => ts.writable.abort(reason))
.catch(() => {});
return ts.readable;
}
ref: https://streams.spec.whatwg.org/#example-identity-transform-usages
from fetch-blob.
Related Issues (20)
- Run test against WPT
- Move check to the top
- exec `npm run test test-wpt` with github workflows
- Use stream consumers HOT 1
- require "stream/web" produces warning HOT 21
- object key naming should not contain '#' HOT 2
- Module not found: Error: Can't resolve 'stream/web' HOT 20
- text() is fatal on non UTF-8 data, while in browser it works without any issue HOT 1
- How can I implement the below code in older version ? HOT 1
- Behavior of .slice() is incorrect when using blobs backed by a file on the disk
- node failing due to unexpected character '#' HOT 8
- Possibility to remove web-streams-polyfill dependency? HOT 1
- fileFromSync just part of a file HOT 1
- The RC version should not be released as latest. HOT 1
- Adding a File class maybe?
- Doesn't work either with latest stable and beta version of node-fetch HOT 6
- Revisit DOMException
- Support Node.js v12 HOT 4
- Implementing a mutable append only blob type? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fetch-blob.