do not modify original object on recursive filter

This commit is contained in:
Timo Hocker 2020-06-26 15:52:53 +02:00
parent 33597eb4e9
commit 0932891b20

View File

@ -81,11 +81,12 @@ function is_nil (obj) {
/**
* filter nested objects
*
* @param {Array<object>} data
* @param {Array<object>} input
* @param {Array<{field: string, filter: RegExp}>} filters
* @returns {Array<object>} filtered data
*/
function recursive_filter (data, filters, children_key = 'children') {
function recursive_filter (input, filters, children_key = 'children') {
const data = copy_object (input);
const filtered = [];
for (const e of data) {
let match = true;