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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support JavaScript Sets #2099

Open
shohamazon opened this issue May 7, 2024 · 3 comments
Open

Support JavaScript Sets #2099

shohamazon opened this issue May 7, 2024 · 3 comments

Comments

@shohamazon
Copy link

Hi there! 馃檪

I'm currently working on a project where I utilize N-API to facilitate the conversion of values from a Rust core to a TypeScript wrapper. However, I've encountered an issue: I'm unable to convert a Set object to a JavaScript Set due to the lack of support for sets in N-API.

Before proceeding further, I wanted to confirm whether my understanding is correct. Does N-API indeed lack support for sets, or is there a method I might have overlooked?

Additionally, I'm curious to know if there are any plans to include support for sets in N-API in future releases. If not, I'd appreciate any suggestions or workarounds that could help me achieve the desired conversion from Rust to TypeScript.

Thank you for your assistance!

@southorange0929
Copy link
Contributor

At present,N-API doesn't provide support to create a Set data structure. The creation from rust's hashmap is done by creating an object.

Could you consider using an array instead? Is there a specific situation where you absolutely need to use a set? Alternatively, after creating the array, you could create a set in the JS environment using this array.

@shohamazon
Copy link
Author

Thank you for your response!
This is exactly what I am doing (using an array and converting to a set in the Node wrapper).

What I wanted to know if I there was a way I could overcome this so many conversions, but I guess there isn't 馃槙.

@southorange0929
Copy link
Contributor

Yeah, there really isn't an ideal solution for this.

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

No branches or pull requests

2 participants