版博士V2.0程序
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

README.md 1.1 KiB

123456789101112131415161718192021222324
  1. # Fast Diff [![Build Status](https://travis-ci.org/jhchen/fast-diff.svg)](https://travis-ci.org/jhchen/fast-diff)
  2. This is a simplified import of the excellent [diff-match-patch](https://code.google.com/p/google-diff-match-patch/) library by [Neil Fraser](https://neil.fraser.name/) into the Node.js environment. The match and patch parts are removed, as well as all the extra diff options. What remains is incredibly fast diffing between two strings.
  3. The diff function is an implementation of ["An O(ND) Difference Algorithm and its Variations" (Myers, 1986)](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.4.6927&rep=rep1&type=pdf) with the suggested divide and conquer strategy along with several [optimizations](http://neil.fraser.name/news/2007/10/09/) Neil added.
  4. ```js
  5. var diff = require('fast-diff');
  6. var good = 'Good dog';
  7. var bad = 'Bad dog';
  8. var result = diff(good, bad);
  9. // [[-1, "Goo"], [1, "Ba"], [0, "d dog"]]
  10. // Respect suggested edit location (cursor position), added in v1.1
  11. diff('aaa', 'aaaa', 1)
  12. // [[0, "a"], [1, "a"], [0, "aa"]]
  13. // For convenience
  14. diff.INSERT === 1;
  15. diff.EQUAL === 0;
  16. diff.DELETE === -1;
  17. ```