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

Mavgen JS: Add require('buffer') statement to allow JS output to work in React Native #919

Merged
merged 1 commit into from
Mar 19, 2024

Conversation

shancock884
Copy link
Contributor

@shancock884 shancock884 commented Feb 10, 2024

I am using the Mavlink JS Nextgen output in a React Native project on Android mobile device.
In Node JS, the 'Buffer' object is globally available by default, but in React Native this is not the case.
This PR adds the line: var Buffer = require('buffer').Buffer; to the generated output.
This provides the Buffer object in React Native, and it is benign to also include this line in Node JS.

I have successfully used the updated generator in my React Native project, and checked that it also can be imported successfully in Node. Also, the CI tests the generator output in various versions of Node.

@shancock884 shancock884 marked this pull request as ready for review February 12, 2024 11:50
@shancock884
Copy link
Contributor Author

shancock884 commented Mar 18, 2024

Hi @davidbuzz. This is a small tweak that I needed to make the JS work with both React Native and NodeJS.
If you are happy with it, are you able to give it the OK?

@davidbuzz
Copy link
Contributor

this looks harmless to me , lets merge it.

@davidbuzz davidbuzz added the javascript Pull requests that update Javascript code label Mar 19, 2024
Copy link
Contributor

@davidbuzz davidbuzz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@peterbarker peterbarker merged commit 2628769 into ArduPilot:master Mar 19, 2024
12 checks passed
@shancock884
Copy link
Contributor Author

Thanks!

@shancock884 shancock884 deleted the mavgen-js-react-buffer branch March 19, 2024 07:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
javascript Pull requests that update Javascript code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants