push
github
162 of 167 branches covered (97.01%)
Branch coverage included in aggregate %.
1 of 3 new or added lines in 1 file covered. (33.33%)
423 of 425 relevant lines covered (99.53%)
55.2 hits per line
| 1 |
// @ts-check
|
|
| 2 |
|
10✔ |
| 3 |
/**
|
10✔ |
| 4 |
* Converts result into data path mapping |
10✔ |
| 5 |
* |
10✔ |
| 6 |
* @param {any} data - The data to map.
|
10✔ |
| 7 |
* @returns {any} The final output.
|
10✔ |
| 8 |
*/ |
10✔ |
| 9 |
const dataPath = (data, paths = '') => { |
|
| 10 |
return paths.split('/').reduce((final, path) => { |
|
|
|
if (final instanceof Array) { |
|
|
NEW
|
return final.map((item) => item[path] || data[path]) |
× |
|
NEW
|
} |
× |
| 14 |
return (final && final[path]) || data[path] |
|
| 15 |
}, data) |
1✔ |
| 16 |
} |
1✔ |
| 17 |
|
10✔ |
| 18 |
module.exports = dataPath |
10✔ |