Skip to content

Commit

Permalink
Filled out README with some semi-useful information
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicholas Rawlings committed Nov 23, 2013
1 parent ef06742 commit 8e741c0
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,31 @@
ArrayDiff
=========

Finds the difference between two JavaScript arrays by computing the longest common subsequence between them
ArrayDiff computes the difference between two JavaScript arrays (as well as any other object that uses numeric subscripts, such as a string or DOMNodeList) by finding the [longest common subsequence](https://en.wikipedia.org/wiki/Longest_common_subsequence_problem) between them.

## Example

```javascript
var thisArray = 'nematode knowledge'.split(''),
thatArray = 'empty bottle'.split(''),
arrayDiff = new ArrayDiff(thatArray, thisArray);

arrayDiff.diff.forEach(function(element) {

if (element.added()) {
var operation = '+'
} else if (element.removed()) {
var operation = '-';
} else {
var operation = ' ';
}

console.log('%s %s', operation, element.item);

});
```


## Acknowledgements

Many thanks to [Professor David Eppstein](http://www.ics.uci.edu/~eppstein/) of the University of California, Irvine, whose [lecture notes](http://www.ics.uci.edu/~eppstein/161/960229.html) from February 1996 helped me get my head around the dynamic programming solution to the longest common subsequence problem.

0 comments on commit 8e741c0

Please sign in to comment.