-
Notifications
You must be signed in to change notification settings - Fork 30
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
feat: make urlSource compatible with new ipfs.add #53
Conversation
@achingbrain I'm unable to push a branch to this repo, so I had to use my own fork for this pull request. |
src/files/url-source.js
Outdated
const readURLContent = async function * (url, options) { | ||
const http = new Http() | ||
const response = await http.get(url, options) | ||
yield * response.iterator() | ||
} |
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 dont understand this change, why the wrapper ?
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.
@hugomrdias so previously we had ipfs.add
that could imported bunch of files or import a single one. Which later we have split into ipfs.add
that imports a single file and takes single file like thing, and ipfs.addAll
which imports multilpe files.
This change just makes return of urlSource
compatible with ipfs.add
as opposed to ipfs.addAll
.
P.S.: ipfs.add
implementation (but not the typings) will still accept many files, but plan is to make that not a case in the future.
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.
To answer your specific question, this does not add a wrapper but rather moves code doing the content fetching into content
field which is expected to be AsyncIterable<Uint8Array>
. effectively changing return type of this urlSource
from AsyncIterable<{ path: string, content: AsyncIterable<Uint8Array> }>
to { path: string, content: AsyncIterable<Uint8Array> }
removing one layer of asynchronicity and making return be a single file as opposed to collection of files that always happen to contain one.
fixes: ipfs/js-ipfs#3195