Skip to content

Inheriting from DataView/TypedArray #39

@rotu

Description

@rotu

Most objects in this library inherit from DataView or TypedArray. That means they have a number of methods which don't respect the type abstraction.

e.g. since Uint16View extends DataView, it has a setFloat32 method. Note this also writes outside of the 2 bytes one expects the view to refer to.
e.g. since GridMixin extends a TypedArray, it has map, at, findIndex, which all use linear indexing.

Furthermore, Int32View extends Uint8View. This renders the type annotation x: Uint8View practically meaningless.

It would be nice if this library used less inheritance. It does make sense for binary-backed objects to implement the more minimal ArrayBufferView interface ({buffer, byteLength, byteOffset}).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions