Closed sebastiansandqvist closed 4 years ago
Looking through the index.d.ts, I was able to figure out that DiffPatcher was the key.
import { diff, Config, DiffPatcher, formatters } from 'jsondiffpatch'; . . . var conf: Config; conf = { objectHash: function(obj) { if (typeof obj._id !== 'undefined') { return obj._id; } if (typeof obj.id !== 'undefined') { return obj.id; } if (typeof obj.name !== 'undefined') { return obj.name; } return JSON.stringify(obj); }, arrays: { detectMove: true, includeValueOnMove: true }, textDiff: { minLength: 60 }, cloneDiffValues: false };
var jsondiffpatch = new DiffPatcher(conf);
var delta = jsondiffpatch.diff(this.left, this.right);
this.htmlOutput = formatters.html.format(delta, this.left);
How can one set config options when using jsondiffpatch with typescript? I see the
Config
interface in the typings, but nocreate
function to pass the config to.