optimize recursive filter

This commit is contained in:
Timo Hocker 2020-06-29 11:33:33 +02:00
parent d8ee6074fa
commit 8eb807714c

View File

@ -86,9 +86,11 @@ function is_nil (obj) {
* @returns {Array<object>} filtered data * @returns {Array<object>} filtered data
*/ */
function recursive_filter (input, filters, children_key = 'children') { function recursive_filter (input, filters, children_key = 'children') {
const data = copy_object (input); const data = [ ...input ];
const filtered = []; const filtered = [];
for (const e of data) { for (let i = 0; i < data.length; i++) {
const e = { ...data[i] };
data[i] = e;
let match = true; let match = true;
for (const filter of filters) { for (const filter of filters) {
let search_str = ''; let search_str = '';