Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes15kdownloads
dmp.js22 linesDownload Raw Back to convert
1/**
2 * converts a list of change objects to the format returned by Google's [diff-match-patch](https://github.com/google/diff-match-patch) library
3 */
4export function convertChangesToDMP(changes) {
5    const ret = [];
6    let change, operation;
7    for (let i = 0; i < changes.length; i++) {
8        change = changes[i];
9        if (change.added) {
10            operation = 1;
11        }
12        else if (change.removed) {
13            operation = -1;
14        }
15        else {
16            operation = 0;
17        }
18        ret.push([operation, change.value]);
19    }
20    return ret;
21}
22 
codekingpro/portable-devtools · Team Ai