{"id":"solarscuffle-bot/deep-delta","name":"deep-delta","scope":"solarscuffle-bot","platform":"roblox","description":"A Luau library that serializes nested table diffs into buffers.","version":"3.1.0","latest":"3.1.0","versions":["3.1.0"],"license":"MIT","licenseRating":"safe","licenseCaveats":["License identified from the packaged LICENSE file; the manifest declared none."],"licenseVerified":true,"dependencies":{},"integrity":"552b87566d89fe3d25d31fc1bdb650f5a67c2c62da203fb3ac7171852ca1949d","likes":0,"downloads":0,"install":"forest install solarscuffle-bot/deep-delta","url":"https://forest.dev/p/roblox/solarscuffle-bot/deep-delta","files":"https://api.forest.dev/ai/package/roblox/solarscuffle-bot/deep-delta/files","readme":"![DeepDeltaLogo_1024x484](/Assets/DeepDelta_1024x484.webp)\r\n\r\nA Luau library that serializes nested table diffs into buffers. Similar to [DeltaCompress](https://nezuo.github.io/delta-compress/), but supporting nested tables. Future updates to improve compression size are likely.\r\n\r\nAvailable on [Wally](https://wally.run/package/solarscuffle-bot/deep-delta)\r\n\r\n## API\r\n`DeepDelta.clone(tab: T): T`\r\n\r\nDeep clones a table, usually used to save a snapshot of old data before diffing or applying.\r\n\r\n```lua\r\n-- Server\r\nlocal oldData = DeepDelta.clone(data)\r\nmutateData(data)\r\nlocal diff = DeepDelta.diff(data, oldData)\r\n```\r\n```lua\r\n-- Client\r\nlocal oldData = DeepDelta.clone(data)\r\nlocal deltas = DeepDelta.apply(data, diff, deltas)\r\nDataChanged:Fire(data, oldData, deltas)\r\n```\r\n---\r\n`DeepDelta.diff(new: T, old: table): (buffer, T)`\r\n\r\nSerializes the deep delta between two tables into a buffer for applying to a table later and returns a new table representing the delta between them. Useful for validating if a change has occurred down-the-chain.\r\n\r\n```lua\r\nlocal oldData = DeepDelta.clone(data)\r\n\r\ndata.money -= 10\r\n\r\nlocal row = math.random(1, #data.loot)\r\ntable.insert(data.loot[row], {\r\n\trarity = \"rare\",\r\n\tduration = 300, -- seconds\r\n})\r\n\r\nlocal diff, deltas = DeepDelta.diff(data, oldData)\r\nDataUpdated:Fire(diff)\r\n```\r\n---\r\n`DeepDelta.apply(target: table, diff: buffer)`\r\n\r\nApplies a previously serialized deep delta diff to a table.\r\n\r\n```lua\r\nlocal oldData = DeepDelta.clone(data)\r\nlocal deltas = DeepDelta.apply(data, diff)\r\nDataChanged:Fire(data, oldData, deltas)\r\n```\r\n","readmeTruncated":false}