Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

chore: remove redundant bytesEqual (#398)

gbirman5ecd0677d29d
diff --git a/js/app/packages/core/util/bytesEqual.ts b/js/app/packages/core/util/bytesEqual.ts
deleted file mode 100644
index d558ce242b..0000000000
--- a/js/app/packages/core/util/bytesEqual.ts
+++ /dev/null
@@ -1,14 +0,0 @@
-export function bytesEqual(
- a: Uint8Array | ArrayBuffer,
- b: Uint8Array | ArrayBuffer
-): boolean {
- const viewA = a instanceof Uint8Array ? a : new Uint8Array(a);
- const viewB = b instanceof Uint8Array ? b : new Uint8Array(b);
-
- if (viewA.length !== viewB.length) return false;
-
- for (let i = 0; i < viewA.length; i++) {
- if (viewA[i] !== viewB[i]) return false;
- }
- return true;
-}
diff --git a/js/app/packages/core/util/compareUtils.ts b/js/app/packages/core/util/compareUtils.ts
index 9cecd8d7c4..ad4bb3ce4d 100644
--- a/js/app/packages/core/util/compareUtils.ts
+++ b/js/app/packages/core/util/compareUtils.ts
@@ -8,7 +8,7 @@ export function setEquals<T>(a: Set<T>, b: Set<T>): boolean {
return true;
}
-export function arrayEquals<T>(a: T[], b: T[]): boolean {
+export function arrayEquals<T extends ArrayLike<any>>(a: T, b: T): boolean {
if (a.length !== b.length) return false;
for (let i = 0; i < a.length; i++) {
diff --git a/js/app/packages/service-sync/source.ts b/js/app/packages/service-sync/source.ts
index 2370117a05..d961a57ece 100644
--- a/js/app/packages/service-sync/source.ts
+++ b/js/app/packages/service-sync/source.ts
@@ -10,7 +10,7 @@ import {
type TimeoutError,
} from '@core/collab/source';
import { SYNC_SERVICE_HOSTS } from '@core/constant/servers';
-import { bytesEqual } from '@core/util/bytesEqual';
+import { arrayEquals } from '@core/util/compareUtils';
import { isErr as isChaseError } from '@core/util/maybeResult';
import { storageServiceClient } from '@service-storage/client';
import { createEventBus } from '@solid-primitives/event-bus';
@@ -271,7 +271,7 @@ export const createSyncServiceSource = async (
untilMessage(ws, (message) => {
return (
message.isRemoteUpdateSince() &&
- bytesEqual(message.value.frontiers, encodedFrontiers)
+ arrayEquals(message.value.frontiers, encodedFrontiers)
);
}),
TIMEOUTS.REQUEST_UPDATES_SINCE,