do not modify original object on recursive filter
This commit is contained in:
parent
33597eb4e9
commit
0932891b20
5
index.js
5
index.js
@ -81,11 +81,12 @@ function is_nil (obj) {
|
|||||||
/**
|
/**
|
||||||
* filter nested objects
|
* filter nested objects
|
||||||
*
|
*
|
||||||
* @param {Array<object>} data
|
* @param {Array<object>} input
|
||||||
* @param {Array<{field: string, filter: RegExp}>} filters
|
* @param {Array<{field: string, filter: RegExp}>} filters
|
||||||
* @returns {Array<object>} filtered data
|
* @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 = [];
|
const filtered = [];
|
||||||
for (const e of data) {
|
for (const e of data) {
|
||||||
let match = true;
|
let match = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user