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

ArrayBufferLike not descriptive enough #90

Open
bhelx opened this issue Aug 1, 2024 · 0 comments
Open

ArrayBufferLike not descriptive enough #90

bhelx opened this issue Aug 1, 2024 · 0 comments

Comments

@bhelx
Copy link
Contributor

bhelx commented Aug 1, 2024

Currently we use the type ArrayBufferLike for Host.outputBytes. But this is too restrictive. It doesn't accept typed array buffers. Which means that the user needs to unwrap their buffer. Example:

var buffer = (new TextEncoder()).encode("Hello, World!").buffer
Host.outputBytes(buffer)

Ideally it could take typed and untyped buffers, but i'm not sure if typescript has a known type for this. We could create one like:

type ArrayBufferLike = ArrayBuffer | SharedArrayBuffer;

type TypedArray =
  | Int8Array
  | Uint8Array
  | Uint8ClampedArray
  | Int16Array
  | Uint16Array
  | Int32Array
  | Uint32Array
  | Float32Array
  | Float64Array
  | BigInt64Array
  | BigUint64Array;

type BufferLike = ArrayBufferLike | TypedArray;
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

1 participant