Skip to content

Handle JS Array #52

Open
Open
@nrigaudiere

Description

@nrigaudiere

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).

Metadata

Metadata

Labels

featureNew feature or request

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions