Closed
Description
🚀 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