diff --git a/index.js b/index.js index 12b29e3..64e691d 100644 --- a/index.js +++ b/index.js @@ -81,11 +81,12 @@ function is_nil (obj) { /** * filter nested objects * - * @param {Array} data + * @param {Array} input * @param {Array<{field: string, filter: RegExp}>} filters * @returns {Array} 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;