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

Plot content #1

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

ManuelHentschel
Copy link

@ManuelHentschel ManuelHentschel commented Oct 17, 2021

Adds a method to the api to get the content of a plot as array buffer, as suggested in REditorSupport/vscode-R#823 (comment)

I had to modify the dependencies a bit, to get fetch and Headers to work in nodejs/vscode. Not really sure, if this is the cleanest way.

Feel free to modify/ignore if you have different plans for the api.

@nx10
Copy link
Owner

nx10 commented Oct 17, 2021

Thanks for the PR. Sorry for the dependency problems, I forgot to push the latest changes yesterday.

I am not sure converting to an ArrayBuffer object is a helpful abstraction here.
With the response promise you can call .text() .json() or .arrayBuffer()` or whatever is needed in the specific case.
Do you think users will generally want to convert to an ArrayBuffer?

@ManuelHentschel
Copy link
Author

Do you think users will generally want to convert to an ArrayBuffer?

I think it would be useful to have a method that returns only the content of a plot, without any http/ws logic (as e.g. the response type). For text-based formats it might make sense to return the text itself, but for binary formats, some type of buffer is needed for this. Buffer seems to be a bit more useful than ArrayBuffer, so i changed the return type.

@nx10
Copy link
Owner

nx10 commented Oct 17, 2021

ArrayBuffer will load the plot into memory before writing it. Keeping it as an Response object allows streaming.

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.

2 participants