Skip to content

Implement portable variants of TypedArray.wrap #1304

Closed
@jletellier

Description

@jletellier

Using e.g. Uint8Array.wrap(buffer) is valid code in AssemblyScript but doesn't work in regular TypeScript, so it isn't portable. As far as I can tell there needs to be a corresponding implementation in std/portable/index.js.

The following code snippet works for me:

Object.defineProperty(Uint8Array, "wrap", {
  value: function(buffer, byteOffset, length) {
    return new Uint8Array(buffer, byteOffset, length);
  }
});

Am I overlooking something or should I submit a pull request?

P.S. Thank you so much for this library!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions