Skip to content

Commit

Permalink
Fix issue with updating index after removing data.
Browse files Browse the repository at this point in the history
Fixes #89.
  • Loading branch information
jasondavies committed Sep 2, 2013
1 parent 89bc6c3 commit 60169ab
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 9 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ crossfilter.js: \
src/zero.js \
src/reduce.js \
src/crossfilter.js \
package.json \
Makefile

%.min.js: %.js Makefile
Expand Down
7 changes: 3 additions & 4 deletions crossfilter.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(function(exports){
crossfilter.version = "1.3.0";
crossfilter.version = "1.3.1";
function crossfilter_identity(d) {
return d;
}
Expand Down Expand Up @@ -698,9 +698,8 @@ function crossfilter() {

function removeData(reIndex) {
for (var i = 0, j = 0, k; i < n; ++i) {
if (filters[k = index[i]] && i !== j) {
values[j] = values[i];
index[j] = reIndex[k];
if (filters[k = index[i]]) {
if (i !== j) values[j] = values[i], index[j] = reIndex[k];
++j;
}
}
Expand Down
2 changes: 1 addition & 1 deletion crossfilter.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "crossfilter",
"version": "1.3.0",
"version": "1.3.1",
"description": "Fast multidimensional filtering for coordinated views.",
"keywords": [
"square",
Expand Down
5 changes: 2 additions & 3 deletions src/crossfilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,8 @@ function crossfilter() {

function removeData(reIndex) {
for (var i = 0, j = 0, k; i < n; ++i) {
if (filters[k = index[i]] && i !== j) {
values[j] = values[i];
index[j] = reIndex[k];
if (filters[k = index[i]]) {
if (i !== j) values[j] = values[i], index[j] = reIndex[k];
++j;
}
}
Expand Down
7 changes: 7 additions & 0 deletions test/crossfilter-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -913,6 +913,13 @@ suite.addBatch({
data.remove();
assert.deepEqual(data.foo.top(Infinity), []);
assert.deepEqual(data.foo.evenOdd.all(), [{key: 0, value: 0}, {key: 1, value: 0}]);
},
"filtering works correctly after removing a record": function(data) {
data.add([{foo: 1}, {foo: 2}, {foo: 3}]);
data.foo.filter(2);
data.remove();
data.foo.filter(null);
assert.deepEqual(data.foo.top(Infinity), [{foo: 3}, {foo: 1}]);
}
}
}
Expand Down

0 comments on commit 60169ab

Please sign in to comment.