datum-diff
v1.0.3
Published
deep-diff js library rewritten in typescript
Readme
sources
the source code of the deep-diff js library has been migrated to typescript . it remains unmaintained and contains some serious bugs that made it unreliable for this project .
- tag:v1.0.2 flitbit/diff
- tag:v1.0.2 flitbit/diff/tests
- tag:v1.0.5 @types/deep-diff
same interfaces have been exposed to maintain compatibility with the last version .
many thanks to the library author and all previous contributors !
usage
recommended to invoke via the wrapper method for simple cases :
import { deepDiff } from "datum-merge";
const datumDiff: Partial<MyType> = deepDiff<MyType>(target, source);or use the existing library interfaces now with types :
import { diff, Diff, applyChange } from "datum-merge";
const simpleDiff: Diff[] = diff(target, source);
for (const dif of simpleDiff) { applyChange(target, null, dif); }
import { Diff, accumulateDiff, PreFilter, Accumulator } from "datum-merge";
const customDiff: Diff[] = accumulateDiff(target, source, prefilter, accum, orderIndep);or for usage on browser environments:
<script src="https://unpkg.com/[email protected]/dist-diff/umd/deep-diff.min.js"></script>see the readme in the original library for detailed examples .
datum-diff
module recently published as a standalone package datum-diff
works as a drop-in replacement for the package deep-diff
simply use datum-diff instead of the datum-merge libary in the examples above .
changes
- all functions and responses are typed
- lhs and rhs should be immutable ( had bug when orderIndependent=true )
- diff response should be immutable
- general code upgrades and variable cleanup
- avoid introducing any dependancies within module
- bundled package size is seven times smaller
