@syncedstore/core
Version:
SyncedStore is an easy-to-use library for building collaborative applications that sync automatically. It's built on top of Yjs, a proven, high performance CRDT implementation.
18 lines (15 loc) • 371 B
text/typescript
import { JSONValue } from "./types";
/**
* @ignore
*/
export class Box<T extends Readonly<JSONValue>> {
constructor(public readonly value: T) {}
}
export function boxed<T extends JSONValue>(value: T) {
if (ArrayBuffer.isView(value)) {
// can't freeze arraybuffer
return new Box(value as T);
} else {
return new Box(Object.freeze(value) as T);
}
}