Files
AFFiNE-Mirror/packages/common/nbstore/src/utils/is-empty-update.ts
2024-12-07 08:05:02 +00:00

14 lines
319 B
TypeScript

/**
* Tell a binary is empty yjs binary or not.
*
* NOTE:
* `[0, 0]` is empty yjs update binary
* `[0]` is empty yjs state vector binary
*/
export function isEmptyUpdate(binary: Uint8Array) {
return (
binary.byteLength === 0 ||
(binary.byteLength === 2 && binary[0] === 0 && binary[1] === 0)
);
}