You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I find myself staring going back to docs / examples to try and figure out what various options would do to make sure I get things right. In my experience this is an opportunity to improve API such that it is difficult to misuse / misinterpret.
Given a bit of experience here are few suggestions:
Expose separate APIs per use case:
pack a file - Most cases I've encountered so far it's a single file in which case following options are confusing and serve little purpose
multiple inputs
path of the input
wrapWithDirectory
pack a directory of files - This could also be simplified by
Getting rid of wrapWithDirectory option (if you want to warp file with dir use packDiretory and pass a single file.
Let user normalize input instead
I think this is idiosyncrasy of IPFS that is really not worth replicating. Input type is extremely complex which is flexible enough to take almost anything yet it is not always obvious how each one is treated.
I think API can be a lot nicer if it let user deal with input normalization and was itself was super simple
packFile({ content: Blob, ... })
packDirectory({ files: File[], ... })
Files and Blobs can easily be created from all those input types and bad inputs.
Allow deciding what output should be afterwards
Right now you have to pick between blob, fs and stream packer. I would suggest instead having single result value Pack that is:
I find myself staring going back to docs / examples to try and figure out what various options would do to make sure I get things right. In my experience this is an opportunity to improve API such that it is difficult to misuse / misinterpret.
Given a bit of experience here are few suggestions:
Expose separate APIs per use case:
wrapWithDirectory
option (if you want to warp file with dir usepackDiretory
and pass a single file.Let user normalize input instead
I think this is idiosyncrasy of IPFS that is really not worth replicating. Input type is extremely complex which is flexible enough to take almost anything yet it is not always obvious how each one is treated.
I think API can be a lot nicer if it let user deal with input normalization and was itself was super simple
packFile({ content: Blob, ... })
packDirectory({ files: File[], ... })
Files and Blobs can easily be created from all those input types and bad inputs.
Allow deciding what output should be afterwards
Right now you have to pick between blob, fs and stream packer. I would suggest instead having single result value
Pack
that is:And following in node:
Also given that web streams and blobs are coming to node, I'm not sure if it's even worth doing node specific things.
The text was updated successfully, but these errors were encountered: