react-native

diff_match_patch.js

2018-03-29  本文已影响77人  猪猪9527
<html>
<body>
<script src="diff_match_patch.js"></script>
<script>
    var dmp = new diff_match_patch();
    // var diff = dmp.diff_main('Hello World.', 'Goodbye World.');

    let a = 'Hello World.' ;
    let b = 'Goodbye World.' ;
    var diff = dmp.patch_make(a,b);

    // Result: [(-1, "Hell"), (1, "G"), (0, "o"), (1, "odbye"), (0, " World.")]
    // dmp.diff_cleanupSemantic(diff);
    // Result: [(-1, "Hello"), (1, "Goodbye"), (0, " World.")]
    let dif = dmp.patch_apply(diff,a)

    alert(dif);
</script>
</body>
</html>

上一篇下一篇

猜你喜欢

热点阅读