-
Notifications
You must be signed in to change notification settings - Fork 35
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 support for Uint8Array's in place of node Buffer's to ipfs-unixfs-importer #56
Comments
Actually I think I have overlooked chunk validation phase that seems to normalize each chunk js-ipfs-unixfs/packages/ipfs-unixfs-importer/src/dag-builder/validate-chunks.js Lines 8 to 19 in 8e8d83d
Although I'm also starting to suspect that P.S.: I'll verify that assumption and submit test / fix as necessary. |
@achingbrain is this the right type signature for the importer: declare function importer(source:AsyncIterable<ImportEntry>, ipld:IPLDResolver, options?:ImporterOptions)
type ImportEntry =
| ImportFile
| ImportDir
type ImportFile = {
path: string|void,
content: Content,
mtime?: Mtime,
mode?: Mode
}
type ImortDir = {
path: string,
content?:void,
mtime?: Mtime,
mode?: Mode
}
type Content =
| Iterable<string>
| Iterable<ArrayBuffer>
| Iterable<ArrayBufferView>
| AsyncIterable<string>
| AsyncIterable<ArrayBuffer>
| AsyncIterable<ArrayBufferView>
type Mode = string | number
type MTime = number | Date | UnixFSTime | HRTime
type UnixFSTime = {
secs: number,
nsecs?: number
}
type HRTime = [number, number]
type IPLDResolver = {
// ...
}
type ImporterOptions = {
// ...
} |
The type it expects to be yielded by the source is:
It handles more, as you found, maybe it shouldn't. |
In that case can we loosen up it a bit to accept |
Of course, we shouldn't require the input to be Buffers anywhere. I think the only place that might get painful is the use of |
fixed by #69 |
I glanced through the implementation and it seems that dependence is inherited from use of following libraries
There are few lines that also use
Buffer
directly but thereUint8Array
would have done just fine as well.Trying to actually remove here might be difficult, however we could probably just remove it from the API surface and turn
Uint8Array
s intoBuffer
s internally where needed.The text was updated successfully, but these errors were encountered: