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

Use TypedArrays instead of Nodejs' Buffer #5

Merged
merged 2 commits into from
May 3, 2024

Conversation

MarcoPolo
Copy link
Contributor

Closes #4

This lets this parser be used from more environments, namely browsers. #4 has more context.

https://sindresorhus.com/blog/goodbye-nodejs-buffer has some context on why we should move on from NodeJS buffers.

Probably also closes #3, because I updated the instructions as a side effect and didn't see that PR.

Copy link
Owner

@ShogunPanda ShogunPanda left a comment

Choose a reason for hiding this comment

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

Just a little nit, the rest looks go to me!
Thanks a lot!

parser/tools/postbuild-wasm.mjs Show resolved Hide resolved
@@ -1,5 +1,8 @@
/* eslint-disable no-unused-vars,camelcase,no-undef */

const textEncoder = new TextEncoder()
const textDecoder = new TextDecoder()

function loadWASM() {
return require('node:fs').readFileSync(require('node:path').resolve(__dirname, 'milo.wasm'))
Copy link
Owner

Choose a reason for hiding this comment

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

For the browser environment this will not work. But we don't need to change this as milo already exports a index-with-wasm (probably I should rename this) which embeds the WASM file inside.

@ShogunPanda
Copy link
Owner

Once you remove the change in the builder file, I'll merge this. Thanks again!

@ShogunPanda ShogunPanda merged commit 0877fd2 into ShogunPanda:main May 3, 2024
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.

Support Browser environments
2 participants