optimize recursive filter
This commit is contained in:
parent
d8ee6074fa
commit
8eb807714c
6
index.js
6
index.js
@ -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 = '';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user