Skip to content

includeamin/diff

Repository files navigation

diff

Diff is a library to calculate deltas between structured data.

Features

  • Calculate detla(s)
  • Rebuild state from delta(s)

Supported Formats

  • JSON
  • YAML
  • XML
  • TOML

Usage

Diff

import diff

old = {"name": "David"}
new = {"name": "Alex"}
deltas = diff.diff(new=new, old=old)

for delta in deltas:
    print(delta)

Output

Operation(op='modified', path='$.name', new_value='Alex', old_value='David')

Rebuild

import diff

old = {"name": "David"}
new = {"name": "Alex"}
deltas = diff.diff(new=new, old=old)

rebuild_new = diff.patch(base=old, deltas=deltas)

assert rebuild_new == old

Install

poetry add git+https://github.com/includeamin/diff.git#tag

About

A library to calculate diff between structured data

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published