MCPcopy
hub / github.com/tinyplex/tinybase / createCustomLocalSynchronizer

Function createCustomLocalSynchronizer

test/unit/persisters/common/mocks.ts:417–450  ·  view source on GitHub ↗
(
  store: MergeableStore,
  clients: Map<string, Receive>,
)

Source from the content-addressed store, hash-verified

415};
416
417const createCustomLocalSynchronizer = (
418 store: MergeableStore,
419 clients: Map<string, Receive>,
420): Synchronizer => {
421 const clientId = 'client' + clients.size;
422 return createCustomSynchronizer(
423 store,
424 (toClientId, requestId, messageType, messageBody): void => {
425 setTimeout(() => {
426 if (toClientId == null) {
427 clients.forEach((receive, otherClientId) =>
428 otherClientId != clientId
429 ? receive(clientId, requestId, messageType, messageBody)
430 : 0,
431 );
432 } else {
433 clients.get(toClientId)?.(
434 clientId,
435 requestId,
436 messageType,
437 messageBody,
438 );
439 }
440 }, 0);
441 },
442 (receive: Receive): void => {
443 clients.set(clientId, receive);
444 },
445 (): void => {
446 clients.delete(clientId);
447 },
448 0.005,
449 );
450};
451
452export const mockCustomSynchronizer: Persistable<
453 [Map<string, Receive>, Synchronizer, MergeableStore]

Callers 1

mocks.tsFile · 0.85

Calls 3

createCustomSynchronizerFunction · 0.90
getMethod · 0.80
deleteMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…