binary-search-tree
Advanced tools
Comparing version 0.2.5 to 0.2.6
@@ -352,3 +352,3 @@ /** | ||
// Delete only a value (no tree modification) | ||
if (currentNode.data.length > 1 && value) { | ||
if (currentNode.data.length > 1 && value !== undefined) { | ||
currentNode.data.forEach(function (d) { | ||
@@ -355,0 +355,0 @@ if (!currentNode.checkValueEquality(d, value)) { newData.push(d); } |
{ | ||
"name": "binary-search-tree", | ||
"version": "0.2.5", | ||
"version": "0.2.6", | ||
"author": { | ||
@@ -5,0 +5,0 @@ "name": "Louis Chatriot", |
@@ -18,2 +18,4 @@ # Binary search trees for Node.js | ||
Values inserted can be anything except `undefined`. | ||
```javascript | ||
@@ -20,0 +22,0 @@ var BinarySearchTree = require('binary-search-tree').BinarySearchTree |
@@ -825,2 +825,19 @@ var should = require('chai').should() | ||
it("Removing falsy values does not delete the entire key", function () { | ||
var avlt = new AVLTree(); | ||
avlt.insert(10, 2); | ||
avlt.insert(10, 1); | ||
assert.deepEqual(avlt.search(10), [2, 1]); | ||
avlt.delete(10, 2); | ||
assert.deepEqual(avlt.search(10), [1]); | ||
avlt.insert(10, 0); | ||
assert.deepEqual(avlt.search(10), [1, 0]); | ||
avlt.delete(10, 0); | ||
assert.deepEqual(avlt.search(10), [1]); | ||
}); | ||
}); // ==== End of 'Deletion' ==== // | ||
@@ -827,0 +844,0 @@ |
101330
2552
126