Expose owned R vector storage as a mutable JavaScript view
js_mutable_view.RdCreates a fixed-length array-like JavaScript object whose indexed writes update R-owned vector storage. The wrapper makes one copy when it is created; passing it to JavaScript does not copy or convert the complete vector.
Details
JavaScript reads convert elements on demand and writes update
view$value. The caller's original vector is never modified. Multiple
JavaScript views of the same wrapper share its owned storage.
The view has length, indexed access, enumeration, iteration, inherited
Array methods, and toArray(). Its length cannot change, properties
cannot be added, and elements cannot be deleted. Methods such as reverse,
sort, fill, and copyWithin work because they only replace
existing elements.
Assignments are type checked. JavaScript null and undefined
write R missing values except for raw vectors. JavaScript NaN remains an
ordinary R NaN. Factors, dates, and other classed vectors are rejected.
Normal R copy-on-write rules still apply. Replacing or modifying
view$value in R after JavaScript retains the view can detach the R
binding from the retained storage.