(obj, wholePackument)
| 388 | } |
| 389 | |
| 390 | function cleanData (obj, wholePackument) { |
| 391 | // JSON formatted output (JSON or specific attributes from packument) |
| 392 | const data = obj.reduce((acc, cur) => { |
| 393 | if (cur) { |
| 394 | Object.entries(cur).forEach(([k, v]) => { |
| 395 | acc[k] ||= {} |
| 396 | Object.keys(v).forEach((t) => { |
| 397 | acc[k][t] = cur[k][t] |
| 398 | }) |
| 399 | }) |
| 400 | } |
| 401 | return acc |
| 402 | }, {}) |
| 403 | |
| 404 | if (wholePackument) { |
| 405 | const cleaned = Object.entries(data).reduce((acc, [k, v]) => { |
| 406 | acc[k] = v[Queryable.ALL] |
| 407 | return acc |
| 408 | }, {}) |
| 409 | log.silly('view', cleaned) |
| 410 | return cleaned |
| 411 | } |
| 412 | |
| 413 | return data |
| 414 | } |
| 415 | |
| 416 | // return whatever was printed |
| 417 | function showFields ({ data, version, fields, json }) { |
no test coverage detected