说明
typescript wed/util encodediff示例是从最受好评的开源项目中提取的实现代码,你可以参考下面示例的使用方式。
编程语言: TypeScript
命名空间/包名称: wed/util
示例#1
文件:
util-test.ts
项目:
lddubeau/wed
it("produces a diff for cases that are not as-is", () => {
expect(util.encodeDiff("Abc", "abc")).to.equal("u1");
expect(util.encodeDiff("abC", "abc")).to.equal("g2u1");
expect(util.encodeDiff("abCdexFGh", "abcdexfgh"))
.to.equal("g2u1g3u2");
// The treatment of "C" cannot be handled with the u operation because the
// diff removes "abc" and then adds "C", and "abc" in uppercase is not
// "C". The algorithm *could* be modified to handle this, but this is an a
// case that won't actually happen with "real" data, and the few rare
// cases that happens in languages other than English are not worth the
// development expense.
expect(util.encodeDiff("CdexFGh", "abcdexfgh"))
.to.equal("m3px43g3u2");
});
示例#2
文件:
util-test.ts
项目:
lddubeau/wed
it("produces an empty diff for as-is cases", () => {
expect(util.encodeDiff("abc", "abc")).to.equal("");
});