mirror of https://github.com/ghostfolio/ghostfolio
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.6 KiB
48 lines
1.6 KiB
import DiffMatchPatch from 'diff-match-patch';
|
|
import DiffPatcher from './diffpatcher.js';
|
|
import dateReviver from './date-reviver.js';
|
|
export { DiffPatcher, dateReviver };
|
|
export function create(options) {
|
|
return new DiffPatcher(Object.assign(Object.assign({}, options), { textDiff: Object.assign(Object.assign({}, options === null || options === void 0 ? void 0 : options.textDiff), { diffMatchPatch: DiffMatchPatch }) }));
|
|
}
|
|
let defaultInstance;
|
|
export function diff(left, right) {
|
|
if (!defaultInstance) {
|
|
defaultInstance = new DiffPatcher({
|
|
textDiff: { diffMatchPatch: DiffMatchPatch },
|
|
});
|
|
}
|
|
return defaultInstance.diff(left, right);
|
|
}
|
|
export function patch(left, delta) {
|
|
if (!defaultInstance) {
|
|
defaultInstance = new DiffPatcher({
|
|
textDiff: { diffMatchPatch: DiffMatchPatch },
|
|
});
|
|
}
|
|
return defaultInstance.patch(left, delta);
|
|
}
|
|
export function unpatch(right, delta) {
|
|
if (!defaultInstance) {
|
|
defaultInstance = new DiffPatcher({
|
|
textDiff: { diffMatchPatch: DiffMatchPatch },
|
|
});
|
|
}
|
|
return defaultInstance.unpatch(right, delta);
|
|
}
|
|
export function reverse(delta) {
|
|
if (!defaultInstance) {
|
|
defaultInstance = new DiffPatcher({
|
|
textDiff: { diffMatchPatch: DiffMatchPatch },
|
|
});
|
|
}
|
|
return defaultInstance.reverse(delta);
|
|
}
|
|
export function clone(value) {
|
|
if (!defaultInstance) {
|
|
defaultInstance = new DiffPatcher({
|
|
textDiff: { diffMatchPatch: DiffMatchPatch },
|
|
});
|
|
}
|
|
return defaultInstance.clone(value);
|
|
}
|
|
|