Skip to content

Typed Arrays support #696

Closed
Closed
@NicolasRannou

Description

@NicolasRannou

🚀 Feature Proposal

Support typed arrays in Immer.

Motivation

Sometimes typed arrays is just the best way to store data. One of the aspects is that if you use web workers, it is much more efficient to pass TypedArrays (Array Buffer) instead of copying things around. Also, from my understanding, those are just the most efficient data structure.

I guess I'm mostly curious whether that's actually possible and how much effort that would take.

Can this be solved in user-land code?

Nope.

Example

import produce from "immer"

const baseState = [
    {
        data: new Uint16(9000),
        data3D:[new Uint16(6756), new Uint16(789)]
    }
]

const nextState = produce(baseState, draftState => {
    draftState[0].data[93] = 0;
})

// or apply a patch

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