treetabular
Advanced tools
Comparing version 3.5.2 to 3.6.0
## treetabular | ||
3.6.0 / 2020-01-27 | ||
================== | ||
* Feature - Improve filtering performance #24 | ||
3.5.2 / 2019-01-02 | ||
@@ -4,0 +9,0 @@ ================== |
@@ -26,2 +26,6 @@ 'use strict'; | ||
// build up a cache of parent ids and whether their child rows should show | ||
// to reduce the amount of lookups for performance | ||
var parentCache = {}; | ||
return rows.filter(function (row, index) { | ||
@@ -32,7 +36,17 @@ if (typeof row[parentField] === 'undefined' || row[parentField] === null) { | ||
var parentVal = parentCache[row[parentField]]; | ||
if (parentVal === false || parentVal === true) { | ||
return parentVal; | ||
} | ||
var parents = (0, _getParents2.default)({ index: index, idField: idField, parentField: parentField })(rows); | ||
return parents.filter(function (parent) { | ||
// if all the rows parents are showing then we know that the row should should | ||
var rowShouldShow = parents.filter(function (parent) { | ||
return parent[fieldName]; | ||
}).length === parents.length; | ||
parentCache[row[parentField]] = rowShouldShow; | ||
return rowShouldShow; | ||
}); | ||
@@ -39,0 +53,0 @@ }; |
{ | ||
"name": "treetabular", | ||
"version": "3.5.2", | ||
"version": "3.6.0", | ||
"description": "Tree utilities", | ||
@@ -5,0 +5,0 @@ "scripts": { |
51865
732