codekingpro/portable-devtools
115k
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.convertChangesToDMP = convertChangesToDMP;
4/**
5 * converts a list of change objects to the format returned by Google's [diff-match-patch](https://github.com/google/diff-match-patch) library
6 */
7function convertChangesToDMP(changes) {
8 var ret = [];
9 var change, operation;
10 for (var i = 0; i < changes.length; i++) {
11 change = changes[i];
12 if (change.added) {
13 operation = 1;
14 }
15 else if (change.removed) {
16 operation = -1;
17 }
18 else {
19 operation = 0;
20 }
21 ret.push([operation, change.value]);
22 }
23 return ret;
24}
25 