MCPcopy Index your code
hub / github.com/tinyplex/tinybase / createPayloads

Function createPayloads

src/synchronizers/common.ts:120–149  ·  view source on GitHub ↗
(
  toClientId: IdOrNull,
  requestId: IdOrNull,
  message: Message,
  body: any,
  fragmentSize?: number,
)

Source from the content-addressed store, hash-verified

118 clientId + MESSAGE_SEPARATOR + remainder;
119
120export const createPayloads = (
121 toClientId: IdOrNull,
122 requestId: IdOrNull,
123 message: Message,
124 body: any,
125 fragmentSize?: number,
126): string[] => {
127 const clientId = toClientId ?? EMPTY_STRING;
128 const remainder = jsonStringWithUndefined([requestId, message, body]);
129 const maxFragmentSize = mathFloor(fragmentSize ?? 0);
130 if (
131 isUndefined(fragmentSize) ||
132 maxFragmentSize < 1 ||
133 size(remainder) <= maxFragmentSize
134 ) {
135 return [createRawPayload(clientId, remainder)];
136 }
137 const fragments = strMatch(
138 remainder,
139 new RegExp(`.{1,${maxFragmentSize}}`, 'g'),
140 );
141 const total = size(fragments ?? []);
142 const messageId = getUniqueId();
143 return arrayMap(fragments ?? [], (fragment, index) =>
144 createRawPayload(
145 clientId,
146 arrayJoin([messageId, index, total, fragment], MESSAGE_SEPARATOR),
147 ),
148 );
149};

Callers 3

constructorMethod · 0.90
sendFunction · 0.90
configureServerClientFunction · 0.90

Calls 8

jsonStringWithUndefinedFunction · 0.90
isUndefinedFunction · 0.90
sizeFunction · 0.90
strMatchFunction · 0.90
getUniqueIdFunction · 0.90
arrayMapFunction · 0.90
arrayJoinFunction · 0.90
createRawPayloadFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…