Skip to content
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

Adds import method to add an existing document to the repo #251

Merged
merged 2 commits into from
Dec 14, 2023

Conversation

acurrieclark
Copy link
Collaborator

Following discussion in #240, I thought I would add an import method to repo for adding an existing document to the repo.

Points for discussion:

  1. Should the parameter be an automerge document, or a Unit8Array? I have made it a document for now, as this made most sense to me, and as it allows us to check the validity of the document and have it typed correctly.
  2. What should the error message be which is thrown if an invalid document is passed in.

@kid-icarus
Copy link
Contributor

Should the parameter be an automerge document, or a Unit8Array

Torn on this. If you have a document without loading it from a Uint8Array, you've likely fetched it from the repo, and can use repo.clone(). However, that assumption is admittedly weak, and it's not too much of a hassle to A.load() the Uint8Array into a doc.

@pvh
Copy link
Member

pvh commented Dec 8, 2023

I agree that on this interface it should be a Uint8Array -- I'd also suggest a matching export.

@kid-icarus
Copy link
Contributor

Added an export method in #256

@acurrieclark
Copy link
Collaborator Author

Updated the signature to take a Uint8Array instead and added the method to the readme

@pvh pvh merged commit 5226d19 into main Dec 14, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants