github
141 of 152 branches covered (0.0%)
Branch coverage included in aggregate %.
324 of 340 new or added lines in 12 files covered. (95.29%)
400 of 419 relevant lines covered (95.47%)
42.0 hits per line
|
// @ts-check
|
|
|
|
7✔ |
|
/**
|
7✔ |
|
* Merges two query objects. |
7✔ |
|
* |
7✔ |
|
* @param {object} query - The original query object. |
7✔ |
|
* @param {object | object[]} nextQuery - The query object(s) to merge with the original. |
7✔ |
|
* @returns {object} The merged query object. |
7✔ |
|
*/ |
7✔ |
|
const mergeQuery = (query, nextQuery) => {
|
|
|
if (Array.isArray(nextQuery)) {
|
|
|
let obj = {} |
3✔ |
|
nextQuery.forEach(q => { |
|
|
if (!Array.isArray(q) && typeof q === 'object') { |
5✔ |
|
obj = { |
5✔ |
|
...obj, |
5✔ |
|
...q |
5✔ |
|
} |
5✔ |
|
} else {
|
|
NEW
|
obj = { |
× |
NEW
|
...obj, |
× |
NEW
|
...(mergeQuery(query, q)) |
× |
NEW
|
} |
× |
NEW
|
} |
× |
|
}) |
3✔ |
|
return mergeQuery(query, obj)
|
3✔ |
|
} else {
|
|
|
return {
|
70✔ |
|
...query, |
70✔ |
|
...nextQuery |
70✔ |
|
} |
70✔ |
|
} |
70✔ |
|
} |
73✔ |
|
|
7✔ |
|
module.exports = mergeQuery |
7✔ |