diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..f257ee5
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2018 Jun Tomioka
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/README.md b/README.md
index d506bad..f0e8d70 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,7 @@
A JavaScript module that finds the most ideal path to change an array to another array.
-
+
### Demo
@@ -76,3 +76,10 @@ arrayDiffItems(left, right)((a, b) => {
// {"type":"Changed","left":"Grape","right":"Grape Fruit"}
// ]
```
+
+### Algorithm
+
+This implementation uses `O(nm)` time and space simple dynamic programming algorithm where `n` and `m` is length of input arrays.
+In practical situation, this algorithm works resonably well.
+Comparing to other efficient algorithms (Wu and Manber's, for exmaple) is the future work.
+
diff --git a/array-diff-items-screenshot.png b/array-diff-items-screenshot.png
index 6d6ae0f..69a5025 100644
Binary files a/array-diff-items-screenshot.png and b/array-diff-items-screenshot.png differ
diff --git a/src/array-diff-items.ts b/src/array-diff-items.ts
index c0ced17..b9fc4dd 100644
--- a/src/array-diff-items.ts
+++ b/src/array-diff-items.ts
@@ -155,11 +155,11 @@ class ArrayDiffItems {
})
}
- const change = this.nodeOf(left + 1, right + 1);
- if (typeof change !== 'undefined' && typeof change.costToChange !== 'undefined') {
- change.tryUpdate({
- totalCost: node.path.totalCost + change.costToChange,
- parent: { node, operation: change.costToChange === 0 ? 'Unchanged' : 'Changed' }
+ const changed = this.nodeOf(left + 1, right + 1);
+ if (typeof changed !== 'undefined' && typeof changed.costToChange !== 'undefined') {
+ changed.tryUpdate({
+ totalCost: node.path.totalCost + changed.costToChange,
+ parent: { node, operation: changed.costToChange === 0 ? 'Unchanged' : 'Changed' }
});
}
};