How to use node-diff3 - 6 common examples

To help you get started, we’ve selected a few node-diff3 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github openstreetmap / iD / modules / actions / merge_remote_changes.js View on Github external
function mergeNodes(base, remote, target) {
        if (_option === 'force_local' || deepEqual(target.nodes, remote.nodes)) {
            return target;
        }
        if (_option === 'force_remote') {
            return target.update({nodes: remote.nodes});
        }

        var ccount = _conflicts.length;
        var o = base.nodes || [];
        var a = target.nodes || [];
        var b = remote.nodes || [];
        var nodes = [];
        var hunks = diff3Merge(a, o, b, true);

        for (var i = 0; i < hunks.length; i++) {
            var hunk = hunks[i];
            if (hunk.ok) {
                nodes.push.apply(nodes, hunk.ok);
            } else {
                // for all conflicts, we can assume c.a !== c.b
                // because `diff3Merge` called with `true` option to exclude false conflicts..
                var c = hunk.conflict;
                if (deepEqual(c.o, c.a)) {  // only changed remotely
                    nodes.push.apply(nodes, c.b);
                } else if (deepEqual(c.o, c.b)) {  // only changed locally
                    nodes.push.apply(nodes, c.a);
                } else {       // changed both locally and remotely
                    _conflicts.push(t('merge_remote_changes.conflict.nodelist', { user: user(remote.user) }));
                    break;
github willmendesneto / update-yeoman-generator / lib / 3-way-merge.js View on Github external
const merge = (fileA, originalFile, fileB) => {
  const merged = diff3Merge(fileA, originalFile, fileB, true);

  const fileHasConflict = merged.some((item) => !item.ok);
  const fileDiffResult = merged.reduce((fileContent, item) => {
    if (item.ok) {
      return fileContent.concat(item.ok);
    }

    return fileContent.concat(
      ['<<<<<<<<<'],
      item.conflict.a,
      ['========='],
      item.conflict.b,
      ['>>>>>>>>>']
    );
  }, []);
github FallenMax / notepad.cc / server / lib / diff3.js View on Github external
  createPatch: (a, b) => compress(stripPatch(diffPatch(toArr(a), toArr(b)))),
}
github FallenMax / notepad.cc / src / common / lib / diff3.ts View on Github external
export const createPatch = (a: string, b: string): Patch =>
  compress(stripPatch(diffPatch(toArr(a), toArr(b))))
github FallenMax / notepad.cc / src / common / lib / diff3.ts View on Github external
export const applyPatch = (a: string, p: Patch): string | undefined =>
  fromArr(patch(toArr(a), decompress(p)))
github FallenMax / notepad.cc / server / lib / diff3.js View on Github external
  applyPatch: (a, p) => fromArr(patch(toArr(a), decompress(p))),
  merge3: (a, o, b) => {

node-diff3

A node.js module for text diffing and three-way-merge.

MIT
Latest version published 2 years ago

Package Health Score

48 / 100
Full package analysis