当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript diff_match_patch.patch_make方法代码示例

本文整理汇总了TypeScript中diff-match-patch.diff_match_patch.patch_make方法的典型用法代码示例。如果您正苦于以下问题:TypeScript diff_match_patch.patch_make方法的具体用法?TypeScript diff_match_patch.patch_make怎么用?TypeScript diff_match_patch.patch_make使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在diff-match-patch.diff_match_patch的用法示例。


在下文中一共展示了diff_match_patch.patch_make方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: testPatchMake

function testPatchMake() {
    const text1 = 'The quick brown fox jumps over the lazy dog.';
    const text2 = 'That quick brown fox jumped over a lazy dog.';
    let expectedPatch = '@@ -1,8 +1,7 @@\n Th\n-at\n+e\n  qui\n@@ -21,17 +21,18 @@\n jump\n-ed\n+s\n  over \n-a\n+the\n  laz\n';
    let patches = dmp.patch_make(text2, text1);
    assertEquals(expectedPatch, dmp.patch_toText(patches));

    // Method 1
    expectedPatch = '@@ -1,11 +1,12 @@\n Th\n-e\n+at\n  quick b\n@@ -22,18 +22,17 @@\n jump\n-s\n+ed\n  over \n-the\n+a\n  laz\n';
    patches = dmp.patch_make(text1, text2);
    assertEquals(expectedPatch, dmp.patch_toText(patches));

    // Method 2
    const diffs = dmp.diff_main(text1, text2, false);
    patches = dmp.patch_make(diffs);
    assertEquals(expectedPatch, dmp.patch_toText(patches));

    // Method 3
    patches = dmp.patch_make(text1, diffs);
    assertEquals(expectedPatch, dmp.patch_toText(patches));

    // Method 4
    patches = dmp.patch_make(text1, text2, diffs);
    assertEquals(expectedPatch, dmp.patch_toText(patches));
}
开发者ID:AbraaoAlves,项目名称:DefinitelyTyped,代码行数:25,代码来源:diff-match-patch-tests.ts

示例2: testPatchApply

function testPatchApply() {
    dmp.Match_Distance = 1000;
    dmp.Match_Threshold = 0.5;
    dmp.Patch_DeleteThreshold = 0.5;
    const patches = dmp.patch_make('The quick brown fox jumps over the lazy dog.', 'That quick brown fox jumped over a lazy dog.');
    const results = dmp.patch_apply(patches, 'The quick brown fox jumps over the lazy dog.');
    assertEquivalent(['That quick brown fox jumped over a lazy dog.', [true, true]], results);
}
开发者ID:AbraaoAlves,项目名称:DefinitelyTyped,代码行数:8,代码来源:diff-match-patch-tests.ts

示例3: testPatchSplitMax

function testPatchSplitMax() {
    const patches = dmp.patch_make('abcdefghijklmnopqrstuvwxyz01234567890', 'XabXcdXefXghXijXklXmnXopXqrXstXuvXwxXyzX01X23X45X67X89X0');
    dmp.patch_splitMax(patches);
    assertEquals(
        [
            '@@ -1,32 +1,46 @@\n',
            '+X\n ab\n+X\n cd\n+X\n ef\n+X\n gh\n+X\n ij\n+X\n kl\n+X\n mn\n+X\n op\n+X\n qr\n+X\n st\n+X\nuv\n+X\n wx\n+X\n yz\n+X\n 012345\n',
            '@@ -25,13 +39,18 @@',
            '\n zX01\n+X\n 23\n+X\n 45\n+X\n 67\n+X\n 89\n+X\n 0\n'
        ].join(''),
        dmp.patch_toText(patches));
}
开发者ID:AbraaoAlves,项目名称:DefinitelyTyped,代码行数:12,代码来源:diff-match-patch-tests.ts

示例4: testPatchAddPadding

function testPatchAddPadding() {
    const patches = dmp.patch_make('', 'test');
    assertEquals('@@ -0,0 +1,4 @@\n+test\n', dmp.patch_toText(patches));
    dmp.patch_addPadding(patches);
    assertEquals('@@ -1,8 +1,12 @@\n %01%02%03%04\n+test\n %01%02%03%04\n', dmp.patch_toText(patches));
}
开发者ID:AbraaoAlves,项目名称:DefinitelyTyped,代码行数:6,代码来源:diff-match-patch-tests.ts


注:本文中的diff-match-patch.diff_match_patch.patch_make方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。