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

Handle JS Array #52

Open
nrigaudiere opened this issue Sep 27, 2023 · 0 comments
Open

Handle JS Array #52

nrigaudiere opened this issue Sep 27, 2023 · 0 comments
Assignees
Labels
feature New feature or request
Milestone

Comments

@nrigaudiere
Copy link
Member

nrigaudiere commented Sep 27, 2023

There is 2 types of JS Array:

  • Array which is just an object list of heterogeneous types with some additional methods
  • TypedArray subclasses for numerical values (Int<x>Array, Uint<x>Array, Float<x>Array, BigInt<x>Array and BigUint<x>Array)

It's not easy to translate those to zig native types (eg. slice, tuple) as:

  • we don't know the shape and the length for Array
  • we do know the type for TypedArray but not all native types have a corresponding JS typed array, eg. we will have to forbid []bool or []<UserType> as they don't have a TypedArray counterpart

As they are JS native types, Array and TypedArray exists in the JS engine native API (eg. v8.Array), with all their public properties and methods like Length().
So maybe the more logical solution is just to expose those types, ie. define a jsruntime.Array type that will use underneath v8.Array (or quickjs.Array).

@francisbouvier francisbouvier transferred this issue from another repository Sep 29, 2023
@francisbouvier francisbouvier added this to the Alpha milestone Sep 29, 2023
@francisbouvier francisbouvier added the feature New feature or request label Sep 29, 2023
@francisbouvier francisbouvier modified the milestones: Alpha, Public Beta Jan 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants