MCPcopy
hub / github.com/tldraw/tldraw / parse

Method parse

apps/dotcom/sync-worker/src/TLPostgresReplicator.ts:54–70  ·  view source on GitHub ↗
(buffer: Buffer)

Source from the content-addressed store, hash-verified

52 // If fixups also fail, we deliberately let the error propagate — a crash loop is
53 // preferable to silently skipping (and acknowledging) unprocessable changes.
54 override parse(buffer: Buffer): any {
55 const raw = buffer.toString()
56 try {
57 return JSON.parse(raw)
58 } catch (e) {
59 const fixed = raw
60 .replace(/"change":\[,+/g, '"change":[') // leading commas: [,{ → [{
61 .replace(/,+]/g, ']') // trailing commas: ,] → ]
62 .replace(/,,+/g, ',') // consecutive commas: ,, → ,
63 const result = JSON.parse(fixed)
64 console.warn(
65 `SafeWal2JsonPlugin: fixed malformed wal2json output (eulerto/wal2json#266). ` +
66 `Original error: ${e}. Payload sample: ${raw.slice(0, 200)}`
67 )
68 return result
69 }
70 }
71}
72
73const ONE_MINUTE = 60 * 1000

Callers 15

renameTemplateFunction · 0.80
getStructuredCloneFunction · 0.80
createMermaidDiagramFunction · 0.80
localStorageAtomFunction · 0.80
handleStorageEventFunction · 0.80
TLStore.test.tsFile · 0.80
getStoredInitialValueFunction · 0.80
getAllIndexDbNamesFunction · 0.80
extractLicenseKeyMethod · 0.80

Calls 3

toStringMethod · 0.65
replaceMethod · 0.65
warnMethod · 0.65

Tested by 1

setupFunction · 0.64