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

Function deconstruct

src/persisters/common/partykit.ts:25–39  ·  view source on GitHub ↗
(
  prefix: string,
  message: string,
  stringified?: 1,
)

Source from the content-addressed store, hash-verified

23 (isString(payload) ? payload : jsonStringWithUndefined(payload));
24
25export const deconstruct = (
26 prefix: string,
27 message: string,
28 stringified?: 1,
29): [type: MessageType | StorageKeyType, payload: string | any] | undefined => {
30 const prefixSize = size(prefix);
31 return strStartsWith(message, prefix)
32 ? [
33 message[prefixSize] as MessageType | StorageKeyType,
34 (stringified ? jsonParseWithUndefined : string)(
35 slice(message, prefixSize + 1),
36 ),
37 ]
38 : undefined;
39};

Callers 3

messageListenerFunction · 0.90
loadStoreFromStorageFunction · 0.90
onMessageMethod · 0.90

Calls 3

sizeFunction · 0.90
strStartsWithFunction · 0.90
sliceFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…