YousefED / SyncedStore

SyncedStore CRDT is an easy-to-use library for building live, collaborative applications that sync automatically.
https://syncedstore.org
MIT License
1.73k stars 52 forks source link

Arrays in store return `false` to `Array.isArray(...)` #91

Closed cgauld closed 1 year ago

cgauld commented 1 year ago

Here's a minimal example:

const store = syncedStore({ exampleArray: [] });
store.exampleArray.push('hello');

console.log(JSON.stringify(store))
// Correctly outputs {"exampleArray":["hello"]}

console.log(Array.isArray(store.exampleArray))
// Incorrectly outputs false, would expect true

I'm not sure how the synced store implementation works behind the scenes but it looks like JavaScript Proxy objects do return true to Array.isArray(...) if proxy target is an array, e.g.

const myProxy = new Proxy([], {});
console.log(Array.isArray(myProxy));
// Outputs true

Let me know if I can help further 😄

YousefED commented 1 year ago

Thanks!