tc39 / proposal-structs

JavaScript Structs: Fixed Layout Objects
http://tc39.es/proposal-structs/
624 stars 11 forks source link

An example for a user-land implementation #24

Open Bnaya opened 6 months ago

Bnaya commented 6 months ago

A while back I wrote a library that exposes js data types behind a proxy, and uses [Shared]ArrayBuffer as the heap https://github.com/Bnaya/objectbuffer The objects are free-form

You can transfer the [Shared]ArrayBuffer to a WebWorker/worker_thread, and with the appropriate locking, you can have shared memory js objects

The memory management is done via some kind of reference counting, and user-triggered free pass While the library actually works, the reason i didn't really use it, is that strings will never be efficient as far as I can see